grablines: allow inline comments
authorZac Medico <zmedico@gentoo.org>
Wed, 2 Mar 2011 17:59:11 +0000 (09:59 -0800)
committerZac Medico <zmedico@gentoo.org>
Mon, 14 Mar 2011 16:03:20 +0000 (09:03 -0700)
pym/portage/util/__init__.py

index f31f33d495983a38f425234d08bb2da3f454d593..8b27be5a3f355b30e4126d4762456efe6213f964 100644 (file)
@@ -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