From 3a084c1da5b3098eb8adf1f70e684e564d5fb27e Mon Sep 17 00:00:00 2001 From: Henrik Sandklef Date: Tue, 29 Aug 2023 00:27:21 +0200 Subject: [PATCH 1/4] add operators option --- python/flame/__main__.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/python/flame/__main__.py b/python/flame/__main__.py index 4f08370..4c7f895 100755 --- a/python/flame/__main__.py +++ b/python/flame/__main__.py @@ -66,6 +66,11 @@ def parse(): 'compats', help='show all compatibilities') parser_cs.set_defaults(which='compats', func=compats) + # operators + parser_os = subparsers.add_parser( + 'operators', help='show all operators') + parser_os.set_defaults(which='operators', func=operators) + # licenses parser_cs = subparsers.add_parser( 'licenses', help='show all licenses') @@ -75,6 +80,10 @@ def parse(): return args +def operators(ldb, formatter, args): + all_op = ldb.operators() + return formatter.format_operators(all_op, args.verbose) + def aliases(ldb, formatter, args): all_aliases = ldb.aliases_list() return formatter.format_identified_list(all_aliases, args.verbose) From ebb5eb3b3e9ab4db60e5fe9d4d0e635fd99a75fc Mon Sep 17 00:00:00 2001 From: Henrik Sandklef Date: Tue, 29 Aug 2023 00:27:33 +0200 Subject: [PATCH 2/4] add list operators function --- python/flame/license_db.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/flame/license_db.py b/python/flame/license_db.py index b4330c1..3b4f426 100644 --- a/python/flame/license_db.py +++ b/python/flame/license_db.py @@ -180,6 +180,9 @@ def aliases(self, license_name): identified_name = self.__identify_license(license_name)[NAME_TAG] return self.license_db[LICENSES_TAG][identified_name][ALIASES_TAG] + def operators(self): + return self.license_db[LICENSE_OPERATORS_TAG] + def compatibility_as(self, license_name): # List compatibility_as for license identified = self.__identify_license(license_name) From 129e9d649cb191e76105da4e5bbd23c5688bde9d Mon Sep 17 00:00:00 2001 From: Henrik Sandklef Date: Tue, 29 Aug 2023 00:27:41 +0200 Subject: [PATCH 3/4] test list operators function --- tests/python/test_ldb.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/python/test_ldb.py b/tests/python/test_ldb.py index 07bb2ab..77efbf6 100644 --- a/tests/python/test_ldb.py +++ b/tests/python/test_ldb.py @@ -70,6 +70,10 @@ def test_licenses(): licenses = ldb.licenses() assert len(licenses) == 3 +def test_operators(): + operators = ldb.operators() + assert len(operators) > 3 + def test_compat_as_bad_input(): with pytest.raises(LicenseDatabaseError) as _error: From 9109f2cd18135a2e90891e596d6a8fdb3ee82716 Mon Sep 17 00:00:00 2001 From: Henrik Sandklef Date: Tue, 29 Aug 2023 00:27:58 +0200 Subject: [PATCH 4/4] test format operators --- python/flame/format.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/python/flame/format.py b/python/flame/format.py index b97ffe7..49ed6fe 100644 --- a/python/flame/format.py +++ b/python/flame/format.py @@ -47,6 +47,9 @@ def format_licenses(self, licenses, verbose): def format_compatibilities(self, compats, verbose): return None + def format_operators(self, operators, verbose): + return None + class JsonOutputFormatter(OutputFormatter): def format_compat(self, compat, verbose): @@ -73,6 +76,9 @@ def format_licenses(self, licenses, verbose): def format_compatibilities(self, compats, verbose): return json.dumps(compats) + def format_operators(self, operators, verbose): + return json.dumps(operators) + class YamlOutputFormatter(OutputFormatter): def format_compat(self, compat, verbose): @@ -99,6 +105,9 @@ def format_licenses(self, licenses, verbose): def format_compatibilities(self, compats, verbose): return yaml.dump(compats) + def format_operators(self, operators, verbose): + return yaml.dump(operators) + class TextOutputFormatter(OutputFormatter): def format_compat(self, compat, verbose): @@ -164,5 +173,8 @@ def format_licenses(self, licenses, verbose): licenses.sort() return "\n".join(licenses) + def format_operators(self, operators, verbose): + return "\n".join(operators) + def format_error(self, error, verbose): return f'Error, {error}'