-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into docs/update
- Loading branch information
Showing
10 changed files
with
47 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -151,3 +151,4 @@ jobs: | |
uses: codecov/codecov-action@v3 | ||
with: | ||
flags: client-tests | ||
token: ${{secrets.CODECOV_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,3 +165,4 @@ jobs: | |
uses: codecov/codecov-action@v3 | ||
with: | ||
flags: server-tests | ||
token: ${{secrets.CODECOV_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,39 @@ | ||
import pkg_resources | ||
import importlib.metadata as metadata | ||
|
||
|
||
def get_license_txt(pkg): | ||
if pkg.has_metadata("LICENSE"): | ||
lic = pkg.get_metadata("LICENSE") | ||
else: | ||
lic = "(license detail not found)" | ||
return lic | ||
|
||
|
||
def get_info(name, lines): | ||
def get_info(name, pkg): | ||
""" | ||
Search information in a list of lines. | ||
Search information in a package metadata. | ||
The expected format of the line is "name: info" | ||
This function search the name and return the info. | ||
This function searches for the name and returns the info. | ||
:param name: name to be search at the beginning of a line. | ||
:param lines: list of strings. | ||
:param name: name to be searched. | ||
:param pkg: a dictionary representing the package metadata. | ||
:return: the info part of the line for the given name. | ||
""" | ||
sep = name + ": " | ||
for line in lines: | ||
if line.startswith(sep): | ||
return line.split(sep, maxsplit=1)[1] | ||
if name in pkg: | ||
return pkg[name] | ||
return f"({name} not found)" | ||
|
||
|
||
def get_main_info(pkg): | ||
""" | ||
Get information from libraries. | ||
:param pkg: a package object from pkg_resources.working_set | ||
:return: a dict with library, license, version, author, description and home page. | ||
""" | ||
lines1 = [] | ||
lines2 = [] | ||
# Find info in metadata | ||
if pkg.has_metadata("METADATA"): | ||
lines1 = pkg.get_metadata_lines("METADATA") | ||
# find info in PKG-INFO | ||
if pkg.has_metadata("PKG-INFO"): | ||
lines2 = pkg.get_metadata_lines("PKG-INFO") | ||
# Transform lines into list | ||
lines = [l for l in lines1] + [l for l in lines2] | ||
|
||
# Manage case where license is UNKNOWN | ||
lic = get_info("License", lines) | ||
if lic == "UNKNOWN": | ||
lic = get_info("Classifier: License :", lines) | ||
return { | ||
"library": get_info("Name", lines), | ||
"license": lic, | ||
"version": get_info("Version", lines), | ||
"author": get_info("Author", lines), | ||
"description": get_info("Summary", lines), | ||
"home page": get_info("Home-page", lines), | ||
} | ||
|
||
|
||
def get_licenses_summary(): | ||
""" | ||
Get a list of dicts with licenses and library information. | ||
:return: a list of dicts with library, license, version, author, description, home page and license text. | ||
""" | ||
license_list = [] | ||
for pkg in sorted(pkg_resources.working_set, key=lambda x: str(x).lower()): | ||
for pkg in sorted(metadata.distributions(), key=lambda x: x.metadata['Name'].lower()): | ||
pkg_metadata = dict(pkg.metadata.items()) | ||
license_list += [ | ||
{ | ||
**get_main_info(pkg), | ||
"license_text": get_license_txt(pkg), | ||
"library": get_info("Name", pkg_metadata), | ||
"license": get_info("License", pkg_metadata), | ||
"version": get_info("Version", pkg_metadata), | ||
"author": get_info("Author", pkg_metadata), | ||
"description": get_info("Summary", pkg_metadata), | ||
"home page": get_info("Home-page", pkg_metadata), | ||
} | ||
] | ||
|
||
return license_list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters