Initial Commit

This commit is contained in:
573dev 2020-10-13 11:42:12 -05:00
commit 2b4120ca2e
25 changed files with 492 additions and 0 deletions

4
.flake8 Normal file
View File

@ -0,0 +1,4 @@
[flake8]
ignore = E203, W503
max-line-length = 88
inline-quotes = double

103
.gitignore vendored Normal file
View File

@ -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/

2
.mypy.ini Normal file
View File

@ -0,0 +1,2 @@
[mypy]
ignore_missing_imports = True

11
.travis.yml Normal file
View File

@ -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

0
AUTHORS Normal file
View File

3
CHANGES.md Normal file
View File

@ -0,0 +1,3 @@
# 0.1.0 (October 13, 2020)
- Initial Release

19
LICENSE Normal file
View File

@ -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.

5
MANIFEST.in Normal file
View File

@ -0,0 +1,5 @@
include v8_server/VERSION
include VERSION
include README.md
include LICENSE
include CHANGES.md

8
README.md Normal file
View File

@ -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.

1
VERSION Symbolic link
View File

@ -0,0 +1 @@
v8_server/VERSION

View File

@ -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 -%}

View File

@ -0,0 +1 @@
{% extends "python/module.rst" %}

88
docs/conf.py Normal file
View File

@ -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)

View File

@ -0,0 +1,4 @@
## Template
Explain Template Here

8
docs/general/index.rst Normal file
View File

@ -0,0 +1,8 @@
General
=======
.. toctree::
:maxdepth: 1
:glob:
gen_*

25
docs/index.rst Normal file
View File

@ -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://>

22
pyproject.toml Normal file
View File

@ -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"

45
setup.py Normal file
View File

@ -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,
)

7
tests/test_template.py Normal file
View File

@ -0,0 +1,7 @@
from v8_server.template import function_test
def test_function_test():
data = 2
expected = 4
assert function_test(data) == expected

20
tests/test_version.py Normal file
View File

@ -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"""
^(?P<major>0|[1-9]\d*)\.
(?P<minor>0|[1-9]\d*)\.
(?P<patch>0|[1-9]\d*)
(?:-(?P<prerelease>(?: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<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$
""",
re.VERBOSE,
)
assert re.search(regex, get_version_number())

42
tox.ini Normal file
View File

@ -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

1
v8_server/VERSION Normal file
View File

@ -0,0 +1 @@
0.1.0

4
v8_server/__init__.py Normal file
View File

@ -0,0 +1,4 @@
from .version import __version__
__all__ = ["__version__"]

21
v8_server/template.py Normal file
View File

@ -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

20
v8_server/version.py Normal file
View File

@ -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()