mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 09:45:41 +00:00
Bug 1604360 - [manifestparser] Remove unused 'defaults_only' logic r=egao
This flag is not passed in from anywhere in mozilla-central. Differential Revision: https://phabricator.services.mozilla.com/D57408 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
f360e451f9
commit
2f17f15aab
@ -24,14 +24,13 @@ class IniParseError(Exception):
|
|||||||
super(IniParseError, self).__init__(msg)
|
super(IniParseError, self).__init__(msg)
|
||||||
|
|
||||||
|
|
||||||
def read_ini(fp, variables=None, default='DEFAULT', defaults_only=False,
|
def read_ini(fp, variables=None, default='DEFAULT', comments=None,
|
||||||
comments=None, separators=None, strict=True, handle_defaults=True):
|
separators=None, strict=True, handle_defaults=True):
|
||||||
"""
|
"""
|
||||||
read an .ini file and return a list of [(section, values)]
|
read an .ini file and return a list of [(section, values)]
|
||||||
- fp : file pointer or path to read
|
- fp : file pointer or path to read
|
||||||
- variables : default set of variables
|
- variables : default set of variables
|
||||||
- default : name of the section for the default section
|
- 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
|
- comments : characters that if they start a line denote a comment
|
||||||
- separators : strings that denote key, value separation in order
|
- separators : strings that denote key, value separation in order
|
||||||
- strict : whether to be strict about parsing
|
- strict : whether to be strict about parsing
|
||||||
@ -137,10 +136,6 @@ def read_ini(fp, variables=None, default='DEFAULT', defaults_only=False,
|
|||||||
# something bad happened!
|
# something bad happened!
|
||||||
raise IniParseError(fp, linenum, "Unexpected line '{}'".format(stripped))
|
raise IniParseError(fp, linenum, "Unexpected line '{}'".format(stripped))
|
||||||
|
|
||||||
# return the default section only if requested
|
|
||||||
if defaults_only:
|
|
||||||
return [(default, variables)]
|
|
||||||
|
|
||||||
global_vars = variables if handle_defaults else {}
|
global_vars = variables if handle_defaults else {}
|
||||||
sections = [(i, combine_fields(global_vars, j)) for i, j in sections]
|
sections = [(i, combine_fields(global_vars, j)) for i, j in sections]
|
||||||
return sections
|
return sections
|
||||||
|
@ -74,7 +74,6 @@ class ManifestParser(object):
|
|||||||
variable in this case.
|
variable in this case.
|
||||||
"""
|
"""
|
||||||
self._defaults = defaults or {}
|
self._defaults = defaults or {}
|
||||||
self._ancestor_defaults = {}
|
|
||||||
self.tests = []
|
self.tests = []
|
||||||
self.manifest_defaults = {}
|
self.manifest_defaults = {}
|
||||||
self.source_files = set()
|
self.source_files = set()
|
||||||
@ -121,16 +120,13 @@ class ManifestParser(object):
|
|||||||
|
|
||||||
# methods for reading manifests
|
# methods for reading manifests
|
||||||
|
|
||||||
def _read(self, root, filename, defaults, defaults_only=False, parentmanifest=None):
|
def _read(self, root, filename, defaults, parentmanifest=None):
|
||||||
"""
|
"""
|
||||||
Internal recursive method for reading and parsing manifests.
|
Internal recursive method for reading and parsing manifests.
|
||||||
Stores all found tests in self.tests
|
Stores all found tests in self.tests
|
||||||
:param root: The base path
|
:param root: The base path
|
||||||
:param filename: File object or string path for the base manifest file
|
:param filename: File object or string path for the base manifest file
|
||||||
:param defaults: Options that apply to all items
|
:param defaults: Options that apply to all items
|
||||||
:param defaults_only: If True will only gather options, not include
|
|
||||||
tests. Used for upstream parent includes
|
|
||||||
(default False)
|
|
||||||
:param parentmanifest: Filename of the parent manifest (default None)
|
:param parentmanifest: Filename of the parent manifest (default None)
|
||||||
"""
|
"""
|
||||||
def read_file(type):
|
def read_file(type):
|
||||||
@ -187,10 +183,6 @@ class ManifestParser(object):
|
|||||||
|
|
||||||
# get the tests
|
# get the tests
|
||||||
for section, data in sections:
|
for section, data in sections:
|
||||||
# In case of defaults only, no section has to be processed.
|
|
||||||
if defaults_only:
|
|
||||||
continue
|
|
||||||
|
|
||||||
# a file to include
|
# a file to include
|
||||||
# TODO: keep track of included file structure:
|
# TODO: keep track of included file structure:
|
||||||
# self.manifests = {'manifest.ini': 'relative/path.ini'}
|
# self.manifests = {'manifest.ini': 'relative/path.ini'}
|
||||||
@ -202,10 +194,7 @@ class ManifestParser(object):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# otherwise an item
|
# otherwise an item
|
||||||
# apply ancestor defaults, while maintaining current file priority
|
test = data.copy()
|
||||||
data = dict(list(self._ancestor_defaults.items()) + list(data.items()))
|
|
||||||
|
|
||||||
test = data
|
|
||||||
test['name'] = section
|
test['name'] = section
|
||||||
|
|
||||||
# Will be None if the manifest being read is a file-like object.
|
# Will be None if the manifest being read is a file-like object.
|
||||||
@ -242,13 +231,6 @@ class ManifestParser(object):
|
|||||||
# append the item
|
# append the item
|
||||||
self.tests.append(test)
|
self.tests.append(test)
|
||||||
|
|
||||||
# if no parent: section was found for defaults-only, only read the
|
|
||||||
# defaults section of the manifest without interpreting variables
|
|
||||||
if defaults_only:
|
|
||||||
sections = read_ini(fp=fp, variables=defaults, defaults_only=True,
|
|
||||||
strict=self.strict)
|
|
||||||
(section, self._ancestor_defaults) = sections[0]
|
|
||||||
|
|
||||||
def read(self, *filenames, **defaults):
|
def read(self, *filenames, **defaults):
|
||||||
"""
|
"""
|
||||||
read and add manifests from file paths or file-like objects
|
read and add manifests from file paths or file-like objects
|
||||||
|
Loading…
Reference in New Issue
Block a user