Sun, 06 Nov 2016 18:04:19 +0100
Fixed issues with the E5ConfigParser with Python2.
--- a/APIs/Python3/eric6.api Sun Nov 06 17:27:02 2016 +0100 +++ b/APIs/Python3/eric6.api Sun Nov 06 18:04:19 2016 +0100 @@ -1615,6 +1615,11 @@ eric6.E5XML.XMLStreamWriterBase.XMLStreamWriterBase.writeXML?4() eric6.E5XML.XMLStreamWriterBase.XMLStreamWriterBase?1(device) eric6.Globals.AppInfo.makeAppInfo?4(argv, name, arg, description, options=[]) +eric6.Globals.E5ConfigParser.E5ConfigParser.OPTCRE?7 +eric6.Globals.E5ConfigParser.E5ConfigParser.OPTCRE_NV?7 +eric6.Globals.E5ConfigParser.E5ConfigParser._OPT_NV_TMPL?8 +eric6.Globals.E5ConfigParser.E5ConfigParser._OPT_TMPL?8 +eric6.Globals.E5ConfigParser.E5ConfigParser?1(defaults=None, dict_type=_default_dict, allow_no_value=False, delimiters=('=', ':')) eric6.Globals.checkBlacklistedVersions?4() eric6.Globals.compatibility_fixes.File.next?4() eric6.Globals.compatibility_fixes.File.read?4(n=-1)
--- a/Documentation/Help/source.qhp Sun Nov 06 17:27:02 2016 +0100 +++ b/Documentation/Help/source.qhp Sun Nov 06 18:04:19 2016 +0100 @@ -4088,6 +4088,7 @@ <keyword name="E5ComboPathPicker (Constructor)" id="E5ComboPathPicker (Constructor)" ref="eric6.E5Gui.E5PathPicker.html#E5ComboPathPicker.__init__" /> <keyword name="E5Completers (Module)" id="E5Completers (Module)" ref="eric6.E5Gui.E5Completers.html" /> <keyword name="E5ConfigParser" id="E5ConfigParser" ref="eric6.Globals.E5ConfigParser.html#E5ConfigParser" /> + <keyword name="E5ConfigParser (Constructor)" id="E5ConfigParser (Constructor)" ref="eric6.Globals.E5ConfigParser.html#E5ConfigParser.__init__" /> <keyword name="E5ConfigParser (Module)" id="E5ConfigParser (Module)" ref="eric6.Globals.E5ConfigParser.html" /> <keyword name="E5ConfigParser.__contains__" id="E5ConfigParser.__contains__" ref="eric6.Globals.E5ConfigParser.html#E5ConfigParser.__contains__" /> <keyword name="E5ConfigParser.__delitem__" id="E5ConfigParser.__delitem__" ref="eric6.Globals.E5ConfigParser.html#E5ConfigParser.__delitem__" />
--- a/Documentation/Source/eric6.Globals.E5ConfigParser.html Sun Nov 06 17:27:02 2016 +0100 +++ b/Documentation/Source/eric6.Globals.E5ConfigParser.html Sun Nov 06 18:04:19 2016 +0100 @@ -32,7 +32,7 @@ <table> <tr> <td><a href="#E5ConfigParser">E5ConfigParser</a></td> -<td>Class implementing a wrapper of the ConfigParser class implementing dictionary like special methods.</td> +<td>Class implementing a wrapper of the ConfigParser class implementing dictionary like special methods and some enhancements from Python 3.</td> </tr> </table> <h3>Functions</h3> @@ -44,13 +44,13 @@ <h2>E5ConfigParser</h2> <p> Class implementing a wrapper of the ConfigParser class implementing - dictionary like special methods. + dictionary like special methods and some enhancements from Python 3. </p> <h3>Derived from</h3> SafeConfigParser <h3>Class Attributes</h3> <table> -<tr><td>None</td></tr> +<tr><td>OPTCRE</td></tr><tr><td>OPTCRE_NV</td></tr><tr><td>_OPT_NV_TMPL</td></tr><tr><td>_OPT_TMPL</td></tr> </table> <h3>Class Methods</h3> <table> @@ -59,6 +59,9 @@ <h3>Methods</h3> <table> <tr> +<td><a href="#E5ConfigParser.__init__">E5ConfigParser</a></td> +<td>Constructor</td> +</tr><tr> <td><a href="#E5ConfigParser.__contains__">__contains__</a></td> <td>Special method to test, if a section is contained in the config.</td> </tr><tr> @@ -82,7 +85,12 @@ <table> <tr><td>None</td></tr> </table> -<a NAME="E5ConfigParser.__contains__" ID="E5ConfigParser.__contains__"></a> +<a NAME="E5ConfigParser.__init__" ID="E5ConfigParser.__init__"></a> +<h4>E5ConfigParser (Constructor)</h4> +<b>E5ConfigParser</b>(<i>defaults=None, dict_type=_default_dict, allow_no_value=False, delimiters=('=', ':')</i>) +<p> + Constructor +</p><a NAME="E5ConfigParser.__contains__" ID="E5ConfigParser.__contains__"></a> <h4>E5ConfigParser.__contains__</h4> <b>__contains__</b>(<i>key</i>) <p>
--- a/Globals/E5ConfigParser.py Sun Nov 06 17:27:02 2016 +0100 +++ b/Globals/E5ConfigParser.py Sun Nov 06 18:04:19 2016 +0100 @@ -14,14 +14,67 @@ from configparser import ConfigParser as E5ConfigParser except ImportError: # Py2 part with the compatibility wrapper class + try: + from collections import OrderedDict as _default_dict # __IGNORE_WARNING__ + except ImportError: + # fallback for setup.py which hasn't yet built _collections + _default_dict = dict + + import re import itertools from ConfigParser import SafeConfigParser, DEFAULTSECT class E5ConfigParser(SafeConfigParser): """ Class implementing a wrapper of the ConfigParser class implementing - dictionary like special methods. + dictionary like special methods and some enhancements from Python 3. """ + _OPT_TMPL = r""" + (?P<option>.*?) # very permissive! + \s*(?P<vi>{delim})\s* # any number of space/tab, + # followed by any of the + # allowed delimiters, + # followed by any space/tab + (?P<value>.*)$ # everything up to eol + """ + _OPT_NV_TMPL = r""" + (?P<option>.*?) # very permissive! + \s*(?: # any number of space/tab, + (?P<vi>{delim})\s* # optionally followed by + # any of the allowed + # delimiters, followed by any + # space/tab + (?P<value>.*))?$ # everything up to eol + """ + # Compiled regular expression for matching options with typical + # separators + OPTCRE = re.compile(_OPT_TMPL.format(delim="=|:"), re.VERBOSE) + # Compiled regular expression for matching options with optional + # values delimited using typical separators + OPTCRE_NV = re.compile(_OPT_NV_TMPL.format(delim="=|:"), re.VERBOSE) + + def __init__(self, defaults=None, dict_type=_default_dict, + allow_no_value=False, delimiters=('=', ':')): + """ + Constructor + """ + SafeConfigParser.__init__( + self, + defaults=defaults, dict_type=dict_type, + allow_no_value=allow_no_value) + + if delimiters == ('=', ':'): + self._optcre = \ + self.OPTCRE_NV if allow_no_value else self.OPTCRE + else: + d = "|".join(re.escape(d) for d in delimiters) + if allow_no_value: + self._optcre = re.compile( + self._OPT_NV_TMPL.format(delim=d), re.VERBOSE) + else: + self._optcre = re.compile( + self._OPT_TMPL.format(delim=d), re.VERBOSE) + def __getitem__(self, key): """ Special method to get a section.