Skip to content

Commit

Permalink
Fixed library to be packagable, added logging, added workflows, corre…
Browse files Browse the repository at this point in the history
…cted spelling mistakes
  • Loading branch information
tristanpoland committed Mar 14, 2023
1 parent 581ee66 commit eb4c9f2
Show file tree
Hide file tree
Showing 23 changed files with 205 additions and 9 deletions.
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
39 changes: 39 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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/*
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 11 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
Expand Down Expand Up @@ -50,6 +49,7 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
Expand All @@ -72,6 +72,7 @@ instance/
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
Expand All @@ -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.
Expand Down Expand Up @@ -127,3 +130,9 @@ dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
Binary file added .vs/ShipHelm/v17/.wsuo
Binary file not shown.
Binary file not shown.
8 changes: 8 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"ExpandedNodes": [
"",
"\\dist"
],
"SelectedNode": "\\setup.py",
"PreviewInSolutionExplorer": false
}
Binary file modified .vs/slnx.sqlite
Binary file not shown.
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include pyproject.toml
include *.md
include LICENSE
recursive-include tests test*.py
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools>=46.4.0", "wheel"]
build-backend = "setuptools.build_meta"
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[metadata]
version = 0.5.0
license_files = LICENSE
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='[email protected]',
install_requires=[
Expand Down
Empty file added src/shipwreck/__init__.py
Empty file.
8 changes: 2 additions & 6 deletions main.py → src/shipwreck/errordetect.py
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -14,10 +14,6 @@
# limitations under the License.
# ----------------------------------------------------------------------------

import traceback
import sys
import re

class Shipwreck:
def __init__(self):
self.error_info = ""
Expand Down Expand Up @@ -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}")
47 changes: 47 additions & 0 deletions src/shipwreck/logging.py
Original file line number Diff line number Diff line change
@@ -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)

Empty file added tests/__init__.py
Empty file.
11 changes: 11 additions & 0 deletions tests/test_module1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import unittest

from shiphelm import helmdocker




class TestSimple(unittest.TestCase):
helmdocker.docker.__init__
if __name__ == '__main__':
unittest.main()

0 comments on commit eb4c9f2

Please sign in to comment.