Skip to content

Commit

Permalink
Revert "Add plumbing files to pass tests"
Browse files Browse the repository at this point in the history
This reverts commit 492ac6c.
  • Loading branch information
Gabrielgerez committed Sep 22, 2023
1 parent 492ac6c commit 895404b
Show file tree
Hide file tree
Showing 12 changed files with 804 additions and 6,802 deletions.
5,493 changes: 2 additions & 5,491 deletions python/mrchem/input_parser/api.py

Large diffs are not rendered by default.

78 changes: 42 additions & 36 deletions python/mrchem/input_parser/plumbing/pyparsing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
:class:`'|'<MatchFirst>`, :class:`'^'<Or>` and :class:`'&'<Each>` operators.
The :class:`ParseResults` object returned from
:class:`ParserElement.parse_string` can be
:class:`ParserElement.parseString` can be
accessed as a nested list, a dictionary, or an object with named
attributes.
Expand Down Expand Up @@ -85,11 +85,11 @@
and :class:`'&'<Each>` operators to combine simple expressions into
more complex ones
- associate names with your parsed results using
:class:`ParserElement.set_results_name`
:class:`ParserElement.setResultsName`
- access the parsed data, which is returned as a :class:`ParseResults`
object
- find some helpful expression short-cuts like :class:`DelimitedList`
and :class:`one_of`
- find some helpful expression short-cuts like :class:`delimitedList`
and :class:`oneOf`
- find more useful common expressions in the :class:`pyparsing_common`
namespace class
"""
Expand All @@ -106,22 +106,30 @@ class version_info(NamedTuple):
@property
def __version__(self):
return (
f"{self.major}.{self.minor}.{self.micro}"
"{}.{}.{}".format(self.major, self.minor, self.micro)
+ (
f"{'r' if self.releaselevel[0] == 'c' else ''}{self.releaselevel[0]}{self.serial}",
"{}{}{}".format(
"r" if self.releaselevel[0] == "c" else "",
self.releaselevel[0],
self.serial,
),
"",
)[self.releaselevel == "final"]
)

def __str__(self):
return f"{__name__} {self.__version__} / {__version_time__}"
return "{} {} / {}".format(__name__, self.__version__, __version_time__)

def __repr__(self):
return f"{__name__}.{type(self).__name__}({', '.join('{}={!r}'.format(*nv) for nv in zip(self._fields, self))})"
return "{}.{}({})".format(
__name__,
type(self).__name__,
", ".join("{}={!r}".format(*nv) for nv in zip(self._fields, self)),
)


__version_info__ = version_info(3, 1, 1, "final", 1)
__version_time__ = "29 Jul 2023 22:27 UTC"
__version_info__ = version_info(3, 0, 9, "final", 0)
__version_time__ = "05 May 2022 07:02 UTC"
__version__ = __version_info__.__version__
__versionTime__ = __version_time__
__author__ = "Paul McGuire <[email protected]>"
Expand All @@ -131,9 +139,9 @@ def __repr__(self):
from .actions import *
from .core import __diag__, __compat__
from .results import *
from .core import * # type: ignore[misc, assignment]
from .core import *
from .core import _builtin_exprs as core_builtin_exprs
from .helpers import * # type: ignore[misc, assignment]
from .helpers import *
from .helpers import _builtin_exprs as helper_builtin_exprs

from .unicode import unicode_set, UnicodeRangeList, pyparsing_unicode as unicode
Expand All @@ -145,11 +153,11 @@ def __repr__(self):

# define backward compat synonyms
if "pyparsing_unicode" not in globals():
pyparsing_unicode = unicode # type: ignore[misc]
pyparsing_unicode = unicode
if "pyparsing_common" not in globals():
pyparsing_common = common # type: ignore[misc]
pyparsing_common = common
if "pyparsing_test" not in globals():
pyparsing_test = testing # type: ignore[misc]
pyparsing_test = testing

core_builtin_exprs += common_builtin_exprs + helper_builtin_exprs

Expand All @@ -166,9 +174,7 @@ def __repr__(self):
"CaselessKeyword",
"CaselessLiteral",
"CharsNotIn",
"CloseMatch",
"Combine",
"DelimitedList",
"Dict",
"Each",
"Empty",
Expand Down Expand Up @@ -221,11 +227,9 @@ def __repr__(self):
"alphas8bit",
"any_close_tag",
"any_open_tag",
"autoname_elements",
"c_style_comment",
"col",
"common_html_entity",
"condition_as_parse_action",
"counted_array",
"cpp_style_comment",
"dbl_quoted_string",
Expand All @@ -237,7 +241,6 @@ def __repr__(self):
"html_comment",
"identchars",
"identbodychars",
"infix_notation",
"java_style_comment",
"line",
"line_end",
Expand All @@ -252,12 +255,8 @@ def __repr__(self):
"null_debug_action",
"nums",
"one_of",
"original_text_for",
"printables",
"punc8bit",
"pyparsing_common",
"pyparsing_test",
"pyparsing_unicode",
"python_style_comment",
"quoted_string",
"remove_quotes",
Expand All @@ -268,33 +267,38 @@ def __repr__(self):
"srange",
"string_end",
"string_start",
"token_map",
"trace_parse_action",
"ungroup",
"unicode_set",
"unicode_string",
"with_attribute",
"indentedBlock",
"original_text_for",
"ungroup",
"infix_notation",
"locatedExpr",
"with_class",
"CloseMatch",
"token_map",
"pyparsing_common",
"pyparsing_unicode",
"unicode_set",
"condition_as_parse_action",
"pyparsing_test",
# pre-PEP8 compatibility names
"__versionTime__",
"anyCloseTag",
"anyOpenTag",
"cStyleComment",
"commonHTMLEntity",
"conditionAsParseAction",
"countedArray",
"cppStyleComment",
"dblQuotedString",
"dblSlashComment",
"delimitedList",
"dictOf",
"htmlComment",
"indentedBlock",
"infixNotation",
"javaStyleComment",
"lineEnd",
"lineStart",
"locatedExpr",
"makeHTMLTags",
"makeXMLTags",
"matchOnlyAtCol",
Expand All @@ -304,7 +308,6 @@ def __repr__(self):
"nullDebugAction",
"oneOf",
"opAssoc",
"originalTextFor",
"pythonStyleComment",
"quotedString",
"removeQuotes",
Expand All @@ -314,12 +317,15 @@ def __repr__(self):
"sglQuotedString",
"stringEnd",
"stringStart",
"tokenMap",
"traceParseAction",
"unicodeString",
"withAttribute",
"indentedBlock",
"originalTextFor",
"infixNotation",
"locatedExpr",
"withClass",
"common",
"unicode",
"testing",
"tokenMap",
"conditionAsParseAction",
"autoname_elements",
]
34 changes: 12 additions & 22 deletions python/mrchem/input_parser/plumbing/pyparsing/actions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# actions.py

from .exceptions import ParseException
from .util import col, replaced_by_pep8
from .util import col


class OnlyOnce:
Expand Down Expand Up @@ -38,7 +38,7 @@ def match_only_at_col(n):

def verify_col(strg, locn, toks):
if col(locn, strg) != n:
raise ParseException(strg, locn, f"matched token not at column {n}")
raise ParseException(strg, locn, "matched token not at column {}".format(n))

return verify_col

Expand Down Expand Up @@ -148,13 +148,15 @@ def pa(s, l, tokens):
raise ParseException(
s,
l,
f"attribute {attrName!r} has value {tokens[attrName]!r}, must be {attrValue!r}",
"attribute {!r} has value {!r}, must be {!r}".format(
attrName, tokens[attrName], attrValue
),
)

return pa


with_attribute.ANY_VALUE = object() # type: ignore [attr-defined]
with_attribute.ANY_VALUE = object()


def with_class(classname, namespace=""):
Expand Down Expand Up @@ -193,25 +195,13 @@ def with_class(classname, namespace=""):
1 4 0 1 0
1,3 2,3 1,1
"""
classattr = f"{namespace}:class" if namespace else "class"
classattr = "{}:class".format(namespace) if namespace else "class"
return with_attribute(**{classattr: classname})


# pre-PEP8 compatibility symbols
# fmt: off
@replaced_by_pep8(replace_with)
def replaceWith(): ...

@replaced_by_pep8(remove_quotes)
def removeQuotes(): ...

@replaced_by_pep8(with_attribute)
def withAttribute(): ...

@replaced_by_pep8(with_class)
def withClass(): ...

@replaced_by_pep8(match_only_at_col)
def matchOnlyAtCol(): ...

# fmt: on
replaceWith = replace_with
removeQuotes = remove_quotes
withAttribute = with_attribute
withClass = with_class
matchOnlyAtCol = match_only_at_col
Loading

0 comments on commit 895404b

Please sign in to comment.