aboutsummaryrefslogtreecommitdiff
path: root/grs
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2015-10-09 19:36:28 -0400
committerAnthony G. Basile <blueness@gentoo.org>2015-10-09 19:38:37 -0400
commit0fbe9351d3aa7571cc1b01679e2dd3f86dee40ed (patch)
treec716d69a0dfc52c465c1b6ede7dbbc8586a8f06b /grs
parentgrs/Interpret.py: skip non-functional build lines (diff)
downloadgrss-0fbe9351d3aa7571cc1b01679e2dd3f86dee40ed.tar.gz
grss-0fbe9351d3aa7571cc1b01679e2dd3f86dee40ed.tar.bz2
grss-0fbe9351d3aa7571cc1b01679e2dd3f86dee40ed.zip
grs/Interpret.py: clean up parsing a line.
Diffstat (limited to 'grs')
-rw-r--r--grs/Interpret.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/grs/Interpret.py b/grs/Interpret.py
index 43c0e48..7add215 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -159,10 +159,13 @@ class Interpret(Daemon):
line_number = 0
medium_type = None
for _line in _file.readlines():
+ # Increment the line number by one and create the name of the
+ # file for the progress stamp.
line_number += 1
+ progress = os.path.join(tmpdir, '.completed_%02d' % line_number)
- # Do nothing for lines with initial # or blank lines.
- # Create a progress stamp only if we are not doing an update run.
+ # Do nothing for lines with initial # or blank lines. Create
+ # a progress stamp only if we are not doing an update run.
if re.search(r'^(#).*$', _line) or len(_line.strip()) == 0:
if not self.update_run:
stampit(progress)
@@ -173,7 +176,8 @@ class Interpret(Daemon):
ignore_stamp = False
_match = re.search(r'^(\+)(.*)$', _line)
if _match:
- # There is a leading +, so remove it and skip if doing an update run
+ # There is a leading +, so remove it and ignore any progress
+ # stamp if its an update run.
ignore_stamp = self.update_run
_line = _match.group(2)
else:
@@ -181,20 +185,17 @@ class Interpret(Daemon):
if self.update_run:
continue
- progress = os.path.join(tmpdir, '.completed_%02d' % line_number)
+ # Skip a line if the progres stamp exists, or ignore it
+ # because its an update run.
if os.path.exists(progress) and not ignore_stamp:
continue
- # This is pretty simple interpretive logic, either its a
- # single 'verb', or a 'verb obj' pair. While restrictive,
- # its good enough for now.
- try:
- _match = re.search(r'(\S+)\s+(\S+)', _line)
- verb = _match.group(1)
- obj = _match.group(2)
- except AttributeError:
- verb = _line.strip()
- obj = None
+ # This is pretty simple syntax. The first word on a line
+ # is a verb. The remaining words are objcts.
+ sentence = _line.split()
+ verb = sentence[0]
+ objs = sentence[1:]
+ obj = objs[0]
# This long concatenated if is where the semantics of the
# build script are implemented. Note: 'hashit' can only come