Skip to content

Commit

Permalink
Fixed #26 - Update link references of ownership from nexB to aboutcod…
Browse files Browse the repository at this point in the history
…e-org and version

Signed-off-by: Chin Yeung Li <[email protected]>
  • Loading branch information
chinyeungli committed Aug 13, 2024
1 parent 857df51 commit 4e23ee2
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 29 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
Changelog
=========

v0.5.2
------

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


v0.5.1
------

- Update README with Pygments and Tree-Sitter example by @keshav-space in https://github.com/aboutcode-org/source-inspector/issues/22
- Pin tree-sitter dependencies by @keshav-space in https://github.com/aboutcode-org/source-inspector/issues/23

v0.5.0
------

- Add support to collect strings, comments and symbols from source using Pygments
- Add support to collect strings, comments and symbols from source using Pygments
- Add support to collect strings and symbols from source using tree-sitter


Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ source-inspector is a set of utilities to inspect and analyze source
code and collect interesting data using various tools such as code symbols, strings and comments.
This is also a ScanCode-toolkit plugin.

Homepage: https://github.com/nexB/source-inspector
Homepage: https://github.com/aboutcode-org/source-inspector
License: Apache-2.0


Expand Down Expand Up @@ -53,4 +53,4 @@ To get started:

7. Run a basic scan to collect symbols and strings using `Tree-Sitter <https://tree-sitter.github.io/tree-sitter/>`_, and display them as YAML on the screen::

scancode --treesitter-symbol-and-string tests/data/symbols_ctags/test3.cpp --yaml -
scancode --treesitter-symbol-and-string tests/data/symbols_ctags/test3.cpp --yaml -
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 = source-inspector
long_description = file:README.rst
long_description_content_type = text/x-rst
url = https://github.com/nexB/source-inspector
url = https://github.com/aboutcode-org/source-inspector

author = nexB. Inc. and others
author_email = [email protected]
Expand Down
10 changes: 6 additions & 4 deletions src/source_inspector/strings_xgettext.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ScanCode is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/nexB/source-inspector for support or download.
# See https://github.com/aboutcode-org/source-inspector for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#

Expand Down Expand Up @@ -43,7 +43,8 @@ class XgettextStringScannerPlugin(ScanPlugin):
help="Collect source strings using xgettext.",
help_group=SCAN_GROUP,
sort_order=100,
conflicting_options=["treesitter_symbol_and_string", "pygments_symbol_and_string"],
conflicting_options=[
"treesitter_symbol_and_string", "pygments_symbol_and_string"],
),
]

Expand Down Expand Up @@ -76,7 +77,7 @@ def collect_strings(location, clean=True):
cmd_loc="xgettext",
args=[
# this is a trick to force getting UTF back
# see https://github.com/nexB/source-inspector/issues/14#issuecomment-2001893496
# see https://github.com/aboutcode-org/source-inspector/issues/14#issuecomment-2001893496
'--copyright-holder="ø"',
"--no-wrap",
"--extract-all",
Expand Down Expand Up @@ -138,7 +139,8 @@ def parse_po_text(po_text, drop_header=False, clean=True):
_, _, line = line.partition("#: ")
filename, _, _ = line.partition(":")
numbers = line.replace(filename + ":", "")
numbers = [int(l) for ln in numbers.split() if (l := ln.strip())]
numbers = [int(l)
for ln in numbers.split() if (l := ln.strip())]
line_numbers.extend(numbers)

elif line.startswith(
Expand Down
5 changes: 3 additions & 2 deletions src/source_inspector/symbols_ctags.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ScanCode is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/nexB/source-inspector for support or download.
# See https://github.com/aboutcode-org/source-inspector for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#

Expand Down Expand Up @@ -44,7 +44,8 @@ class CtagsSymbolScannerPlugin(ScanPlugin):
help="Collect source symbols using Universal ctags.",
help_group=SCAN_GROUP,
sort_order=100,
conflicting_options=["treesitter_symbol_and_string", "pygments_symbol_and_string"],
conflicting_options=[
"treesitter_symbol_and_string", "pygments_symbol_and_string"],
),
]

Expand Down
5 changes: 3 additions & 2 deletions src/source_inspector/symbols_pygments.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ScanCode is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/nexB/source-inspector for support or download.
# See https://github.com/aboutcode-org/source-inspector for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#

Expand Down Expand Up @@ -51,7 +51,8 @@ class PygmentsSymbolsAndStringScannerPlugin(ScanPlugin):
help="Collect source symbols, strings and comments using pygments.",
help_group=SCAN_GROUP,
sort_order=100,
conflicting_options=["source_symbol", "source_string", "treesitter_symbol_and_string"],
conflicting_options=["source_symbol",
"source_string", "treesitter_symbol_and_string"],
),
]

Expand Down
5 changes: 3 additions & 2 deletions src/source_inspector/symbols_tree_sitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ScanCode is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/nexB/source-inspector for support or download.
# See https://github.com/aboutcode-org/source-inspector for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#

Expand Down Expand Up @@ -66,7 +66,8 @@ class TreeSitterSymbolAndStringScannerPlugin(ScanPlugin):
help="Collect source symbols and strings using tree-sitter.",
help_group=SCAN_GROUP,
sort_order=100,
conflicting_options=["source_symbol", "source_string", "pygments_symbol_and_string"],
conflicting_options=["source_symbol",
"source_string", "pygments_symbol_and_string"],
),
]

Expand Down
2 changes: 1 addition & 1 deletion tests/test_symbols_ctags.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ScanCode is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/nexB/source_inspector for support or download.
# See https://github.com/aboutcode-org/source_inspector for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#

Expand Down
17 changes: 11 additions & 6 deletions tests/test_symbols_pygments.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ScanCode is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/nexB/source-inspector for support or download.
# See https://github.com/aboutcode-org/source-inspector for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#

Expand Down Expand Up @@ -40,24 +40,28 @@ def check_json(expected, results, regen=REGEN_TEST_FIXTURES):

class TestPygmentsSymbolScannerPlugin(FileBasedTesting):

test_data_dir = os.path.join(os.path.dirname(__file__), "data/symbols_pygments")
test_data_dir = os.path.join(
os.path.dirname(__file__), "data/symbols_pygments")

def test_get_tokens_basic(self):
test_file = self.get_test_loc("test3.cpp")
expected_loc = self.get_test_loc("test3.cpp-expected-tokens.json", must_exist=False)
expected_loc = self.get_test_loc(
"test3.cpp-expected-tokens.json", must_exist=False)
results = list(get_tokens(test_file, with_comments=True))
check_json(expected_loc, results, regen=REGEN_TEST_FIXTURES)

def test_get_tokens_long(self):
test_file = self.get_test_loc("if_ath.c")
expected_loc = self.get_test_loc("if_ath.c-expected-tokens.json", must_exist=False)
expected_loc = self.get_test_loc(
"if_ath.c-expected-tokens.json", must_exist=False)
results = list(get_tokens(test_file, with_comments=True))
check_json(expected_loc, results, regen=REGEN_TEST_FIXTURES)

def test_symbols_scanner_basic_cli_cpp(self):
test_file = self.get_test_loc("test3.cpp")
result_file = self.get_temp_file("json")
args = ["--pygments-symbol-and-string", test_file, "--json-pp", result_file]
args = ["--pygments-symbol-and-string",
test_file, "--json-pp", result_file]
run_scan_click(args)

expected_loc = self.get_test_loc("test3.cpp-expected.json")
Expand All @@ -66,7 +70,8 @@ def test_symbols_scanner_basic_cli_cpp(self):
def test_symbols_scanner_long_cli(self):
test_file = self.get_test_loc("if_ath.c")
result_file = self.get_temp_file("json")
args = ["--pygments-symbol-and-string", test_file, "--json-pp", result_file]
args = ["--pygments-symbol-and-string",
test_file, "--json-pp", result_file]
run_scan_click(args)

expected_loc = self.get_test_loc("if_ath.c-expected.json")
Expand Down
11 changes: 7 additions & 4 deletions tests/test_symbols_tree_shitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ScanCode is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/nexB/source-inspector for support or download.
# See https://github.com/aboutcode-org/source-inspector for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#

Expand Down Expand Up @@ -38,12 +38,14 @@ def check_json(expected, results, regen=REGEN_TEST_FIXTURES):

class TestPygmentsSymbolScannerPlugin(FileBasedTesting):

test_data_dir = os.path.join(os.path.dirname(__file__), "data/symbols_tree_sitter")
test_data_dir = os.path.join(os.path.dirname(
__file__), "data/symbols_tree_sitter")

def test_symbols_scanner_basic_cli_cpp(self):
test_file = self.get_test_loc("test3.cpp")
result_file = self.get_temp_file("json")
args = ["--treesitter-symbol-and-string", test_file, "--json-pp", result_file]
args = ["--treesitter-symbol-and-string",
test_file, "--json-pp", result_file]
run_scan_click(args)

expected_loc = self.get_test_loc("test3.cpp-expected.json")
Expand All @@ -52,7 +54,8 @@ def test_symbols_scanner_basic_cli_cpp(self):
def test_symbols_scanner_long_cli(self):
test_file = self.get_test_loc("if_ath.c")
result_file = self.get_temp_file("json")
args = ["--treesitter-symbol-and-string", test_file, "--json-pp", result_file]
args = ["--treesitter-symbol-and-string",
test_file, "--json-pp", result_file]
run_scan_click(args)

expected_loc = self.get_test_loc("if_ath.c-expected.json")
Expand Down
11 changes: 7 additions & 4 deletions tests/test_symbols_xgettext.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ScanCode is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/nexB/source_inspector for support or download.
# See https://github.com/aboutcode-org/source_inspector for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#

Expand All @@ -25,7 +25,8 @@

class TestXgettextSymbolScannerPlugin(FileBasedTesting):

test_data_dir = os.path.join(os.path.dirname(__file__), "data/strings_xgettext")
test_data_dir = os.path.join(
os.path.dirname(__file__), "data/strings_xgettext")

def test_is_xgettext_installed(self):
assert is_xgettext_installed()
Expand Down Expand Up @@ -232,7 +233,8 @@ def test_strings_scanner_multilines_utf8(self):
args = ["--source-string", test_file, "--json-pp", result_file]
run_scan_click(args)

expected_loc = self.get_test_loc("lineedit.c-expected.json", must_exist=False)
expected_loc = self.get_test_loc(
"lineedit.c-expected.json", must_exist=False)
check_json_scan(expected_loc, result_file, regen=REGEN_TEST_FIXTURES)

@pytest.mark.skipif(
Expand All @@ -247,5 +249,6 @@ def test_strings_scanner_unicode(self):
args = ["--source-string", test_file, "--json-pp", result_file]
run_scan_click(args)

expected_loc = self.get_test_loc("fdisk.c-expected.json", must_exist=False)
expected_loc = self.get_test_loc(
"fdisk.c-expected.json", must_exist=False)
check_json_scan(expected_loc, result_file, regen=REGEN_TEST_FIXTURES)

0 comments on commit 4e23ee2

Please sign in to comment.