1
0
mirror of https://github.com/enpaul/glassy.git synced 2024-11-10 16:46:51 +00:00

Initial commit

This commit is contained in:
Ethan Paul 2022-05-21 12:31:15 -04:00
commit 63a6421220
No known key found for this signature in database
GPG Key ID: D0E2CBF1245E92BF
13 changed files with 2501 additions and 0 deletions

7
.coveragerc Normal file
View File

@ -0,0 +1,7 @@
[run]
branch = True
[report]
exclude_lines =
\.\.\.
pass

109
.gitignore vendored Normal file
View File

@ -0,0 +1,109 @@
# 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
requirements.txt
# 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/
docs/awesome_template*.rst
docs/modules.rst
# 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/
# Pycharm
.idea/
.idea/vcs.xml

66
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,66 @@
---
repos:
- repo: local
hooks:
- id: end-of-file-fixer
name: end-of-file-fixer
entry: end-of-file-fixer
language: system
types:
- text
- id: fix-encoding-pragma
name: fix-encoding-pragma
entry: fix-encoding-pragma
language: system
args:
- "--remove"
types:
- python
- id: trailing-whitespace-fixer
name: trailing-whitespace-fixer
entry: trailing-whitespace-fixer
language: system
types:
- text
- id: check-merge-conflict
name: check-merge-conflict
entry: check-merge-conflict
language: system
types:
- text
- id: reorder-python-imports
name: reorder-python-imports
entry: reorder-python-imports
language: system
args:
- "--unclassifiable-application-module=glassy"
types:
- python
- id: black
name: black
entry: black
language: system
types:
- python
- id: blacken-docs
name: blacken-docs
entry: blacken-docs
language: system
types:
- text
- id: mdformat
name: mdformat
entry: mdformat
language: system
args:
- "--number"
- "--wrap=90"
types:
- markdown

55
.pylintrc Normal file
View File

@ -0,0 +1,55 @@
[MESSAGES CONTROL]
# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
# file where it should appear only once).You can also use "--disable=all" to
# disable everything first and then reenable specific checks. For example, if
# you want to run only the similarities checker, you can use "--disable=all
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=logging-fstring-interpolation
,logging-format-interpolation
,bad-continuation
,line-too-long
,ungrouped-imports
,typecheck
,wrong-import-order
,wrong-import-position
[REPORTS]
# Set the output format. Available formats are text, parseable, colorized, json
# and msvs (visual studio).You can also give a reporter class, eg
# mypackage.mymodule.MyReporterClass.
output-format=colorized
[BASIC]
# Good variable names which should always be accepted, separated by a comma
good-names=_,ip,T
[MISCELLANEOUS]
# Not FIXME or TODO
notes=XXX
[SIMILARITIES]
# Ignore imports when computing similarities.
ignore-imports=yes
# Ignore function signatures when computing similarities.
ignore-signatures=yes
# Minimum lines number of a similarity.
min-similarity-lines=10
[DESIGN]
# Maximum number of arguments for function / method
max-args=7

17
LICENSE.md Normal file
View File

@ -0,0 +1,17 @@
## Copyright 2022 Ethan Paul
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.

40
Makefile Normal file
View File

@ -0,0 +1,40 @@
# glassy makefile
.PHONY: help
# Put it first so that "make" without argument is like "make help"
# Adapted from:
# https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help: ## List Makefile targets
$(info Makefile documentation)
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-10s\033[0m %s\n", $$1, $$2}'
clean-tox:
rm --recursive --force ./.mypy_cache
rm --recursive --force ./.tox
rm --recursive --force tests/__pycache__/
rm --recursive --force .pytest_cache/
rm --force .coverage
clean-py:
rm --recursive --force ./dist
rm --recursive --force ./build
rm --recursive --force ./*.egg-info
rm --recursive --force ./**/__pycache__/
clean: clean-tox clean-py; ## Clean temp build/cache files and directories
wheel: ## Build Python binary distribution wheel package
poetry build --format wheel
source: ## Build Python source distribution package
poetry build --format sdist
test: ## Run the project testsuite(s)
poetry run tox --recreate --parallel
dev: ## Create the local dev environment
poetry install
poetry run pre-commit install
publish: test wheel source ## Build and upload to pypi (requires $PYPI_API_KEY be set)
@poetry publish --username __token__ --password $(PYPI_API_KEY)

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# glassy
ASCII-based network status diagram generator

8
glassy.py Normal file
View File

@ -0,0 +1,8 @@
"""Tool for generating cool ASCII-based network status panels"""
__title__ = "glassy"
__version__ = "0.1.0"
__license__ = "MIT"
__summary__ = "ASCII network status map generator"
__url__ = "https://github.com/enpaul/glassy/"
__authors__ = ["Ethan Paul <24588726+enpaul@users.noreply.github.com>"]

2031
poetry.lock generated Normal file

File diff suppressed because it is too large Load Diff

41
pyproject.toml Normal file
View File

@ -0,0 +1,41 @@
[tool.poetry]
name = "glassy"
version = "0.1.0"
license = "MIT"
authors = ["Ethan Paul <24588726+enpaul@users.noreply.github.com>"]
description = "ASCII network status map generator"
repository = "https://github.com/enpaul/glassy/"
packages = [
{include = "glassy.py"},
{include = "tests/*.py", format = "sdist"}
]
keywords = ["terminal", "ascii", "network", "monitoring", "dashboard"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.7"
colorama = "^0.4.4"
[tool.poetry.dev-dependencies]
bandit = "^1.6.2"
black = "^22.3.0"
blacken-docs = "^1.8.0"
ipython = "^7.18.1"
mdformat = "^0.6"
mdformat-gfm = "^0.2"
mypy = "^0.930"
pre-commit = "^2.7.1"
pre-commit-hooks = "^3.3.0"
pylint = "^2.4.4"
pytest = "^6.0.2"
pytest-cov = "^2.10.1"
reorder-python-imports = "^2.3.5"
safety = "^1.9.0"
toml = "^0.10.1"
tox = "^3.20.0"
tox-poetry-installer = {extras = ["poetry"], version = "^0.8.3"}
types-toml = "^0.10.1"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

0
tests/__init__.py Normal file
View File

37
tests/test_metadata.py Normal file
View File

@ -0,0 +1,37 @@
"""Ensure that the pyproject and module metadata never drift out of sync
The next best thing to having one source of truth is having a way to ensure all of your
sources of truth agree with each other.
"""
from pathlib import Path
import toml
import glassy
def test_metadata():
"""Test that module metadata matches pyproject poetry metadata"""
with (Path(__file__).resolve().parent / ".." / "pyproject.toml").open() as infile:
pyproject = toml.load(infile, _dict=dict)
assert pyproject["tool"]["poetry"]["name"] == glassy.__title__
assert pyproject["tool"]["poetry"]["version"] == glassy.__version__
assert pyproject["tool"]["poetry"]["license"] == glassy.__license__
assert pyproject["tool"]["poetry"]["description"] == glassy.__summary__
assert pyproject["tool"]["poetry"]["repository"] == glassy.__url__
assert (
all(
item in glassy.__authors__
for item in pyproject["tool"]["poetry"]["authors"]
)
is True
)
assert (
all(
item in pyproject["tool"]["poetry"]["authors"]
for item in glassy.__authors__
)
is True
)

87
tox.ini Normal file
View File

@ -0,0 +1,87 @@
[tox]
envlist = py37, py38, py39, py310, static, static-tests, security
isolated_build = true
skip_missing_interpreters = true
[testenv]
description = Run the tests
require_locked_deps = true
require_poetry = true
locked_deps =
pytest
pytest-cov
toml
commands =
pytest {toxinidir}/tests/ \
--cov glassy \
--cov-config {toxinidir}/.coveragerc \
--cov-report term-missing
[testenv:static]
description = Static formatting and quality enforcement
basepython = python3.8
platform = linux
ignore_errors = true
locked_deps =
black
blacken-docs
mdformat
mdformat-gfm
mypy
reorder-python-imports
pre-commit
pre-commit-hooks
pylint
types-toml
commands =
pre-commit run \
--all-files
pylint {toxinidir}/glassy.py \
--rcfile {toxinidir}/.pylintrc
mypy {toxinidir}/glassy.py \
--ignore-missing-imports \
--no-strict-optional
[testenv:static-tests]
description = Static formatting and quality enforcement for the tests
basepython = python3.8
platform = linux
ignore_errors = true
locked_deps =
pylint
pytest
mypy
types-toml
commands =
pylint {toxinidir}/tests/ \
--rcfile {toxinidir}/.pylintrc
mypy {toxinidir}/tests/ \
--ignore-missing-imports \
--no-strict-optional
[testenv:security]
description = Security checks
basepython = python3.8
platform = linux
ignore_errors = true
skip_install = true
locked_deps =
bandit
safety
poetry
commands =
bandit {toxinidir}/glassy.py \
--recursive \
--quiet
bandit {toxinidir}/tests/ \
--recursive \
--quiet \
--skip B101
poetry export \
--format requirements.txt \
--output {envtmpdir}/requirements.txt \
--without-hashes \
--dev
safety check \
--file {envtmpdir}/requirements.txt \
--json