Skip to content

Commit

Permalink
#63 - 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 db9dd08 commit 3b1526f
Show file tree
Hide file tree
Showing 29 changed files with 1,253 additions and 686 deletions.
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# 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/extractcode for support or download.
# See https://github.com/aboutcode-org/extractcode for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#
18 changes: 9 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ExtractCode

- license: Apache-2.0
- copyright: copyright (c) nexB. Inc. and others
- homepage_url: https://github.com/nexB/extractcode
- homepage_url: https://github.com/aboutcode-org/extractcode
- keywords: archive, extraction, libarchive, 7zip, scancode-toolkit, extractcode

Supports Windows, Linux and macOS on 64 bits processors and Python 3.6 to 3.9.
Expand Down Expand Up @@ -83,7 +83,7 @@ libmagic) to select the most appropriate extractor or decompressor function.
It can handle multi-level archives such as tar.gz and can extract recursively
any nested archives.

Visit https://aboutcode.org and https://github.com/nexB/ for support and download.
Visit https://aboutcode.org and https://github.com/aboutcode-org/ for support and download.


We run CI tests on:
Expand All @@ -109,7 +109,7 @@ In this case, you will need to provide a working and compatible libarchive and
find them:

- **a typecode-libarchive and typecode-7z plugin**: See the standard ones at
https://github.com/nexB/scancode-plugins/tree/main/builtins
https://github.com/aboutcode-org/scancode-plugins/tree/main/builtins
These can either bundle a libarchive library, a 7z executable or expose a
system-installed libraries.
It does so by providing plugin entry points as ``scancode_location_provider``
Expand All @@ -121,8 +121,8 @@ find them:

See for example:

- https://github.com/nexB/scancode-plugins/blob/4da5fe8a5ab1c87b9b4af9e54d7ad60e289747f5/builtins/extractcode_libarchive-linux/setup.py#L40
- https://github.com/nexB/scancode-plugins/blob/4da5fe8a5ab1c87b9b4af9e54d7ad60e289747f5/builtins/extractcode_libarchive-linux/src/extractcode_libarchive/__init__.py#L17
- https://github.com/aboutcode-org/scancode-plugins/blob/4da5fe8a5ab1c87b9b4af9e54d7ad60e289747f5/builtins/extractcode_libarchive-linux/setup.py#L40
- https://github.com/aboutcode-org/scancode-plugins/blob/4da5fe8a5ab1c87b9b4af9e54d7ad60e289747f5/builtins/extractcode_libarchive-linux/src/extractcode_libarchive/__init__.py#L17

And in the same way, the ``scancode_location_provider`` for ``extractcode_7zip``
should point to a ``LocationProviderPlugin`` subclass with a ``get_locations()``
Expand All @@ -132,8 +132,8 @@ find them:

See for example:

- https://github.com/nexB/scancode-plugins/blob/4da5fe8a5ab1c87b9b4af9e54d7ad60e289747f5/builtins/extractcode_7z-linux/setup.py#L40
- https://github.com/nexB/scancode-plugins/blob/4da5fe8a5ab1c87b9b4af9e54d7ad60e289747f5/builtins/extractcode_7z-linux/src/extractcode_7z/__init__.py#L18
- https://github.com/aboutcode-org/scancode-plugins/blob/4da5fe8a5ab1c87b9b4af9e54d7ad60e289747f5/builtins/extractcode_7z-linux/setup.py#L40
- https://github.com/aboutcode-org/scancode-plugins/blob/4da5fe8a5ab1c87b9b4af9e54d7ad60e289747f5/builtins/extractcode_7z-linux/src/extractcode_7z/__init__.py#L18

- use **environment variables** to point to installed binaries:

Expand Down Expand Up @@ -181,14 +181,14 @@ ExtractCode will use these environment variables if set:
- EXTRACTCODE_LIBARCHIVE_PATH : the path to the ``libarchive.so`` libarchive
shared library used to support some of the archive formats. If not provided,
ExtractCode will look for a plugin-provided libarchive library path. See
https://github.com/nexB/scancode-plugins/tree/main/builtins for such plugins.
https://github.com/aboutcode-org/scancode-plugins/tree/main/builtins for such plugins.
If no plugin contributes libarchive, then a final attempt is made to look for
it in the PATH using standard DLL loading techniques.

- EXTRACTCODE_7Z_PATH : the path to the ``7z`` 7zip executable used to support
some of the archive formats. If not provided, ExtractCode will look for a
plugin-provided 7z executable path. See
https://github.com/nexB/scancode-plugins/tree/main/builtins for such plugins.
https://github.com/aboutcode-org/scancode-plugins/tree/main/builtins for such plugins.
If no plugin contributes 7z, then a final attempt is made to look for
it in the PATH.

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 extractcode
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# ScanCode is a trademark of nexB Inc.
# See https://github.com/nexB/extractcode for support or download.
# See https://github.com/aboutcode-org/extractcode for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#
# A minimal shell wrapper to the CLI entry point fo ExtractCode
Expand Down
4 changes: 2 additions & 2 deletions extractcode.ABOUT
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ about_resource: .
copyright: copyright (c) nexB. Inc. and others
description: A mostly universal archive extractor using 7zip, libarchive and the
Python standard library for reliable archive extraction on Linux, Windows and
macOS. It is used by ScanCode toolkit and related projects.
macOS. It is used by ScanCode toolkit and related projects.
keywords: archive, extraction, libarchive, 7zip, gzip, xz, lzma, bzip2, tar, ar, cpio, scancode-toolkit
homepage_url: https://github.com/nexB/extractcode
homepage_url: https://github.com/aboutcode-org/extractcode
holder: nexB. Inc. and others
holder_contact: [email protected]
license_expression: apache-2.0
Expand Down
2 changes: 1 addition & 1 deletion extractcode.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@rem SPDX-License-Identifier: Apache-2.0
@rem See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
@rem ScanCode is a trademark of nexB Inc.
@rem See https://github.com/nexB/extractcode for support or download.
@rem See https://github.com/aboutcode-org/extractcode for support or download.
@rem See https://aboutcode.org for more information about nexB OSS projects.

@rem A wrapper to ExtractCode command line entry point
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 = A mostly universal archive extractor using 7zip, libarchive and the Python standard library for reliable archive extraction.
long_description = file:README.rst
long_description_content_type = text/x-rst
url = https://github.com/nexB/extractcode
url = https://github.com/aboutcode-org/extractcode

author = nexB. Inc. and others
author_email = [email protected]
Expand Down
2 changes: 1 addition & 1 deletion src/extractcode/NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# 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/extractcode for support or download.
# See https://github.com/aboutcode-org/extractcode for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#
5 changes: 3 additions & 2 deletions src/extractcode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,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/extractcode for support or download.
# See https://github.com/aboutcode-org/extractcode for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#

Expand Down Expand Up @@ -123,7 +123,8 @@ def remove_backslashes_and_dotdots(directory):
continue
try:
new_path = as_posixpath(filename).strip('/')
new_path = posixpath.normpath(new_path).replace('..', '/').strip('/')
new_path = posixpath.normpath(
new_path).replace('..', '/').strip('/')
new_path = posixpath.normpath(new_path)
segments = new_path.split('/')
directory = join(top, *segments[:-1])
Expand Down
2 changes: 1 addition & 1 deletion src/extractcode/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,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/extractcode for support or download.
# See https://github.com/aboutcode-org/extractcode for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#

Expand Down
62 changes: 37 additions & 25 deletions src/extractcode/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,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/extractcode for support or download.
# See https://github.com/aboutcode-org/extractcode for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#

Expand Down Expand Up @@ -102,7 +102,7 @@ def should_extract(location, kinds, ignore_pattern=()):
"""
location = os.path.abspath(os.path.expanduser(location))
ignore_pattern = {
extension : 'User ignore: Supplied by --ignore'
extension: 'User ignore: Supplied by --ignore'
for extension in ignore_pattern
}
should_ignore = is_ignored(location, ignore_pattern)
Expand Down Expand Up @@ -218,10 +218,13 @@ def get_handlers(location):
raise Exception('Maximum level of archive nesting is two.')

# default to False
type_matched = handler.filetypes and any(t in ftype for t in handler.filetypes)
type_matched = handler.filetypes and any(
t in ftype for t in handler.filetypes)
if TRACE_DEEP:
logger.debug(f' get_handlers: handler.filetypes={handler.filetypes}')
mime_matched = handler.mimetypes and any(m in mtype for m in handler.mimetypes)
logger.debug(
f' get_handlers: handler.filetypes={handler.filetypes}')
mime_matched = handler.mimetypes and any(
m in mtype for m in handler.mimetypes)
exts = handler.extensions
if exts:
extension_matched = exts and location.lower().endswith(exts)
Expand All @@ -230,7 +233,7 @@ def get_handlers(location):
print(
f' get_handlers: matched type: {type_matched}, '
f'mime: {mime_matched}, ext: {extension_matched}' % locals()
)
)

if (
handler.strict
Expand All @@ -247,7 +250,8 @@ def get_handlers(location):
if type_matched or mime_matched or extension_matched:
if TRACE_DEEP:
handler_name = handler.name
logger.debug(' get_handlers: yielding handler: %(handler_name)r' % locals())
logger.debug(
' get_handlers: yielding handler: %(handler_name)r' % locals())
yield handler, type_matched, mime_matched, extension_matched


Expand All @@ -267,7 +271,8 @@ def score_handlers(handlers):
# increment kind value: higher kinds numerical values are more
# specific by design
score += handler.kind
if TRACE_DEEP: logger.debug(f' score_handlers: score += handler.kind {score}')
if TRACE_DEEP:
logger.debug(f' score_handlers: score += handler.kind {score}')

# increment score based on matched criteria
if type_matched and mime_matched and extension_matched:
Expand Down Expand Up @@ -384,13 +389,15 @@ def extract_twice(location, target_dir, extractor1, extractor2):

# extract this intermediate payload to the final target_dir
try:
inner_archives = list(fileutils.resource_iter(temp_target, with_dirs=False))
inner_archives = list(fileutils.resource_iter(
temp_target, with_dirs=False))
if not inner_archives:
warnings.append(location + ': No files found in archive.')
else:
for extracted1_loc in inner_archives:
if TRACE:
logger.debug('extract_twice: extractor2: %(extracted1_loc)r' % locals())
logger.debug(
'extract_twice: extractor2: %(extracted1_loc)r' % locals())
warnings.extend(extractor2(extracted1_loc, abs_target_dir))
finally:
# cleanup the temporary output from extractor1
Expand All @@ -415,14 +422,17 @@ def extract_with_fallback(location, target_dir, extractor1, extractor2):
try:
warnings = extractor1(abs_location, temp_target1)
if TRACE:
logger.debug('extract_with_fallback: temp_target1: %(temp_target1)r' % locals())
logger.debug(
'extract_with_fallback: temp_target1: %(temp_target1)r' % locals())
fileutils.copytree(temp_target1, abs_target_dir)
except:
try:
temp_target2 = str(fileutils.get_temp_dir(prefix='extractcode-extract2-'))
temp_target2 = str(fileutils.get_temp_dir(
prefix='extractcode-extract2-'))
warnings = extractor2(abs_location, temp_target2)
if TRACE:
logger.debug('extract_with_fallback: temp_target2: %(temp_target2)r' % locals())
logger.debug(
'extract_with_fallback: temp_target2: %(temp_target2)r' % locals())
fileutils.copytree(temp_target2, abs_target_dir)
finally:
fileutils.delete(temp_target2)
Expand All @@ -446,7 +456,8 @@ def try_to_extract(location, target_dir, extractor):
try:
warnings = extractor(abs_location, temp_target)
if TRACE:
logger.debug('try_to_extract: temp_target: %(temp_target)r' % locals())
logger.debug(
'try_to_extract: temp_target: %(temp_target)r' % locals())
fileutils.copytree(temp_target, abs_target_dir)
except:
return warnings
Expand Down Expand Up @@ -685,7 +696,7 @@ def try_to_extract(location, target_dir, extractor):
XzHandler = Handler(
name='xz',
filetypes=('xz compressed',),
mimetypes=('application/x-xz',) ,
mimetypes=('application/x-xz',),
extensions=('.xz',),
kind=regular,
extractors=[extract_xz],
Expand All @@ -695,7 +706,7 @@ def try_to_extract(location, target_dir, extractor):
LzmaHandler = Handler(
name='lzma',
filetypes=('lzma compressed',),
mimetypes=('application/x-xz',) ,
mimetypes=('application/x-xz',),
extensions=('.lzma',),
kind=regular,
extractors=[extract_lzma],
Expand All @@ -705,7 +716,7 @@ def try_to_extract(location, target_dir, extractor):
TarXzHandler = Handler(
name='Tar xz',
filetypes=('xz compressed',),
mimetypes=('application/x-xz',) ,
mimetypes=('application/x-xz',),
extensions=('.tar.xz', '.txz', '.tarxz',),
kind=regular_nested,
extractors=[extract_xz, extract_tar],
Expand All @@ -715,7 +726,7 @@ def try_to_extract(location, target_dir, extractor):
TarLzmaHandler = Handler(
name='Tar lzma',
filetypes=('lzma compressed',),
mimetypes=('application/x-lzma',) ,
mimetypes=('application/x-lzma',),
extensions=('tar.lzma', '.tlz', '.tarlz', '.tarlzma',),
kind=regular_nested,
extractors=[extract_lzma, extract_tar],
Expand All @@ -726,7 +737,8 @@ def try_to_extract(location, target_dir, extractor):
name='Tar gzip',
filetypes=('gzip compressed',),
mimetypes=('application/gzip',),
extensions=('.tgz', '.tar.gz', '.tar.gzip', '.targz', '.targzip', '.tgzip',),
extensions=('.tgz', '.tar.gz', '.tar.gzip',
'.targz', '.targzip', '.tgzip',),
kind=regular_nested,
extractors=[extract_tar],
strict=False
Expand All @@ -735,7 +747,7 @@ def try_to_extract(location, target_dir, extractor):
TarLzipHandler = Handler(
name='Tar lzip',
filetypes=('lzip compressed',),
mimetypes=('application/x-lzip',) ,
mimetypes=('application/x-lzip',),
extensions=('.tar.lz', '.tar.lzip',),
kind=regular_nested,
extractors=[extract_lzip, extract_tar],
Expand All @@ -745,7 +757,7 @@ def try_to_extract(location, target_dir, extractor):
TarZstdHandler = Handler(
name='Tar zstd',
filetypes=('zstandard compressed',),
mimetypes=('application/x-zstd',) ,
mimetypes=('application/x-zstd',),
extensions=('.tar.zst', '.tar.zstd',),
kind=regular_nested,
extractors=[extract_zstd, extract_tar],
Expand All @@ -755,7 +767,7 @@ def try_to_extract(location, target_dir, extractor):
TarLz4Handler = Handler(
name='Tar lz4',
filetypes=('lz4 compressed',),
mimetypes=('application/x-lz4',) ,
mimetypes=('application/x-lz4',),
extensions=('.tar.lz4',),
kind=regular_nested,
extractors=[extract_lz4, extract_tar],
Expand Down Expand Up @@ -788,7 +800,7 @@ def try_to_extract(location, target_dir, extractor):
LzipHandler = Handler(
name='lzip',
filetypes=('lzip compressed',),
mimetypes=('application/x-lzip',) ,
mimetypes=('application/x-lzip',),
extensions=('.lzip',),
kind=regular,
extractors=[extract_lzip],
Expand All @@ -798,7 +810,7 @@ def try_to_extract(location, target_dir, extractor):
ZstdHandler = Handler(
name='zstd',
filetypes=('zstandard compressed',),
mimetypes=('application/x-zstd',) ,
mimetypes=('application/x-zstd',),
extensions=('.zst', '.zstd',),
kind=regular_nested,
extractors=[extract_zstd],
Expand All @@ -808,7 +820,7 @@ def try_to_extract(location, target_dir, extractor):
Lz4Handler = Handler(
name='lz4',
filetypes=('lz4 compressed',),
mimetypes=('application/x-lz4',) ,
mimetypes=('application/x-lz4',),
extensions=('.lz4',),
kind=regular_nested,
extractors=[extract_lz4],
Expand Down
Loading

0 comments on commit 3b1526f

Please sign in to comment.