diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d9de0c9 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.py] +charset = utf-8 +indent_style = space +indent_size = 4 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{md,mdx}] +trim_trailing_whitespace = false diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 0000000..bdaab28 --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,39 @@ +# This workflow will upload a Python Package using Twine when a release is created +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Upload Python Package + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..91100b4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,26 @@ +name: Release + +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.x" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build and publish + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + run: | + python setup.py sdist bdist_wheel + twine upload --repository pypi dist/* diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..7be9344 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,30 @@ +name: Test + +on: + push: + branches: + - main + - master + pull_request: + branches: + - main + - master + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python: [3.6, 3.7, 3.8, 3.9] + + steps: + - uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + - name: Install Tox and any other packages + run: pip install tox + - name: Run Tox + # Run tox using the version of Python in `PATH` + run: tox -e py diff --git a/.gitignore b/.gitignore index b6e4761..a81c8ee 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,6 @@ parts/ sdist/ var/ wheels/ -pip-wheel-metadata/ share/python-wheels/ *.egg-info/ .installed.cfg @@ -50,6 +49,7 @@ coverage.xml *.py,cover .hypothesis/ .pytest_cache/ +cover/ # Translations *.mo @@ -72,6 +72,7 @@ instance/ docs/_build/ # PyBuilder +.pybuilder/ target/ # Jupyter Notebook @@ -82,7 +83,9 @@ profile_default/ ipython_config.py # pyenv -.python-version +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version # pipenv # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. @@ -127,3 +130,9 @@ dmypy.json # Pyre type checker .pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ diff --git a/.vs/ShipHelm/FileContentIndex/0e381e5b-9409-4ffc-9c4e-02d580443435.vsidx b/.vs/ShipHelm/FileContentIndex/0e381e5b-9409-4ffc-9c4e-02d580443435.vsidx new file mode 100644 index 0000000..1329353 Binary files /dev/null and b/.vs/ShipHelm/FileContentIndex/0e381e5b-9409-4ffc-9c4e-02d580443435.vsidx differ diff --git a/.vs/ShipHelm/FileContentIndex/2667559c-c77f-4162-9ef3-fef940b13df2.vsidx b/.vs/ShipHelm/FileContentIndex/2667559c-c77f-4162-9ef3-fef940b13df2.vsidx new file mode 100644 index 0000000..64b6cb3 Binary files /dev/null and b/.vs/ShipHelm/FileContentIndex/2667559c-c77f-4162-9ef3-fef940b13df2.vsidx differ diff --git a/.vs/ShipHelm/FileContentIndex/5f0240db-9267-4a3c-9bc0-bc9b9f4fa559.vsidx b/.vs/ShipHelm/FileContentIndex/5f0240db-9267-4a3c-9bc0-bc9b9f4fa559.vsidx new file mode 100644 index 0000000..32aa35f Binary files /dev/null and b/.vs/ShipHelm/FileContentIndex/5f0240db-9267-4a3c-9bc0-bc9b9f4fa559.vsidx differ diff --git a/.vs/ShipHelm/FileContentIndex/63424c4f-3749-4dc3-b82b-7a73206eef4d.vsidx b/.vs/ShipHelm/FileContentIndex/63424c4f-3749-4dc3-b82b-7a73206eef4d.vsidx new file mode 100644 index 0000000..1a12c3f Binary files /dev/null and b/.vs/ShipHelm/FileContentIndex/63424c4f-3749-4dc3-b82b-7a73206eef4d.vsidx differ diff --git a/.vs/Shipwreck/FileContentIndex/read.lock b/.vs/ShipHelm/FileContentIndex/read.lock similarity index 100% rename from .vs/Shipwreck/FileContentIndex/read.lock rename to .vs/ShipHelm/FileContentIndex/read.lock diff --git a/.vs/ShipHelm/v17/.wsuo b/.vs/ShipHelm/v17/.wsuo new file mode 100644 index 0000000..f12e1c3 Binary files /dev/null and b/.vs/ShipHelm/v17/.wsuo differ diff --git a/.vs/Shipwreck/FileContentIndex/bae79108-9b47-40e9-a4e4-d14590be1602.vsidx b/.vs/Shipwreck/FileContentIndex/bae79108-9b47-40e9-a4e4-d14590be1602.vsidx deleted file mode 100644 index f32d216..0000000 Binary files a/.vs/Shipwreck/FileContentIndex/bae79108-9b47-40e9-a4e4-d14590be1602.vsidx and /dev/null differ diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json new file mode 100644 index 0000000..02b6164 --- /dev/null +++ b/.vs/VSWorkspaceState.json @@ -0,0 +1,8 @@ +{ + "ExpandedNodes": [ + "", + "\\dist" + ], + "SelectedNode": "\\setup.py", + "PreviewInSolutionExplorer": false +} \ No newline at end of file diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite index 981ebef..8fc8d1d 100644 Binary files a/.vs/slnx.sqlite and b/.vs/slnx.sqlite differ diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..b1dbe7e --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,4 @@ +include pyproject.toml +include *.md +include LICENSE +recursive-include tests test*.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..ead8162 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools>=46.4.0", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..9f64178 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,3 @@ +[metadata] +version = 0.5.0 +license_files = LICENSE \ No newline at end of file diff --git a/setup.py b/setup.py index 203ba58..c701aea 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='Shipwreck', version='0.1.3', - description='A library for handling Python errors and suggesting fixes', + description='A library for logging and handling Python errors and suggesting fixes', author='Gameplex Sfotware', author_email='info@gameplexsoftware.com', install_requires=[ diff --git a/src/shipwreck/__init__.py b/src/shipwreck/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/main.py b/src/shipwreck/errordetect.py similarity index 97% rename from main.py rename to src/shipwreck/errordetect.py index 6c8931e..0a11a38 100644 --- a/main.py +++ b/src/shipwreck/errordetect.py @@ -1,5 +1,5 @@ # ---------------------------------------------------------------------------- -# Shipwrek Copyright 2020-2023 by Gameplex Software and contributors +# ShipHelm Copyright 2020-2023 by Gameplex Software and contributors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,10 +14,6 @@ # limitations under the License. # ---------------------------------------------------------------------------- -import traceback -import sys -import re - class Shipwreck: def __init__(self): self.error_info = "" @@ -107,4 +103,4 @@ def show_popup(self): if self.suggested_fixes: print("\nSuggested fixes:\n") for fix in self.suggested_fixes: - print(f"- {fix}") + print(f"- {fix}") \ No newline at end of file diff --git a/src/shipwreck/logging.py b/src/shipwreck/logging.py new file mode 100644 index 0000000..061b93f --- /dev/null +++ b/src/shipwreck/logging.py @@ -0,0 +1,47 @@ +# ---------------------------------------------------------------------------- +# ShipHelm Copyright 2020-2023 by Gameplex Software and contributors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------- + +import datetime + +class logging: + def __init__(self): + logging.log(logline="ShipWreck logging and error detection active! \n \n # ---------------------------------------------------------------------------- \n # ShipHelm Copyright 2020-2023 by Gameplex Software and contributors \n # \n # Licensed under the Apache License, Version 2.0 (the 'License'); \n # you may not use this file except in compliance with the License. \n # You may obtain a copy of the License at \n # \n # http://www.apache.org/licenses/LICENSE-2.0 \n # \n # Unless required by applicable law or agreed to in writing, software \n # distributed under the License is distributed on an 'AS IS' BASIS, \n # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \n # See the License for the specific language governing permissions and \n # limitations under the License. \n # ----------------------------------------------------------------------------\n",type="n") + logging.log(logline="\n _________.__ .__ __ __ __ \n / _____/| |__ |__|______ / \ / \_______ ____ ____ | | __ \n \_____ \ | | \ | |\____ \\ \/\/ /\_ __ \_/ __ \_/ ___\ | |/ / \n / \| Y \| || |_> >\ / | | \/\ ___/\ \___ | < \n /_______ /|___| /|__|| __/ \__/\ / |__| \___ >\___ >|__|_ \ \n \/ \/ |__| \/ \/ \/ \/ \n ",type="n") + print("ShipWreck logging and error detection active! \n \n # ---------------------------------------------------------------------------- \n # ShipHelm Copyright 2020-2023 by Gameplex Software and contributors \n # \n # Licensed under the Apache License, Version 2.0 (the 'License'); \n # you may not use this file except in compliance with the License. \n # You may obtain a copy of the License at \n # \n # http://www.apache.org/licenses/LICENSE-2.0 \n # \n # Unless required by applicable law or agreed to in writing, software \n # distributed under the License is distributed on an 'AS IS' BASIS, \n # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \n # See the License for the specific language governing permissions and \n # limitations under the License. \n # ----------------------------------------------------------------------------\n") + print("\n _________.__ .__ __ __ __ \n / _____/| |__ |__|______ / \ / \_______ ____ ____ | | __ \n \_____ \ | | \ | |\____ \\ \/\/ /\_ __ \_/ __ \_/ ___\ | |/ / \n / \| Y \| || |_> >\ / | | \/\ ___/\ \___ | < \n /_______ /|___| /|__|| __/ \__/\ / |__| \___ >\___ >|__|_ \ \n \/ \/ |__| \/ \/ \/ \/ \n ") + + + def log(self, logline, type): + with open('latest.log', 'a') as file: + logging = logline + "[" + datetime.strftime("%Y-%m-%d %H:%M:%S") + " " + if type == "w": + logline = "WARN]: " + logline + "\n" + elif type == "d": + logline = "DEBUG]: " + logline + "\n" + elif type == "e": + logline = "ERROR]: Oh mo! looks like you hit a ShipWreck, here is what we know: \n ---------[Begin Error]--------- \n" + logline + "\n ----------[End Error]---------- \n" + elif type == "n": + logline = logline + else: + logline = "INFO]: " + logline + "\n" + print(logline) + file.write(logline) + + def clearlog(self): + with open('latest.log') as file: + logline = "" + file.write(logline) + diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_module1.py b/tests/test_module1.py new file mode 100644 index 0000000..0b45a73 --- /dev/null +++ b/tests/test_module1.py @@ -0,0 +1,11 @@ +import unittest + +from shiphelm import helmdocker + + + + +class TestSimple(unittest.TestCase): + helmdocker.docker.__init__ +if __name__ == '__main__': + unittest.main()