diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 193ff78..be37d8e 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -1,26 +1,37 @@ -# This workflows will upload a Python Package using Twine when a release is created +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# # For more information see: -# https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries - -name: Upload Python Package +# https://nasa-ammos.github.io/slim/docs/guides/software-lifecycle/application-starter-kits/python-starter-kit/ +# +# ******** NOTE ******** +# This file publishes to TestPyPi. To enable public PyPi the repository flag +# must be removed from the Twine upload call in the "Publish package" block. +# +name: "Upload Python Package" on: release: - types: [published] branches: [main] + types: [published] jobs: deploy: + name: Deploy runs-on: ubuntu-latest + permissions: + actions: write + contents: read + security-events: write steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout repository + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: '3.10' - name: Upgrade tooling run: | python3 -m pip install --upgrade pip diff --git a/slim_sample_project/__init__.py b/slim_sample_project/__init__.py index 1fb901f..087f8a2 100644 --- a/slim_sample_project/__init__.py +++ b/slim_sample_project/__init__.py @@ -14,4 +14,4 @@ from .version import __version__ -ignore = True +IGNORE = True diff --git a/slim_sample_project/api/__init__.py b/slim_sample_project/api/__init__.py index b1cdfe9..7ba5fd5 100644 --- a/slim_sample_project/api/__init__.py +++ b/slim_sample_project/api/__init__.py @@ -1,2 +1,2 @@ # Sample code: REPLACE with project code. -ignore = False +IGNORE = False diff --git a/slim_sample_project/api/text_processor.py b/slim_sample_project/api/text_processor.py index 32247cb..44874b8 100644 --- a/slim_sample_project/api/text_processor.py +++ b/slim_sample_project/api/text_processor.py @@ -1,7 +1,8 @@ # Sample code: REPLACE with project code. -from colorama import Fore, Back, Style from random import randint +from colorama import Fore, Back, Style + class TextWriter: """ @@ -29,8 +30,16 @@ def out(self, text): """ Output writer to apply color settings to terminal text. :param text: The value to write to a string. - :type text: Any type that supports an internal str reporesentation. + :type text: Any type that supports an internal str representation. """ if not text: text = "Hello World" print(self.color, self.bg, self.style, str(text), Style.RESET_ALL) + + def __str__(self): + """ + Override default str method to return a string representation of the text properties. + @return: str representing class instance text properties + """ + desc = f"color: {self.color}, background: {self.bg}, style: {self.style}" + return desc diff --git a/slim_sample_project/hello_world.py b/slim_sample_project/hello_world.py index b3ea638..4b908e7 100644 --- a/slim_sample_project/hello_world.py +++ b/slim_sample_project/hello_world.py @@ -3,7 +3,7 @@ import sys from api.text_processor import TextWriter -from version_tooling import version +from version_tooling import VERSION def main(): @@ -12,7 +12,7 @@ def main(): """ w = TextWriter() w.out("Hello World!") - w.out(version) + w.out(VERSION) print("EXITING!") sys.exit(os.EX_OK) diff --git a/slim_sample_project/version_tooling.py b/slim_sample_project/version_tooling.py index bdc52b9..999fd92 100644 --- a/slim_sample_project/version_tooling.py +++ b/slim_sample_project/version_tooling.py @@ -2,8 +2,7 @@ import version as v try: - version = metadata.version(__name__) + VERSION = metadata.version(__name__) except metadata.PackageNotFoundError: # package is not installed, try reading from slim_sample_project script - version = v.__version__ if v.__version__ else "unset" - pass + VERSION = v.__version__ if v.__version__ else "unset"