Bug 1333564 - [manifestparser] Allow multi-character comment tokens, r?jmaher draft
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Wed, 25 Jan 2017 09:41:10 -0500
changeset 466824 54f17191340ace72a9cefa5591d4f79f83bd334c
parent 466730 a338e596b1d9f37186aaeddcfaa572ae043e578d
child 466825 feff0c1c04f933b583b3641222177607eef5bee9
push id43008
push userahalberstadt@mozilla.com
push dateThu, 26 Jan 2017 17:34:22 +0000
reviewersjmaher
bugs1333564
milestone54.0a1
Bug 1333564 - [manifestparser] Allow multi-character comment tokens, r?jmaher MozReview-Commit-ID: 8RDgAkBVmcK
testing/mozbase/manifestparser/manifestparser/ini.py
--- a/testing/mozbase/manifestparser/manifestparser/ini.py
+++ b/testing/mozbase/manifestparser/manifestparser/ini.py
@@ -3,17 +3,17 @@
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import os
 
 __all__ = ['read_ini', 'combine_fields']
 
 
 def read_ini(fp, variables=None, default='DEFAULT', defaults_only=False,
-             comments=';#', separators=('=', ':'), strict=True,
+             comments=(';', '#'), separators=('=', ':'), strict=True,
              handle_defaults=True):
     """
     read an .ini file and return a list of [(section, values)]
     - fp : file pointer or path to read
     - variables : default set of variables
     - default : name of the section for the default section
     - defaults_only : if True, return the default section only
     - comments : characters that if they start a line denote a comment
@@ -37,17 +37,17 @@ def read_ini(fp, variables=None, default
 
         # ignore blank lines
         if not stripped:
             # reset key and value to avoid continuation lines
             key = value = None
             continue
 
         # ignore comment lines
-        if stripped[0] in comments:
+        if any(stripped.startswith(c) for c in comments):
             continue
 
         # check for a new section
         if len(stripped) > 2 and stripped[0] == '[' and stripped[-1] == ']':
             section = stripped[1:-1].strip()
             key = value = None
 
             # deal with DEFAULT section