Coverage for src/robotide/preferences/configobj/src/configobj/__init__.py: 76%
1110 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-06 10:40 +0100
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-06 10:40 +0100
1# configobj.py
2# A config file reader/writer that supports nested sections in config files.
3# Copyright (C) 2005-2014:
4# (name) : (email)
5# Michael Foord: fuzzyman AT voidspace DOT org DOT uk
6# Nicola Larosa: nico AT tekNico DOT net
7# Rob Dennis: rdennis AT gmail DOT com
8# Eli Courtwright: eli AT courtwright DOT org
10# This software is licensed under the terms of the BSD license.
11# http://opensource.org/licenses/BSD-3-Clause
13# ConfigObj 5 - main repository for documentation and issue tracking:
14# https://github.com/DiffSK/configobj
16import os 2a pc
17import re 2a pc
18import sys 2a pc
20from codecs import BOM_UTF8, BOM_UTF16, BOM_UTF16_BE, BOM_UTF16_LE 2a pc
22from ._version import __version__ 2a pc
24# imported lazily to avoid startup performance hit if it isn't used
25compiler = None 2a pc
27# A dictionary mapping BOM to
28# the encoding to decode with, and what to set the
29# encoding attribute to.
30BOMS = { 2a pc
31 BOM_UTF8: ('utf_8', None),
32 BOM_UTF16_BE: ('utf16_be', 'utf_16'),
33 BOM_UTF16_LE: ('utf16_le', 'utf_16'),
34 BOM_UTF16: ('utf_16', 'utf_16'),
35 }
36# All legal variants of the BOM codecs.
37# TODO: the list of aliases is not meant to be exhaustive, is there a
38# better way ?
39BOM_LIST = { 2a pc
40 'utf_16': 'utf_16',
41 'u16': 'utf_16',
42 'utf16': 'utf_16',
43 'utf-16': 'utf_16',
44 'utf16_be': 'utf16_be',
45 'utf_16_be': 'utf16_be',
46 'utf-16be': 'utf16_be',
47 'utf16_le': 'utf16_le',
48 'utf_16_le': 'utf16_le',
49 'utf-16le': 'utf16_le',
50 'utf_8': 'utf_8',
51 'u8': 'utf_8',
52 'utf': 'utf_8',
53 'utf8': 'utf_8',
54 'utf-8': 'utf_8',
55 }
57# Map of encodings to the BOM to write.
58BOM_SET = { 2a pc
59 'utf_8': BOM_UTF8,
60 'utf_16': BOM_UTF16,
61 'utf16_be': BOM_UTF16_BE,
62 'utf16_le': BOM_UTF16_LE,
63 None: BOM_UTF8
64 }
67def match_utf8(encoding): 2a pc
68 return BOM_LIST.get(encoding.lower()) == 'utf_8'
71# Quote strings used for writing values
72squot = "'%s'" 2a pc
73dquot = '"%s"' 2a pc
74noquot = "%s" 2a pc
75wspace_plus = ' \r\n\v\t\'"' 2a pc
76tsquot = '"""%s"""' 2a pc
77tdquot = "'''%s'''" 2a pc
79# Sentinel for use in getattr calls to replace hasattr
80MISSING = object() 2a pc
82__all__ = ( 2a pc
83 'DEFAULT_INDENT_TYPE',
84 'DEFAULT_INTERPOLATION',
85 'ConfigObjError',
86 'NestingError',
87 'ParseError',
88 'DuplicateError',
89 'ConfigspecError',
90 'ConfigObj',
91 'SimpleVal',
92 'InterpolationError',
93 'InterpolationLoopError',
94 'MissingInterpolationOption',
95 'RepeatSectionError',
96 'ReloadError',
97 'UnreprError',
98 'UnknownType',
99 'flatten_errors',
100 'get_extra_values'
101)
103DEFAULT_INTERPOLATION = 'configparser' 2a pc
104DEFAULT_INDENT_TYPE = ' ' 2a pc
105MAX_INTERPOL_DEPTH = 10 2a pc
107OPTION_DEFAULTS = { 2a pc
108 'interpolation': True,
109 'raise_errors': False,
110 'list_values': True,
111 'create_empty': False,
112 'file_error': False,
113 'configspec': None,
114 'stringify': True,
115 # option may be set to one of ('', ' ', '\t')
116 'indent_type': None,
117 'encoding': None,
118 'default_encoding': None,
119 'unrepr': False,
120 'write_empty_values': False,
121}
123def getObj(s): 2a pc
124 global compiler
125 if compiler is None:
126 import compiler
127 s = "a=" + s
128 p = compiler.parse(s)
129 return p.getChildren()[1].getChildren()[0].getChildren()[1]
132class UnknownType(Exception): 2a pc
133 pass 2a pc
136class Builder(object): 2a pc
138 def build(self, o): 2a pc
139 if m is None:
140 raise UnknownType(o.__class__.__name__)
141 return m(o)
143 def build_List(self, o): 2a pc
144 return list(map(self.build, o.getChildren()))
146 def build_Const(self, o): 2a pc
147 return o.value
149 def build_Dict(self, o): 2a pc
150 d = {}
151 i = iter(map(self.build, o.getChildren()))
152 for el in i:
153 d[el] = next(i)
154 return d
156 def build_Tuple(self, o): 2a pc
157 return tuple(self.build_List(o))
159 def build_Name(self, o): 2a pc
160 if o.name == 'None':
161 return None
162 if o.name == 'True':
163 return True
164 if o.name == 'False':
165 return False
167 # An undefined Name
168 raise UnknownType('Undefined Name')
170 def build_Add(self, o): 2a pc
171 real, imag = list(map(self.build_Const, o.getChildren()))
172 try:
173 real = float(real)
174 except TypeError:
175 raise UnknownType('Add')
176 if not isinstance(imag, complex) or imag.real != 0.0:
177 raise UnknownType('Add')
178 return real+imag
180 def build_Getattr(self, o): 2a pc
181 parent = self.build(o.expr)
182 return getattr(parent, o.attrname)
184 def build_UnarySub(self, o): 2a pc
185 return -self.build_Const(o.getChildren()[0])
187 def build_UnaryAdd(self, o): 2a pc
188 return self.build_Const(o.getChildren()[0])
191_builder = Builder() 2a pc
194def unrepr(s): 2a pc
195 if not s: 195 ↛ 196line 195 didn't jump to line 196 because the condition on line 195 was never true2a u `b]bdc)bvcwcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
196 return s
198 # this is supposed to be safe
199 import ast 2a u `b]bdc)bvcwcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
200 return ast.literal_eval(s) 2a u `b]bdc)bvcwcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
203class ConfigObjError(SyntaxError): 2a pc
204 """
205 This is the base class for all errors that ConfigObj raises.
206 It is a subclass of SyntaxError.
207 """
208 def __init__(self, message='', line_number=None, line=''): 2a pc
209 self.line = line 2icjcWcxc7c6c8cycPd?bfcPbuc
210 self.line_number = line_number 2icjcWcxc7c6c8cycPd?bfcPbuc
211 SyntaxError.__init__(self, message) 2icjcWcxc7c6c8cycPd?bfcPbuc
214class NestingError(ConfigObjError): 2a pc
215 """
216 This error indicates a level of nesting that doesn't match.
217 """
220class ParseError(ConfigObjError): 2a pc
221 """
222 This error indicates that a line is badly written.
223 It is neither a valid ``key = value`` line,
224 nor a valid section marker line.
225 """
228class ReloadError(IOError): 2a pc
229 """
230 A 'reload' operation failed.
231 This exception is a subclass of ``IOError``.
232 """
233 def __init__(self): 2a pc
234 IOError.__init__(self, 'reload failed, filename is not set.') 2McPd
237class DuplicateError(ConfigObjError): 2a pc
238 """
239 The keyword or section specified already exists.
240 """
243class ConfigspecError(ConfigObjError): 2a pc
244 """
245 An error occured whilst parsing a configspec.
246 """
249class InterpolationError(ConfigObjError): 2a pc
250 """Base class for the two interpolation errors."""
253class InterpolationLoopError(InterpolationError): 2a pc
254 """Maximum interpolation depth exceeded in string interpolation."""
256 def __init__(self, option): 2a pc
257 InterpolationError.__init__( 2WcPd
258 self,
259 'interpolation loop detected in value "%s".' % option)
262class RepeatSectionError(ConfigObjError): 2a pc
263 """
264 This error indicates additional sections in a section with a
265 ``__many__`` (repeated) section.
266 """
269class MissingInterpolationOption(InterpolationError): 2a pc
270 """A value specified for interpolation was missing."""
271 def __init__(self, option): 2a pc
272 msg = 'missing option "%s" in interpolation.' % option 2WcPd?b
273 InterpolationError.__init__(self, msg) 2WcPd?b
276class UnreprError(ConfigObjError): 2a pc
277 """An error parsing in unrepr mode."""
281class InterpolationEngine(object): 2a pc
282 """
283 A helper class to help perform string interpolation.
285 This class is an abstract base class; its descendants perform
286 the actual work.
287 """
289 # compiled regexp to use in self.interpolate()
290 _KEYCRE = re.compile(r"%\(([^)]*)\)s") 2a pc
291 _cookie = '%' 2a pc
293 def __init__(self, section): 2a pc
294 # the Section instance that "owns" this engine
295 self.section = section 2a u yb[bbckcccWcXcVcc 4c#bRbYc5cZc^bgcb Dce ?bCbqcAcd v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ t {b|b}b~bac[ zb] ^ _ ` SbPbecYbZbBb1blc2b3b4b5b6b7bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
298 def interpolate(self, key, value): 2a pc
299 # short-cut
300 if not self._cookie in value: 2a u yb[bbckcccWcXcVcc 4c#bRbYc5cZc^bgcb Dce ?bCbqcAcd !c#c$c%cv 'crbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 (c)c*c+c,c-c.c/c:c;c=c?c@c[c]c^c_c`c{c|c}c9c~cadbdcdddedfd! # $ % ' ( ) * + xb, - . / : ; = ? @ t {b|b}b~bac[ zb] ^ _ ` SbPbecYbZbBb1blc2b3b4b5b6b7bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
301 return value 2a u yb[bbckcccVcc 4c#bRbYc5cZc^bgcb Dce ?bCbAcd !c#c$c%cv 'crbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 (c)c*c+c,c-c.c/c:c;c=c?c@c[c]c^c_c`c{c|c}c9c~cadbdcdddedfd! # $ % ' ( ) * + xb, - . / : ; = ? @ t {b|b}b~bac[ zb] ^ _ ` SbPbecYbZbBb1blc2b3b4b5b6b7bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
303 def recursive_interpolate(key, value, section, backtrail): 2WcXcVc?bCbqc
304 """The function that does the actual work.
306 ``value``: the string we're trying to interpolate.
307 ``section``: the section in which that string was found
308 ``backtrail``: a dict to keep track of where we've been,
309 to detect and prevent infinite recursion loops
311 This is similar to a depth-first-search algorithm.
312 """
313 # Have we been here already?
314 if (key, section.name) in backtrail: 2WcXcVc?bCbqc
315 # Yes - infinite loop detected
316 raise InterpolationLoopError(key) 2Wc
317 # Place a marker on our backtrail so we won't come back here again
318 backtrail[(key, section.name)] = 1 2WcXcVc?bCbqc
320 # Now start the actual work
321 match = self._KEYCRE.search(value) 2WcXcVc?bCbqc
322 while match: 2WcXcVc?bCbqc
323 # The actual parsing of the match is implementation-dependent,
324 # so delegate to our helper function
325 k, v, s = self._parse_match(match) 2WcXcVc?bCbqc
326 if k is None: 2WcXcVcCbqc
327 # That's the signal that no further interpolation is needed
328 replacement = v 2Vc
329 else:
330 # Further interpolation may be needed to obtain final value
331 replacement = recursive_interpolate(k, v, s, backtrail) 2WcXcVcCbqc
332 # Replace the matched string with its final value
333 start, end = match.span() 2XcVcCbqc
334 value = ''.join((value[:start], replacement, value[end:])) 2XcVcCbqc
335 new_search_start = start + len(replacement) 2XcVcCbqc
336 # Pick up the next interpolation key, if any, for next time
337 # through the while loop
338 match = self._KEYCRE.search(value, new_search_start) 2XcVcCbqc
340 # Now safe to come back here again; remove marker from backtrail
341 del backtrail[(key, section.name)] 2XcVcCbqc
343 return value 2XcVcCbqc
345 # Back in interpolate(), all we have to do is kick off the recursive
346 # function with appropriate starting values
347 value = recursive_interpolate(key, value, self.section, {}) 2WcXcVc?bCbqc
348 return value 2XcVcCbqc
351 def _fetch(self, key): 2a pc
352 """Helper function to fetch values from owning section.
354 Returns a 2-tuple: the value, and the section where it was found.
355 """
356 # switch off interpolation before we try and fetch anything !
357 save_interp = self.section.main.interpolation 2WcXcVc?bCbqc
358 self.section.main.interpolation = False 2WcXcVc?bCbqc
360 # Start at section that "owns" this InterpolationEngine
361 current_section = self.section 2WcXcVc?bCbqc
362 while True: 2WcXcVc?bCbqc
363 # try the current section first
364 val = current_section.get(key) 2WcXcVc?bCbqc
365 if val is not None and not isinstance(val, Section): 2WcXcVc?bCbqc
366 break 2WcXcVcCbqc
367 # try "DEFAULT" next
368 val = current_section.get('DEFAULT', {}).get(key) 2WcXcVc?bCb
369 if val is not None and not isinstance(val, Section): 2WcXcVc?bCb
370 break 2XcVc
371 # move up to parent and try again
372 # top-level's parent is itself
373 if current_section.parent is current_section: 2WcXcVc?bCb
374 # reached top level, time to give up
375 break 2Wc?b
376 current_section = current_section.parent 2WcXcVcCb
378 # restore interpolation to previous value before returning
379 self.section.main.interpolation = save_interp 2WcXcVc?bCbqc
380 if val is None: 2WcXcVc?bCbqc
381 raise MissingInterpolationOption(key) 2Wc?b
382 return val, current_section 2WcXcVcCbqc
385 def _parse_match(self, match): 2a pc
386 """Implementation-dependent helper function.
388 Will be passed a match object corresponding to the interpolation
389 key we just found (e.g., "%(foo)s" or "$foo"). Should look up that
390 key in the appropriate config file section (using the ``_fetch()``
391 helper function) and return a 3-tuple: (key, value, section)
393 ``key`` is the name of the key we're looking for
394 ``value`` is the value found for that key
395 ``section`` is a reference to the section where it was found
397 ``key`` and ``section`` should be None if no further
398 interpolation should be performed on the resulting value
399 (e.g., if we interpolated "$$" and returned "$").
400 """
401 raise NotImplementedError()
405class ConfigParserInterpolation(InterpolationEngine): 2a pc
406 """Behaves like ConfigParser."""
407 _cookie = '%' 2a pc
408 _KEYCRE = re.compile(r"%\(([^)]*)\)s") 2a pc
410 def _parse_match(self, match): 2a pc
411 key = match.group(1) 2WcXcqc
412 value, section = self._fetch(key) 2WcXcqc
413 return key, value, section 2WcXcqc
417class TemplateInterpolation(InterpolationEngine): 2a pc
418 """Behaves like string.Template."""
419 _cookie = '$' 2a pc
420 _delimiter = '$' 2a pc
421 _KEYCRE = re.compile(r""" 2a pc
422 \$(?:
423 (?P<escaped>\$) | # Two $ signs
424 (?P<named>[_a-z][_a-z0-9]*) | # $name format
425 {(?P<braced>[^}]*)} # ${name} format
426 )
427 """, re.IGNORECASE | re.VERBOSE)
429 def _parse_match(self, match): 2a pc
430 # Valid name (in or out of braces): fetch value from section
431 key = match.group('named') or match.group('braced') 2Vc?bCb
432 if key is not None: 2Vc?bCb
433 value, section = self._fetch(key) 2Vc?bCb
434 return key, value, section 2VcCb
435 # Escaped delimiter (e.g., $$): return single delimiter
436 if match.group('escaped') is not None: 436 ↛ 440line 436 didn't jump to line 440 because the condition on line 436 was always true2Vc
437 # Return None for key and section to indicate it's time to stop
438 return None, self._delimiter, None 2Vc
439 # Anything else: ignore completely, just return it unchanged
440 return None, match.group(), None
443interpolation_engines = { 2a pc
444 'configparser': ConfigParserInterpolation,
445 'template': TemplateInterpolation,
446}
449def __newobj__(cls, *args): 2a pc
450 # Hack for pickle
451 return cls.__new__(cls, *args)
453class Section(dict): 2a pc
454 """
455 A dictionary-like object that represents a section in a config file.
457 It does string interpolation if the 'interpolation' attribute
458 of the 'main' object is set to True.
460 Interpolation is tried first from this object, then from the 'DEFAULT'
461 section of this object, next from the parent and its 'DEFAULT' section,
462 and so on until the main object is reached.
464 A Section will behave like an ordered dictionary - following the
465 order of the ``scalars`` and ``sections`` attributes.
466 You can use this to change the order of members.
468 Iteration follows the order: scalars, then sections.
469 """
472 def __setstate__(self, state): 2a pc
473 dict.update(self, state[0])
474 self.__dict__.update(state[1])
476 def __reduce__(self): 2a pc
477 state = (dict(self), self.__dict__)
478 return (__newobj__, (self.__class__,), state)
481 def __init__(self, parent, depth, main, indict=None, name=None): 2a pc
482 """
483 * parent is the section above
484 * depth is the depth level of this section
485 * main is the main ConfigObj
486 * indict is a dictionary to initialise the section with
487 """
488 if indict is None: 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZb0c1cGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
489 indict = {} 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
490 dict.__init__(self) 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZb0c1cGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
491 # used for nesting level *and* interpolation
492 self.parent = parent 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZb0c1cGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
493 # used for the interpolation attribute
494 self.main = main 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZb0c1cGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
495 # level of nesting depth of this Section
496 self.depth = depth 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZb0c1cGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
497 # purely for information
498 self.name = name 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZb0c1cGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
499 #
500 self._initialise() 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZb0c1cGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
501 # we do this explicitly so that __setitem__ is used properly
502 # (rather than just passing to ``dict.__init__``)
503 for entry, value in indict.items(): 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZb0c1cGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
504 self[entry] = value 2a zcDcscEcWb
507 def _initialise(self): 2a pc
508 # the sequence of scalar values in this Section
509 self.scalars = [] 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZb0c1cGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
510 # the sequence of sections in this Section
511 self.sections = [] 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZb0c1cGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
512 # for comments :-)
513 self.comments = {} 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZb0c1cGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
514 self.inline_comments = {} 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZb0c1cGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
515 # the configspec
516 self.configspec = None 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZb0c1cGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
517 # for defaults
518 self.defaults = [] 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZb0c1cGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
519 self.default_values = {} 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZb0c1cGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
520 self.extra_values = [] 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZb0c1cGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
521 self._created = False 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZb0c1cGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
524 def _interpolate(self, key, value): 2a pc
525 try: 2a u yb[bbckcccWcXcVcc 4c#bRbYc5cZc^bgcb Dce ?bCbqcAcd !c#c$c%cv 'crbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 (c)c*c+c,c-c.c/c:c;c=c?c@c[c]c^c_c`c{c|c}c9c~cadbdcdddedfd! # $ % ' ( ) * + xb, - . / : ; = ? @ t {b|b}b~bac[ zb] ^ _ ` SbPbecYbZbBb1blc2b3b4b5b6b7bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
526 # do we already have an interpolation engine?
527 engine = self._interpolation_engine 2a u yb[bbckcccWcXcVcc 4c#bRbYc5cZc^bgcb Dce ?bCbqcAcd !c#c$c%cv 'crbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 (c)c*c+c,c-c.c/c:c;c=c?c@c[c]c^c_c`c{c|c}c9c~cadbdcdddedfd! # $ % ' ( ) * + xb, - . / : ; = ? @ t {b|b}b~bac[ zb] ^ _ ` SbPbecYbZbBb1blc2b3b4b5b6b7bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
528 except AttributeError: 2a u yb[bbckcccWcXcVcc 4c#bRbYc5cZc^bgcb Dce ?bCbqcAcd v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ t {b|b}b~bac[ zb] ^ _ ` SbPbecYbZbBb1blc2b3b4b5b6b7bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
529 # not yet: first time running _interpolate(), so pick the engine
530 name = self.main.interpolation 2a u yb[bbckcccWcXcVcc 4c#bRbYc5cZc^bgcb Dce ?bCbqcAcd v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ t {b|b}b~bac[ zb] ^ _ ` SbPbecYbZbBb1blc2b3b4b5b6b7bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
531 if name == True: # note that "if name:" would be incorrect here 2a u yb[bbckcccWcXcVcc 4c#bRbYc5cZc^bgcb Dce ?bCbqcAcd v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ t {b|b}b~bac[ zb] ^ _ ` SbPbecYbZbBb1blc2b3b4b5b6b7bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
532 # backwards-compatibility: interpolation=True means use default
533 name = DEFAULT_INTERPOLATION 2a u yb[bbckcccWcXcc 4c#bRbYc5cZc^bgcb Dce qcAcd v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ t {b|b}b~bac[ zb] ^ _ ` SbPbecYbZbBb1blc2b3b4b5b6b7bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
534 name = name.lower() # so that "Template", "template", etc. all work 2a u yb[bbckcccWcXcVcc 4c#bRbYc5cZc^bgcb Dce ?bCbqcAcd v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ t {b|b}b~bac[ zb] ^ _ ` SbPbecYbZbBb1blc2b3b4b5b6b7bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
535 class_ = interpolation_engines.get(name, None) 2a u yb[bbckcccWcXcVcc 4c#bRbYc5cZc^bgcb Dce ?bCbqcAcd v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ t {b|b}b~bac[ zb] ^ _ ` SbPbecYbZbBb1blc2b3b4b5b6b7bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
536 if class_ is None: 536 ↛ 538line 536 didn't jump to line 538 because the condition on line 536 was never true2a u yb[bbckcccWcXcVcc 4c#bRbYc5cZc^bgcb Dce ?bCbqcAcd v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ t {b|b}b~bac[ zb] ^ _ ` SbPbecYbZbBb1blc2b3b4b5b6b7bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
537 # invalid value for self.main.interpolation
538 self.main.interpolation = False
539 return value
540 else:
541 # save reference to engine so we don't have to do this again
542 engine = self._interpolation_engine = class_(self) 2a u yb[bbckcccWcXcVcc 4c#bRbYc5cZc^bgcb Dce ?bCbqcAcd v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ t {b|b}b~bac[ zb] ^ _ ` SbPbecYbZbBb1blc2b3b4b5b6b7bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
543 # let the engine do the actual work
544 return engine.interpolate(key, value) 2a u yb[bbckcccWcXcVcc 4c#bRbYc5cZc^bgcb Dce ?bCbqcAcd !c#c$c%cv 'crbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 (c)c*c+c,c-c.c/c:c;c=c?c@c[c]c^c_c`c{c|c}c9c~cadbdcdddedfd! # $ % ' ( ) * + xb, - . / : ; = ? @ t {b|b}b~bac[ zb] ^ _ ` SbPbecYbZbBb1blc2b3b4b5b6b7bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
547 def __getitem__(self, key): 2a pc
548 """Fetch the item and do string interpolation."""
549 val = dict.__getitem__(self, key) 2a u Nc_btcXb`bocUc]byb[bbckccc0b9bzcWcXcSdVcc 4c#bRb)bvcYc5cZc^bgcb =b@b8bDce ?bscCbqcAcCcf d Fc!c#c$c%cv 'cOcQdrbsbtbubvbw gdhdidwbs x y z RdA B C D E F G H I J K L jdg h i j k l M N O m n Dbo P Q R p S T kdU V W ldmdndodpdqdrdsdtdudvdwdxdydzdAdBdCdDdEdFdGdHdIdJcKcLcPcQcRcJdX Y Z 0 1 2 3 4 5 6 7 8 9 (c)c*c+c,c-c.c/c:c;c=c?c@c[c]c^c_c`c{c|c}c9c~cadbdcdddedfd! # $ % ' ( ) * + KdLdMdxbNd, - Od. / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$becYb!bZb0c1cTcGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4b5b6b(b7b;bmcAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
550 if self.main.interpolation: 2a u Nc_btcXb`bocUc]byb[bbckccc0b9bzcWcXcSdVcc 4c#bRb)bvcYc5cZc^bgcb =b@b8bDce ?bscCbqcAcCcf d Fc!c#c$c%cv 'cOcQdrbsbtbubvbw gdhdidwbs x y z RdA B C D E F G H I J K L jdg h i j k l M N O m n Dbo P Q R p S T kdU V W ldmdndodpdqdrdsdtdudvdwdxdydzdAdBdCdDdEdFdGdHdIdJcKcLcPcQcRcJdX Y Z 0 1 2 3 4 5 6 7 8 9 (c)c*c+c,c-c.c/c:c;c=c?c@c[c]c^c_c`c{c|c}c9c~cadbdcdddedfd! # $ % ' ( ) * + KdLdMdxbNd, - Od. / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$becYb!bZb0c1cTcGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4b5b6b(b7b;bmcAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
551 if isinstance(val, str): 2a u Nc_b`b]byb[bbckcccWcXcVcc 4c#bRbvcYc5cZc^bgcb Dce ?bCbqcAcCcd Fc!c#c$c%cv 'cOcQdrbsbtbubvbw gdhdidwbs x y z RdA B C D E F G H I J K L jdg h i j k l M N O m n Dbo P Q R p S T kdU V W ldmdndodpdqdrdsdtdudvdwdxdydzdAdBdCdDdEdFdGdHdIdJcKcLcPcQcRcJdX Y Z 0 1 2 3 4 5 6 7 8 9 (c)c*c+c,c-c.c/c:c;c=c?c@c[c]c^c_c`c{c|c}c9c~cadbdcdddedfd! # $ % ' ( ) * + KdLdMdxbNd, - Od. / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$becYbZb0c1cTcGcTbHc2cQb3cBbUbVb1blc2b3b4b5b6b7bmcAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
552 return self._interpolate(key, val) 2a u yb[bbckcccWcXcVcc 4c#bRbYc5cZcgcb Dce ?bCbd !c#c$c%cv 'crbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 (c)c*c+c,c-c.c/c:c;c=c?c@c[c]c^c_c`c{c|c}c9c~cadbdcdddedfd! # $ % ' ( ) * + xb, - . / : ; = ? @ t {b|b}b~bac[ zb] ^ _ ` SbPbecYbZbBb1blc2b3b4b5b6b7bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
553 if isinstance(val, list): 2a u Nc_b`b]byb[bWcXcVcc 4c#bRbvc^bb Dce ?bCbqcAcCcFc!c#c$c%cv 'cOcQdrbsbtbubvbw gdhdidwbs x y z RdA B C D E F G H I J K L jdg h i j k l M N O m n Dbo P Q R p S T kdU V W ldmdndodpdqdrdsdtdudvdwdxdydzdAdBdCdDdEdFdGdHdIdJcKcLcPcQcRcJdX Y Z 0 1 2 3 4 5 6 7 8 9 (c)c*c+c,c-c.c/c:c;c=c?c@c[c]c^c_c`c{c|c}c9c~cadbdcdddedfd! # $ % ' ( ) * + KdLdMdxbNd, - Od. / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` Sb$b0c1cTcGcTbHc2cQb3cBbUbVbAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
554 def _check(entry): 2a u ^bqcAcv rbsbtbubvbw gdhdidwbs x y z A B C D E F G H I J K L jdg h i j k l M N O m n Dbo P Q R p S T kdU V W ldmdndodpdqdrdsdtdudvdwdxdydzdAdBdCdDdEdFdGdHdIdJcKcLcJdX Y Z 0 1 2 3 4 5 6 7 8 9 9c! # $ % ' ( ) * + KdLdMdxbNd, - Od. / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` q { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
555 if isinstance(entry, str): 2a u ^bqcAcv rbsbtbubvbw s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ zb] ^ _ ` q { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
556 return self._interpolate(key, entry) 2a u ^bqcAcv w s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ ] ^ _ ` q { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
557 return entry 2a u v rbsbtbubvbw s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ zb] ^ _ ` q { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
558 new = [_check(entry) for entry in val] 2a u ^bqcAcv rbsbtbubvbw gdhdidwbs x y z A B C D E F G H I J K L jdg h i j k l M N O m n Dbo P Q R p S T kdU V W ldmdndodpdqdrdsdtdudvdwdxdydzdAdBdCdDdEdFdGdHdIdJcKcLcJdX Y Z 0 1 2 3 4 5 6 7 8 9 9c! # $ % ' ( ) * + KdLdMdxbNd, - Od. / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` q { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
559 if new != val: 2a u ^bqcAcv rbsbtbubvbw gdhdidwbs x y z A B C D E F G H I J K L jdg h i j k l M N O m n Dbo P Q R p S T kdU V W ldmdndodpdqdrdsdtdudvdwdxdydzdAdBdCdDdEdFdGdHdIdJcKcLcJdX Y Z 0 1 2 3 4 5 6 7 8 9 9c! # $ % ' ( ) * + KdLdMdxbNd, - Od. / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` q { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
560 return new 2qc
561 return val 2a u Nc_btcXb`bocUc]byb[b0b9bzcWcXcSdVcc 4c#bRb)bvc^bb =b@b8bDce ?bscCbqcAcCcf d Fc!c#c$c%cv 'cOcQdrbsbtbubvbw gdhdidwbs x y z RdA B C D E F G H I J K L jdg h i j k l M N O m n Dbo P Q R p S T kdU V W ldmdndodpdqdrdsdtdudvdwdxdydzdAdBdCdDdEdFdGdHdIdJcKcLcPcQcRcJdX Y Z 0 1 2 3 4 5 6 7 8 9 (c)c*c+c,c-c.c/c:c;c=c?c@c[c]c^c_c`c{c|c}c9c~cadbdcdddedfd! # $ % ' ( ) * + KdLdMdxbNd, - Od. / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZb0c1cTcGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
564 def __setitem__(self, key, value, unrepr=False): 2a pc
565 """
566 Correctly set a value.
568 Making dictionary values Section instances.
569 (We have to special case 'Section' instances - which are also dicts)
571 Keys must be strings.
572 Values need only be strings (or lists of strings) if
573 ``main.stringify`` is set.
575 ``unrepr`` must be set when setting a value to a dictionary, without
576 creating a new sub-section.
577 """
578 if not isinstance(key, str): 578 ↛ 579line 578 didn't jump to line 579 because the condition on line 578 was never true2a u Nc_btcXb`bicjcocUc]byb[bbckccc0b9bzcc #bRbdc)bvcwcYc5cZchc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPb$becYb!bZb0c1cTcGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
579 raise ValueError('The key "%s" is not a string.' % key)
581 # add the comment
582 if key not in self.comments: 2a u Nc_btcXb`bicjcocUc]byb[bbckccc0b9bzcc #bRbdc)bvcwcYc5cZchc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPb$becYb!bZb0c1cTcGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
583 self.comments[key] = [] 2a u Nc_btcXb`bicjcocUc]byb[bbckccc0b9bzcc #bRbdc)bvcwcYc5cZchc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPb$becYb!bZb0c1cTcGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
584 self.inline_comments[key] = '' 2a u Nc_btcXb`bicjcocUc]byb[bbckccc0b9bzcc #bRbdc)bvcwcYc5cZchc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPb$becYb!bZb0c1cTcGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
585 # remove the entry from defaults
586 if key in self.defaults: 586 ↛ 587line 586 didn't jump to line 587 because the condition on line 586 was never true2a u Nc_btcXb`bicjcocUc]byb[bbckccc0b9bzcc #bRbdc)bvcwcYc5cZchc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPb$becYb!bZb0c1cTcGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
587 self.defaults.remove(key)
588 #
589 if isinstance(value, Section): 2a u Nc_btcXb`bicjcocUc]byb[bbckccc0b9bzcc #bRbdc)bvcwcYc5cZchc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPb$becYb!bZb0c1cTcGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
590 if key not in self: 590 ↛ 592line 590 didn't jump to line 592 because the condition on line 590 was always true2a u _bXb`bicjcyb[b0b9bc #bRbb e Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` TbQbBbUbVbWbAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
591 self.sections.append(key) 2a u _bXb`bicjcyb[b0b9bc #bRbb e Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` TbQbBbUbVbWbAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
592 dict.__setitem__(self, key, value) 2a u _bXb`bicjcyb[b0b9bc #bRbb e Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` TbQbBbUbVbWbAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
593 elif isinstance(value, dict) and not unrepr: 2a u Nc_btcXb`bicjcocUc]byb[bbckccc0b9bzcc #bRbdc)bvcwcYc5cZchc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPb$becYb!bZb0c1cTcGcTbHc2cQb3cBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
594 # First create the new depth level,
595 # then create the section
596 if key not in self: 2a zcb Dc?bscCcEcwbg h i j k l m n Dbo p xbEbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac0c1cGcTbHc2cQb3cBbUbVbWbq
597 self.sections.append(key) 2a zcb Dc?bscCcEcwbg h i j k l m n Dbo p xbEbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac0c1cGcTbHc2cQb3cBbUbVbWbq
598 new_depth = self.depth + 1 2a zcb Dc?bscCcEcwbg h i j k l m n Dbo p xbEbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac0c1cGcTbHc2cQb3cBbUbVbWbq
599 dict.__setitem__( 2a zcb Dc?bscCcEcwbg h i j k l m n Dbo p xbEbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac0c1cGcTbHc2cQb3cBbUbVbWbq
600 self,
601 key,
602 Section(
603 self,
604 new_depth,
605 self.main,
606 indict=value,
607 name=key))
608 else:
609 if key not in self: 2a u Nc_btcXb`bicjcocUc]byb[bbckccc0b9bzcc #bRbdc)bvcwcYc5cZchc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPb$becYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
610 self.scalars.append(key) 2a u Nc_btcXb`bicjcocUc]byb[bbckccc0b9bzcc #bRbdc)bvcwcYc5cZchc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPb$becYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
611 if not self.main.stringify: 2a u Nc_btcXb`bicjcocUc]byb[bbckccc0b9bzcc #bRbdc)bvcwcYc5cZchc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPb$becYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
612 if isinstance(value, str): 612 ↛ 613line 612 didn't jump to line 613 because the condition on line 612 was never true2Ic
613 pass
614 elif isinstance(value, (list, tuple)): 614 ↛ 615line 614 didn't jump to line 615 because the condition on line 614 was never true2Ic
615 for entry in value:
616 if not isinstance(entry, str):
617 raise TypeError('Value is not a string "%s".' % entry)
618 else:
619 raise TypeError('Value is not a string "%s".' % value) 2Ic
620 dict.__setitem__(self, key, value) 2a u Nc_btcXb`bicjcocUc]byb[bbckccc0b9bzcc #bRbdc)bvcwcYc5cZchc^bgcb =b@b8bDce ?bscCbqcAcCcf Ecd Fcv Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPb$becYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
623 def __delitem__(self, key): 2a pc
624 """Remove items from the sequence when deleting."""
625 dict. __delitem__(self, key) 2c 8bqcFcSb
626 if key in self.scalars: 2c 8bqcFcSb
627 self.scalars.remove(key) 2c 8bqcFcSb
628 else:
629 self.sections.remove(key) 1c
630 del self.comments[key] 2c 8bqcFcSb
631 del self.inline_comments[key] 2c 8bqcFcSb
634 def get(self, key, default=None): 2a pc
635 """A version of ``get`` that doesn't bypass string interpolation."""
636 try: 2a u WcXcVcc b e ?bCbqcv rbsbtbubvbw s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ ] ^ _ ` Sbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
637 return self[key] 2a u WcXcVcc b e ?bCbqcv rbsbtbubvbw s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ ] ^ _ ` Sbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
638 except KeyError: 2a WcXcVcc b e ?bCbSbq
639 return default 2a WcXcVcc b e ?bCbSbq
642 def update(self, indict): 2a pc
643 """
644 A version of update that uses our ``__setitem__``.
645 """
646 for entry in indict:
647 self[entry] = indict[entry]
650 def pop(self, key, default=MISSING): 2a pc
651 """
652 'D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
653 If key is not found, d is returned if given, otherwise KeyError is raised'
654 """
655 try: 2qcFc
656 val = self[key] 2qcFc
657 except KeyError: 2Fc
658 if default is MISSING: 2Fc
659 raise 2Fc
660 val = default 2Fc
661 else:
662 del self[key] 2qcFc
663 return val 2qcFc
666 def popitem(self): 2a pc
667 """Pops the first (key,val)"""
668 sequence = (self.scalars + self.sections)
669 if not sequence:
670 raise KeyError(": 'popitem(): dictionary is empty'")
671 key = sequence[0]
672 val = self[key]
673 del self[key]
674 return key, val
677 def clear(self): 2a pc
678 """
679 A version of clear that also affects scalars/sections
680 Also clears comments and configspec.
682 Leaves other attributes alone :
683 depth/main/parent are not affected
684 """
685 dict.clear(self) 2c Ec
686 self.scalars = [] 2c Ec
687 self.sections = [] 2c Ec
688 self.comments = {} 2c Ec
689 self.inline_comments = {} 2c Ec
690 self.configspec = None 2c Ec
691 self.defaults = [] 2c Ec
692 self.extra_values = [] 2c Ec
695 def setdefault(self, key, default=None): 2a pc
696 """A version of setdefault that sets sequence if appropriate."""
697 try:
698 return self[key]
699 except KeyError:
700 self[key] = default
701 return self[key]
704 def items(self): 2a pc
705 """D.items() -> list of D's (key, value) pairs, as 2-tuples"""
706 return list(zip((self.scalars + self.sections), list(self.values()))) 2a u #bv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ t [ zb] ^ _ ` SbPbecYb!bZbQbBbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
709 def keys(self): 2a pc
710 """D.keys() -> list of D's keys"""
711 return (self.scalars + self.sections)
714 def values(self): 2a pc
715 """D.values() -> list of D's values"""
716 return [self[key] for key in (self.scalars + self.sections)] 2a u #bv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ t [ zb] ^ _ ` SbPbecYb!bZbQbBbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
719 def iteritems(self): 2a pc
720 """D.iteritems() -> an iterator over the (key, value) items of D"""
721 return iter(list(self.items()))
724 def iterkeys(self): 2a pc
725 """D.iterkeys() -> an iterator over the keys of D"""
726 return iter((self.scalars + self.sections)) 24c#bRbb Dcr
728 __iter__ = iterkeys 2a pc
731 def itervalues(self): 2a pc
732 """D.itervalues() -> an iterator over the values of D"""
733 return iter(list(self.values()))
736 def __repr__(self): 2a pc
737 """x.__repr__() <==> repr(x)"""
738 def _getval(key): 2a ?bCbwbxb
739 try: 2a ?bCbwbxb
740 return self[key] 2a ?bCbwbxb
741 except MissingInterpolationOption:
742 return dict.__getitem__(self, key)
743 return '{%s}' % ', '.join([('%s: %s' % (repr(key), repr(_getval(key)))) 2a ?bCbwbxb
744 for key in (self.scalars + self.sections)])
746 __str__ = __repr__ 2a pc
747 __str__.__doc__ = "x.__str__() <==> str(x)" 2a pc
750 # Extra methods - not in a normal dictionary
752 def dict(self): 2a pc
753 """
754 Return a deepcopy of self as a dictionary.
756 All members that are ``Section`` instances are recursively turned to
757 ordinary dictionaries - by calling their ``dict`` method.
759 >>> n = a.dict()
760 >>> n == a
761 1
762 >>> n is a
763 0
764 """
765 newdict = {} 24c#bRbb Dc
766 for entry in self: 24c#bRbb Dc
767 this_entry = self[entry] 24c#bRbb Dc
768 if isinstance(this_entry, Section): 24c#bRbb Dc
769 this_entry = this_entry.dict() 24c#bRbb Dc
770 elif isinstance(this_entry, list): 770 ↛ 772line 770 didn't jump to line 772 because the condition on line 770 was never true24c#bRbb Dc
771 # create a copy rather than a reference
772 this_entry = list(this_entry)
773 elif isinstance(this_entry, tuple): 773 ↛ 775line 773 didn't jump to line 775 because the condition on line 773 was never true24c#bRbb Dc
774 # create a copy rather than a reference
775 this_entry = tuple(this_entry)
776 newdict[entry] = this_entry 24c#bRbb Dc
777 return newdict 24c#bRbb Dc
780 def merge(self, indict): 2a pc
781 """
782 A recursive update - useful for merging config files.
784 >>> a = '''[section1]
785 ... option1 = True
786 ... [[subsection]]
787 ... more_options = False
788 ... # end of file'''.splitlines()
789 >>> b = '''# File is user.ini
790 ... [section1]
791 ... option1 = False
792 ... # end of file'''.splitlines()
793 >>> c1 = ConfigObj(b)
794 >>> c2 = ConfigObj(a)
795 >>> c2.merge(c1)
796 >>> c2
797 ConfigObj({'section1': {'option1': 'False', 'subsection': {'more_options': 'False'}}})
798 """
799 for key, val in list(indict.items()): 2a u #bv rbsbtbubvbw s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ zb] ^ _ ` SbPbecYb!bZbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
800 if (key in self and isinstance(self[key], dict) and 2a u #bv rbsbtbubvbw s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ zb] ^ _ ` SbPbecYbZbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
801 isinstance(val, dict)):
802 self[key].merge(val) 2a u #bv rbsbtbubvbw s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ zb] ^ _ ` q { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
803 else:
804 self[key] = val 2a u #bv rbsbtbubvbw s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ zb] ^ _ ` SbPbecYbZbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
807 def rename(self, oldkey, newkey): 2a pc
808 """
809 Change a keyname to another, without changing position in sequence.
811 Implemented so that transformations can be made on keys,
812 as well as on values. (used by encode and decode)
814 Also renames comments.
815 """
816 if oldkey in self.scalars: 2Rb
817 the_list = self.scalars 2Rb
818 elif oldkey in self.sections: 818 ↛ 821line 818 didn't jump to line 821 because the condition on line 818 was always true2Rb
819 the_list = self.sections 2Rb
820 else:
821 raise KeyError('Key "%s" not found.' % oldkey)
822 pos = the_list.index(oldkey) 2Rb
823 #
824 val = self[oldkey] 2Rb
825 dict.__delitem__(self, oldkey) 2Rb
826 dict.__setitem__(self, newkey, val) 2Rb
827 the_list.remove(oldkey) 2Rb
828 the_list.insert(pos, newkey) 2Rb
829 comm = self.comments[oldkey] 2Rb
830 inline_comment = self.inline_comments[oldkey] 2Rb
831 del self.comments[oldkey] 2Rb
832 del self.inline_comments[oldkey] 2Rb
833 self.comments[newkey] = comm 2Rb
834 self.inline_comments[newkey] = inline_comment 2Rb
837 def walk(self, function, raise_errors=True, 2a pc
838 call_on_sections=False, **keywargs):
839 """
840 Walk every member and call a function on the keyword and value.
842 Return a dictionary of the return values
844 If the function raises an exception, raise the errror
845 unless ``raise_errors=False``, in which case set the return value to
846 ``False``.
848 Any unrecognised keyword arguments you pass to walk, will be pased on
849 to the function you pass in.
851 Note: if ``call_on_sections`` is ``True`` then - on encountering a
852 subsection, *first* the function is called for the *whole* subsection,
853 and then recurses into it's members. This means your function must be
854 able to handle strings, dictionaries and lists. This allows you
855 to change the key of subsections as well as for ordinary members. The
856 return value when called on the whole subsection has to be discarded.
858 See the encode and decode methods for examples, including functions.
860 .. admonition:: caution
862 You can use ``walk`` to transform the names of members of a section
863 but you mustn't add or delete members.
865 >>> config = '''[XXXXsection]
866 ... XXXXkey = XXXXvalue'''.splitlines()
867 >>> cfg = ConfigObj(config)
868 >>> cfg
869 ConfigObj({'XXXXsection': {'XXXXkey': 'XXXXvalue'}})
870 >>> def transform(section, key):
871 ... val = section[key]
872 ... newkey = key.replace('XXXX', 'CLIENT1')
873 ... section.rename(key, newkey)
874 ... if isinstance(val, (tuple, list, dict)):
875 ... pass
876 ... else:
877 ... val = val.replace('XXXX', 'CLIENT1')
878 ... section[newkey] = val
879 >>> cfg.walk(transform, call_on_sections=True)
880 {'CLIENT1section': {'CLIENT1key': None}}
881 >>> cfg
882 ConfigObj({'CLIENT1section': {'CLIENT1key': 'CLIENT1value'}})
883 """
884 out = {} 2Rb
885 # scalars first
886 for i in range(len(self.scalars)): 2Rb
887 entry = self.scalars[i] 2Rb
888 try: 2Rb
889 val = function(self, entry, **keywargs) 2Rb
890 # bound again in case name has changed
891 entry = self.scalars[i] 2Rb
892 out[entry] = val 2Rb
893 except Exception:
894 if raise_errors:
895 raise
896 else:
897 entry = self.scalars[i]
898 out[entry] = False
899 # then sections
900 for i in range(len(self.sections)): 2Rb
901 entry = self.sections[i] 2Rb
902 if call_on_sections: 902 ↛ 914line 902 didn't jump to line 914 because the condition on line 902 was always true2Rb
903 try: 2Rb
904 function(self, entry, **keywargs) 2Rb
905 except Exception:
906 if raise_errors:
907 raise
908 else:
909 entry = self.sections[i]
910 out[entry] = False
911 # bound again in case name has changed
912 entry = self.sections[i] 2Rb
913 # previous result is discarded
914 out[entry] = self[entry].walk( 2Rb
915 function,
916 raise_errors=raise_errors,
917 call_on_sections=call_on_sections,
918 **keywargs)
919 return out 2Rb
922 def as_bool(self, key): 2a pc
923 """
924 Accepts a key as input. The corresponding value must be a string or
925 the objects (``True`` or 1) or (``False`` or 0). We allow 0 and 1 to
926 retain compatibility with Python 2.2.
928 If the string is one of ``True``, ``On``, ``Yes``, or ``1`` it returns
929 ``True``.
931 If the string is one of ``False``, ``Off``, ``No``, or ``0`` it returns
932 ``False``.
934 ``as_bool`` is not case sensitive.
936 Any other input will raise a ``ValueError``.
938 >>> a = ConfigObj()
939 >>> a['a'] = 'fish'
940 >>> a.as_bool('a')
941 Traceback (most recent call last):
942 ValueError: Value "fish" is neither True nor False
943 >>> a['b'] = 'True'
944 >>> a.as_bool('b')
945 1
946 >>> a['b'] = 'off'
947 >>> a.as_bool('b')
948 0
949 """
950 val = self[key] 2YcZc
951 if val == True: 951 ↛ 952line 951 didn't jump to line 952 because the condition on line 951 was never true2YcZc
952 return True
953 elif val == False: 953 ↛ 954line 953 didn't jump to line 954 because the condition on line 953 was never true2YcZc
954 return False
955 else:
956 try: 2YcZc
957 if not isinstance(val, str): 957 ↛ 959line 957 didn't jump to line 959 because the condition on line 957 was never true2YcZc
958 # TODO: Why do we raise a KeyError here?
959 raise KeyError()
960 else:
961 return self.main._bools[val.lower()] 2YcZc
962 except KeyError: 2Yc
963 raise ValueError('Value "%s" is neither True nor False' % val) 2Yc
966 def as_int(self, key): 2a pc
967 """
968 A convenience method which coerces the specified value to an integer.
970 If the value is an invalid literal for ``int``, a ``ValueError`` will
971 be raised.
973 >>> a = ConfigObj()
974 >>> a['a'] = 'fish'
975 >>> a.as_int('a')
976 Traceback (most recent call last):
977 ValueError: invalid literal for int() with base 10: 'fish'
978 >>> a['b'] = '1'
979 >>> a.as_int('b')
980 1
981 >>> a['b'] = '3.2'
982 >>> a.as_int('b')
983 Traceback (most recent call last):
984 ValueError: invalid literal for int() with base 10: '3.2'
985 """
986 return int(self[key]) 2Zc
989 def as_float(self, key): 2a pc
990 """
991 A convenience method which coerces the specified value to a float.
993 If the value is an invalid literal for ``float``, a ``ValueError`` will
994 be raised.
996 >>> a = ConfigObj()
997 >>> a['a'] = 'fish'
998 >>> a.as_float('a') #doctest: +IGNORE_EXCEPTION_DETAIL
999 Traceback (most recent call last):
1000 ValueError: invalid literal for float(): fish
1001 >>> a['b'] = '1'
1002 >>> a.as_float('b')
1003 1.0
1004 >>> a['b'] = '3.2'
1005 >>> a.as_float('b') #doctest: +ELLIPSIS
1006 3.2...
1007 """
1008 return float(self[key]) 25c
1011 def as_list(self, key): 2a pc
1012 """
1013 A convenience method which fetches the specified value, guaranteeing
1014 that it is a list.
1016 >>> a = ConfigObj()
1017 >>> a['a'] = 1
1018 >>> a.as_list('a')
1019 [1]
1020 >>> a['a'] = (1,)
1021 >>> a.as_list('a')
1022 [1]
1023 >>> a['a'] = [1]
1024 >>> a.as_list('a')
1025 [1]
1026 """
1027 result = self[key]
1028 if isinstance(result, (tuple, list)):
1029 return list(result)
1030 return [result]
1033 def restore_default(self, key): 2a pc
1034 """
1035 Restore (and return) default value for the specified key.
1037 This method will only work for a ConfigObj that was created
1038 with a configspec and has been validated.
1040 If there is no default value for this key, ``KeyError`` is raised.
1041 """
1042 default = self.default_values[key]
1043 dict.__setitem__(self, key, default)
1044 if key not in self.defaults:
1045 self.defaults.append(key)
1046 return default
1049 def restore_defaults(self): 2a pc
1050 """
1051 Recursively restore default values to all members
1052 that have them.
1054 This method will only work for a ConfigObj that was created
1055 with a configspec and has been validated.
1057 It doesn't delete or modify entries without default values.
1058 """
1059 for key in self.default_values:
1060 self.restore_default(key)
1062 for section in self.sections:
1063 self[section].restore_defaults()
1066class ConfigObj(Section): 2a pc
1067 """An object to read, create, and write config files."""
1069 _keyword = re.compile(r'''^ # line start 2a pc
1070 (\s*) # indentation
1071 ( # keyword
1072 (?:".*?")| # double quotes
1073 (?:'.*?')| # single quotes
1074 (?:[^'"=].*?) # no quotes
1075 )
1076 \s*=\s* # divider
1077 (.*) # value (including list values and comments)
1078 $ # line end
1079 ''',
1080 re.VERBOSE)
1082 _sectionmarker = re.compile(r'''^ 2a pc
1083 (\s*) # 1: indentation
1084 ((?:\[\s*)+) # 2: section marker open
1085 ( # 3: section name open
1086 (?:"\s*\S.*?\s*")| # at least one non-space with double quotes
1087 (?:'\s*\S.*?\s*')| # at least one non-space with single quotes
1088 (?:[^'"\s].*?) # at least one non-space unquoted
1089 ) # section name close
1090 ((?:\s*\])+) # 4: section marker close
1091 \s*(\#.*)? # 5: optional comment
1092 $''',
1093 re.VERBOSE)
1095 # this regexp pulls list values out as a single string
1096 # or single values and comments
1097 # FIXME: this regex adds a '' to the end of comma terminated lists
1098 # workaround in ``_handle_value``
1099 _valueexp = re.compile(r'''^ 2a pc
1100 (?:
1101 (?:
1102 (
1103 (?:
1104 (?:
1105 (?:".*?")| # double quotes
1106 (?:'.*?')| # single quotes
1107 (?:[^'",\#][^,\#]*?) # unquoted
1108 )
1109 \s*,\s* # comma
1110 )* # match all list items ending in a comma (if any)
1111 )
1112 (
1113 (?:".*?")| # double quotes
1114 (?:'.*?')| # single quotes
1115 (?:[^'",\#\s][^,]*?)| # unquoted
1116 (?:(?<!,)) # Empty value
1117 )? # last item in a list - or string value
1118 )|
1119 (,) # alternatively a single comma - empty list
1120 )
1121 \s*(\#.*)? # optional comment
1122 $''',
1123 re.VERBOSE)
1125 # use findall to get the members of a list value
1126 _listvalueexp = re.compile(r''' 2a pc
1127 (
1128 (?:".*?")| # double quotes
1129 (?:'.*?')| # single quotes
1130 (?:[^'",\#]?.*?) # unquoted
1131 )
1132 \s*,\s* # comma
1133 ''',
1134 re.VERBOSE)
1136 # this regexp is used for the value
1137 # when lists are switched off
1138 _nolistvalue = re.compile(r'''^ 2a pc
1139 (
1140 (?:".*?")| # double quotes
1141 (?:'.*?')| # single quotes
1142 (?:[^'"\#].*?)| # unquoted
1143 (?:) # Empty value
1144 )
1145 \s*(\#.*)? # optional comment
1146 $''',
1147 re.VERBOSE)
1149 # regexes for finding triple quoted values on one line
1150 _single_line_single = re.compile(r"^'''(.*?)'''\s*(#.*)?$") 2a pc
1151 _single_line_double = re.compile(r'^"""(.*?)"""\s*(#.*)?$') 2a pc
1152 _multi_line_single = re.compile(r"^(.*?)'''\s*(#.*)?$") 2a pc
1153 _multi_line_double = re.compile(r'^(.*?)"""\s*(#.*)?$') 2a pc
1155 _triple_quote = { 2a pc
1156 "'''": (_single_line_single, _multi_line_single),
1157 '"""': (_single_line_double, _multi_line_double),
1158 }
1160 # Used by the ``istrue`` Section method
1161 _bools = { 2a pc
1162 'yes': True, 'no': False,
1163 'on': True, 'off': False,
1164 '1': True, '0': False,
1165 'true': True, 'false': False,
1166 }
1169 def __init__(self, infile=None, options=None, configspec=None, encoding=None, 2a pc
1170 interpolation=True, raise_errors=False, list_values=True,
1171 create_empty=False, file_error=False, stringify=True,
1172 indent_type=None, default_encoding=None, unrepr=False,
1173 write_empty_values=False, _inspec=False):
1174 """
1175 Parse a config file or create a config file object.
1177 ``ConfigObj(infile=None, configspec=None, encoding=None,
1178 interpolation=True, raise_errors=False, list_values=True,
1179 create_empty=False, file_error=False, stringify=True,
1180 indent_type=None, default_encoding=None, unrepr=False,
1181 write_empty_values=False, _inspec=False)``
1182 """
1183 self._inspec = _inspec 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1184 # init the superclass
1185 Section.__init__(self, self, 0, self) 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1187 infile = infile or [] 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1189 _options = {'configspec': configspec, 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1190 'encoding': encoding, 'interpolation': interpolation,
1191 'raise_errors': raise_errors, 'list_values': list_values,
1192 'create_empty': create_empty, 'file_error': file_error,
1193 'stringify': stringify, 'indent_type': indent_type,
1194 'default_encoding': default_encoding, 'unrepr': unrepr,
1195 'write_empty_values': write_empty_values}
1197 if options is None: 1197 ↛ 1200line 1197 didn't jump to line 1200 because the condition on line 1197 was always true2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1198 options = _options 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1199 else:
1200 import warnings
1201 warnings.warn('Passing in an options dictionary to ConfigObj() is '
1202 'deprecated. Use **options instead.',
1203 DeprecationWarning, stacklevel=2)
1205 # TODO: check the values too.
1206 for entry in options:
1207 if entry not in OPTION_DEFAULTS:
1208 raise TypeError('Unrecognised option "%s".' % entry)
1209 for entry, value in list(OPTION_DEFAULTS.items()):
1210 if entry not in options:
1211 options[entry] = value
1212 keyword_value = _options[entry]
1213 if value != keyword_value:
1214 options[entry] = keyword_value
1216 # XXXX this ignores an explicit list_values = True in combination
1217 # with _inspec. The user should *never* do that anyway, but still...
1218 if _inspec: 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1219 options['list_values'] = False 1cbe
1221 self._initialise(options) 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1222 configspec = options['configspec'] 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1223 self._original_configspec = configspec 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1224 self._load(infile, configspec) 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1227 def _load(self, infile, configspec): 2a pc
1228 if isinstance(infile, str): 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1229 self.filename = infile 2a u _b`bBcyb[bbcccc #bRbdchc^bgce Cbf v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1230 if os.path.isfile(infile): 2a u _b`bBcyb[bbcccc #bRbdchc^bgce Cbf v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1231 with open(infile, 'rb') as h: 2a u _b`bBcyb[bbcccc #bRbdchc^bgce Cbf v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1232 content = h.readlines() or [] 2a u _b`bBcyb[bbcccc #bRbdchc^bgce Cbf v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1233 elif self.file_error: 1233 ↛ 1235line 1233 didn't jump to line 1235 because the condition on line 1233 was never true2a {bnc|b}b~bac!bq
1234 # raise an error if the file doesn't exist
1235 raise IOError('Config file not found: "%s".' % self.filename)
1236 else:
1237 # file doesn't already exist
1238 if self.create_empty: 1238 ↛ 1241line 1238 didn't jump to line 1241 because the condition on line 1238 was never true2a {bnc|b}b~bac!bq
1239 # this is a good test that the filename specified
1240 # isn't impossible - like on a non-existent device
1241 with open(infile, 'w') as h:
1242 h.write('')
1243 content = [] 2a {bnc|b}b~bac!bq
1245 elif isinstance(infile, (list, tuple)): 2a tcXbicjcoc]bkc0b9bzcxcMc)bvcwcycb =b@b8bDcIc?bscqcAcCcEcd Fc
1246 content = list(infile) 2a tcXbicjcoc]bkc0b9bxcMc)bvcwcycb =b@b8bIc?bscqcAcCcEcd Fc
1248 elif isinstance(infile, dict): 2zcMcDcCcd
1249 # initialise self
1250 # the Section class handles creating subsections
1251 if isinstance(infile, ConfigObj): 2zcDcCc
1252 # get a copy of our ConfigObj
1253 def set_section(in_section, this_section): 2Cc
1254 for entry in in_section.scalars: 2Cc
1255 this_section[entry] = in_section[entry] 2Cc
1256 for section in in_section.sections: 2Cc
1257 this_section[section] = {} 2Cc
1258 set_section(in_section[section], this_section[section]) 2Cc
1259 set_section(infile, self) 2Cc
1261 else:
1262 for entry in infile: 2zcDc
1263 self[entry] = infile[entry] 2zcDc
1264 del self._errors 2zcDcCc
1266 if configspec is not None: 1266 ↛ 1267line 1266 didn't jump to line 1267 because the condition on line 1266 was never true2zcDcCc
1267 self._handle_configspec(configspec)
1268 else:
1269 self.configspec = None 2zcDcCc
1270 return 2zcDcCc
1272 elif getattr(infile, 'read', MISSING) is not MISSING: 1272 ↛ 1278line 1272 didn't jump to line 1278 because the condition on line 1272 was always true2Mcd
1273 # This supports file like objects
1274 content = infile.read() or [] 2Mcd
1275 # needs splitting into lines - but needs doing *after* decoding
1276 # in case it's not an 8 bit encoding
1277 else:
1278 raise TypeError('infile must be a filename, file like object, or list of lines.')
1280 if content: 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8be Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1281 # don't do it for the empty ConfigObj
1282 content = self._handle_bom(content) 2a u _bXb`bicjcBc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1283 # infile is now *always* a list
1284 #
1285 # Set the newlines attribute (first line ending it finds)
1286 # and strip trailing '\n' or '\r' from lines
1287 for line in content: 2a u _bXb`bicjcBc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1288 if (not line) or (line[-1] not in ('\r', '\n')): 2a u _bXb`bicjcBc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1289 continue 2Xbicjc]bkc0b9bxc)bvcwcycb =b@b8b?bfcPbuc
1290 for end in ('\r\n', '\n', '\r'): 1290 ↛ 1294line 1290 didn't jump to line 1294 because the loop on line 1290 didn't complete2a u _b`bBcyb[bbcccc #bRbdchc^bgce Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPb$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1291 if line.endswith(end): 2a u _b`bBcyb[bbcccc #bRbdchc^bgce Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPb$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1292 self.newlines = end 2a u _b`bBcyb[bbcccc #bRbdchc^bgce Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPb$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1293 break 2a u _b`bBcyb[bbcccc #bRbdchc^bgce Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPb$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1294 break 2a u _b`bBcyb[bbcccc #bRbdchc^bgce Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPb$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1296 assert all(isinstance(line, str) for line in content), repr(content) 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8be Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1297 content = [line.rstrip('\r\n') for line in content] 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8be Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1299 self._parse(content) 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8be Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1300 # if we had any errors, now is the time to raise them
1301 if self._errors: 2a u _btcXb`bBcoc]byb[bbckccc0b9bxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8be Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1302 info = "at line %s." % self._errors[0].line_number 2xcycfcPbuc
1303 if len(self._errors) > 1: 2xcycfcPbuc
1304 msg = "Parsing failed with several errors.\nFirst error %s" % info 2xcyc
1305 error = ConfigObjError(msg) 2xcyc
1306 else:
1307 error = self._errors[0] 2fcPbuc
1308 # set the errors attribute; it's a list of tuples:
1309 # (error_type, message, line_number)
1310 error.errors = self._errors 2xcycfcPbuc
1311 # set the config attribute
1312 error.config = self 2xcycfcPbuc
1313 raise error 2xcycfcPbuc
1314 # delete private attributes
1315 del self._errors 2a u _btcXb`bBcoc]byb[bbckccc0b9bMcc #bRbdc)bvcwchc^bgcb =b@b8be Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPb$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1317 if configspec is None: 2a u _btcXb`bBcoc]byb[bbckccc0b9bMcc #bRbdc)bvcwchc^bgcb =b@b8be Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPb$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1318 self.configspec = None 2a u _btcXb`bBcoc]byb[bbckccc0b9bMcc #bRbdc)bvcwchc^bgcb =b@b8be Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPb$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1319 else:
1320 self._handle_configspec(configspec) 1cbe
1323 def _initialise(self, options=None): 2a pc
1324 if options is None: 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1325 options = OPTION_DEFAULTS 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1327 # initialise a few variables
1328 self.filename = None 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1329 self._errors = [] 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1330 self.raise_errors = options['raise_errors'] 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1331 self.interpolation = options['interpolation'] 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1332 self.list_values = options['list_values'] 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1333 self.create_empty = options['create_empty'] 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1334 self.file_error = options['file_error'] 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1335 self.stringify = options['stringify'] 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1336 self.indent_type = options['indent_type'] 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1337 self.encoding = options['encoding'] 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1338 self.default_encoding = options['default_encoding'] 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1339 self.BOM = False 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1340 self.newlines = None 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1341 self.write_empty_values = options['write_empty_values'] 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1342 self.unrepr = options['unrepr'] 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1344 self.initial_comment = [] 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1345 self.final_comment = [] 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1346 self.configspec = None 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1348 if self._inspec: 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1349 self.list_values = False 1cbe
1351 # Clear section attributes as well
1352 Section._initialise(self) 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bzcxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8bDce Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1355 def __repr__(self): 2a pc
1356 def _getval(key): 2]b?bCbEc
1357 try: 2]b?bCb
1358 return self[key] 2]b?bCb
1359 except MissingInterpolationOption: 2?b
1360 return dict.__getitem__(self, key) 2?b
1361 return ('ConfigObj({%s})' % 2]b?bCbEc
1362 ', '.join([('%s: %s' % (repr(key), repr(_getval(key))))
1363 for key in (self.scalars + self.sections)]))
1366 def _handle_bom(self, infile): 2a pc
1367 """
1368 Handle any BOM, and decode if necessary.
1370 If an encoding is specified, that *must* be used - but the BOM should
1371 still be removed (and the BOM attribute set).
1373 (If the encoding is wrongly specified, then a BOM for an alternative
1374 encoding won't be discovered or removed.)
1376 If an encoding is not specified, UTF8 or UTF16 BOM will be detected and
1377 removed. The BOM attribute will be set. UTF16 will be decoded to
1378 unicode.
1380 NOTE: This method must not be called with an empty ``infile``.
1382 Specifying the *wrong* encoding is likely to cause a
1383 ``UnicodeDecodeError``.
1385 ``infile`` must always be returned as a list of lines, but may be
1386 passed in as a single string.
1387 """
1389 if ((self.encoding is not None) and 1389 ↛ 1394line 1389 didn't jump to line 1394 because the condition on line 1389 was never true2a u _bXb`bicjcBc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1390 (self.encoding.lower() not in BOM_LIST)):
1391 # No need to check for a BOM
1392 # the encoding specified doesn't have one
1393 # just decode
1394 return self._decode(infile, self.encoding)
1396 if isinstance(infile, (list, tuple)): 2a u _bXb`bicjcBc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1397 line = infile[0] 2a u _bXb`bicjcBc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1398 else:
1399 line = infile 1d
1401 if isinstance(line, str): 2a u _bXb`bicjcBc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1402 # it's already decoded and there's no need to do anything
1403 # else, just use the _decode utility method to handle
1404 # listifying appropriately
1405 return self._decode(infile, self.encoding) 2Xbicjc]b0b9bxc)bvcwcycb =b?b
1407 if self.encoding is not None: 2a u _b`bBcyb[bbckccc0bc #bRbdc)bhc^bgc@b8be Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1408 # encoding explicitly supplied
1409 # And it could have an associated BOM
1410 # TODO: if encoding is just UTF16 - we ought to check for both
1411 # TODO: big endian and little endian versions.
1412 enc = BOM_LIST[self.encoding.lower()] 2a u yb[bkcccd v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1413 if enc == 'utf_16': 1413 ↛ 1415line 1413 didn't jump to line 1415 because the condition on line 1413 was never true2a u yb[bkcccd v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1414 # For UTF16 we try big endian and little endian
1415 for BOM, (encoding, final_encoding) in list(BOMS.items()):
1416 if not final_encoding:
1417 # skip UTF8
1418 continue
1419 if infile.startswith(BOM):
1420 ### BOM discovered
1421 ##self.BOM = True
1422 # Don't need to remove BOM
1423 return self._decode(infile, encoding)
1425 # If we get this far, will *probably* raise a DecodeError
1426 # As it doesn't appear to start with a BOM
1427 return self._decode(infile, self.encoding)
1429 # Must be UTF8
1430 BOM = BOM_SET[enc] 2a u yb[bkcccd v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1431 if not line.startswith(BOM): 2a u yb[bkcccd v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1432 return self._decode(infile, self.encoding) 2a u yb[bkcccv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1434 newline = line[len(BOM):] 1d
1436 # BOM removed
1437 if isinstance(infile, (list, tuple)): 1437 ↛ 1440line 1437 didn't jump to line 1440 because the condition on line 1437 was always true1d
1438 infile[0] = newline 1d
1439 else:
1440 infile = newline
1441 self.BOM = True 1d
1442 return self._decode(infile, self.encoding) 1d
1444 # No encoding specified - so we need to check for UTF8/UTF16
1445 for BOM, (encoding, final_encoding) in list(BOMS.items()): 2a _b`bBcbc0bc #bRbdc)bhc^bgc@b8be Cbf d
1446 if not isinstance(line, bytes) or not line.startswith(BOM): 2a _b`bBcbc0bc #bRbdc)bhc^bgc@b8be Cbf d
1447 # didn't specify a BOM, or it's not a bytestring
1448 continue 2a _b`bBcbc0bc #bRbdc)bhc^bgc@b8be Cbf d
1449 else:
1450 # BOM discovered
1451 self.encoding = final_encoding 1d
1452 if not final_encoding: 1452 ↛ 1469line 1452 didn't jump to line 1469 because the condition on line 1452 was always true1d
1453 self.BOM = True 1d
1454 # UTF8
1455 # remove BOM
1456 newline = line[len(BOM):] 1d
1457 if isinstance(infile, (list, tuple)): 1457 ↛ 1460line 1457 didn't jump to line 1460 because the condition on line 1457 was always true1d
1458 infile[0] = newline 1d
1459 else:
1460 infile = newline
1461 # UTF-8
1462 if isinstance(infile, str): 1462 ↛ 1463line 1462 didn't jump to line 1463 because the condition on line 1462 was never true1d
1463 return infile.splitlines(True)
1464 elif isinstance(infile, bytes): 1464 ↛ 1465line 1464 didn't jump to line 1465 because the condition on line 1464 was never true1d
1465 return infile.decode('utf-8').splitlines(True)
1466 else:
1467 return self._decode(infile, 'utf-8') 1d
1468 # UTF16 - have to decode
1469 return self._decode(infile, encoding)
1472 # No BOM discovered and no encoding specified, default to UTF-8
1473 if isinstance(infile, bytes): 2a _b`bBcbc0bc #bRbdc)bhc^bgc@b8be Cbf d
1474 return infile.decode('utf-8').splitlines(True) 1d
1475 else:
1476 return self._decode(infile, 'utf-8') 2a _b`bBcbc0bc #bRbdc)bhc^bgc@b8be Cbf d
1479 def _a_to_u(self, aString): 2a pc
1480 """Decode ASCII strings to unicode if a self.encoding is specified."""
1481 if isinstance(aString, bytes) and self.encoding: 1481 ↛ 1482line 1481 didn't jump to line 1482 because the condition on line 1481 was never true2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1482 return aString.decode(self.encoding)
1483 else:
1484 return aString 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1487 def _decode(self, infile, encoding): 2a pc
1488 """
1489 Decode infile to unicode. Using the specified encoding.
1491 if is a string, it also needs converting to a list.
1492 """
1493 if isinstance(infile, str): 1493 ↛ 1494line 1493 didn't jump to line 1494 because the condition on line 1493 was never true2a u _bXb`bicjcBc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1494 return infile.splitlines(True)
1495 if isinstance(infile, bytes): 1495 ↛ 1497line 1495 didn't jump to line 1497 because the condition on line 1495 was never true2a u _bXb`bicjcBc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1496 # NOTE: Could raise a ``UnicodeDecodeError``
1497 if encoding:
1498 return infile.decode(encoding).splitlines(True)
1499 else:
1500 return infile.splitlines(True)
1502 if encoding: 2a u _bXb`bicjcBc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1503 for i, line in enumerate(infile): 2a u _b`bBcyb[bbckccc0bc #bRbdc)bhc^bgc@b8be Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1504 if isinstance(line, bytes): 1504 ↛ 1503line 1504 didn't jump to line 1503 because the condition on line 1504 was always true2a u _b`bBcyb[bbckccc0bc #bRbdc)bhc^bgc@b8be Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1505 # NOTE: The isinstance test here handles mixed lists of unicode/string
1506 # NOTE: But the decode will break on any non-string values
1507 # NOTE: Or could raise a ``UnicodeDecodeError``
1508 infile[i] = line.decode(encoding) 2a u _b`bBcyb[bbckccc0bc #bRbdc)bhc^bgc@b8be Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1509 return infile 2a u _bXb`bicjcBc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1512 def _decode_element(self, line): 2a pc
1513 """Decode element to unicode if necessary."""
1514 if isinstance(line, bytes) and self.default_encoding: 1514 ↛ 1515line 1514 didn't jump to line 1515 because the condition on line 1514 was never true2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1515 return line.decode(self.default_encoding)
1516 else:
1517 return line 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1520 # TODO: this may need to be modified
1521 def _str(self, value): 2a pc
1522 """
1523 Used by ``stringify`` within validate, to turn non-string values
1524 into strings.
1525 """
1526 if not isinstance(value, str):
1527 # intentially 'str' because it's just whatever the "normal"
1528 # string type is for the python version we're dealing with
1529 return str(value)
1530 else:
1531 return value
1534 def _parse(self, infile): 2a pc
1535 """Actually parse the config file."""
1536 temp_list_values = self.list_values 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8be Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1537 if self.unrepr: 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8be Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1538 self.list_values = False 2a u `b]bdc)bvcwcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1540 comment_list = [] 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8be Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1541 done_start = False 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8be Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1542 this_section = self 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8be Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1543 maxline = len(infile) - 1 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8be Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1544 cur_index = -1 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8be Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1545 reset_comment = False 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8be Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1547 while cur_index < maxline: 2a u _btcXb`bicjcBcoc]byb[bbckccc0b9bxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8be Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1548 if reset_comment: 2a u _bXb`bicjcBc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1549 comment_list = [] 2a u _bXb`bicjcyb[b0b9bxcc #bRbdc)bwchcyc^bgcb =b@b8be Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbecYb!bZbTbQbBbUbVb%bWb1blc2b'b3b4brc5b6b(b7bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1550 cur_index += 1 2a u _bXb`bicjcBc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1551 line = infile[cur_index] 2a u _bXb`bicjcBc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1552 sline = line.strip() 2a u _bXb`bicjcBc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1553 # do we have anything on the line ?
1554 if not sline or sline.startswith('#'): 2a u _bXb`bicjcBc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1555 reset_comment = False 2a u _bXb`bicjcBcyb[bxcc #bRbdc)bhcyc^bgcb =b@b8be Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` Abq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1556 comment_list.append(line) 2a u _bXb`bicjcBcyb[bxcc #bRbdc)bhcyc^bgcb =b@b8be Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` Abq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1557 continue 2a u _bXb`bicjcBcyb[bxcc #bRbdc)bhcyc^bgcb =b@b8be Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` Abq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1559 if not done_start: 2a u _bXb`bicjc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1560 # preserve initial comment
1561 self.initial_comment = comment_list 2a u _bXb`bicjc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1562 comment_list = [] 2a u _bXb`bicjc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1563 done_start = True 2a u _bXb`bicjc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1565 reset_comment = True 2a u _bXb`bicjc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1566 # first we check if it's a section marker
1567 mat = self._sectionmarker.match(line) 2a u _bXb`bicjc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1568 if mat is not None: 2a u _bXb`bicjc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1569 # is a section line
1570 (indent, sect_open, sect_name, sect_close, comment) = mat.groups() 2a u _bXb`bicjcyb[b0b9bc #bRbb e Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` TbQbBbUbVbWbAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1571 if indent and (self.indent_type is None): 2a u _bXb`bicjcyb[b0b9bc #bRbb e Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` TbQbBbUbVbWbAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1572 self.indent_type = indent 2a icjcyb[b0b9bCb
1573 cur_depth = sect_open.count('[') 2a u _bXb`bicjcyb[b0b9bc #bRbb e Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` TbQbBbUbVbWbAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1574 if cur_depth != sect_close.count(']'): 1574 ↛ 1575line 1574 didn't jump to line 1575 because the condition on line 1574 was never true2a u _bXb`bicjcyb[b0b9bc #bRbb e Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` TbQbBbUbVbWbAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1575 self._handle_error("Cannot compute the section depth",
1576 NestingError, infile, cur_index)
1577 continue
1579 if cur_depth < this_section.depth: 2a u _bXb`bicjcyb[b0b9bc #bRbb e Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` TbQbBbUbVbWbAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1580 # the new section is dropping back to a previous level
1581 try: 2a u Xbc Cbf v w s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ ] ^ _ ` q { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1582 parent = self._match_depth(this_section, 2a u Xbc Cbf v w s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ ] ^ _ ` q { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1583 cur_depth).parent
1584 except SyntaxError:
1585 self._handle_error("Cannot compute nesting level",
1586 NestingError, infile, cur_index)
1587 continue
1588 elif cur_depth == this_section.depth: 2a u _bXb`bicjcyb[b0b9bc #bRbb e Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` TbQbBbUbVbWbAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1589 # the new section is a sibling of the current section
1590 parent = this_section.parent 2a u XbicjcCbf v rbsbtbubvbw s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ zb] ^ _ ` QbBbAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1591 elif cur_depth == this_section.depth + 1: 1591 ↛ 1595line 1591 didn't jump to line 1595 because the condition on line 1591 was always true2a u _bXb`bicjcyb[b0b9bc #bRbb e Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` TbQbBbUbVbWbAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1592 # the new section is a child the current section
1593 parent = this_section 2a u _bXb`bicjcyb[b0b9bc #bRbb e Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` TbQbBbUbVbWbAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1594 else:
1595 self._handle_error("Section too nested",
1596 NestingError, infile, cur_index)
1597 continue
1599 sect_name = self._unquote(sect_name) 2a u _bXb`bicjcyb[b0b9bc #bRbb e Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` TbQbBbUbVbWbAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1600 if sect_name in parent: 2a u _bXb`bicjcyb[b0b9bc #bRbb e Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` TbQbBbUbVbWbAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1601 self._handle_error('Duplicate section name', 2jc
1602 DuplicateError, infile, cur_index)
1603 continue
1605 # create the new section
1606 this_section = Section( 2a u _bXb`bicjcyb[b0b9bc #bRbb e Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` TbQbBbUbVbWbAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1607 parent,
1608 cur_depth,
1609 self,
1610 name=sect_name)
1611 parent[sect_name] = this_section 2a u _bXb`bicjcyb[b0b9bc #bRbb e Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` TbQbBbUbVbWbAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1612 parent.inline_comments[sect_name] = comment 2a u _bXb`bicjcyb[b0b9bc #bRbb e Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` TbQbBbUbVbWbAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1613 parent.comments[sect_name] = comment_list 2a u _bXb`bicjcyb[b0b9bc #bRbb e Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` TbQbBbUbVbWbAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1614 continue 2a u _bXb`bicjcyb[b0b9bc #bRbb e Cbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` TbQbBbUbVbWbAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1615 #
1616 # it's not a section marker,
1617 # so it should be a valid ``key = value`` line
1618 mat = self._keyword.match(line) 2a u _bXb`bicjc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1619 if mat is None: 2a u _bXb`bicjc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1620 self._handle_error( 2Pb
1621 'Invalid line ({0!r}) (matched as neither section nor keyword)'.format(line),
1622 ParseError, infile, cur_index)
1623 else:
1624 # is a keyword value
1625 # value will include any inline comment
1626 (indent, key, value) = mat.groups() 2a u _bXb`bicjc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1627 if indent and (self.indent_type is None): 2a u _bXb`bicjc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1628 self.indent_type = indent 2Xbxcc yce f d
1629 # check for a multiline value
1630 if value[:3] in ['"""', "'''"]: 2a u _bXb`bicjc]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1631 try: 2a dcf
1632 value, comment, cur_index = self._multiline( 2a dcf
1633 value, infile, cur_index, maxline)
1634 except SyntaxError:
1635 self._handle_error(
1636 'Parse error in multiline value',
1637 ParseError, infile, cur_index)
1638 continue
1639 else:
1640 if self.unrepr: 2a dcf
1641 comment = '' 2dc
1642 try: 2dc
1643 value = unrepr(value) 2dc
1644 except Exception as e:
1645 if type(e) == UnknownType:
1646 msg = 'Unknown name or type in value'
1647 else:
1648 msg = 'Parse error from unrepr-ing multiline value'
1649 self._handle_error(msg, UnreprError, infile,
1650 cur_index)
1651 continue
1652 else:
1653 if self.unrepr: 2a u _bXb`bicjc]byb[bbckccc0b9bxcc #bRb)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1654 comment = '' 2a u `b]b)bvcwcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1655 try: 2a u `b]b)bvcwcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1656 value = unrepr(value) 2a u `b]b)bvcwcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1657 except Exception as e: 2fcuc
1658 if isinstance(e, UnknownType): 1658 ↛ 1659line 1658 didn't jump to line 1659 because the condition on line 1658 was never true2fcuc
1659 msg = 'Unknown name or type in value'
1660 else:
1661 msg = 'Parse error from unrepr-ing value' 2fcuc
1662 self._handle_error(msg, UnreprError, infile, 2fcuc
1663 cur_index)
1664 continue 2fcuc
1665 else:
1666 # extract comment and lists
1667 try: 2a _bXbicjcyb[bbckccc0b9bxcc #bRbhcyc^bgcb =b@b8be ?bCbf d
1668 (value, comment) = self._handle_value(value) 2a _bXbicjcyb[bbckccc0b9bxcc #bRbhcyc^bgcb =b@b8be ?bCbf d
1669 except SyntaxError: 2xcyc
1670 self._handle_error( 2xcyc
1671 'Parse error in value',
1672 ParseError, infile, cur_index)
1673 continue 2xcyc
1674 #
1675 key = self._unquote(key) 2a u _bXb`bicjc]byb[bbckccc0b9bc #bRbdc)bvcwchc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPb$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1676 if key in this_section: 2a u _bXb`bicjc]byb[bbckccc0b9bc #bRbdc)bvcwchc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPb$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1677 self._handle_error( 2ic
1678 'Duplicate keyword name',
1679 DuplicateError, infile, cur_index)
1680 continue
1681 # add the key.
1682 # we set unrepr because if we have got this far we will never
1683 # be creating a new section
1684 this_section.__setitem__(key, value, unrepr=True) 2a u _bXb`bicjc]byb[bbckccc0b9bc #bRbdc)bvcwchc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPb$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1685 this_section.inline_comments[key] = comment 2a u _bXb`bicjc]byb[bbckccc0b9bc #bRbdc)bvcwchc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPb$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1686 this_section.comments[key] = comment_list 2a u _bXb`bicjc]byb[bbckccc0b9bc #bRbdc)bvcwchc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPb$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1687 continue 2a u _bXb`bicjc]byb[bbckccc0b9bc #bRbdc)bvcwchc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPb$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1688 #
1689 if self.indent_type is None: 2a u _btcXb`bBcoc]byb[bbckccc0b9bxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8be Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1690 # no indentation used, set the type accordingly
1691 self.indent_type = '' 2a u _btc`bBcoc]bbckccc9bMc#bRbdc)bvcwchc^bgcb =b@b8bIc?bscqcAcCcf EcFcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1693 # preserve the final comment
1694 if not self and not self.initial_comment: 2a u _btcXb`bBcoc]byb[bbckccc0b9bxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8be Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1695 self.initial_comment = comment_list 2a tcBcocMcb @bIcscqcAcCcEcFc{bnc|b}b~bacfcPbuc!bq
1696 elif not reset_comment: 2a u _bXb`b]byb[bbckccc0b9bxcc #bRbdc)bvcwchcyc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPb$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1697 self.final_comment = comment_list 2a u _bXb`byb[bxcc #bRbdc)byc^bgc@b8be d v w s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ ] ^ _ ` Abq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1698 self.list_values = temp_list_values 2a u _btcXb`bBcoc]byb[bbckccc0b9bxcMcc #bRbdc)bvcwchcyc^bgcb =b@b8be Ic?bscCbqcAcCcf Ecd Fcv rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbfcPbuc$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1701 def _match_depth(self, sect, depth): 2a pc
1702 """
1703 Given a section and a depth level, walk back through the sections
1704 parents to see if the depth level matches a previous section.
1706 Return a reference to the right section,
1707 or raise a SyntaxError.
1708 """
1709 while depth < sect.depth: 2a u Xbc Cbf v w s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ ] ^ _ ` q { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1710 if sect is sect.parent: 1710 ↛ 1712line 1710 didn't jump to line 1712 because the condition on line 1710 was never true2a u Xbc Cbf v w s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ ] ^ _ ` q { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1711 # we've reached the top level already
1712 raise SyntaxError()
1713 sect = sect.parent 2a u Xbc Cbf v w s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ ] ^ _ ` q { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1714 if sect.depth == depth: 1714 ↛ 1717line 1714 didn't jump to line 1717 because the condition on line 1714 was always true2a u Xbc Cbf v w s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ ] ^ _ ` q { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1715 return sect 2a u Xbc Cbf v w s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ ] ^ _ ` q { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1716 # shouldn't get here
1717 raise SyntaxError()
1720 def _handle_error(self, text, ErrorClass, infile, cur_index): 2a pc
1721 """
1722 Handle an error according to the error settings.
1724 Either raise the error or store it.
1725 The error will have occured at ``cur_index``
1726 """
1727 line = infile[cur_index] 2icjcxcycfcPbuc
1728 cur_index += 1 2icjcxcycfcPbuc
1729 message = '{0} at line {1}.'.format(text, cur_index) 2icjcxcycfcPbuc
1730 error = ErrorClass(message, cur_index, line) 2icjcxcycfcPbuc
1731 if self.raise_errors: 2icjcxcycfcPbuc
1732 # raise the error - parsing stops here
1733 raise error 2icjc
1734 # store the error
1735 # reraise when parsing has finished
1736 self._errors.append(error) 2xcycfcPbuc
1739 def _unquote(self, value): 2a pc
1740 """Return an unquoted version of a value"""
1741 if not value: 1741 ↛ 1743line 1741 didn't jump to line 1743 because the condition on line 1741 was never true2a u _bXb`bicjc]byb[bbckccc0b9bc #bRbdc)bvcwchc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPb$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1742 # should only happen during parsing of lists
1743 raise SyntaxError
1744 if (value[0] == value[-1]) and (value[0] in ('"', "'")): 2a u _bXb`bicjc]byb[bbckccc0b9bc #bRbdc)bvcwchc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPb$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1745 value = value[1:-1] 2a _bicjchc=b8bCbf
1746 return value 2a u _bXb`bicjc]byb[bbckccc0b9bc #bRbdc)bvcwchc^bgcb =b@b8be ?bCbf d v rbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt [ zb] ^ _ ` SbfcPb$becYb!bZbTbQbBbUbVb%b*bWb+b,b-b.b/b:b1blc2b'b3b4brc5b6b(b7b;bmcAbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1749 def _quote(self, value, multiline=True): 2a pc
1750 """
1751 Return a safely quoted version of a value.
1753 Raise a ConfigObjError if the value cannot be safely quoted.
1754 If multiline is ``True`` (default) then use triple quotes
1755 if necessary.
1757 * Don't quote values that don't need it.
1758 * Recursively quote members of a list and return a comma joined list.
1759 * Multiline is ``False`` for lists.
1760 * Obey list syntax for empty and single member lists.
1762 If ``list_values=False`` then the value is only quoted if it contains
1763 a ``\\n`` (is multiline) or '#'.
1765 If ``write_empty_values`` is set, and the value is an empty string, it
1766 won't be quoted.
1767 """
1768 if multiline and self.write_empty_values and value == '': 2a u NctcXbocUc]byb0b9bzc7c6c8c)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1769 # Only if multiline is set, so that it is used for values not
1770 # keys, and not values that are part of a list
1771 return '' 2=b
1773 if multiline and isinstance(value, (list, tuple)): 2a u NctcXbocUc]byb0b9bzc7c6c8c)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1774 if not value: 1774 ↛ 1775line 1774 didn't jump to line 1775 because the condition on line 1774 was never true2oc
1775 return ','
1776 elif len(value) == 1: 1776 ↛ 1777line 1776 didn't jump to line 1777 because the condition on line 1776 was never true2oc
1777 return self._quote(value[0], multiline=False) + ','
1778 return ', '.join([self._quote(val, multiline=False) 2oc
1779 for val in value])
1780 if not isinstance(value, str): 2a u NctcXbocUc]byb0b9bzc7c6c8c)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1781 if self.stringify: 1781 ↛ 1786line 1781 didn't jump to line 1786 because the condition on line 1781 was always true1b
1782 # intentially 'str' because it's just whatever the "normal"
1783 # string type is for the python version we're dealing with
1784 value = str(value) 1b
1785 else:
1786 raise TypeError('Value "%s" is not a string.' % value)
1788 if not value: 2a u NctcXbocUc]byb0b9bzc7c6c8c)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1789 return '""' 2=b
1791 no_lists_no_quotes = not self.list_values and '\n' not in value and '#' not in value 2a u NctcXbocUc]byb0b9bzc7c6c8c)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1792 need_triple = multiline and ((("'" in value) and ('"' in value)) or ('\n' in value )) 2a u NctcXbocUc]byb0b9bzc7c6c8c)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1793 hash_triple_quote = multiline and not need_triple and ("'" in value) and ('"' in value) and ('#' in value) 2a u NctcXbocUc]byb0b9bzc7c6c8c)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1794 check_for_single = (no_lists_no_quotes or not need_triple) and not hash_triple_quote 2a u NctcXbocUc]byb0b9bzc7c6c8c)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1796 if check_for_single: 2a u NctcXbocUc]byb0b9bzc7c6c8c)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1797 if not self.list_values: 2a u NctcXbocUc]byb0b9bzc7c6c)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1798 # we don't quote if ``list_values=False``
1799 quot = noquot 2@b
1800 # for normal values either single or double quotes will do
1801 elif '\n' in value: 2a u NctcXbocUc]byb0b9bzc7c6c)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1802 # will only happen if multiline is off - e.g. '\n' in key
1803 raise ConfigObjError('Value "%s" cannot be safely quoted.' % value) 27c
1804 elif ((value[0] not in wspace_plus) and 2a u NctcXbocUc]byb0b9bzc6c)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1805 (value[-1] not in wspace_plus) and
1806 (',' not in value)):
1807 quot = noquot 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1808 else:
1809 quot = self._get_single_quote(value) 26cf d
1810 else:
1811 # if value has '\n' or "'" *and* '"', it will need triple quotes
1812 quot = self._get_triple_quote(value) 28c@bf
1814 if quot == noquot and '#' in value and self.list_values: 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1815 quot = self._get_single_quote(value) 2oc
1817 return quot % value 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1820 def _get_single_quote(self, value): 2a pc
1821 if ("'" in value) and ('"' in value): 2oc6cf d
1822 raise ConfigObjError('Value "%s" cannot be safely quoted.' % value) 26c
1823 elif '"' in value: 1823 ↛ 1824line 1823 didn't jump to line 1824 because the condition on line 1823 was never true2ocf d
1824 quot = squot
1825 else:
1826 quot = dquot 2ocf d
1827 return quot 2ocf d
1830 def _get_triple_quote(self, value): 2a pc
1831 if (value.find('"""') != -1) and (value.find("'''") != -1): 28c@bf
1832 raise ConfigObjError('Value "%s" cannot be safely quoted.' % value) 28c
1833 if value.find('"""') == -1: 1833 ↛ 1836line 1833 didn't jump to line 1836 because the condition on line 1833 was always true2@bf
1834 quot = tdquot 2@bf
1835 else:
1836 quot = tsquot
1837 return quot 2@bf
1840 def _handle_value(self, value): 2a pc
1841 """
1842 Given a value string, unquote, remove comment,
1843 handle lists. (including empty and single member lists)
1844 """
1845 if self._inspec: 2a _bXbicjcyb[bbckccc0b9bxcc #bRbhcyc^bgcb =b@b8be ?bCbf d
1846 # Parsing a configspec so don't handle comments
1847 return (value, '') 1cbe
1848 # do we look for lists in values ?
1849 if not self.list_values: 2a _bXbicjcyb[bbckccc0b9bxcc #bRbhcyc^bgc=b@b8be ?bCbf d
1850 mat = self._nolistvalue.match(value) 2hcgc@b
1851 if mat is None: 1851 ↛ 1852line 1851 didn't jump to line 1852 because the condition on line 1851 was never true2hcgc@b
1852 raise SyntaxError()
1853 # NOTE: we don't unquote here
1854 return mat.groups() 2hcgc@b
1855 #
1856 mat = self._valueexp.match(value) 2a _bXbicjcyb[bbckccc0b9bxcc #bRbhcyc^b=b8be ?bCbf d
1857 if mat is None: 2a _bXbicjcyb[bbckccc0b9bxcc #bRbhcyc^b=b8be ?bCbf d
1858 # the value is badly constructed, probably badly quoted,
1859 # or an invalid list
1860 raise SyntaxError() 2xcyc
1861 (list_values, single, empty_list, comment) = mat.groups() 2a _bXbicjcyb[bbckccc0b9bc #bRbhc^b=b8be ?bCbf d
1862 if (list_values == '') and (single is None): 1862 ↛ 1864line 1862 didn't jump to line 1864 because the condition on line 1862 was never true2a _bXbicjcyb[bbckccc0b9bc #bRbhc^b=b8be ?bCbf d
1863 # change this if you want to accept empty values
1864 raise SyntaxError()
1865 # NOTE: note there is no error handling from here if the regex
1866 # is wrong: then incorrect values will slip through
1867 if empty_list is not None: 2a _bXbicjcyb[bbckccc0b9bc #bRbhc^b=b8be ?bCbf d
1868 # the single comma - meaning an empty list
1869 return ([], comment) 2hc^b
1870 if single is not None: 2a _bXbicjcyb[bbckccc0b9bc #bRbhc^b=b8be ?bCbf d
1871 # handle empty values
1872 if list_values and not single: 2a _bXbicjcyb[bbckccc0b9bc #bRbhc^b=b8be ?bCbf d
1873 # FIXME: the '' is a workaround because our regex now matches
1874 # '' at the end of a list if it has a trailing comma
1875 single = None 2hc
1876 else:
1877 single = single or '""' 2a _bXbicjcyb[bbckccc0b9bc #bRbhc^b=b8be ?bCbf d
1878 single = self._unquote(single) 2a _bXbicjcyb[bbckccc0b9bc #bRbhc^b=b8be ?bCbf d
1879 if list_values == '': 2a _bXbicjcyb[bbckccc0b9bc #bRbhc^b=b8be ?bCbf d
1880 # not a list value
1881 return (single, comment) 2a _bXbicjcyb[bbckccc0b9bc #bRbhc=b8be ?bCbf d
1882 the_list = self._listvalueexp.findall(list_values) 2hc^b
1883 the_list = [self._unquote(val) for val in the_list] 2hc^b
1884 if single is not None: 2hc^b
1885 the_list += [single] 2hc^b
1886 return (the_list, comment) 2hc^b
1889 def _multiline(self, value, infile, cur_index, maxline): 2a pc
1890 """Extract the value, where we are in a multiline situation."""
1891 quot = value[:3] 2a dcf
1892 newvalue = value[3:] 2a dcf
1893 single_line = self._triple_quote[quot][0] 2a dcf
1894 multi_line = self._triple_quote[quot][1] 2a dcf
1895 mat = single_line.match(value) 2a dcf
1896 if mat is not None: 2a dcf
1897 retval = list(mat.groups())
1898 retval.append(cur_index)
1899 return retval
1900 elif newvalue.find(quot) != -1: 1900 ↛ 1902line 1900 didn't jump to line 1902 because the condition on line 1900 was never true2a dcf
1901 # somehow the triple quote is missing
1902 raise SyntaxError()
1903 #
1904 while cur_index < maxline: 1904 ↛ 1915line 1904 didn't jump to line 1915 because the condition on line 1904 was always true2a dcf
1905 cur_index += 1 2a dcf
1906 newvalue += '\n' 2a dcf
1907 line = infile[cur_index] 2a dcf
1908 if line.find(quot) == -1: 2a dcf
1909 newvalue += line 2a dcf
1910 else:
1911 # end of multiline, process it
1912 break 2a dcf
1913 else:
1914 # we've got to the end of the config, oops...
1915 raise SyntaxError()
1916 mat = multi_line.match(line) 2a dcf
1917 if mat is None: 1917 ↛ 1919line 1917 didn't jump to line 1919 because the condition on line 1917 was never true2a dcf
1918 # a badly formed line
1919 raise SyntaxError()
1920 (value, comment) = mat.groups() 2a dcf
1921 return (newvalue + value, comment, cur_index) 2a dcf
1924 def _handle_configspec(self, configspec): 2a pc
1925 """Parse the configspec."""
1926 # FIXME: Should we check that the configspec was created with the
1927 # correct settings ? (i.e. ``list_values=False``)
1928 if not isinstance(configspec, ConfigObj): 1928 ↛ 1941line 1928 didn't jump to line 1941 because the condition on line 1928 was always true1cbe
1929 try: 1cbe
1930 configspec = ConfigObj(configspec, 1cbe
1931 raise_errors=True,
1932 file_error=True,
1933 _inspec=True)
1934 except ConfigObjError as e:
1935 # FIXME: Should these errors have a reference
1936 # to the already parsed ConfigObj ?
1937 raise ConfigspecError('Parsing configspec failed: %s' % e)
1938 except IOError as e:
1939 raise IOError('Reading configspec failed: %s' % e)
1941 self.configspec = configspec 1cbe
1945 def _set_configspec(self, section, copy): 2a pc
1946 """
1947 Called by validate. Handles setting the configspec on subsections
1948 including sections to be validated by __many__
1949 """
1950 configspec = section.configspec 1cbe
1951 many = configspec.get('__many__') 1cbe
1952 if isinstance(many, dict): 1952 ↛ 1953line 1952 didn't jump to line 1953 because the condition on line 1952 was never true1cbe
1953 for entry in section.sections:
1954 if entry not in configspec:
1955 section[entry].configspec = many
1957 for entry in configspec.sections: 1cbe
1958 if entry == '__many__': 1958 ↛ 1959line 1958 didn't jump to line 1959 because the condition on line 1958 was never true1cbe
1959 continue
1960 if entry not in section: 1cbe
1961 section[entry] = {} 1b
1962 section[entry]._created = True 1b
1963 if copy: 1963 ↛ 1969line 1963 didn't jump to line 1969 because the condition on line 1963 was always true1b
1964 # copy comments
1965 section.comments[entry] = configspec.comments.get(entry, []) 1b
1966 section.inline_comments[entry] = configspec.inline_comments.get(entry, '') 1b
1968 # Could be a scalar when we expect a section
1969 if isinstance(section[entry], Section): 1969 ↛ 1957line 1969 didn't jump to line 1957 because the condition on line 1969 was always true1cbe
1970 section[entry].configspec = configspec[entry] 1cbe
1973 def _write_line(self, indent_string, entry, this_entry, comment): 2a pc
1974 """Write an individual line, for the write method"""
1975 # NOTE: the calls to self._quote here handles non-StringType values.
1976 if not self.unrepr: 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1977 val = self._decode_element(self._quote(this_entry)) 2tcXbocUcyb0b9bzcb =b@b8bscf d
1978 else:
1979 val = repr(this_entry) 2a u Nc]b)bv Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1980 return '%s%s%s%s%s' % (indent_string, 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1981 self._decode_element(self._quote(entry, multiline=False)),
1982 self._a_to_u(' = '),
1983 val,
1984 self._decode_element(comment))
1987 def _write_marker(self, indent_string, depth, entry, comment): 2a pc
1988 """Write a section marker line"""
1989 return '%s%s%s%s%s' % (indent_string, 2a u NcXbyb0b9bzcb scf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` GcTbHcQbBbUbVbWbAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1990 self._a_to_u('[' * depth),
1991 self._quote(self._decode_element(entry), multiline=False),
1992 self._a_to_u(']' * depth),
1993 self._decode_element(comment))
1996 def _handle_comment(self, comment): 2a pc
1997 """Deal with a comment."""
1998 if not comment: 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
1999 return '' 2a u NcocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2000 start = self.indent_type 2a u tcXbb =bf d v w s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ ] ^ _ ` q { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2001 if not comment.startswith('#'): 2a u tcXbb =bf d v w s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ ] ^ _ ` q { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2002 start += self._a_to_u(' # ') 2tc
2003 return (start + comment) 2a u tcXbb =bf d v w s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ ] ^ _ ` q { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2006 # Public methods
2008 def write(self, outfile=None, section=None): 2a pc
2009 """
2010 Write the current ConfigObj as a file
2012 tekNico: FIXME: use StringIO instead of real files
2014 >>> filename = a.filename
2015 >>> a.filename = 'test.ini'
2016 >>> a.write()
2017 >>> a.filename = filename
2018 >>> a == ConfigObj('test.ini', raise_errors=True)
2019 1
2020 >>> import os
2021 >>> os.remove('test.ini')
2022 """
2023 if self.indent_type is None: 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2024 # this can be true if initialised from a dictionary
2025 self.indent_type = DEFAULT_INDENT_TYPE 2zc
2027 out = [] 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2028 cs = self._a_to_u('#') 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2029 csp = self._a_to_u('# ') 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2030 if section is None: 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2031 int_val = self.interpolation 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2032 self.interpolation = False 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2033 section = self 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2034 for line in self.initial_comment: 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2035 line = self._decode_element(line) 2a Ncyb)bb =b8bf d Ocrbsbtbubvbwbs g h i j k l m n Dbo p JcKcLcPcQcRcxbEbFbGbHbIbJbKbLbMbNbObAbScr
2036 stripped_line = line.strip() 2a Ncyb)bb =b8bf d Ocrbsbtbubvbwbs g h i j k l m n Dbo p JcKcLcPcQcRcxbEbFbGbHbIbJbKbLbMbNbObAbScr
2037 if stripped_line and not stripped_line.startswith(cs): 2037 ↛ 2038line 2037 didn't jump to line 2038 because the condition on line 2037 was never true2a Ncyb)bb =b8bf d Ocrbsbtbubvbwbs g h i j k l m n Dbo p JcKcLcPcQcRcxbEbFbGbHbIbJbKbLbMbNbObAbScr
2038 line = csp + line
2039 out.append(line) 2a Ncyb)bb =b8bf d Ocrbsbtbubvbwbs g h i j k l m n Dbo p JcKcLcPcQcRcxbEbFbGbHbIbJbKbLbMbNbObAbScr
2041 indent_string = self.indent_type * section.depth 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2042 for entry in (section.scalars + section.sections): 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2043 if entry in section.defaults: 2043 ↛ 2045line 2043 didn't jump to line 2045 because the condition on line 2043 was never true2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2044 # don't write out default values
2045 continue
2046 for comment_line in section.comments[entry]: 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2047 comment_line = self._decode_element(comment_line.lstrip()) 2a u Xbb f d v w s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ zb] ^ _ ` Abq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2048 if comment_line and not comment_line.startswith(cs): 2048 ↛ 2049line 2048 didn't jump to line 2049 because the condition on line 2048 was never true2a u Xbb f d v w s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ zb] ^ _ ` Abq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2049 comment_line = csp + comment_line
2050 out.append(indent_string + comment_line) 2a u Xbb f d v w s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ zb] ^ _ ` Abq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2051 this_entry = section[entry] 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2052 comment = self._handle_comment(section.inline_comments[entry]) 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2054 if isinstance(this_entry, Section): 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2055 # a section
2056 out.append(self._write_marker( 2a u NcXbyb0b9bzcb scf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` GcTbHcQbBbUbVbWbAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2057 indent_string,
2058 this_entry.depth,
2059 entry,
2060 comment))
2061 out.extend(self.write(section=this_entry)) 2a u NcXbyb0b9bzcb scf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` GcTbHcQbBbUbVbWbAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2062 else:
2063 out.append(self._write_line( 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2064 indent_string,
2065 entry,
2066 this_entry,
2067 comment))
2069 if section is self: 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2070 for line in self.final_comment: 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2071 line = self._decode_element(line) 2a u yb)b8bf d v w s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ ] ^ _ ` Abq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2072 stripped_line = line.strip() 2a u yb)b8bf d v w s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ ] ^ _ ` Abq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2073 if stripped_line and not stripped_line.startswith(cs): 2073 ↛ 2074line 2073 didn't jump to line 2074 because the condition on line 2073 was never true2a u yb)b8bf d v w s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ ] ^ _ ` Abq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2074 line = csp + line
2075 out.append(line) 2a u yb)b8bf d v w s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ ] ^ _ ` Abq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2076 self.interpolation = int_val 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2078 if section is not self: 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2079 return out 2a u NcXbyb0b9bzcb scf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` GcTbHcQbBbUbVbWbAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2081 if (self.filename is None) and (outfile is None): 2a u NctcXbocUc]byb0b9bzc)bb =b@b8bscf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2082 # output a list of lines
2083 # might need to encode
2084 # NOTE: This will *screw* UTF16, each line will start with the BOM
2085 if self.encoding: 2tcXb]b0b9bzc)bb =b@b8bscd
2086 out = [l.encode(self.encoding) for l in out] 1d
2087 if (self.BOM and ((self.encoding is None) or 2tcXb]b0b9bzc)bb =b@b8bscd
2088 (BOM_LIST.get(self.encoding.lower()) == 'utf_8'))):
2089 # Add the UTF8 BOM
2090 if not out: 2090 ↛ 2091line 2090 didn't jump to line 2091 because the condition on line 2090 was never true1d
2091 out.append('')
2092 out[0] = BOM_UTF8 + out[0] 1d
2093 return out 2tcXb]b0b9bzc)bb =b@b8bscd
2095 # Turn the list to a string, joined with correct newlines
2096 newline = self.newlines or os.linesep 2a u NcocUcybf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2097 if (getattr(outfile, 'mode', None) is not None and outfile.mode == 'w' 2097 ↛ 2100line 2097 didn't jump to line 2100 because the condition on line 2097 was never true2a u NcocUcybf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2098 and sys.platform == 'win32' and newline == '\r\n'):
2099 # Windows specific hack to avoid writing '\r\r\n'
2100 newline = '\n'
2101 output = self._a_to_u(newline).join(out) 2a u NcocUcybf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2102 if not output.endswith(newline): 2a u NcocUcybf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2103 output += newline 2a NcocUcybf d Ocrbsbtbubvbwbs g h i j k l m n Dbo p JcKcLcPcQcRcxbEbFbGbHbIbJbKbLbMbNbOb{bnc|b}b~baczbSbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScr
2105 if isinstance(output, bytes): 2105 ↛ 2106line 2105 didn't jump to line 2106 because the condition on line 2105 was never true2a u NcocUcybf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2106 output_bytes = output
2107 else:
2108 output_bytes = output.encode(self.encoding or 2a u NcocUcybf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2109 self.default_encoding or
2110 'ascii')
2112 if self.BOM and ((self.encoding is None) or match_utf8(self.encoding)): 2112 ↛ 2114line 2112 didn't jump to line 2114 because the condition on line 2112 was never true2a u NcocUcybf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2113 # Add the UTF8 BOM
2114 output_bytes = BOM_UTF8 + output_bytes
2116 if outfile is not None: 2a u NcocUcybf d v Ocrbsbtbubvbw wbs x y z A B C D E F G H I J K L g h i j k l M N O m n Dbo P Q R p S T U V W JcKcLcPcQcRcX Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + xb, - . / : ; = ? @ EbFbGbHbIbJbKbLbMbNbObt {bnc|b}b~bac[ zb] ^ _ ` SbPb$bYb!bZbTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2117 outfile.write(output_bytes) 2a u ocUcd v rbsbtbubvbw s x y z A B C D E F G H I J K L g h i j k l M N O m n o P Q R p S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ t [ zb] ^ _ ` SbPbYb!bZbq { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbr
2118 else:
2119 with open(self.filename, 'wb') as h: 2a Ncybf Ocwbs g h i j k l m n Dbo p JcKcLcPcQcRcxbEbFbGbHbIbJbKbLbMbNbOb{bnc|b}b~bac$bTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScr
2120 h.write(output_bytes) 2a Ncybf Ocwbs g h i j k l m n Dbo p JcKcLcPcQcRcxbEbFbGbHbIbJbKbLbMbNbOb{bnc|b}b~bac$bTcGcTbHcQbBbUbVb%b*bWb+b,b-b.b/b:b1b2b'b3b4b5b6b(b7b;bAbScr
2122 def validate(self, validator, preserve_errors=False, copy=False, 2a pc
2123 section=None):
2124 """
2125 Test the ConfigObj against a configspec.
2127 It uses the ``validator`` object from *validate.py*.
2129 To run ``validate`` on the current ConfigObj, call: ::
2131 test = config.validate(validator)
2133 (Normally having previously passed in the configspec when the ConfigObj
2134 was created - you can dynamically assign a dictionary of checks to the
2135 ``configspec`` attribute of a section though).
2137 It returns ``True`` if everything passes, or a dictionary of
2138 pass/fails (True/False). If every member of a subsection passes, it
2139 will just have the value ``True``. (It also returns ``False`` if all
2140 members fail).
2142 In addition, it converts the values from strings to their native
2143 types if their checks pass (and ``stringify`` is set).
2145 If ``preserve_errors`` is ``True`` (``False`` is default) then instead
2146 of a marking a fail with a ``False``, it will preserve the actual
2147 exception object. This can contain info about the reason for failure.
2148 For example the ``VdtValueTooSmallError`` indicates that the value
2149 supplied was too small. If a value (or section) is missing it will
2150 still be marked as ``False``.
2152 You must have the validate module to use ``preserve_errors=True``.
2154 You can then use the ``flatten_errors`` function to turn your nested
2155 results dictionary into a flattened list of failures - useful for
2156 displaying meaningful error messages.
2157 """
2158 if section is None: 1cbe
2159 if self.configspec is None: 2159 ↛ 2160line 2159 didn't jump to line 2160 because the condition on line 2159 was never true1cbe
2160 raise ValueError('No configspec supplied.')
2161 if preserve_errors: 1cbe
2162 # We do this once to remove a top level dependency on the validate module
2163 # Which makes importing configobj faster
2164 from configobj.validate import VdtMissingValue 1e
2165 self._vdtMissingValue = VdtMissingValue 1e
2167 section = self 1cbe
2169 if copy: 1cbe
2170 section.initial_comment = section.configspec.initial_comment 1b
2171 section.final_comment = section.configspec.final_comment 1b
2172 section.encoding = section.configspec.encoding 1b
2173 section.BOM = section.configspec.BOM 1b
2174 section.newlines = section.configspec.newlines 1b
2175 section.indent_type = section.configspec.indent_type 1b
2177 #
2178 # section.default_values.clear() #??
2179 configspec = section.configspec 1cbe
2180 self._set_configspec(section, copy) 1cbe
2183 def validate_entry(entry, spec, val, missing, ret_true, ret_false): 1cbe
2184 section.default_values.pop(entry, None) 1cbe
2186 try: 1cbe
2187 section.default_values[entry] = validator.get_default_value(configspec[entry]) 1cbe
2188 except (KeyError, AttributeError, validator.baseErrorClass): 1ce
2189 # No default, bad default or validator has no 'get_default_value'
2190 # (e.g. SimpleVal)
2191 pass 1ce
2193 try: 1cbe
2194 check = validator.check(spec, 1cbe
2195 val,
2196 missing=missing
2197 )
2198 except validator.baseErrorClass as e: 1e
2199 if not preserve_errors or isinstance(e, self._vdtMissingValue): 1e
2200 out[entry] = False 1e
2201 else:
2202 # preserve the error
2203 out[entry] = e 1e
2204 ret_false = False 1e
2205 ret_true = False 1e
2206 else:
2207 ret_false = False 1cbe
2208 out[entry] = True 1cbe
2209 if self.stringify or missing: 2209 ↛ 2223line 2209 didn't jump to line 2223 because the condition on line 2209 was always true1cbe
2210 # if we are doing type conversion
2211 # or the value is a supplied default
2212 if not self.stringify: 2212 ↛ 2213line 2212 didn't jump to line 2213 because the condition on line 2212 was never true1cbe
2213 if isinstance(check, (list, tuple)):
2214 # preserve lists
2215 check = [self._str(item) for item in check]
2216 elif missing and check is None:
2217 # convert the None from a default to a ''
2218 check = ''
2219 else:
2220 check = self._str(check)
2221 if (check != val) or missing: 1cbe
2222 section[entry] = check 1cbe
2223 if not copy and missing and entry not in section.defaults: 2223 ↛ 2224line 2223 didn't jump to line 2224 because the condition on line 2223 was never true1cbe
2224 section.defaults.append(entry)
2225 return ret_true, ret_false 1cbe
2227 #
2228 out = {} 1cbe
2229 ret_true = True 1cbe
2230 ret_false = True 1cbe
2232 unvalidated = [k for k in section.scalars if k not in configspec] 1cbe
2233 incorrect_sections = [k for k in configspec.sections if k in section.scalars] 1cbe
2234 incorrect_scalars = [k for k in configspec.scalars if k in section.sections] 1cbe
2236 for entry in configspec.scalars: 1cbe
2237 if entry in ('__many__', '___many___'): 2237 ↛ 2239line 2237 didn't jump to line 2239 because the condition on line 2237 was never true1cbe
2238 # reserved names
2239 continue
2240 if (not entry in section.scalars) or (entry in section.defaults): 1cbe
2241 # missing entries
2242 # or entries from defaults
2243 missing = True 1b
2244 val = None 1b
2245 if copy and entry not in section.scalars: 2245 ↛ 2256line 2245 didn't jump to line 2256 because the condition on line 2245 was always true1b
2246 # copy comments
2247 section.comments[entry] = ( 1b
2248 configspec.comments.get(entry, []))
2249 section.inline_comments[entry] = ( 1b
2250 configspec.inline_comments.get(entry, ''))
2251 #
2252 else:
2253 missing = False 1ce
2254 val = section[entry] 1ce
2256 ret_true, ret_false = validate_entry(entry, configspec[entry], val, 1cbe
2257 missing, ret_true, ret_false)
2259 many = None 1cbe
2260 if '__many__' in configspec.scalars: 2260 ↛ 2261line 2260 didn't jump to line 2261 because the condition on line 2260 was never true1cbe
2261 many = configspec['__many__']
2262 elif '___many___' in configspec.scalars: 2262 ↛ 2263line 2262 didn't jump to line 2263 because the condition on line 2262 was never true1cbe
2263 many = configspec['___many___']
2265 if many is not None: 2265 ↛ 2266line 2265 didn't jump to line 2266 because the condition on line 2265 was never true1cbe
2266 for entry in unvalidated:
2267 val = section[entry]
2268 ret_true, ret_false = validate_entry(entry, many, val, False,
2269 ret_true, ret_false)
2270 unvalidated = []
2272 for entry in incorrect_scalars: 2272 ↛ 2273line 2272 didn't jump to line 2273 because the loop on line 2272 never started1cbe
2273 ret_true = False
2274 if not preserve_errors:
2275 out[entry] = False
2276 else:
2277 ret_false = False
2278 msg = 'Value %r was provided as a section' % entry
2279 out[entry] = validator.baseErrorClass(msg)
2280 for entry in incorrect_sections: 2280 ↛ 2281line 2280 didn't jump to line 2281 because the loop on line 2280 never started1cbe
2281 ret_true = False
2282 if not preserve_errors:
2283 out[entry] = False
2284 else:
2285 ret_false = False
2286 msg = 'Section %r was provided as a single value' % entry
2287 out[entry] = validator.baseErrorClass(msg)
2289 # Missing sections will have been created as empty ones when the
2290 # configspec was read.
2291 for entry in section.sections: 1cbe
2292 # FIXME: this means DEFAULT is not copied in copy mode
2293 if section is self and entry == 'DEFAULT': 2293 ↛ 2294line 2293 didn't jump to line 2294 because the condition on line 2293 was never true1cbe
2294 continue
2295 if section[entry].configspec is None: 2295 ↛ 2296line 2295 didn't jump to line 2296 because the condition on line 2295 was never true1cbe
2296 unvalidated.append(entry)
2297 continue
2298 if copy: 1cbe
2299 section.comments[entry] = configspec.comments.get(entry, []) 1b
2300 section.inline_comments[entry] = configspec.inline_comments.get(entry, '') 1b
2301 check = self.validate(validator, preserve_errors=preserve_errors, copy=copy, section=section[entry]) 1cbe
2302 out[entry] = check 1cbe
2303 if check == False: 2303 ↛ 2304line 2303 didn't jump to line 2304 because the condition on line 2303 was never true1cbe
2304 ret_true = False
2305 elif check == True: 1cbe
2306 ret_false = False 1cb
2307 else:
2308 ret_true = False 1e
2310 section.extra_values = unvalidated 1cbe
2311 if preserve_errors and not section._created: 1cbe
2312 # If the section wasn't created (i.e. it wasn't missing)
2313 # then we can't return False, we need to preserve errors
2314 ret_false = False 1e
2315 #
2316 if ret_false and preserve_errors and out: 2316 ↛ 2321line 2316 didn't jump to line 2321 because the condition on line 2316 was never true1cbe
2317 # If we are preserving errors, but all
2318 # the failures are from missing sections / values
2319 # then we can return False. Otherwise there is a
2320 # real failure that we need to preserve.
2321 ret_false = not any(out.values())
2322 if ret_true: 1cbe
2323 return True 1cb
2324 elif ret_false: 2324 ↛ 2325line 2324 didn't jump to line 2325 because the condition on line 2324 was never true1e
2325 return False
2326 return out 1e
2329 def reset(self): 2a pc
2330 """Clear ConfigObj instance and restore to 'freshly created' state."""
2331 self.clear() 2Ec
2332 self._initialise() 2Ec
2333 # FIXME: Should be done by '_initialise', but ConfigObj constructor (and reload)
2334 # requires an empty dictionary
2335 self.configspec = None 2Ec
2336 # Just to be sure ;-)
2337 self._original_configspec = None 2Ec
2340 def reload(self): 2a pc
2341 """
2342 Reload a ConfigObj from file.
2344 This method raises a ``ReloadError`` if the ConfigObj doesn't have
2345 a filename attribute pointing to a file.
2346 """
2347 if not isinstance(self.filename, str): 2Mcc
2348 raise ReloadError() 2Mc
2350 filename = self.filename 1c
2351 current_options = {} 1c
2352 for entry in OPTION_DEFAULTS: 1c
2353 if entry == 'configspec': 1c
2354 continue 1c
2355 current_options[entry] = getattr(self, entry) 1c
2357 configspec = self._original_configspec 1c
2358 current_options['configspec'] = configspec 1c
2360 self.clear() 1c
2361 self._initialise(current_options) 1c
2362 self._load(filename, configspec) 1c
2366class SimpleVal(object): 2a pc
2367 """
2368 A simple validator.
2369 Can be used to check that all members expected are present.
2371 To use it, provide a configspec with all your members in (the value given
2372 will be ignored). Pass an instance of ``SimpleVal`` to the ``validate``
2373 method of your ``ConfigObj``. ``validate`` will return ``True`` if all
2374 members are present, or a dictionary with True/False meaning
2375 present/missing. (Whole missing sections will be replaced with ``False``)
2376 """
2378 def __init__(self): 2a pc
2379 self.baseErrorClass = ConfigObjError
2381 def check(self, check, member, missing=False): 2a pc
2382 """A dummy check method, always returns the value unchanged."""
2383 if missing:
2384 raise self.baseErrorClass()
2385 return member
2388def flatten_errors(cfg, res, levels=None, results=None): 2a pc
2389 """
2390 An example function that will turn a nested dictionary of results
2391 (as returned by ``ConfigObj.validate``) into a flat list.
2393 ``cfg`` is the ConfigObj instance being checked, ``res`` is the results
2394 dictionary returned by ``validate``.
2396 (This is a recursive function, so you shouldn't use the ``levels`` or
2397 ``results`` arguments - they are used by the function.)
2399 Returns a list of keys that failed. Each member of the list is a tuple::
2401 ([list of sections...], key, result)
2403 If ``validate`` was called with ``preserve_errors=False`` (the default)
2404 then ``result`` will always be ``False``.
2406 *list of sections* is a flattened list of sections that the key was found
2407 in.
2409 If the section was missing (or a section was expected and a scalar provided
2410 - or vice-versa) then key will be ``None``.
2412 If the value (or section) was missing then ``result`` will be ``False``.
2414 If ``validate`` was called with ``preserve_errors=True`` and a value
2415 was present, but failed the check, then ``result`` will be the exception
2416 object returned. You can use this as a string that describes the failure.
2418 For example *The value "3" is of the wrong type*.
2419 """
2420 if levels is None: 1e
2421 # first time called
2422 levels = [] 1e
2423 results = [] 1e
2424 if res == True: 2424 ↛ 2425line 2424 didn't jump to line 2425 because the condition on line 2424 was never true1e
2425 return sorted(results)
2426 if res == False or isinstance(res, Exception): 2426 ↛ 2427line 2426 didn't jump to line 2427 because the condition on line 2426 was never true1e
2427 results.append((levels[:], None, res))
2428 if levels:
2429 levels.pop()
2430 return sorted(results)
2431 for (key, val) in list(res.items()): 1e
2432 if val == True: 1e
2433 continue 1e
2434 if isinstance(cfg.get(key), dict): 1e
2435 # Go down one level
2436 levels.append(key) 1e
2437 flatten_errors(cfg[key], val, levels, results) 1e
2438 continue 1e
2439 results.append((levels[:], key, val)) 1e
2440 #
2441 # Go up one level
2442 if levels: 1e
2443 levels.pop() 1e
2444 #
2445 return sorted(results) 1e
2448def get_extra_values(conf, _prepend=()): 2a pc
2449 """
2450 Find all the values and sections not in the configspec from a validated
2451 ConfigObj.
2453 ``get_extra_values`` returns a list of tuples where each tuple represents
2454 either an extra section, or an extra value.
2456 The tuples contain two values, a tuple representing the section the value
2457 is in and the name of the extra values. For extra values in the top level
2458 section the first member will be an empty tuple. For values in the 'foo'
2459 section the first member will be ``('foo',)``. For members in the 'bar'
2460 subsection of the 'foo' section the first member will be ``('foo', 'bar')``.
2462 NOTE: If you call ``get_extra_values`` on a ConfigObj instance that hasn't
2463 been validated it will return an empty list.
2464 """
2465 out = []
2467 out.extend([(_prepend, name) for name in conf.extra_values])
2468 for name in conf.sections:
2469 if name not in conf.extra_values:
2470 out.extend(get_extra_values(conf[name], _prepend + (name,)))
2471 return out
2474"""*A programming language is a medium of expression.* - Paul Graham""" 2a pc