From 81839209753e258f86dc9e549f3b2a755ca57e80 Mon Sep 17 00:00:00 2001 From: Chin Yeung Li Date: Wed, 14 Aug 2024 14:09:42 +0800 Subject: [PATCH] #11 - Update link references of ownership from nexB to aboutcode-org Signed-off-by: Chin Yeung Li --- CHANGELOG.rst | 7 +++++++ NOTICE | 2 +- README.rst | 2 +- configure | 2 +- configure.bat | 2 +- setup.cfg | 2 +- src/pygmars/__init__.py | 2 +- src/pygmars/lex.py | 5 +++-- src/pygmars/parse.py | 18 +++++++++++------- src/pygmars/tree.py | 19 ++++++++++++------- tests/test_lex.py | 2 +- tests/test_lex_doctest.py | 2 +- tests/test_parse.py | 2 +- tests/test_parse_doctest.py | 2 +- 14 files changed, 43 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9bd4b053..eebbc5cb 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,13 @@ Changelog +Version 0.8.1 +------------- + +- Update link references of ownership from nexB to aboutcode-org + + + Version 0.8.0 ----------------- diff --git a/NOTICE b/NOTICE index 53943778..e8f36b1e 100644 --- a/NOTICE +++ b/NOTICE @@ -2,7 +2,7 @@ # Copyright (c) nexB Inc. and others. # SPDX-License-Identifier: Apache-2.0 # -# Visit https://aboutcode.org and https://github.com/nexB/pygmars for support and download. +# Visit https://aboutcode.org and https://github.com/aboutcode-org/pygmars for support and download. # ScanCode is a trademark of nexB Inc. # # Based on a heavily modified Natural Language Toolkit (NLTK) diff --git a/README.rst b/README.rst index e49def77..cb290eab 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ Pygmars ======== -https://github.com/nexB/pygmars +https://github.com/aboutcode-org/pygmars pygmars is a simple lexing and parsing library designed to craft lightweight lexers and parsers using regular expressions. diff --git a/configure b/configure index 926a894e..22d92885 100755 --- a/configure +++ b/configure @@ -3,7 +3,7 @@ # Copyright (c) nexB Inc. and others. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # See http://www.apache.org/licenses/LICENSE-2.0 for the license text. -# See https://github.com/nexB/ for support or download. +# See https://github.com/aboutcode-org/ for support or download. # See https://aboutcode.org for more information about nexB OSS projects. # diff --git a/configure.bat b/configure.bat index 5e95b311..5b9a9d68 100644 --- a/configure.bat +++ b/configure.bat @@ -4,7 +4,7 @@ @rem Copyright (c) nexB Inc. and others. All rights reserved. @rem SPDX-License-Identifier: Apache-2.0 @rem See http://www.apache.org/licenses/LICENSE-2.0 for the license text. -@rem See https://github.com/nexB/ for support or download. +@rem See https://github.com/aboutcode-org/ for support or download. @rem See https://aboutcode.org for more information about nexB OSS projects. diff --git a/setup.cfg b/setup.cfg index 62d98778..feb913e5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,7 +6,7 @@ license = Apache-2.0 description = Craft simple regex-based small language lexers and parsers. Build parsers from grammars and accept Pygments lexers as an input. Derived from NLTK. long_description = file:README.rst long_description_content_type = text/x-rst -url = https://github.com/nexB/pygmars +url = https://github.com/aboutcode-org/pygmars author = nexB. Inc. and others author_email = info@aboutcode.org diff --git a/src/pygmars/__init__.py b/src/pygmars/__init__.py index c43cf842..524da800 100644 --- a/src/pygmars/__init__.py +++ b/src/pygmars/__init__.py @@ -1,7 +1,7 @@ # SPDX-License-Identifier: Apache-2.0 # Copyright (C) nexB Inc. and others # See http://www.apache.org/licenses/LICENSE-2.0 for the license text. -# See https://github.com/nexB/pygmars for support or download. +# See https://github.com/aboutcode-org/pygmars for support or download. # See https://aboutcode.org for more information about nexB OSS projects. # diff --git a/src/pygmars/lex.py b/src/pygmars/lex.py index a0b17f67..f0364486 100644 --- a/src/pygmars/lex.py +++ b/src/pygmars/lex.py @@ -2,7 +2,7 @@ # Copyright (C) nexB Inc. and others # Copyright (C) 2001-2020 NLTK Project # See http://www.apache.org/licenses/LICENSE-2.0 for the license text. -# See https://github.com/nexB/pygmars for support or download. +# See https://github.com/aboutcode-org/pygmars for support or download. # See https://aboutcode.org for more information about nexB OSS projects. # @@ -113,7 +113,8 @@ def __init__(self, matchers, re_flags=0): ) except (Exception, FutureWarning) as e: - raise InvalidLexerMatcher(f"Invalid Lexer matcher: {m!r}, label: {label}") from e + raise InvalidLexerMatcher( + f"Invalid Lexer matcher: {m!r}, label: {label}") from e def tokenize(self, string, splitter=str.split): """ diff --git a/src/pygmars/parse.py b/src/pygmars/parse.py index 1ef8353a..8472bb5a 100644 --- a/src/pygmars/parse.py +++ b/src/pygmars/parse.py @@ -2,7 +2,7 @@ # Copyright (C) nexB Inc. and others # Copyright (C) 2001-2020 NLTK Project # See http://www.apache.org/licenses/LICENSE-2.0 for the license text. -# See https://github.com/nexB/pygmars for support or download. +# See https://github.com/aboutcode-org/pygmars for support or download. # See https://aboutcode.org for more information about nexB OSS projects. # @@ -50,7 +50,7 @@ grouping encoded by a ``ParseString``. A ``pattern`` uses a modified version of regular expression patterns. Patterns -are used to match sequence of Token or Tree labels. +are used to match sequence of Token or Tree labels. This string contains a sequence of angle-bracket delimited labels (e.g. the Token or Tree labels), with the grouping indicated by curly braces. Some examples of encoding label patterns are:: @@ -140,7 +140,8 @@ def __init__(self, grammar, root_label="ROOT", loop=1, trace=0, validate=False): on rules and rule parse results. """ self._grammar = grammar - self.rules = list(Rule.from_grammar(grammar, root_label, validate=validate)) + self.rules = list(Rule.from_grammar( + grammar, root_label, validate=validate)) self._root_label = root_label self._loop = loop self._trace = trace @@ -238,7 +239,8 @@ def validate(self, s): raise ValueError(f"Invalid parse:\n {s}") if not has_balanced_non_nested_curly_braces(s): - raise ValueError(f"Invalid parse: unbalanced or nested curly braces:\n {s}") + raise ValueError( + f"Invalid parse: unbalanced or nested curly braces:\n {s}") tags1 = tag_splitter(s)[1:-1] tags2 = [node.label for node in self._tree] @@ -276,7 +278,7 @@ def to_tree(self, label="GROUP", pieces_splitter=re.compile(r"[{}]").split): # Find the list of tokens contained in this piece. length = piece.count("<") - subsequence = tree[index : index + length] + subsequence = tree[index: index + length] # Add this list of tokens to our tree. if matched: @@ -434,7 +436,8 @@ def label_pattern_to_regex(label_pattern): should not contain nested or mismatched angle-brackets. """ # Clean up the regular expression - label_pattern = remove_spaces("", label_pattern).replace("<", "(?:<(?:").replace(">", ")>)") + label_pattern = remove_spaces("", label_pattern).replace( + "<", "(?:<(?:").replace(">", ")>)") # Check the regular expression if not is_label_pattern(label_pattern): @@ -533,7 +536,8 @@ def parse(self, tree, trace=0): if trace > 1: # verbose print(tree.pformat()) - print("with pattern:", self.description, "(" + repr(self.pattern) + ")") + print("with pattern:", self.description, + "(" + repr(self.pattern) + ")") print(" before:", repr(before_parse)) print(" after :", repr(after_parse)) diff --git a/src/pygmars/tree.py b/src/pygmars/tree.py index 1c7409ed..b07b35ef 100644 --- a/src/pygmars/tree.py +++ b/src/pygmars/tree.py @@ -3,7 +3,7 @@ # Copyright (C) nexB Inc. and others # Copyright (C) 2001-2020 NLTK Project # See http://www.apache.org/licenses/LICENSE-2.0 for the license text. -# See https://github.com/nexB/pygmars for support or download. +# See https://github.com/aboutcode-org/pygmars for support or download. # See https://aboutcode.org for more information about nexB OSS projects. # @@ -168,7 +168,8 @@ def __getitem__(self, index): return self[index[0]][index[1:]] else: raise TypeError( - "%s indices must be integers, not %s" % (type(self).__name__, type(index).__name__) + "%s indices must be integers, not %s" % ( + type(self).__name__, type(index).__name__) ) def __setitem__(self, index, value): @@ -176,14 +177,16 @@ def __setitem__(self, index, value): return list.__setitem__(self, index, value) elif isinstance(index, (list, tuple)): if len(index) == 0: - raise IndexError("The tree position () may not be " "assigned to.") + raise IndexError( + "The tree position () may not be " "assigned to.") elif len(index) == 1: self[index[0]] = value else: self[index[0]][index[1:]] = value else: raise TypeError( - "%s indices must be integers, not %s" % (type(self).__name__, type(index).__name__) + "%s indices must be integers, not %s" % ( + type(self).__name__, type(index).__name__) ) def leaves(self): @@ -270,7 +273,8 @@ def from_string( if leaf_pattern is None: leaf_pattern = r"[^\s%s%s]+" % (open_pattern, close_pattern) token_re = re.compile( - r"%s\s*(%s)?|%s|(%s)" % (open_pattern, node_pattern, close_pattern, leaf_pattern) + r"%s\s*(%s)?|%s|(%s)" % (open_pattern, + node_pattern, close_pattern, leaf_pattern) ) # Walk through each token, updating a stack of trees. stack = [(None, [])] # list of (node, children) tuples @@ -339,7 +343,7 @@ def _parse_error(cls, s, match, expecting): if len(s) > pos + 10: s = s[: pos + 10] + "..." if pos > 10: - s = "..." + s[pos - 10 :] + s = "..." + s[pos - 10:] offset = 13 msg += '\n%s"%s"\n%s^' % (" " * 16, s, " " * (17 + offset)) raise ValueError(msg) @@ -372,7 +376,8 @@ def pformat(self, indent=0, *args, **kwargs): for child in self: if isinstance(child, Tree): - s += "\n" + " " * (indent + 2) + child.pformat(indent=indent + 2) + s += "\n" + " " * (indent + 2) + \ + child.pformat(indent=indent + 2) elif isinstance(child, tuple): s += "\n" + " " * (indent + 2) + "/".join(child) elif isinstance(child, str): diff --git a/tests/test_lex.py b/tests/test_lex.py index 2bfb0221..ad2dbcc4 100644 --- a/tests/test_lex.py +++ b/tests/test_lex.py @@ -3,7 +3,7 @@ # Copyright (C) nexB Inc. and others # Copyright (C) 2001-2020 NLTK Project # See http://www.apache.org/licenses/LICENSE-2.0 for the license text. -# See https://github.com/nexB/pygmars for support or download. +# See https://github.com/aboutcode-org/pygmars for support or download. # See https://aboutcode.org for more information about nexB OSS projects. # Originally based on: Natural Language Toolkit diff --git a/tests/test_lex_doctest.py b/tests/test_lex_doctest.py index 3f0b392b..dbf88b5a 100644 --- a/tests/test_lex_doctest.py +++ b/tests/test_lex_doctest.py @@ -2,7 +2,7 @@ # Copyright (C) nexB Inc. and others # Copyright (C) 2001-2020 NLTK Project # See http://www.apache.org/licenses/LICENSE-2.0 for the license text. -# See https://github.com/nexB/pygmars for support or download. +# See https://github.com/aboutcode-org/pygmars for support or download. # See https://aboutcode.org for more information about nexB OSS projects. # Originally based on: Natural Language Toolkit diff --git a/tests/test_parse.py b/tests/test_parse.py index 88bef58e..1206dc82 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -3,7 +3,7 @@ # Copyright (C) nexB Inc. and others # Copyright (C) 2001-2020 NLTK Project # See http://www.apache.org/licenses/LICENSE-2.0 for the license text. -# See https://github.com/nexB/pygmars for support or download. +# See https://github.com/aboutcode-org/pygmars for support or download. # See https://aboutcode.org for more information about nexB OSS projects. # Originally based on: Natural Language Toolkit diff --git a/tests/test_parse_doctest.py b/tests/test_parse_doctest.py index f10bef29..23e36bf5 100644 --- a/tests/test_parse_doctest.py +++ b/tests/test_parse_doctest.py @@ -2,7 +2,7 @@ # Copyright (C) nexB Inc. and others # Copyright (C) 2001-2020 NLTK Project # See http://www.apache.org/licenses/LICENSE-2.0 for the license text. -# See https://github.com/nexB/pygmars for support or download. +# See https://github.com/aboutcode-org/pygmars for support or download. # See https://aboutcode.org for more information about nexB OSS projects. # Originally based on: Natural Language Toolkit