mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-21 05:43:16 -07:00
Merge pull request #1053 from clinton-hall/lib-update-configobj
Update configobj to v5.0.6:
This commit is contained in:
commit
e6383b4a98
3 changed files with 32 additions and 26 deletions
|
@ -1 +1 @@
|
|||
__version__ = '5.0.4'
|
||||
__version__ = '5.0.6'
|
|
@ -19,9 +19,10 @@ import sys
|
|||
|
||||
from codecs import BOM_UTF8, BOM_UTF16, BOM_UTF16_BE, BOM_UTF16_LE
|
||||
|
||||
# imported lazily to avoid startup performance hit if it isn't used
|
||||
import six
|
||||
from _version import __version__
|
||||
|
||||
# imported lazily to avoid startup performance hit if it isn't used
|
||||
compiler = None
|
||||
|
||||
# A dictionary mapping BOM to
|
||||
|
@ -1580,7 +1581,7 @@ class ConfigObj(Section):
|
|||
self.indent_type = indent
|
||||
cur_depth = sect_open.count('[')
|
||||
if cur_depth != sect_close.count(']'):
|
||||
self._handle_error("Cannot compute the section depth at line %s.",
|
||||
self._handle_error("Cannot compute the section depth",
|
||||
NestingError, infile, cur_index)
|
||||
continue
|
||||
|
||||
|
@ -1590,7 +1591,7 @@ class ConfigObj(Section):
|
|||
parent = self._match_depth(this_section,
|
||||
cur_depth).parent
|
||||
except SyntaxError:
|
||||
self._handle_error("Cannot compute nesting level at line %s.",
|
||||
self._handle_error("Cannot compute nesting level",
|
||||
NestingError, infile, cur_index)
|
||||
continue
|
||||
elif cur_depth == this_section.depth:
|
||||
|
@ -1600,12 +1601,13 @@ class ConfigObj(Section):
|
|||
# the new section is a child the current section
|
||||
parent = this_section
|
||||
else:
|
||||
self._handle_error("Section too nested at line %s.",
|
||||
self._handle_error("Section too nested",
|
||||
NestingError, infile, cur_index)
|
||||
continue
|
||||
|
||||
sect_name = self._unquote(sect_name)
|
||||
if sect_name in parent:
|
||||
self._handle_error('Duplicate section name at line %s.',
|
||||
self._handle_error('Duplicate section name',
|
||||
DuplicateError, infile, cur_index)
|
||||
continue
|
||||
|
||||
|
@ -1625,7 +1627,7 @@ class ConfigObj(Section):
|
|||
mat = self._keyword.match(line)
|
||||
if mat is None:
|
||||
self._handle_error(
|
||||
'Invalid line ({0!r}) (matched as neither section nor keyword) at line "%s".'.format(line),
|
||||
'Invalid line ({0!r}) (matched as neither section nor keyword)'.format(line),
|
||||
ParseError, infile, cur_index)
|
||||
else:
|
||||
# is a keyword value
|
||||
|
@ -1640,7 +1642,7 @@ class ConfigObj(Section):
|
|||
value, infile, cur_index, maxline)
|
||||
except SyntaxError:
|
||||
self._handle_error(
|
||||
'Parse error in multiline value at line %s.',
|
||||
'Parse error in multiline value',
|
||||
ParseError, infile, cur_index)
|
||||
continue
|
||||
else:
|
||||
|
@ -1650,9 +1652,9 @@ class ConfigObj(Section):
|
|||
value = unrepr(value)
|
||||
except Exception as e:
|
||||
if type(e) == UnknownType:
|
||||
msg = 'Unknown name or type in value at line %s.'
|
||||
msg = 'Unknown name or type in value'
|
||||
else:
|
||||
msg = 'Parse error from unrepr-ing multiline value at line %s.'
|
||||
msg = 'Parse error from unrepr-ing multiline value'
|
||||
self._handle_error(msg, UnreprError, infile,
|
||||
cur_index)
|
||||
continue
|
||||
|
@ -1663,9 +1665,9 @@ class ConfigObj(Section):
|
|||
value = unrepr(value)
|
||||
except Exception as e:
|
||||
if isinstance(e, UnknownType):
|
||||
msg = 'Unknown name or type in value at line %s.'
|
||||
msg = 'Unknown name or type in value'
|
||||
else:
|
||||
msg = 'Parse error from unrepr-ing value at line %s.'
|
||||
msg = 'Parse error from unrepr-ing value'
|
||||
self._handle_error(msg, UnreprError, infile,
|
||||
cur_index)
|
||||
continue
|
||||
|
@ -1675,14 +1677,14 @@ class ConfigObj(Section):
|
|||
(value, comment) = self._handle_value(value)
|
||||
except SyntaxError:
|
||||
self._handle_error(
|
||||
'Parse error in value at line %s.',
|
||||
'Parse error in value',
|
||||
ParseError, infile, cur_index)
|
||||
continue
|
||||
#
|
||||
key = self._unquote(key)
|
||||
if key in this_section:
|
||||
self._handle_error(
|
||||
'Duplicate keyword name at line %s.',
|
||||
'Duplicate keyword name',
|
||||
DuplicateError, infile, cur_index)
|
||||
continue
|
||||
# add the key.
|
||||
|
@ -1733,7 +1735,7 @@ class ConfigObj(Section):
|
|||
"""
|
||||
line = infile[cur_index]
|
||||
cur_index += 1
|
||||
message = text % cur_index
|
||||
message = '{0} at line {1}.'.format(text, cur_index)
|
||||
error = ErrorClass(message, cur_index, line)
|
||||
if self.raise_errors:
|
||||
# raise the error - parsing stops here
|
||||
|
@ -2106,21 +2108,25 @@ class ConfigObj(Section):
|
|||
# Windows specific hack to avoid writing '\r\r\n'
|
||||
newline = '\n'
|
||||
output = self._a_to_u(newline).join(out)
|
||||
if self.encoding:
|
||||
output = output.encode(self.encoding)
|
||||
if self.BOM and ((self.encoding is None) or match_utf8(self.encoding)):
|
||||
# Add the UTF8 BOM
|
||||
output = BOM_UTF8 + output
|
||||
|
||||
if not output.endswith(newline):
|
||||
output += newline
|
||||
|
||||
if isinstance(output, six.binary_type):
|
||||
output_bytes = output
|
||||
else:
|
||||
output_bytes = output.encode(self.encoding or
|
||||
self.default_encoding or
|
||||
'ascii')
|
||||
|
||||
if self.BOM and ((self.encoding is None) or match_utf8(self.encoding)):
|
||||
# Add the UTF8 BOM
|
||||
output_bytes = BOM_UTF8 + output_bytes
|
||||
|
||||
if outfile is not None:
|
||||
outfile.write(output)
|
||||
outfile.write(output_bytes)
|
||||
else:
|
||||
with open(self.filename, 'wb') as h:
|
||||
h.write(output.encode(self.encoding or
|
||||
self.default_encoding or
|
||||
'ascii'))
|
||||
h.write(output_bytes)
|
||||
|
||||
def validate(self, validator, preserve_errors=False, copy=False,
|
||||
section=None):
|
||||
|
|
|
@ -538,7 +538,7 @@ class Validator(object):
|
|||
ConfigObj, an alternative to ConfigParser which supports lists and
|
||||
can validate a config file using a config schema.
|
||||
For more details on using Validator with ConfigObj see:
|
||||
http://www.voidspace.org.uk/python/configobj.html
|
||||
https://configobj.readthedocs.org/en/latest/configobj.html
|
||||
"""
|
||||
|
||||
# this regex does the initial parsing of the checks
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue