Accepting request 695770 from devel:languages:python

- update to 2.4.0
- drop nose_to_unittest.patch
- drop _service
 * Adds a pyparsing.__compat__ object for specifying compatibility with
   future breaking changes.
 * Conditionalizes the API-breaking behavior, based on the value
   pyparsing.__compat__.collect_all_And_tokens.  By default, this value
   will be set to True, reflecting the new bugfixed behavior.
 * User code that is dependent on the pre-bugfix behavior can restore
   it by setting this value to False.
 * Updated unitTests.py and simple_unit_tests.py to be compatible with
   "python setup.py test".
 * Fixed bug in runTests handling '\n' literals in quoted strings.
 * Added tag_body attribute to the start tag expressions generated by
   makeHTMLTags, so that you can avoid using SkipTo to roll your own
   tag body expression:
 * indentedBlock failure handling was improved
 * Address Py2 incompatibility in simpleUnitTests, plus explain() and
   Forward str() cleanup
 * Fixed docstring with embedded '\w', which creates SyntaxWarnings in Py3.8.
 * Added example parser for rosettacode.org tutorial compiler.
 * Added example to show how an HTML table can be parsed into a
   collection of Python lists or dicts, one per row.
 * Updated SimpleSQL.py example to handle nested selects, reworked
   'where' expression to use infixNotation.
 * Added include_preprocessor.py, similar to macroExpander.py.
 * Examples using makeHTMLTags use new tag_body expression when
   retrieving a tag's body text.
 * Updated examples that are runnable as unit tests

OBS-URL: https://build.opensuse.org/request/show/695770
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pyparsing?expand=0&rev=32
This commit is contained in:
Dominique Leuenberger 2019-04-19 16:37:59 +00:00 committed by Git OBS Bridge
commit 748a5df303
7 changed files with 48 additions and 402 deletions

View File

@ -1,15 +0,0 @@
<services>
<service name="tar_scm" mode="disabled">
<param name="versionprefix">2.3.0+git</param>
<param name="url">https://github.com/pyparsing/pyparsing</param>
<param name="scm">git</param>
<param name="exclude">.git*</param>
<!--param name="revision">lsp-support</param-->
<param name="changesgenerate">enable</param>
</service>
<service name="recompress" mode="disabled">
<param name="compression">xz</param>
<param name="file">*.tar</param>
</service>
<service name="set_version" mode="disabled" />
</services>

View File

@ -1,4 +0,0 @@
<servicedata>
<service name="tar_scm">
<param name="url">https://github.com/pyparsing/pyparsing</param>
<param name="changesrevision">bf348d6f00c58b6dbcfcc8e4e5ef2af7f904926c</param></service></servicedata>

View File

@ -1,374 +0,0 @@
--- a/examples/test_bibparse.py
+++ b/examples/test_bibparse.py
@@ -1,191 +1,192 @@
""" Test for bibparse grammar """
+import unittest
from pyparsing import ParseException
from .btpyparse import Macro
from . import btpyparse as bp
-from nose.tools import assert_equal, assert_raises
-def test_names():
- # check various types of names
- # All names can contains alphas, but not some special chars
- bad_chars = '"#%\'(),={}'
- for name_type, dig1f in ((bp.macro_def, False),
- (bp.field_name, False),
- (bp.entry_type, False),
- (bp.cite_key, True)):
- if dig1f: # can start with digit
- assert_equal(name_type.parseString('2t')[0], '2t')
- else:
- assert_raises(ParseException, name_type.parseString, '2t')
- # All of the names cannot contain some characters
+class TestBibParse(unittest.TestCase):
+ def test_names(self):
+ # check various types of names
+ # All names can contains alphas, but not some special chars
+ bad_chars = '"#%\'(),={}'
+ for name_type, dig1f in ((bp.macro_def, False),
+ (bp.field_name, False),
+ (bp.entry_type, False),
+ (bp.cite_key, True)):
+ if dig1f: # can start with digit
+ self.assertEqual(name_type.parseString('2t')[0], '2t')
+ else:
+ self.assertRaises(ParseException, name_type.parseString, '2t')
+ # All of the names cannot contain some characters
+ for char in bad_chars:
+ self.assertRaises(ParseException, name_type.parseString, char)
+ # standard strings all OK
+ self.assertEqual(name_type.parseString('simple_test')[0], 'simple_test')
+ # Test macro ref
+ mr = bp.macro_ref
+ # can't start with digit
+ self.assertRaises(ParseException, mr.parseString, '2t')
for char in bad_chars:
- assert_raises(ParseException, name_type.parseString, char)
- # standard strings all OK
- assert_equal(name_type.parseString('simple_test')[0], 'simple_test')
- # Test macro ref
- mr = bp.macro_ref
- # can't start with digit
- assert_raises(ParseException, mr.parseString, '2t')
- for char in bad_chars:
- assert_raises(ParseException, mr.parseString, char)
- assert_equal(mr.parseString('simple_test')[0].name, 'simple_test')
-
-
-def test_numbers():
- assert_equal(bp.number.parseString('1066')[0], '1066')
- assert_equal(bp.number.parseString('0')[0], '0')
- assert_raises(ParseException, bp.number.parseString, '-4')
- assert_raises(ParseException, bp.number.parseString, '+4')
- assert_raises(ParseException, bp.number.parseString, '.4')
- # something point something leaves a trailing .4 unmatched
- assert_equal(bp.number.parseString('0.4')[0], '0')
-
-
-def test_parse_string():
- # test string building blocks
- assert_equal(bp.chars_no_quotecurly.parseString('x')[0], 'x')
- assert_equal(bp.chars_no_quotecurly.parseString("a string")[0], 'a string')
- assert_equal(bp.chars_no_quotecurly.parseString('a "string')[0], 'a ')
- assert_equal(bp.chars_no_curly.parseString('x')[0], 'x')
- assert_equal(bp.chars_no_curly.parseString("a string")[0], 'a string')
- assert_equal(bp.chars_no_curly.parseString('a {string')[0], 'a ')
- assert_equal(bp.chars_no_curly.parseString('a }string')[0], 'a ')
- # test more general strings together
- for obj in (bp.curly_string, bp.string, bp.field_value):
- assert_equal(obj.parseString('{}').asList(), [])
- assert_equal(obj.parseString('{a "string}')[0], 'a "string')
- assert_equal(obj.parseString('{a {nested} string}').asList(),
- ['a ', ['nested'], ' string'])
- assert_equal(obj.parseString('{a {double {nested}} string}').asList(),
- ['a ', ['double ', ['nested']], ' string'])
- for obj in (bp.quoted_string, bp.string, bp.field_value):
- assert_equal(obj.parseString('""').asList(), [])
- assert_equal(obj.parseString('"a string"')[0], 'a string')
- assert_equal(obj.parseString('"a {nested} string"').asList(),
- ['a ', ['nested'], ' string'])
- assert_equal(obj.parseString('"a {double {nested}} string"').asList(),
- ['a ', ['double ', ['nested']], ' string'])
- # check macro def in string
- assert_equal(bp.string.parseString('someascii')[0], Macro('someascii'))
- assert_raises(ParseException, bp.string.parseString, '%#= validstring')
- # check number in string
- assert_equal(bp.string.parseString('1994')[0], '1994')
-
-
-def test_parse_field():
- # test field value - hashes included
- fv = bp.field_value
- # Macro
- assert_equal(fv.parseString('aname')[0], Macro('aname'))
- assert_equal(fv.parseString('ANAME')[0], Macro('aname'))
- # String and macro
- assert_equal(fv.parseString('aname # "some string"').asList(),
- [Macro('aname'), 'some string'])
- # Nested string
- assert_equal(fv.parseString('aname # {some {string}}').asList(),
- [Macro('aname'), 'some ', ['string']])
- # String and number
- assert_equal(fv.parseString('"a string" # 1994').asList(),
- ['a string', '1994'])
- # String and number and macro
- assert_equal(fv.parseString('"a string" # 1994 # a_macro').asList(),
- ['a string', '1994', Macro('a_macro')])
-
-
-def test_comments():
- res = bp.comment.parseString('@Comment{about something}')
- assert_equal(res.asList(), ['comment', '{about something}'])
- assert_equal(
- bp.comment.parseString('@COMMENT{about something').asList(),
- ['comment', '{about something'])
- assert_equal(
- bp.comment.parseString('@comment(about something').asList(),
- ['comment', '(about something'])
- assert_equal(
- bp.comment.parseString('@COMment about something').asList(),
- ['comment', ' about something'])
- assert_raises(ParseException, bp.comment.parseString,
- '@commentabout something')
- assert_raises(ParseException, bp.comment.parseString,
- '@comment+about something')
- assert_raises(ParseException, bp.comment.parseString,
- '@comment"about something')
-
-
-def test_preamble():
- res = bp.preamble.parseString('@preamble{"about something"}')
- assert_equal(res.asList(), ['preamble', 'about something'])
- assert_equal(bp.preamble.parseString(
- '@PREamble{{about something}}').asList(),
- ['preamble', 'about something'])
- assert_equal(bp.preamble.parseString("""@PREamble{
- {about something}
- }""").asList(),
- ['preamble', 'about something'])
-
-
-def test_macro():
- res = bp.macro.parseString('@string{ANAME = "about something"}')
- assert_equal(res.asList(), ['string', 'aname', 'about something'])
- assert_equal(
- bp.macro.parseString('@string{aname = {about something}}').asList(),
- ['string', 'aname', 'about something'])
-
-
-def test_entry():
- txt = """@some_entry{akey, aname = "about something",
- another={something else}}"""
- res = bp.entry.parseString(txt)
- assert_equal(res.asList(),
- ['some_entry', 'akey',
- ['aname', 'about something'], ['another', 'something else']])
- # Case conversion
- txt = """@SOME_ENTRY{akey, ANAME = "about something",
- another={something else}}"""
- res = bp.entry.parseString(txt)
- assert_equal(res.asList(),
- ['some_entry', 'akey',
- ['aname', 'about something'], ['another', 'something else']])
-
-
-def test_bibfile():
- txt = """@some_entry{akey, aname = "about something",
- another={something else}}"""
- res = bp.bibfile.parseString(txt)
- assert_equal(res.asList(),
- [['some_entry', 'akey',
- ['aname', 'about something'],
- ['another', 'something else']]])
-
-
-def test_bib1():
- # First pass whole bib-like tests
- txt = """
-Some introductory text
-(implicit comment)
-
- @ARTICLE{Brett2002marsbar,
- author = {Matthew Brett and Jean-Luc Anton and Romain Valabregue and Jean-Baptise
- Poline},
- title = {{Region of interest analysis using an SPM toolbox}},
- journal = {Neuroimage},
- year = {2002},
- volume = {16},
- pages = {1140--1141},
- number = {2}
-}
-
-@some_entry{akey, aname = "about something",
-another={something else}}
-"""
- res = bp.bibfile.parseString(txt)
- assert_equal(len(res), 3)
- res2 = bp.parse_str(txt)
- assert_equal(res.asList(), res2.asList())
- res3 = [r.asList()[0] for r, start, end in bp.definitions.scanString(txt)]
- assert_equal(res.asList(), res3)
+ self.assertRaises(ParseException, mr.parseString, char)
+ self.assertEqual(mr.parseString('simple_test')[0].name, 'simple_test')
+
+
+ def test_numbers(self):
+ self.assertEqual(bp.number.parseString('1066')[0], '1066')
+ self.assertEqual(bp.number.parseString('0')[0], '0')
+ self.assertRaises(ParseException, bp.number.parseString, '-4')
+ self.assertRaises(ParseException, bp.number.parseString, '+4')
+ self.assertRaises(ParseException, bp.number.parseString, '.4')
+ # something point something leaves a trailing .4 unmatched
+ self.assertEqual(bp.number.parseString('0.4')[0], '0')
+
+
+ def test_parse_string(self):
+ # test string building blocks
+ self.assertEqual(bp.chars_no_quotecurly.parseString('x')[0], 'x')
+ self.assertEqual(bp.chars_no_quotecurly.parseString("a string")[0], 'a string')
+ self.assertEqual(bp.chars_no_quotecurly.parseString('a "string')[0], 'a ')
+ self.assertEqual(bp.chars_no_curly.parseString('x')[0], 'x')
+ self.assertEqual(bp.chars_no_curly.parseString("a string")[0], 'a string')
+ self.assertEqual(bp.chars_no_curly.parseString('a {string')[0], 'a ')
+ self.assertEqual(bp.chars_no_curly.parseString('a }string')[0], 'a ')
+ # test more general strings together
+ for obj in (bp.curly_string, bp.string, bp.field_value):
+ self.assertEqual(obj.parseString('{}').asList(), [])
+ self.assertEqual(obj.parseString('{a "string}')[0], 'a "string')
+ self.assertEqual(obj.parseString('{a {nested} string}').asList(),
+ ['a ', ['nested'], ' string'])
+ self.assertEqual(obj.parseString('{a {double {nested}} string}').asList(),
+ ['a ', ['double ', ['nested']], ' string'])
+ for obj in (bp.quoted_string, bp.string, bp.field_value):
+ self.assertEqual(obj.parseString('""').asList(), [])
+ self.assertEqual(obj.parseString('"a string"')[0], 'a string')
+ self.assertEqual(obj.parseString('"a {nested} string"').asList(),
+ ['a ', ['nested'], ' string'])
+ self.assertEqual(obj.parseString('"a {double {nested}} string"').asList(),
+ ['a ', ['double ', ['nested']], ' string'])
+ # check macro def in string
+ self.assertEqual(bp.string.parseString('someascii')[0], Macro('someascii'))
+ self.assertRaises(ParseException, bp.string.parseString, '%#= validstring')
+ # check number in string
+ self.assertEqual(bp.string.parseString('1994')[0], '1994')
+
+
+ def test_parse_field(self):
+ # test field value - hashes included
+ fv = bp.field_value
+ # Macro
+ self.assertEqual(fv.parseString('aname')[0], Macro('aname'))
+ self.assertEqual(fv.parseString('ANAME')[0], Macro('aname'))
+ # String and macro
+ self.assertEqual(fv.parseString('aname # "some string"').asList(),
+ [Macro('aname'), 'some string'])
+ # Nested string
+ self.assertEqual(fv.parseString('aname # {some {string}}').asList(),
+ [Macro('aname'), 'some ', ['string']])
+ # String and number
+ self.assertEqual(fv.parseString('"a string" # 1994').asList(),
+ ['a string', '1994'])
+ # String and number and macro
+ self.assertEqual(fv.parseString('"a string" # 1994 # a_macro').asList(),
+ ['a string', '1994', Macro('a_macro')])
+
+
+ def test_comments(self):
+ res = bp.comment.parseString('@Comment{about something}')
+ self.assertEqual(res.asList(), ['comment', '{about something}'])
+ self.assertEqual(
+ bp.comment.parseString('@COMMENT{about something').asList(),
+ ['comment', '{about something'])
+ self.assertEqual(
+ bp.comment.parseString('@comment(about something').asList(),
+ ['comment', '(about something'])
+ self.assertEqual(
+ bp.comment.parseString('@COMment about something').asList(),
+ ['comment', ' about something'])
+ self.assertRaises(ParseException, bp.comment.parseString,
+ '@commentabout something')
+ self.assertRaises(ParseException, bp.comment.parseString,
+ '@comment+about something')
+ self.assertRaises(ParseException, bp.comment.parseString,
+ '@comment"about something')
+
+
+ def test_preamble(self):
+ res = bp.preamble.parseString('@preamble{"about something"}')
+ self.assertEqual(res.asList(), ['preamble', 'about something'])
+ self.assertEqual(bp.preamble.parseString(
+ '@PREamble{{about something}}').asList(),
+ ['preamble', 'about something'])
+ self.assertEqual(bp.preamble.parseString("""@PREamble{
+ {about something}
+ }""").asList(),
+ ['preamble', 'about something'])
+
+
+ def test_macro(self):
+ res = bp.macro.parseString('@string{ANAME = "about something"}')
+ self.assertEqual(res.asList(), ['string', 'aname', 'about something'])
+ self.assertEqual(
+ bp.macro.parseString('@string{aname = {about something}}').asList(),
+ ['string', 'aname', 'about something'])
+
+
+ def test_entry(self):
+ txt = """@some_entry{akey, aname = "about something",
+ another={something else}}"""
+ res = bp.entry.parseString(txt)
+ self.assertEqual(res.asList(),
+ ['some_entry', 'akey',
+ ['aname', 'about something'], ['another', 'something else']])
+ # Case conversion
+ txt = """@SOME_ENTRY{akey, ANAME = "about something",
+ another={something else}}"""
+ res = bp.entry.parseString(txt)
+ self.assertEqual(res.asList(),
+ ['some_entry', 'akey',
+ ['aname', 'about something'], ['another', 'something else']])
+
+
+ def test_bibfile(self):
+ txt = """@some_entry{akey, aname = "about something",
+ another={something else}}"""
+ res = bp.bibfile.parseString(txt)
+ self.assertEqual(res.asList(),
+ [['some_entry', 'akey',
+ ['aname', 'about something'],
+ ['another', 'something else']]])
+
+
+ def test_bib1(self):
+ # First pass whole bib-like tests
+ txt = """
+ Some introductory text
+ (implicit comment)
+
+ @ARTICLE{Brett2002marsbar,
+ author = {Matthew Brett and Jean-Luc Anton and Romain Valabregue and Jean-Baptise
+ Poline},
+ title = {{Region of interest analysis using an SPM toolbox}},
+ journal = {Neuroimage},
+ year = {2002},
+ volume = {16},
+ pages = {1140--1141},
+ number = {2}
+ }
+
+ @some_entry{akey, aname = "about something",
+ another={something else}}
+ """
+ res = bp.bibfile.parseString(txt)
+ self.assertEqual(len(res), 3)
+ res2 = bp.parse_str(txt)
+ self.assertEqual(res.asList(), res2.asList())
+ res3 = [r.asList()[0] for r, start, end in bp.definitions.scanString(txt)]
+ self.assertEqual(res.asList(), res3)
if __name__ == '__main__':

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fdc7efcfe4cb9a8ab577c71bf9af1d3068f18ee5f1cf70eec7585885bd4d6977
size 541564

3
pyparsing-2.4.0.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:1873c03321fc118f4e9746baf201ff990ceb915f433f23b395f5580d1840cb2a
size 611956

View File

@ -1,3 +1,43 @@
-------------------------------------------------------------------
Thu Apr 18 13:30:30 UTC 2019 - Ondřej Súkup <mimi.vx@gmail.com>
- update to 2.4.0
- drop nose_to_unittest.patch
- drop _service
* Adds a pyparsing.__compat__ object for specifying compatibility with
future breaking changes.
* Conditionalizes the API-breaking behavior, based on the value
pyparsing.__compat__.collect_all_And_tokens. By default, this value
will be set to True, reflecting the new bugfixed behavior.
* User code that is dependent on the pre-bugfix behavior can restore
it by setting this value to False.
* Updated unitTests.py and simple_unit_tests.py to be compatible with
"python setup.py test".
* Fixed bug in runTests handling '\n' literals in quoted strings.
* Added tag_body attribute to the start tag expressions generated by
makeHTMLTags, so that you can avoid using SkipTo to roll your own
tag body expression:
* indentedBlock failure handling was improved
* Address Py2 incompatibility in simpleUnitTests, plus explain() and
Forward str() cleanup
* Fixed docstring with embedded '\w', which creates SyntaxWarnings in Py3.8.
* Added example parser for rosettacode.org tutorial compiler.
* Added example to show how an HTML table can be parsed into a
collection of Python lists or dicts, one per row.
* Updated SimpleSQL.py example to handle nested selects, reworked
'where' expression to use infixNotation.
* Added include_preprocessor.py, similar to macroExpander.py.
* Examples using makeHTMLTags use new tag_body expression when
retrieving a tag's body text.
* Updated examples that are runnable as unit tests
-------------------------------------------------------------------
Thu Apr 11 15:55:25 UTC 2019 - Thomas Bechtold <tbechtold@suse.com>
- Do not BuildRequire python-unittest2 when no tests are executed.
This breaks a build cycle for pyparsing->unittest2->traceback2->pbr->
Pygments->pytest->setuptools_scm->packaging which needs pyparsing
-------------------------------------------------------------------
Thu Jan 17 15:54:39 UTC 2019 - Dominique Leuenberger <dimstar@opensuse.org>

View File

@ -28,22 +28,22 @@
%bcond_with test
%endif
Name: python-pyparsing%{psuffix}
Version: 2.3.0+git.1546912853.bf348d6
Version: 2.4.0
Release: 0
Summary: Grammar Parser Library for Python
License: MIT AND GPL-2.0-or-later AND GPL-3.0-or-later
Group: Development/Languages/Python
URL: https://github.com/pyparsing/pyparsing/
# Upstream tarball from the master branch with gh#pyparsing/pyparsing#47
# Source: https://files.pythonhosted.org/packages/source/p/pyparsing/pyparsing-%%{version}.tar.gz
Source: pyparsing-%{version}.tar.xz
# Remove dependency on nose, gh#pyparsing/pyparsing#64
Patch0: nose_to_unittest.patch
Source: https://files.pythonhosted.org/packages/source/p/pyparsing/pyparsing-%{version}.tar.gz
# Source: pyparsing-%{version}.tar.xz
BuildRequires: %{python_module base}
BuildRequires: %{python_module setuptools}
%if "%{flavor}" == "test"
# Not necessary for python3, but tests fail with the standard unittest
# and python 2.7
BuildRequires: %{python_module unittest2}
%endif
BuildRequires: fdupes
BuildRequires: python-rpm-macros
#!BuildIgnore: python2-pyparsing
@ -66,7 +66,6 @@ code uses to construct the grammar directly in Python code.
%prep
%setup -q -n %{modname}-%{version}
%autopatch -p1
%build
%python_build