From 2b4120ca2e219789dba41e8e14d9ff067dde4585 Mon Sep 17 00:00:00 2001 From: 573dev <> Date: Tue, 13 Oct 2020 11:42:12 -0500 Subject: [PATCH] Initial Commit --- .flake8 | 4 + .gitignore | 103 ++++++++++++++++++++ .mypy.ini | 2 + .travis.yml | 11 +++ AUTHORS | 0 CHANGES.md | 3 + LICENSE | 19 ++++ MANIFEST.in | 5 + README.md | 8 ++ VERSION | 1 + docs/autoapi_templates/python/module.rst_t | 28 ++++++ docs/autoapi_templates/python/package.rst_t | 1 + docs/conf.py | 88 +++++++++++++++++ docs/general/gen_template.md | 4 + docs/general/index.rst | 8 ++ docs/index.rst | 25 +++++ pyproject.toml | 22 +++++ setup.py | 45 +++++++++ tests/test_template.py | 7 ++ tests/test_version.py | 20 ++++ tox.ini | 42 ++++++++ v8_server/VERSION | 1 + v8_server/__init__.py | 4 + v8_server/template.py | 21 ++++ v8_server/version.py | 20 ++++ 25 files changed, 492 insertions(+) create mode 100644 .flake8 create mode 100644 .gitignore create mode 100644 .mypy.ini create mode 100644 .travis.yml create mode 100644 AUTHORS create mode 100644 CHANGES.md create mode 100644 LICENSE create mode 100644 MANIFEST.in create mode 100644 README.md create mode 120000 VERSION create mode 100644 docs/autoapi_templates/python/module.rst_t create mode 100644 docs/autoapi_templates/python/package.rst_t create mode 100644 docs/conf.py create mode 100644 docs/general/gen_template.md create mode 100644 docs/general/index.rst create mode 100644 docs/index.rst create mode 100644 pyproject.toml create mode 100644 setup.py create mode 100644 tests/test_template.py create mode 100644 tests/test_version.py create mode 100644 tox.ini create mode 100644 v8_server/VERSION create mode 100644 v8_server/__init__.py create mode 100644 v8_server/template.py create mode 100644 v8_server/version.py diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..dd622a3 --- /dev/null +++ b/.flake8 @@ -0,0 +1,4 @@ +[flake8] +ignore = E203, W503 +max-line-length = 88 +inline-quotes = double diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a236861 --- /dev/null +++ b/.gitignore @@ -0,0 +1,103 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +pip-wheel-metadata + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# dotenv +.env + +# virtualenv +.venv +venv/ +ENV/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ diff --git a/.mypy.ini b/.mypy.ini new file mode 100644 index 0000000..976ba02 --- /dev/null +++ b/.mypy.ini @@ -0,0 +1,2 @@ +[mypy] +ignore_missing_imports = True diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..08a3646 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +sudo: false +language: python +python: + - "3.8" +install: + - pip install tox-travis + - pip install coveralls +script: + - tox -r +after_success: + - coveralls diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..e69de29 diff --git a/CHANGES.md b/CHANGES.md new file mode 100644 index 0000000..fb33f04 --- /dev/null +++ b/CHANGES.md @@ -0,0 +1,3 @@ +# 0.1.0 (October 13, 2020) + +- Initial Release diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7ff579d --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright 2020 573dev + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..096099b --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,5 @@ +include v8_server/VERSION +include VERSION +include README.md +include LICENSE +include CHANGES.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..57605bf --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# V8 Server +[![Python Version](https://img.shields.io/badge/python-3.8-blue.svg)](https://www.python.org/) +[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black) + +Simlated eAmuse Server for GFDM V8 + +## License +v8\_server is provided under an MIT License. diff --git a/VERSION b/VERSION new file mode 120000 index 0000000..d1f4695 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +v8_server/VERSION \ No newline at end of file diff --git a/docs/autoapi_templates/python/module.rst_t b/docs/autoapi_templates/python/module.rst_t new file mode 100644 index 0000000..518f78b --- /dev/null +++ b/docs/autoapi_templates/python/module.rst_t @@ -0,0 +1,28 @@ +{{obj.name}} +{{obj.name|length * "="}} + +.. automodule:: {{obj.name}}{%- block subpackages %} +{%- if obj.subpackages %} + +Subpackages +----------- + +.. toctree:: + :titlesonly: + :maxdepth: 1 +{% for subpackage in obj.subpackages %} + {% if subpackage.display %}{{ subpackage.short_name }}/index.rst{% endif -%} +{%- endfor %} +{%- endif %}{%- endblock -%}{%- block submodules %} +{%- if obj.submodules %} + +Submodules +---------- + +.. toctree:: + :titlesonly: + :maxdepth: 1 +{% for submodule in obj.submodules %} + {% if submodule.display %}{{ submodule.short_name }}/index.rst{% endif -%} +{%- endfor %} +{%- endif %}{%- endblock -%} diff --git a/docs/autoapi_templates/python/package.rst_t b/docs/autoapi_templates/python/package.rst_t new file mode 100644 index 0000000..fb9a649 --- /dev/null +++ b/docs/autoapi_templates/python/package.rst_t @@ -0,0 +1 @@ +{% extends "python/module.rst" %} diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..cb27825 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,88 @@ +from recommonmark.transform import AutoStructify + +from v8_server import __version__ + + +# Sphinx Base -------------------------------------------------------------------------- +# Extensions +extensions = [ + # http://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html + "sphinx.ext.autodoc", + # http://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html + "sphinx.ext.napoleon", + # http://www.sphinx-doc.org/en/master/usage/extensions/todo.html + "sphinx.ext.todo", + # http://www.sphinx-doc.org/en/master/usage/extensions/viewcode.html + "sphinx.ext.viewcode", + # https://sphinx-autoapi.readthedocs.io/en/latest/ + "autoapi.extension", + # https://github.com/rtfd/recommonmark + "recommonmark", +] + +# Set initial page name +master_doc = "index" + +# Project settings +project = "V8 Server" +year = "2020" +author = "573dev" +copyright = f"{year}, {author}" + +# Short version name +version = __version__ + +# Long version name +release = version + +# HTML Settings +html_theme = "sphinx_rtd_theme" +html_last_updated_fmt = "%b %d, %Y" +html_short_title = f"{project}-{version}" + +# Pygments Style Settings +pygments_style = "monokai" + +# Sphinx Extension Autodoc ------------------------------------------------------------- + +# Order members by source order +autodoc_member_order = "bysource" + +# Always show members, and member-inheritance by default +autodoc_default_options = {"members": True, "show-inheritance": True} + +# Sphinx Extension Napoleon ------------------------------------------------------------ + +# We want to force google style docstrings, so disable numpy style +napoleon_numpy_docstring = False + +# Set output style +napoleon_use_ivar = True +napoleon_use_rtype = False +napoleon_use_param = False + +# Sphinx Extension AutoAPI ------------------------------------------------------------- +autoapi_type = "python" +autoapi_dirs = ["../v8_server/"] +autoapi_template_dir = "docs/autoapi_templates" +autoapi_root = "autoapi" +autoapi_ignore = ["*/v8_server/version.py"] +autoapi_add_toctree_entry = False +autoapi_keep_files = False + +# Exclude the autoapi templates in the doc building +exclude_patterns = ["autoapi_templates"] + + +# Add any Sphinx plugin settings here that don't have global variables exposed. +def setup(app): + # App Settings --------------------------------------------------------------------- + # Set source filetype(s) + # Allow .rst files along with .md + app.add_source_suffix(".rst", "restructuredtext") + + # RecommonMark Settings ------------------------------------------------------------ + # Enable the evaluation of rst directive in .md files + # https://recommonmark.readthedocs.io/en/latest/auto_structify.html + app.add_config_value("recommonmark_config", {"enable_eval_rst": True}, True) + app.add_transform(AutoStructify) diff --git a/docs/general/gen_template.md b/docs/general/gen_template.md new file mode 100644 index 0000000..3a4ef30 --- /dev/null +++ b/docs/general/gen_template.md @@ -0,0 +1,4 @@ +## Template + +Explain Template Here + diff --git a/docs/general/index.rst b/docs/general/index.rst new file mode 100644 index 0000000..c761a18 --- /dev/null +++ b/docs/general/index.rst @@ -0,0 +1,8 @@ +General +======= + +.. toctree:: + :maxdepth: 1 + :glob: + + gen_* diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..a62c6c8 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,25 @@ +V8 Server +========= + +Simlated eAmuse Server for GFDM V8 + +.. toctree:: + :maxdepth: 1 + :caption: General + :name: sec-general + + general/index + +.. toctree:: + :maxdepth: 1 + :caption: Code Reference + :name: sec-code-ref + + autoapi/v8_server/index + +.. toctree:: + :maxdepth: 1 + :caption: Code Coverage + :name: sec-code-coverage + + Coverage <./coverage/index.html#http://> diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..ee0592d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,22 @@ +[tool.black] +target-version = ["py38"] + +[tool.coverage.run] +relative_files = true + +[tool.coverage.report] +precision = 2 +show_missing = true +skip_covered = true +exclude_lines = ["if __name__ == .__main__.:", "def __str__", "def __repr__", "pragma: no cover"] + +[tool.isort] +line_length = 88 +force_grid_wrap = "0" +multi_line_output = "3" +use_parentheses = true +combine_as_imports = true +known_first_party = ["v8_server"] +known_third_party = ["pytest, recommonmark"] +include_trailing_comma = true +lines_after_imports = "2" diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..b205083 --- /dev/null +++ b/setup.py @@ -0,0 +1,45 @@ +import codecs +from os.path import abspath, dirname, join + +from setuptools import find_packages, setup + + +TEST_DEPS = ["coverage[toml]", "pytest", "pytest-cov"] +DOCS_DEPS = ["sphinx", "sphinx-rtd-theme", "sphinx-autoapi", "recommonmark"] +CHECK_DEPS = ["isort", "flake8", "flake8-quotes", "pep8-naming", "mypy", "black"] +REQUIREMENTS = ["flask"] + +EXTRAS = { + "test": TEST_DEPS, + "docs": DOCS_DEPS, + "check": CHECK_DEPS, + "dev": TEST_DEPS + DOCS_DEPS + CHECK_DEPS, +} + +# Read in the version +with open(join(dirname(abspath(__file__)), "VERSION")) as version_file: + version = version_file.read().strip() + + +setup( + name="V8 Server", + version=version, + description="Simlated eAmuse Server for GFDM V8", + long_description=codecs.open("README.md", "r", "utf-8").read(), + long_description_content_type="text/markdown", + author="573dev", + url="https://github.com/573dev/gfdm_server", + packages=find_packages(exclude=["tests"]), + install_requires=REQUIREMENTS, + classifiers=[ + "Environment :: Console", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3.8", + ], + platforms=["any"], + include_package_data=True, + tests_require=TEST_DEPS, + extras_require=EXTRAS, +) diff --git a/tests/test_template.py b/tests/test_template.py new file mode 100644 index 0000000..7953070 --- /dev/null +++ b/tests/test_template.py @@ -0,0 +1,7 @@ +from v8_server.template import function_test + + +def test_function_test(): + data = 2 + expected = 4 + assert function_test(data) == expected diff --git a/tests/test_version.py b/tests/test_version.py new file mode 100644 index 0000000..8066c22 --- /dev/null +++ b/tests/test_version.py @@ -0,0 +1,20 @@ +import re + +from v8_server.version import get_version_number + + +# Make sure version matches SemVer +def test_version_string(): + # Regex found here: https://github.com/k-bx/python-semver/blob/master/semver.py + regex = re.compile( + r""" + ^(?P0|[1-9]\d*)\. + (?P0|[1-9]\d*)\. + (?P0|[1-9]\d*) + (?:-(?P(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*) + (?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))? + (?:\+(?P[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$ + """, + re.VERBOSE, + ) + assert re.search(regex, get_version_number()) diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..163db74 --- /dev/null +++ b/tox.ini @@ -0,0 +1,42 @@ +[tox] +envlist = + check + py38, + coverage + docs + +[testenv] +usedevelop = True +extras = test +setenv = + PYTHONPATH = {toxinidir} + COVERAGE_FILE=.coverage.{envname} +commands = + py.test --cov=v8_server --verbose --tb=long {posargs} + +[testenv:coverage] +basepython = python3.8 +deps = coverage[toml] +skip_install = True +skipsdist = True +commands = + /usr/bin/env bash -c "{envpython} -m coverage combine .coverage.*" + coverage report + +[testenv:check] +basepython = python3.8 +extras = check +commands = + isort v8_server tests setup.py docs/conf.py --check-only --diff + black v8_server tests setup.py docs/conf.py --quiet --check --diff + flake8 v8_server tests setup.py docs/conf.py + mypy v8_server setup.py docs/conf.py + +[testenv:docs] +basepython = python3.8 +extras = docs +commands = sphinx-build {posargs:-E} -b html docs dist/docs + +[travis] +python = + 3.8: check, py38, coverage, docs diff --git a/v8_server/VERSION b/v8_server/VERSION new file mode 100644 index 0000000..6e8bf73 --- /dev/null +++ b/v8_server/VERSION @@ -0,0 +1 @@ +0.1.0 diff --git a/v8_server/__init__.py b/v8_server/__init__.py new file mode 100644 index 0000000..f79dd92 --- /dev/null +++ b/v8_server/__init__.py @@ -0,0 +1,4 @@ +from .version import __version__ + + +__all__ = ["__version__"] diff --git a/v8_server/template.py b/v8_server/template.py new file mode 100644 index 0000000..e8530e7 --- /dev/null +++ b/v8_server/template.py @@ -0,0 +1,21 @@ +import logging + + +logger = logging.getLogger(__name__) + + +def function_test(x: int) -> int: + """ + Returns the input value multiplied by 2 + + Args: + x (int): Value to multiply + + Returns: + int: input value multiplied by 2 + + Example: + >>> function_test(2) + 4 + """ + return x * 2 diff --git a/v8_server/version.py b/v8_server/version.py new file mode 100644 index 0000000..63d33c5 --- /dev/null +++ b/v8_server/version.py @@ -0,0 +1,20 @@ +from pathlib import Path + + +def get_version_number(): + # This file must exist in the root of the module, as the following code + # tries to find the module root so that it can find the VERSION file. + # project_root/ + # - module/ + # - VERSION + # - version.py + root_dir = Path(__file__).parent + version = "-1.-1.-1" + + with (root_dir / "VERSION").open() as version_file: + version = version_file.read().strip() + + return version + + +__version__ = get_version_number()