Skip to content

Commit

Permalink
Change license blurb (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
gecrooks authored Dec 12, 2020
1 parent 23458a8 commit 8a53a62
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion gecrooks_python_template/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2019-2021, Gavin E. Crooks and contributors
#
# This source code is licensed under the Apache License, Version 2.0 found in
# This source code is licensed under the Apache License 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.

from .config import __version__ # noqa: F401
Expand Down
2 changes: 1 addition & 1 deletion gecrooks_python_template/about.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2019-2021, Gavin E. Crooks and contributors
#
# This source code is licensed under the Apache License, Version 2.0 found in
# This source code is licensed under the Apache License 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.

# Command line interface for the about() function
Expand Down
21 changes: 12 additions & 9 deletions gecrooks_python_template/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2019-2021, Gavin E. Crooks and contributors
#
# This source code is licensed under the Apache License, Version 2.0 found in
# This source code is licensed under the Apache License 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.

"""
Expand All @@ -23,38 +23,41 @@
__all__ = ["__version__", "about"]


package_name = "gecrooks_python_template"

try:
__version__ = importlib_metadata.version(package_name) # type: ignore
__version__ = importlib_metadata.version(__package__) # type: ignore
except Exception: # pragma: no cover
# package is not installed
__version__ = "?.?.?"


def about(file: typing.TextIO = None) -> None:
f"""Print information about the configuration
f"""Print information about the package
``> python -m {package_name}.about``
``> python -m {__package__}.about``
Args:
file: Output stream (Defaults to stdout)
"""
metadata = importlib_metadata.metadata(__package__) # type: ignore
print(f"# {metadata['Name']}", file=file)
print(f"{metadata['Summary']}", file=file)
print(f"{metadata['Home-page']}", file=file)

name_width = 24
versions = {}
versions["platform"] = platform.platform(aliased=True)
versions[package_name] = __version__
versions[__package__] = __version__
versions["python"] = sys.version[0:5]

for req in importlib_metadata.requires(package_name): # type: ignore
for req in importlib_metadata.requires(__package__): # type: ignore
name = re.split("[; =><]", req)[0]
try:
versions[name] = importlib_metadata.version(name) # type: ignore
except Exception: # pragma: no cover
pass

print(file=file)
print(f"# Configuration (> python -m {package_name}.about)", file=file)
print("# Configuration", file=file)
for name, vers in versions.items():
print(name.ljust(name_width), vers, file=file)
print(file=file)
2 changes: 1 addition & 1 deletion gecrooks_python_template/config_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2019-2021, Gavin E. Crooks and contributors
#
# This source code is licensed under the Apache License, Version 2.0 found in
# This source code is licensed under the Apache License 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.

import glob
Expand Down

0 comments on commit 8a53a62

Please sign in to comment.