Control: tags -1 patch Control: tags -1 pending Dear maintainer > The python-parse package currently only supports python 2, though the actual > code (including the PyPI release) support python 3 without issue. I would like > to use a python3 version of this package in one of my packages and so would > like to see this option released. > > I have attached an update control and rules file that will move this package > over to pybuild as the build system. This worked better for building on my > system than the distutils system did. I have also attached an updated control > file which will add the python3 package.
Since this package needs some care, I added some more changes to the above debdiff and made it lintian clean. Summary of the changes are: * Non-maintainer upload. * Adds python3 support (closes: #849937). [ Gianfranco Costamagna ] * New upstream release. * Bump compat level to 10 * Bump std-version to 3.9.8 * Add homepage field * Add watch file * Add upstream signing key * Convert copyright file in dep-5 format This way we will notice if a new release is out, and we add some new features to the packaging (e.g. machine readable copyright file, Homepage fields to BTS, lintian free package and so on). I'm uploading right now in deferred/10, please let me know if I can reschedule it thanks G.
diff -Nru python-parse-1.6.3/debian/changelog python-parse-1.6.6/debian/changelog --- python-parse-1.6.3/debian/changelog 2013-11-11 15:37:03.000000000 +0100 +++ python-parse-1.6.6/debian/changelog 2017-01-13 08:55:28.000000000 +0100 @@ -1,3 +1,19 @@ +python-parse (1.6.6-0.1) unstable; urgency=low + + * Non-maintainer upload. + * Adds python3 support (closes: #849937). + + [ Gianfranco Costamagna ] + * New upstream release. + * Bump compat level to 10 + * Bump std-version to 3.9.8 + * Add homepage field + * Add watch file + * Add upstream signing key + * Convert copyright file in dep-5 format + + -- Daniel Manila <d...@springwater7.org> Thu, 12 Jan 2017 16:57:30 +0600 + python-parse (1.6.3-1) unstable; urgency=low * Initial release (closes: #726715). diff -Nru python-parse-1.6.3/debian/compat python-parse-1.6.6/debian/compat --- python-parse-1.6.3/debian/compat 2013-10-18 11:42:01.000000000 +0200 +++ python-parse-1.6.6/debian/compat 2017-01-13 08:28:48.000000000 +0100 @@ -1 +1 @@ -7 +10 diff -Nru python-parse-1.6.3/debian/control python-parse-1.6.6/debian/control --- python-parse-1.6.3/debian/control 2013-11-11 15:38:39.000000000 +0100 +++ python-parse-1.6.6/debian/control 2017-01-13 08:40:33.000000000 +0100 @@ -5,13 +5,14 @@ Cyril Bouthors <cy...@bouthors.org> Section: python Priority: optional -Build-Depends: python-all (>= 2.6.6-3), debhelper (>= 7) -Standards-Version: 3.9.4 +Build-Depends: python-all, python3-all, debhelper (>= 10), dh-python +Standards-Version: 3.9.8 +Homepage: https://github.com/r1chardj0n3s/parse Package: python-parse Architecture: all Depends: ${misc:Depends}, ${python:Depends} -Description: Parse provides the reverse function for format(). +Description: Parse provides the reverse function for format(), Python2 package Parse strings using a specification based on the Python format() syntax. . ``parse()`` is the opposite of ``format()`` @@ -32,3 +33,32 @@ . >>> search('Age: {:d}\n', 'Name: Rufus\nAge: 42\nColor: red\n') <Result (42,) {}> + . + This is the Python 2 package + +Package: python3-parse +Architecture: all +Depends: ${misc:Depends}, ${python3:Depends} +Description: Parse provides the reverse function for format(), Python3 package + Parse strings using a specification based on the Python format() syntax. + . + ``parse()`` is the opposite of ``format()`` + . + The module is set up to only export ``parse()``, ``search()`` and + ``findall()`` when ``import *`` is used: + . + >>> from parse import * + . + From there it's a simple thing to parse a string: + . + >>> parse("It's {}, I love it!", "It's spam, I love it!") + <Result ('spam',) {}> + >>> _[0] + 'spam' + . + Or to search a string for some pattern: + . + >>> search('Age: {:d}\n', 'Name: Rufus\nAge: 42\nColor: red\n') + <Result (42,) {}> + . + This is the Python 3 package diff -Nru python-parse-1.6.3/debian/copyright python-parse-1.6.6/debian/copyright --- python-parse-1.6.3/debian/copyright 2013-10-18 11:50:31.000000000 +0200 +++ python-parse-1.6.6/debian/copyright 2017-01-13 08:47:04.000000000 +0100 @@ -1,30 +1,30 @@ -This package was debianized by Arthur Vuillard <art...@hashbang.fr> on -Fri Oct 18 11:46:48 CEST 2013 - -It was downloaded from <https://pypi.python.org/pypi/parse> - -Upstream Author: - - Richard Jones <rjo...@ekit-inc.com> - -License: - -Copyright (c) 2012-2013 Richard Jones <rich...@python.org> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Source: https://github.com/r1chardj0n3s/parse +Upstream-Contact: Richard Jones <rich...@python.org> + +Files: * +Copyright: 2012-2013 Richard Jones <rich...@python.org> +License: Expat + +Files: debian/* +Copyright: 2013 Arthur Vuillard <art...@hashbang.fr> +License: Expat + +License: Expat + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + . + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. diff -Nru python-parse-1.6.3/debian/rules python-parse-1.6.6/debian/rules --- python-parse-1.6.3/debian/rules 2013-10-18 11:42:01.000000000 +0200 +++ python-parse-1.6.6/debian/rules 2017-01-13 08:28:11.000000000 +0100 @@ -3,7 +3,9 @@ # This file was automatically generated by stdeb 0.6.0+git at # Fri, 18 Oct 2013 09:42:01 +0000 +export PYBUILD_NAME = parse + %: - dh $@ --with python2 --buildsystem=python_distutils + dh $@ --with python2,python3 --buildsystem=pybuild diff -Nru python-parse-1.6.3/debian/upstream/signing-key.asc python-parse-1.6.6/debian/upstream/signing-key.asc --- python-parse-1.6.3/debian/upstream/signing-key.asc 1970-01-01 01:00:00.000000000 +0100 +++ python-parse-1.6.6/debian/upstream/signing-key.asc 2017-01-13 08:54:56.000000000 +0100 @@ -0,0 +1,51 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1 + +mQGiBD6V9pkRBACkiR0/dAaV2vYtmAsh7Be4a3NWzZ9jSmTMzrjzpMM9QGZM3zKB +aLRLLCrJrOzpi7TX55mXjEtGStg3wvRyheraNa/xAJKVwE25m2xFou0d8CpkhqiQ +2HE7HJGGzqglhIoOdKd9HDeh0u3LpvqgXqtD/VTExS0OPpDKFFxk/IVqzwCghxCL +6Ca2DHqEVTI02Gpwa03E9icD/iKXFmqOXPtvmfUsAoHp8RF0HbsWlljb+Jvw+bkj +WwaWY/rE+zcprM75kNNVcNtztXwKCiuY17LK2n8itHacHUAMm9FClkn2k8rDi6ej +XG8x7o0MSRaz6IqDnaxag5icg6AziOzl021UQFbbN6uUxE5bXThJ//e8osEsB5h/ +qVXgA/9j85h9VYUnFalib/UkeI6Gf3gVWdewIrp8WHeX1WfqskplLB3EbRtTEJOl +RBZbaHL/WTg8CTXW2pGZ8UyXnabdPVITo98Mu4pz3dZaA+L0x3E8EzIPGkfDzql6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b25lcyA8cjFjaGFy +ZGowbjNzQGdtYWlsLmNvbT6IuAQTAQIAIgUCU+AoLwIbLwYLCQgHAwIGFQgCCQoL +BBYCAwECHgECF4AACgkQBSJliUHG6TAZMgQAr7e0I/EdEIyEj8m4YBjBFOk9U6qX +9+D8XVAXOm3ODNEakLXU/VFQ8bCcFH4V+iJ8ez9cGBZbMKBAWhLizJ5pfBjiif4W +8kBs9G154tYl8Esk8u4lwyUpYCeSeRV/RmX6CCEx41nUEtk+b3LVVeVU+AmvEaeM +b5bLuIEM8q0hoYM= +=hqdC +-----END PGP PUBLIC KEY BLOCK----- diff -Nru python-parse-1.6.3/debian/watch python-parse-1.6.6/debian/watch --- python-parse-1.6.3/debian/watch 1970-01-01 01:00:00.000000000 +0100 +++ python-parse-1.6.6/debian/watch 2017-01-13 08:39:58.000000000 +0100 @@ -0,0 +1,3 @@ +version=3 +opts=uversionmangle=s/(rc|a|b|c)/~$1/,pgpsigurlmangle=s/$/.asc/ \ +https://pypi.debian.net/parse/parse-(.+)\.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz))) diff -Nru python-parse-1.6.3/parse.py python-parse-1.6.6/parse.py --- python-parse-1.6.3/parse.py 2013-10-15 02:23:02.000000000 +0200 +++ python-parse-1.6.6/parse.py 2014-11-17 05:11:02.000000000 +0100 @@ -93,7 +93,7 @@ Most of `format()`'s `Format Specification Mini-Language`_ is supported: - [[fill]align][0][width][type] + [[fill]align][0][width][.precision][type] The differences between `parse()` and `format()` are: @@ -104,7 +104,7 @@ That is, the "#" format character is handled automatically by d, b, o and x formats. For "d" any will be accepted, but for the others the correct prefix must be present if at all. -- Numberic sign is handled automatically. +- Numeric sign is handled automatically. - The thousands separator is handled automatically if the "n" type is used. - The types supported are a slightly different mix to the format() types. Some format() types come directly over: "d", "n", "%", "f", "e", "b", "o" and "x". @@ -144,6 +144,8 @@ e.g. Sun Sep 16 01:03:52 1973 th HTTP log format date/time datetime e.g. 21/Nov/2011:00:07:11 +0000 + ts Linux system log format date/time datetime + e.g. Nov 9 03:37:44 tt Time time e.g. 10:21:36 PM -5:30 ===== =========================================== ======== @@ -276,6 +278,9 @@ **Version history (in brief)**: +- 1.6.6 parse Linux system log dates (thanks Alex Cowan) +- 1.6.5 handle precision in float format (thanks Levi Kilcher) +- 1.6.4 handle pipe "|" characters in parse string (thanks Martijn Pieters) - 1.6.3 handle repeated instances of named fields, fix bug in PM time overflow - 1.6.2 fix logging to use local, not root logger (thanks Necku) @@ -319,7 +324,7 @@ This code is copyright 2012-2013 Richard Jones <rich...@python.org> See the end of the source file for the license of use. ''' -__version__ = '1.6.3' +__version__ = '1.6.6' # yes, I now have two problems import re @@ -447,13 +452,17 @@ def date_convert(string, match, ymd=None, mdy=None, dmy=None, - d_m_y=None, hms=None, am=None, tz=None): + d_m_y=None, hms=None, am=None, tz=None, mm=None, dd=None): '''Convert the incoming string containing some date / time info into a datetime instance. ''' groups = match.groups() time_only = False - if ymd is not None: + if mm and dd: + y=datetime.today().year + m=groups[mm] + d=groups[dd] + elif ymd is not None: y, m, d = re.split('[-/\s]', groups[ymd]) elif mdy is not None: m, d, y = re.split('[-/\s]', groups[mdy]) @@ -539,15 +548,15 @@ # note: {} are handled separately # note: I don't use r'' here because Sublime Text 2 syntax highlight has a fit -REGEX_SAFETY = re.compile('([?\\\\.[\]()*+\^$!])') +REGEX_SAFETY = re.compile('([?\\\\.[\]()*+\^$!\|])') # allowed field types ALLOWED_TYPES = set(list('nbox%fegwWdDsS') + - ['t' + c for c in 'ieahgct']) + ['t' + c for c in 'ieahgcts']) def extract_format(format, extra_types): - '''Pull apart the format [[fill]align][0][width][type] + '''Pull apart the format [[fill]align][0][width][.precision][type] ''' fill = align = None if format[0] in '<>=^': @@ -570,6 +579,17 @@ width += format[0] format = format[1:] + if format.startswith('.'): + # Precision isn't needed but we need to capture it so that + # the ValueError isn't raised. + format = format[1:] # drop the '.' + precision = '' + while format: + if not format[0].isdigit(): + break + precision += format[0] + format = format[1:] + # the rest is the type, if present type = format if type and type not in ALLOWED_TYPES and type not in extra_types: @@ -896,6 +916,13 @@ self._type_conversions[group] = partial(date_convert, hms=n + 1, am=n + 4, tz=n + 5) self._group_index += 5 + elif type == 'ts': + s = r'%s(\s+)(\d+)(\s+)(\d{1,2}:\d{1,2}:\d{1,2})?' % (MONTHS_PAT) + n = self._group_index + self._type_conversions[group] = partial(date_convert, mm=n+1, dd=n+3, + hms=n + 5) + self._group_index += 5 + elif type: s = r'\%s+' % type else: diff -Nru python-parse-1.6.3/PKG-INFO python-parse-1.6.6/PKG-INFO --- python-parse-1.6.3/PKG-INFO 2013-10-15 02:24:56.000000000 +0200 +++ python-parse-1.6.6/PKG-INFO 2014-11-17 05:19:19.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: parse -Version: 1.6.3 +Version: 1.6.6 Summary: parse() is the opposite of format() Home-page: https://github.com/r1chardj0n3s/parse Author: Richard Jones @@ -101,7 +101,7 @@ Most of `format()`'s `Format Specification Mini-Language`_ is supported: - [[fill]align][0][width][type] + [[fill]align][0][width][.precision][type] The differences between `parse()` and `format()` are: @@ -112,7 +112,7 @@ That is, the "#" format character is handled automatically by d, b, o and x formats. For "d" any will be accepted, but for the others the correct prefix must be present if at all. - - Numberic sign is handled automatically. + - Numeric sign is handled automatically. - The thousands separator is handled automatically if the "n" type is used. - The types supported are a slightly different mix to the format() types. Some format() types come directly over: "d", "n", "%", "f", "e", "b", "o" and "x". @@ -152,6 +152,8 @@ e.g. Sun Sep 16 01:03:52 1973 th HTTP log format date/time datetime e.g. 21/Nov/2011:00:07:11 +0000 + ts Linux system log format date/time datetime + e.g. Nov 9 03:37:44 tt Time time e.g. 10:21:36 PM -5:30 ===== =========================================== ======== @@ -284,6 +286,9 @@ **Version history (in brief)**: + - 1.6.6 parse Linux system log dates (thanks Alex Cowan) + - 1.6.5 handle precision in float format (thanks Levi Kilcher) + - 1.6.4 handle pipe "|" characters in parse string (thanks Martijn Pieters) - 1.6.3 handle repeated instances of named fields, fix bug in PM time overflow - 1.6.2 fix logging to use local, not root logger (thanks Necku) diff -Nru python-parse-1.6.3/README.rst python-parse-1.6.6/README.rst --- python-parse-1.6.3/README.rst 2013-10-15 02:24:56.000000000 +0200 +++ python-parse-1.6.6/README.rst 2014-11-17 05:19:18.000000000 +0100 @@ -93,7 +93,7 @@ Most of `format()`'s `Format Specification Mini-Language`_ is supported: - [[fill]align][0][width][type] + [[fill]align][0][width][.precision][type] The differences between `parse()` and `format()` are: @@ -104,7 +104,7 @@ That is, the "#" format character is handled automatically by d, b, o and x formats. For "d" any will be accepted, but for the others the correct prefix must be present if at all. -- Numberic sign is handled automatically. +- Numeric sign is handled automatically. - The thousands separator is handled automatically if the "n" type is used. - The types supported are a slightly different mix to the format() types. Some format() types come directly over: "d", "n", "%", "f", "e", "b", "o" and "x". @@ -144,6 +144,8 @@ e.g. Sun Sep 16 01:03:52 1973 th HTTP log format date/time datetime e.g. 21/Nov/2011:00:07:11 +0000 + ts Linux system log format date/time datetime + e.g. Nov 9 03:37:44 tt Time time e.g. 10:21:36 PM -5:30 ===== =========================================== ======== @@ -276,6 +278,9 @@ **Version history (in brief)**: +- 1.6.6 parse Linux system log dates (thanks Alex Cowan) +- 1.6.5 handle precision in float format (thanks Levi Kilcher) +- 1.6.4 handle pipe "|" characters in parse string (thanks Martijn Pieters) - 1.6.3 handle repeated instances of named fields, fix bug in PM time overflow - 1.6.2 fix logging to use local, not root logger (thanks Necku) diff -Nru python-parse-1.6.3/test_parse.py python-parse-1.6.6/test_parse.py --- python-parse-1.6.3/test_parse.py 2013-10-15 02:22:28.000000000 +0200 +++ python-parse-1.6.6/test_parse.py 2014-11-17 05:09:40.000000000 +0100 @@ -75,6 +75,8 @@ _('.^010d', dict(type='d', width='10', align='^', fill='.', zero=True)) + _('.2f', dict(type='f', precision='2')) + _('10.2f', dict(type='f', width='10', precision='2')) def test_dot_separated_fields(self): # this should just work and provide the named value @@ -137,6 +139,11 @@ r = parse.parse('"{}"?', '"teststr"?') self.assertEqual(r[0], 'teststr') + def test_pipe(self): + # issue22: make sure a | in the parse string is handled correctly + r = parse.parse('| {}', '| teststr') + self.assertEqual(r[0], 'teststr') + def test_fixed(self): # pull a fixed value out of string r = parse.parse('hello {}', 'hello world') @@ -164,6 +171,19 @@ r = parse.parse('hello {:w} {:w}', 'hello 12 people') self.assertEqual(r.fixed, ('12', 'people')) + def test_precision(self): + # pull a float out of a string + r = parse.parse('Pi = {:.7f}', 'Pi = 3.1415926') + self.assertEqual(r.fixed, (3.1415926, )) + r = parse.parse('Pi/10 = {:8.5f}', 'Pi/10 = 0.31415') + self.assertEqual(r.fixed, (0.31415, )) + + def test_precision_fail(self): + # floats must have a leading zero + # IS THIS CORRECT? + r = parse.parse('Pi/10 = {:8.5f}', 'Pi/10 = .31415') + self.assertEqual(r, None) + def test_custom_type(self): # use a custom type r = parse.parse('{:shouty} {:spam}', 'hello world', @@ -205,7 +225,7 @@ r = parse.parse('{n:d} {n:d}', '1 2') self.assertEqual(r, None) - def test_named_repeated_type_fail_value(self): + def test_named_repeated_type_mismatch(self): # test repeated name with mismatched type self.assertRaises(parse.RepeatedNameError, parse.compile, '{n:d} {n:w}') @@ -454,6 +474,11 @@ y('a {:ta} b', 'a November-21-2011 10:21:36 AM +1000 b', aest_d) y('a {:ta} b', 'a November-21-2011 b', d) + # ts Linux System log format datetime + y('a {:ts} b', 'a Nov 21 10:21:36 b', datetime(datetime.today().year, 11, 21, 10, 21, 36)) + y('a {:ts} b', 'a Nov 1 10:21:36 b', datetime(datetime.today().year, 11, 1, 10, 21, 36)) + y('a {:ts} b', 'a Nov 1 03:21:36 b', datetime(datetime.today().year, 11, 1, 3, 21, 36)) + # th HTTP log format date/time datetime y('a {:th} b', 'a 21/Nov/2011:10:21:36 +1000 b', aest_d) y('a {:th} b', 'a 21/Nov/2011:10:21:36 +10:00 b', aest_d)
signature.asc
Description: OpenPGP digital signature