From b0115fb837bf197c64bb686ba6cf94aa52465379 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Wed, 2 Mar 2011 09:59:11 -0800 Subject: [PATCH] grablines: allow inline comments --- pym/portage/util/__init__.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py index f31f33d49..8b27be5a3 100644 --- a/pym/portage/util/__init__.py +++ b/pym/portage/util/__init__.py @@ -125,8 +125,18 @@ def grabfile(myfilename, compat_level=0, recursive=0, remember_source_file=False for x, source_file in mylines: #the split/join thing removes leading and trailing whitespace, and converts any whitespace in the line #into single spaces. - myline = _unicode_decode(' ').join(x.split()) - if not len(myline): + myline = x.split() + if x and x[0] != "#": + mylinetemp = [] + for item in myline: + if item[:1] != "#": + mylinetemp.append(item) + else: + break + myline = mylinetemp + + myline = " ".join(myline) + if not myline: continue if myline[0]=="#": # Check if we have a compat-level string. BC-integration data. @@ -316,7 +326,7 @@ def grabdict(myfilename, juststrings=0, empty=0, recursive=0, incremental=1): myline=x.split() mylinetemp = [] for item in myline: - if not item.startswith('#'): + if item[:1] != "#": mylinetemp.append(item) else: break -- 2.26.2