mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 21:33:13 -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
|
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
|
import six
|
||||||
|
from _version import __version__
|
||||||
|
|
||||||
|
# imported lazily to avoid startup performance hit if it isn't used
|
||||||
compiler = None
|
compiler = None
|
||||||
|
|
||||||
# A dictionary mapping BOM to
|
# A dictionary mapping BOM to
|
||||||
|
@ -1580,7 +1581,7 @@ class ConfigObj(Section):
|
||||||
self.indent_type = indent
|
self.indent_type = indent
|
||||||
cur_depth = sect_open.count('[')
|
cur_depth = sect_open.count('[')
|
||||||
if cur_depth != sect_close.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)
|
NestingError, infile, cur_index)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -1590,7 +1591,7 @@ class ConfigObj(Section):
|
||||||
parent = self._match_depth(this_section,
|
parent = self._match_depth(this_section,
|
||||||
cur_depth).parent
|
cur_depth).parent
|
||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
self._handle_error("Cannot compute nesting level at line %s.",
|
self._handle_error("Cannot compute nesting level",
|
||||||
NestingError, infile, cur_index)
|
NestingError, infile, cur_index)
|
||||||
continue
|
continue
|
||||||
elif cur_depth == this_section.depth:
|
elif cur_depth == this_section.depth:
|
||||||
|
@ -1600,12 +1601,13 @@ class ConfigObj(Section):
|
||||||
# the new section is a child the current section
|
# the new section is a child the current section
|
||||||
parent = this_section
|
parent = this_section
|
||||||
else:
|
else:
|
||||||
self._handle_error("Section too nested at line %s.",
|
self._handle_error("Section too nested",
|
||||||
NestingError, infile, cur_index)
|
NestingError, infile, cur_index)
|
||||||
|
continue
|
||||||
|
|
||||||
sect_name = self._unquote(sect_name)
|
sect_name = self._unquote(sect_name)
|
||||||
if sect_name in parent:
|
if sect_name in parent:
|
||||||
self._handle_error('Duplicate section name at line %s.',
|
self._handle_error('Duplicate section name',
|
||||||
DuplicateError, infile, cur_index)
|
DuplicateError, infile, cur_index)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -1625,7 +1627,7 @@ class ConfigObj(Section):
|
||||||
mat = self._keyword.match(line)
|
mat = self._keyword.match(line)
|
||||||
if mat is None:
|
if mat is None:
|
||||||
self._handle_error(
|
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)
|
ParseError, infile, cur_index)
|
||||||
else:
|
else:
|
||||||
# is a keyword value
|
# is a keyword value
|
||||||
|
@ -1640,7 +1642,7 @@ class ConfigObj(Section):
|
||||||
value, infile, cur_index, maxline)
|
value, infile, cur_index, maxline)
|
||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
self._handle_error(
|
self._handle_error(
|
||||||
'Parse error in multiline value at line %s.',
|
'Parse error in multiline value',
|
||||||
ParseError, infile, cur_index)
|
ParseError, infile, cur_index)
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
|
@ -1650,9 +1652,9 @@ class ConfigObj(Section):
|
||||||
value = unrepr(value)
|
value = unrepr(value)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if type(e) == UnknownType:
|
if type(e) == UnknownType:
|
||||||
msg = 'Unknown name or type in value at line %s.'
|
msg = 'Unknown name or type in value'
|
||||||
else:
|
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,
|
self._handle_error(msg, UnreprError, infile,
|
||||||
cur_index)
|
cur_index)
|
||||||
continue
|
continue
|
||||||
|
@ -1663,9 +1665,9 @@ class ConfigObj(Section):
|
||||||
value = unrepr(value)
|
value = unrepr(value)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if isinstance(e, UnknownType):
|
if isinstance(e, UnknownType):
|
||||||
msg = 'Unknown name or type in value at line %s.'
|
msg = 'Unknown name or type in value'
|
||||||
else:
|
else:
|
||||||
msg = 'Parse error from unrepr-ing value at line %s.'
|
msg = 'Parse error from unrepr-ing value'
|
||||||
self._handle_error(msg, UnreprError, infile,
|
self._handle_error(msg, UnreprError, infile,
|
||||||
cur_index)
|
cur_index)
|
||||||
continue
|
continue
|
||||||
|
@ -1675,14 +1677,14 @@ class ConfigObj(Section):
|
||||||
(value, comment) = self._handle_value(value)
|
(value, comment) = self._handle_value(value)
|
||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
self._handle_error(
|
self._handle_error(
|
||||||
'Parse error in value at line %s.',
|
'Parse error in value',
|
||||||
ParseError, infile, cur_index)
|
ParseError, infile, cur_index)
|
||||||
continue
|
continue
|
||||||
#
|
#
|
||||||
key = self._unquote(key)
|
key = self._unquote(key)
|
||||||
if key in this_section:
|
if key in this_section:
|
||||||
self._handle_error(
|
self._handle_error(
|
||||||
'Duplicate keyword name at line %s.',
|
'Duplicate keyword name',
|
||||||
DuplicateError, infile, cur_index)
|
DuplicateError, infile, cur_index)
|
||||||
continue
|
continue
|
||||||
# add the key.
|
# add the key.
|
||||||
|
@ -1733,7 +1735,7 @@ class ConfigObj(Section):
|
||||||
"""
|
"""
|
||||||
line = infile[cur_index]
|
line = infile[cur_index]
|
||||||
cur_index += 1
|
cur_index += 1
|
||||||
message = text % cur_index
|
message = '{0} at line {1}.'.format(text, cur_index)
|
||||||
error = ErrorClass(message, cur_index, line)
|
error = ErrorClass(message, cur_index, line)
|
||||||
if self.raise_errors:
|
if self.raise_errors:
|
||||||
# raise the error - parsing stops here
|
# raise the error - parsing stops here
|
||||||
|
@ -2106,21 +2108,25 @@ class ConfigObj(Section):
|
||||||
# Windows specific hack to avoid writing '\r\r\n'
|
# Windows specific hack to avoid writing '\r\r\n'
|
||||||
newline = '\n'
|
newline = '\n'
|
||||||
output = self._a_to_u(newline).join(out)
|
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):
|
if not output.endswith(newline):
|
||||||
output += 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:
|
if outfile is not None:
|
||||||
outfile.write(output)
|
outfile.write(output_bytes)
|
||||||
else:
|
else:
|
||||||
with open(self.filename, 'wb') as h:
|
with open(self.filename, 'wb') as h:
|
||||||
h.write(output.encode(self.encoding or
|
h.write(output_bytes)
|
||||||
self.default_encoding or
|
|
||||||
'ascii'))
|
|
||||||
|
|
||||||
def validate(self, validator, preserve_errors=False, copy=False,
|
def validate(self, validator, preserve_errors=False, copy=False,
|
||||||
section=None):
|
section=None):
|
||||||
|
|
|
@ -538,7 +538,7 @@ class Validator(object):
|
||||||
ConfigObj, an alternative to ConfigParser which supports lists and
|
ConfigObj, an alternative to ConfigParser which supports lists and
|
||||||
can validate a config file using a config schema.
|
can validate a config file using a config schema.
|
||||||
For more details on using Validator with ConfigObj see:
|
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
|
# this regex does the initial parsing of the checks
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue