Skip to content

Commit

Permalink
#11 - Update link references of ownership from nexB to aboutcode-org
Browse files Browse the repository at this point in the history
Signed-off-by: Chin Yeung Li <[email protected]>
  • Loading branch information
chinyeungli committed Aug 14, 2024
1 parent acfe2d1 commit 8183920
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 26 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ Changelog



Version 0.8.1
-------------

- Update link references of ownership from nexB to aboutcode-org



Version 0.8.0
-----------------

Expand Down
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#

Expand Down
2 changes: 1 addition & 1 deletion configure.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [email protected]
Expand Down
2 changes: 1 addition & 1 deletion src/pygmars/__init__.py
Original file line number Diff line number Diff line change
@@ -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.
#

Expand Down
5 changes: 3 additions & 2 deletions src/pygmars/lex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#

Expand Down Expand Up @@ -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):
"""
Expand Down
18 changes: 11 additions & 7 deletions src/pygmars/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#

Expand Down Expand Up @@ -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::
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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))
Expand Down
19 changes: 12 additions & 7 deletions src/pygmars/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#

Expand Down Expand Up @@ -168,22 +168,25 @@ 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):
if isinstance(index, (int, slice)):
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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_lex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_lex_doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_parse_doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8183920

Please sign in to comment.