Fix package and image list comment cleanup

When cleaning up comments from lines of the form:

  foo bar # this is a comment

You want to remove remove everything after the first comment character
not after the last comment character. This is because:

  foo bar # this is # a comment

Should get everything after bar removed not everything after is.
Unfortunately when you use str.rfind() you remove everything after is
not everything after bar. Switch to regular trusty find to fix this.

Change-Id: I78aa6b51b5be03bd3b8ce7885415442171218977
This commit is contained in:
Clark Boylan 2016-04-19 17:27:14 -07:00
parent c1bf90ec40
commit 7f35178617
2 changed files with 4 additions and 4 deletions

View File

@ -81,7 +81,7 @@ def tokenize(fn, tokens, distribution, comment=None):
if 'qpid' in line:
continue # TODO: explain why this is here
if comment and comment in line:
line = line[:line.rfind(comment)]
line = line[:line.find(comment)]
line = line.strip()
if line and line not in tokens:
tokens.append(line)
@ -94,7 +94,7 @@ def _legacy_find_images(basedir):
line = line.strip()
if line.startswith('IMAGE_URLS'):
if '#' in line:
line = line[:line.rfind('#')]
line = line[:line.find('#')]
if line.endswith(';;'):
line = line[:-2]
line = line.split('=', 1)[1].strip()

View File

@ -46,7 +46,7 @@ def tokenize(fn, tokens, distribution, comment=None):
if 'qpid' in line:
continue # TODO: explain why this is here
if comment and comment in line:
line = line[:line.rfind(comment)]
line = line[:line.find(comment)]
line = line.strip()
if line and line not in tokens:
tokens.append(line)
@ -59,7 +59,7 @@ def _legacy_find_images(basedir):
line = line.strip()
if line.startswith('IMAGE_URLS'):
if '#' in line:
line = line[:line.rfind('#')]
line = line[:line.find('#')]
if line.endswith(';;'):
line = line[:-2]
line = line.split('=', 1)[1].strip()