summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorptmcg <ptmcg@austin.rr.com>2020-05-13 14:13:52 -0500
committerptmcg <ptmcg@austin.rr.com>2020-05-13 14:13:52 -0500
commit75bac5978133342537b92cce6e518435d4a8cb57 (patch)
treed2561fa79f4a3a31babad55a66a8d9c1b164b5bf
parent42e7022d549d0ded980fb51a57765fcf476954cf (diff)
downloadpyparsing-git-75bac5978133342537b92cce6e518435d4a8cb57.tar.gz
Convert internal imports to relative imports, to support projects that vendor pyparsing
-rw-r--r--CHANGES63
-rw-r--r--pyparsing/__init__.py28
-rw-r--r--pyparsing/actions.py4
-rw-r--r--pyparsing/common.py4
-rw-r--r--pyparsing/core.py6
-rw-r--r--pyparsing/exceptions.py2
-rw-r--r--pyparsing/helpers.py17
-rw-r--r--pyparsing/testing.py2
8 files changed, 101 insertions, 25 deletions
diff --git a/CHANGES b/CHANGES
index 4d189c2..864ed74 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,13 +2,76 @@
Change Log
==========
+Version 3.0.0 (projected)
+-------------------------
+API change summary:
+ . countedArray formerly returned its list of items nested
+ within another list, so that accessing the items required
+ indexing the 0'th element to get the actual list. This
+ extra nesting has been removed. In addition, if there are
+ other metadata fields parsed between the count and the
+ list items, they can be preserved in the resulting list
+ if given results names.
+
+ . ParseException.explain is now an instance method of
+ ParseException. To run explain against other exceptions,
+ use ParseException.explain_exception.
+
+ . ZeroOrMore expressions that have results names will now
+ include empty lists for their name if no matches are found.
+ Previously, no named result would be present.
+
+ . ParserElement.setDefaultWhitespaceChars will now update
+ whitespace characters on all built-in expressions defined
+ in the pyparsing module.
+
+ . __diag__ now uses enable() and disable() method to
+ enable specific diagnostic values (instead of setting them
+ to True or False). __diag__.enable_all_warnings() has
+ also been added.
+
+Deprecated features removed:
+
+ . ParseResults.asXML() - if used for debugging, switch
+ to using ParseResults.dump(); if used for data transfer,
+ use ParseResults.asDict() to convert to a nested Python
+ dict, which can then be converted to XML or JSON or
+ other transfer format
+
+ . operatorPrecedence synonym for infixNotation -
+ convert to calling infixNotation
+
+ . commaSeparatedList - convert to using
+ pyparsing_common.comma_separated_list
+
+ . upcaseTokens and downcaseTokens - convert to using
+ pyparsing_common.upcaseTokens and downcaseTokens
+
+ . __compat__.collect_all_And_tokens will not be settable to
+ False to revert to pre-2.3.1 results name behavior -
+ review use of names for MatchFirst and Or expressions
+ containing And expressions, as they will return the
+ complete list of parsed tokens, not just the first one.
+ Use `__diag__.warn_multiple_tokens_in_named_alternation`
+ to help identify those expressions in your parsers that
+ will have changed as a result.
+
+
Version 3.0.0a2
---------------
+- API CHANGE
+ Changed result returned when parsing using countedArray,
+ the array items are no long returned in a doubly-nested
+ list.
+
- Fixed bug in ParseResults repr() which showed all matching
entries for a results name, even if listAllMatches was set
to False when creating the ParseResults originally. Reported
by Nicholas42 on GitHub, good catch! (Issue #205)
+- Modified refactored modules to use relative imports, as
+ pointed out by setuptools project member jaraco, thank you!
+
Version 3.0.0a1 - April, 2020
-----------------------------
diff --git a/pyparsing/__init__.py b/pyparsing/__init__.py
index 53550c5..7ea212c 100644
--- a/pyparsing/__init__.py
+++ b/pyparsing/__init__.py
@@ -95,22 +95,22 @@ classes inherit from. Use the docstrings for examples of how to:
"""
__version__ = "3.0.0a2"
-__versionTime__ = "10 Apr 2020 21:46 UTC"
+__versionTime__ = "13 May 2020 19:13 UTC"
__author__ = "Paul McGuire <ptmcg@users.sourceforge.net>"
-from pyparsing.util import *
-from pyparsing.exceptions import *
-from pyparsing.actions import *
-from pyparsing.core import __diag__, __compat__
-from pyparsing.results import *
-from pyparsing.core import *
-from pyparsing.core import _builtin_exprs as core_builtin_exprs
-from pyparsing.helpers import *
-from pyparsing.helpers import _builtin_exprs as helper_builtin_exprs
-
-from pyparsing.unicode import unicode_set, pyparsing_unicode as unicode
-from pyparsing.testing import pyparsing_test as testing
-from pyparsing.common import (
+from .util import *
+from .exceptions import *
+from .actions import *
+from .core import __diag__, __compat__
+from .results import *
+from .core import *
+from .core import _builtin_exprs as core_builtin_exprs
+from .helpers import *
+from .helpers import _builtin_exprs as helper_builtin_exprs
+
+from .unicode import unicode_set, pyparsing_unicode as unicode
+from .testing import pyparsing_test as testing
+from .common import (
pyparsing_common as common,
_builtin_exprs as common_builtin_exprs,
)
diff --git a/pyparsing/actions.py b/pyparsing/actions.py
index 9cf88fe..921b23f 100644
--- a/pyparsing/actions.py
+++ b/pyparsing/actions.py
@@ -1,7 +1,7 @@
# actions.py
-from pyparsing.exceptions import ParseException
-from pyparsing.util import col
+from .exceptions import ParseException
+from .util import col
def matchOnlyAtCol(n):
diff --git a/pyparsing/common.py b/pyparsing/common.py
index f6eccf2..abafcf3 100644
--- a/pyparsing/common.py
+++ b/pyparsing/common.py
@@ -1,6 +1,6 @@
# common.py
-from pyparsing.core import *
-from pyparsing.helpers import delimitedList, anyOpenTag, anyCloseTag
+from .core import *
+from .helpers import delimitedList, anyOpenTag, anyCloseTag
from datetime import datetime
# some other useful expressions - using lower-case class name since we are really using this as a namespace
diff --git a/pyparsing/core.py b/pyparsing/core.py
index 2808303..c2c97ac 100644
--- a/pyparsing/core.py
+++ b/pyparsing/core.py
@@ -23,9 +23,9 @@ from .util import (
_bslash,
_flatten,
)
-from pyparsing.exceptions import *
-from pyparsing.actions import *
-from pyparsing.results import ParseResults, _ParseResultsWithOffset
+from .exceptions import *
+from .actions import *
+from .results import ParseResults, _ParseResultsWithOffset
_MAX_INT = sys.maxsize
str_type = (str, bytes)
diff --git a/pyparsing/exceptions.py b/pyparsing/exceptions.py
index 362b4c1..51eed66 100644
--- a/pyparsing/exceptions.py
+++ b/pyparsing/exceptions.py
@@ -1,7 +1,7 @@
# exceptions.py
import sys
-from pyparsing.util import col, line, lineno
+from .util import col, line, lineno
class ParseBaseException(Exception):
diff --git a/pyparsing/helpers.py b/pyparsing/helpers.py
index 97e5943..a4c042c 100644
--- a/pyparsing/helpers.py
+++ b/pyparsing/helpers.py
@@ -1,6 +1,6 @@
# helpers.py
-from pyparsing.core import *
-from pyparsing.util import _bslash, _flatten, _escapeRegexRangeChars
+from .core import *
+from .util import _bslash, _flatten, _escapeRegexRangeChars
#
@@ -50,6 +50,19 @@ def countedArray(expr, intExpr=None):
# '10' indicating that 2 values are in the array
binaryConstant = Word('01').setParseAction(lambda t: int(t[0], 2))
countedArray(Word(alphas), intExpr=binaryConstant).parseString('10 ab cd ef') # -> ['ab', 'cd']
+
+ # if other fields must be parsed after the count but before the
+ # list items, give the fields results names and they will
+ # be preserved in the returned ParseResults:
+ count_with_metadata = integer + Word(alphas)("type")
+ typed_array = countedArray(Word(alphanums), intExpr=count_with_metadata)("items")
+ result = typed_array.parseString("3 bool True True False")
+ print(result.dump())
+
+ # prints
+ # ['True', 'True', 'False']
+ # - items: ['True', 'True', 'False']
+ # - type: 'bool'
"""
arrayExpr = Forward()
diff --git a/pyparsing/testing.py b/pyparsing/testing.py
index d924793..0cbefa9 100644
--- a/pyparsing/testing.py
+++ b/pyparsing/testing.py
@@ -2,7 +2,7 @@
from contextlib import contextmanager
-from pyparsing.core import (
+from .core import (
ParserElement,
ParseException,
Keyword,