Bug 1333564 - [manifestparser] Allow multi-character comment tokens, r?jmaher
MozReview-Commit-ID: 8RDgAkBVmcK
--- 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