From 6ffab588fc1fda35f788fc144957429bd09bb7b6 Mon Sep 17 00:00:00 2001 From: mxmlnkn Date: Sat, 12 Nov 2022 23:28:55 +0100 Subject: [PATCH] [doc] Add open source software attributions --- LICENSE | 2 +- core/LICENSE | 2 +- ratarmount.py | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index e49b4960..5d712843 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 Maximilian K. +Copyright (c) 2019-2022 Maximilian Knespel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/core/LICENSE b/core/LICENSE index e49b4960..5d712843 100644 --- a/core/LICENSE +++ b/core/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 Maximilian K. +Copyright (c) 2019-2022 Maximilian Knespel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/ratarmount.py b/ratarmount.py index a0474be1..8f4057ff 100755 --- a/ratarmount.py +++ b/ratarmount.py @@ -16,6 +16,7 @@ import time import traceback import urllib.parse +import urllib.request import zipfile from typing import Any, Callable, Dict, Iterable, IO, List, Optional, Tuple, Union @@ -918,6 +919,35 @@ def printModuleVersion(moduleName: str): sys.exit(0) +class PrintOSSAttributionAction(argparse.Action): + def __call__(self, parser, args, values, option_string=None): + licenses = [] + for name, githubPath in [ + ("fusepy", "/fusepy/fusepy/master/LICENSE"), + ("python-xz", "/Rogdham/python-xz/master/LICENSE.txt"), + ("rarfile", "/markokr/rarfile/master/LICENSE"), + ("libfuse", "/libfuse/libfuse/master/LGPL2.txt"), + ("libsqlite3", "/sqlite/sqlite/master/LICENSE.md"), + ("cpython", "/python/cpython/main/LICENSE"), + ("libzstd-seek", "/martinellimarco/libzstd-seek/main/LICENSE"), + ("zstd", "/facebook/zstd/dev/LICENSE"), + ("zlib", "/madler/zlib/master/LICENSE"), + ("ratarmountcore", "/mxmlnkn/ratarmount/master/core/LICENSE"), + ("indexed_bzip2", "/mxmlnkn/indexed_bzip2/master/LICENSE"), + ("indexed_gzip", "/mxmlnkn/indexed_gzip/master/LICENSE"), + ("indexed_zstd", "/martinellimarco/indexed_zstd/master/LICENSE"), + ]: + licenseUrl = "https://raw.githubusercontent.com" + githubPath + licenseContents = urllib.request.urlopen(licenseUrl).read().decode() + homepage = "https://github.com" + '/'.join(githubPath.split('/', 3)[:3]) + licenses.append((name, homepage, licenseContents)) + + for moduleName, url, license in sorted(licenses): + print(f"# {moduleName}\n\n{url}\n\n\n```\n{license}\n```\n\n") + + sys.exit(0) + + def _parseArgs(rawArgs: Optional[List[str]] = None): parser = argparse.ArgumentParser( formatter_class=_CustomFormatter, @@ -1227,6 +1257,10 @@ def _parseArgs(rawArgs: Optional[List[str]] = None): 'backends. Arguments specified last will have the highest priority. A comma-separated list may be ' f'specified. Possible backends: {moduleNames}') + advancedGroup.add_argument( + '--oss-attributions', action=PrintOSSAttributionAction, nargs=0, default=argparse.SUPPRESS, + help='Show licenses of used libraries.') + # Positional Arguments positionalGroup.add_argument(