Skip to content

Commit

Permalink
major refactor of code start
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkflame72 committed Sep 27, 2020
1 parent 9522e8e commit 35bbf0f
Show file tree
Hide file tree
Showing 30 changed files with 2,173 additions and 79 deletions.
2 changes: 2 additions & 0 deletions .darglint
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[darglint]
strictness = short
9 changes: 9 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[flake8]
select = ANN,B,B9,BLK,C,D,DAR,E,F,I,S,W
ignore = E203,E501,W503,ANN101,ANN102,DAR103
max-line-length = 80
max-complexity = 10
application-import-names = mcsrvstats,tests
import-order-style = google
docstring-convention = google
per-file-ignores = tests/*:S101
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip"
directory: "/" # Location of package manifests
schedule:
interval: "daily"
26 changes: 26 additions & 0 deletions .github/releasedrafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
categories:
- title: ":boom: Breaking Changes"
label: "breaking"
- title: ":package: Build System"
label: "build"
- title: ":construction_worker: Continuous Integration"
label: "ci"
- title: ":books: Documentation"
label: "documentation"
- title: ":rocket: Features"
label: "enhancement"
- title: ":beetle: Fixes"
label: "bug"
- title: ":racehorse: Performance"
label: "performance"
- title: ":hammer: Refactoring"
label: "refactoring"
- title: ":fire: Removals and Deprecations"
label: "removal"
- title: ":lipstick: Style"
label: "style"

template: |
## What’s Changed
$CHANGES
16 changes: 16 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Coverage
on: push
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: "3.8"
architecture: x64
- run: pip install nox==2019.11.9
- run: pip install poetry==1.0.4
- run: nox --sessions tests-3.8 coverage
env:
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
11 changes: 0 additions & 11 deletions .github/workflows/lint.yml

This file was deleted.

27 changes: 0 additions & 27 deletions .github/workflows/publish_pypi.yml

This file was deleted.

12 changes: 12 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Release Drafter
on:
push:
branches:
- master
jobs:
draft_release:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18 changes: 18 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Release
on:
release:
types: [published]
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: "3.8"
architecture: x64
- run: pip install nox==2019.11.9
- run: pip install poetry==1.0.5
- run: nox
- run: poetry build
- run: poetry publish --username=__token__ --password=${{ secrets.PYPI_TOKEN }}
25 changes: 25 additions & 0 deletions .github/workflows/test-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: TestPyPI
on:
push:
branches:
- master
jobs:
test_pypi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: "3.8"
architecture: x64
- run: pip install poetry==1.0.5
- run: >-
poetry version patch &&
version=$(poetry version | awk '{print $2}') &&
poetry version $version.dev.$(date +%s)
- run: poetry build
- uses: pypa/gh-action-pypi-publish@v1.0.0a0
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/
18 changes: 18 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Tests
on: push
jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8"]
name: Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- run: pip install nox==2019.11.9
- run: pip install poetry==1.0.4
- run: nox
19 changes: 19 additions & 0 deletions .pre-commit-config.yasml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: local
hooks:
- id: black
name: black
entry: poetry run black
language: system
types: [python]
- id: flake8
name: flake8
entry: poetry run flake8
language: system
types: [python]
9 changes: 9 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2
sphinx:
configuration: docs/conf.py
formats: all
python:
version: 3.7
install:
- requirements: docs/requirements.txt
- path: .
12 changes: 12 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Sphinx configuration."""
from datetime import datetime


project = "mcsrvstats"
author = "Leon Bowie"
copyright = f"{datetime.now().year}, {author}"
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"sphinx_autodoc_typehints",
]
29 changes: 29 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
The Ayncpixel Python Project
==============================

.. toctree::
:hidden:
:maxdepth: 1

license
reference

TODO


Installation
------------

To install the mcsrvstats Python project,
run this command in your terminal:

.. code-block:: console
$ pip install mcsrvstats
Usage
-----

Asyncpixel Python's usage looks like:
TODO
4 changes: 4 additions & 0 deletions docs/license.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
License
=======

.. include:: ../LICENSE
13 changes: 13 additions & 0 deletions docs/reference.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Reference
=========

.. contents::
:local:
:backlinks: none


asyncpixel
--------------------------

.. automodule:: asyncpixel
:members:
2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sphinx==2.3.1
sphinx-autodoc-typehints==1.10.3
33 changes: 32 additions & 1 deletion mcsrvstats/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
from .main import *
"""Minecraft Server Stats Wrapper.
~~~~~~~~~~~~~~~~~~~
A wrapper for a collection of popular minecraft server stats.
:copyright: (c) 2020 Darkflame72
:license: MIT, see LICENSE for more details.
"""

__title__ = "mcsrvstats"
__author__ = "Leon Bowie"
__license__ = "MIT"
__copyright__ = "Copyright 2020 Darkflame72"


try:
from importlib.metadata import version, PackageNotFoundError # type: ignore
except ImportError: # pragma: no cover
from importlib_metadata import version, PackageNotFoundError # type: ignore


try:
__version__ = version(__name__)
except PackageNotFoundError: # pragma: no cover
__version__ = "unknown"


from collections import namedtuple


VersionInfo = namedtuple("VersionInfo", "major minor micro releaselevel serial")

version_info = VersionInfo(major=0, minor=1, micro=1, releaselevel="alpha", serial=0)
1 change: 1 addition & 0 deletions mcsrvstats/exceptions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Exceptions for asyncpixel."""
23 changes: 23 additions & 0 deletions mcsrvstats/exceptions/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""All exceptions for asyncpixel."""


class ApiError(Exception):
"""Raised when a error occurs on the api side"""

def __init__(self, error: str, source: str = "unknown source") -> None:
"""Error raised when api is not succesful.
Args:
error (str): Error message
source (str, optional): Source of the error. Defaults to "unknown source".
"""
self.message = f"The {source}API had {error}"
super().__init__(self.message)

def __str__(self) -> str:
"""Return error in readable format.
Returns:
str: string version of error
"""
return self.message

0 comments on commit 35bbf0f

Please sign in to comment.