|
@@ -1645,6 +1645,27 @@ class UnhosedConfigParser(ConfigParser.RawConfigParser):
|
|
|
s = StringIO(s)
|
|
|
return self.readfp(s)
|
|
|
|
|
|
+ def read(self, filenames, **kwargs):
|
|
|
+ '''Attempt to read and parse a list of filenames, returning a list
|
|
|
+ of filenames which were successfully parsed. This is a method of
|
|
|
+ RawConfigParser that is overridden to build self.section_to_file,
|
|
|
+ which is a mapping of section names to the files they came from.
|
|
|
+ '''
|
|
|
+ if isinstance(filenames, basestring): # RawConfigParser compat
|
|
|
+ filenames = [filenames]
|
|
|
+
|
|
|
+ ok_filenames = []
|
|
|
+ for filename in filenames:
|
|
|
+ sections_orig = self._sections.copy()
|
|
|
+
|
|
|
+ ok_filenames.extend(
|
|
|
+ ConfigParser.RawConfigParser.read(self, [filename], **kwargs))
|
|
|
+
|
|
|
+ diff = frozenset(self._sections) - frozenset(sections_orig)
|
|
|
+ for section in diff:
|
|
|
+ self.section_to_file[section] = filename
|
|
|
+ return ok_filenames
|
|
|
+
|
|
|
def saneget(self, section, option, default=_marker, do_expand=True,
|
|
|
expansions={}):
|
|
|
try:
|
|
@@ -1668,22 +1689,6 @@ class UnhosedConfigParser(ConfigParser.RawConfigParser):
|
|
|
return self.saneget(self.mysection, option, default=default,
|
|
|
expansions=expansions, **kwargs)
|
|
|
|
|
|
- def read(self, filenames, **kwargs):
|
|
|
- if isinstance(filenames, basestring): # RawConfigParser compat
|
|
|
- filenames = [filenames]
|
|
|
-
|
|
|
- ok_filenames = []
|
|
|
- for filename in filenames:
|
|
|
- sections_orig = self._sections.copy()
|
|
|
-
|
|
|
- ok_filenames.extend(
|
|
|
- ConfigParser.RawConfigParser.read(self, [filename], **kwargs))
|
|
|
-
|
|
|
- diff = frozenset(self._sections) - frozenset(sections_orig)
|
|
|
- for section in diff:
|
|
|
- self.section_to_file[section] = filename
|
|
|
- return ok_filenames
|
|
|
-
|
|
|
|
|
|
class Config(object):
|
|
|
def __ne__(self, other):
|