Initial commit
This commit is contained in:
commit
8466e8bc6c
161
.drone.star
Normal file
161
.drone.star
Normal file
@ -0,0 +1,161 @@
|
||||
# Build pipelines
|
||||
|
||||
PYTHON_VERSIONS = [
|
||||
"3.6",
|
||||
"3.7",
|
||||
"3.8",
|
||||
"3.9",
|
||||
"latest",
|
||||
]
|
||||
|
||||
PYPY3_VERSIONS = [
|
||||
"3",
|
||||
]
|
||||
|
||||
|
||||
def main(ctx):
|
||||
pipelines = []
|
||||
|
||||
# Run tests
|
||||
pipelines += tests()
|
||||
|
||||
# Add pypi push pipeline
|
||||
pipelines += push_to_pypi()
|
||||
|
||||
# Add notifications
|
||||
pipeline_names = [
|
||||
pipeline["name"] for pipeline in pipelines
|
||||
]
|
||||
pipelines += notify(pipeline_names)
|
||||
|
||||
return pipelines
|
||||
|
||||
|
||||
# Return workspace in the container
|
||||
def get_workspace():
|
||||
return {
|
||||
"base": "/app",
|
||||
"path": ".",
|
||||
}
|
||||
|
||||
|
||||
# Builds a list of all test pipelines to be executed
|
||||
def tests():
|
||||
return [{
|
||||
"kind": "pipeline",
|
||||
"name": "tests",
|
||||
"workspace": get_workspace(),
|
||||
"steps": [
|
||||
tox_step("python:"+version)
|
||||
for version in PYTHON_VERSIONS
|
||||
] + [
|
||||
tox_step("pypy:"+version, "pypy3", "pypy3")
|
||||
for version in PYPY3_VERSIONS
|
||||
],
|
||||
}]
|
||||
|
||||
|
||||
# Builds a single python test step
|
||||
def tox_step(docker_tag, python_cmd="python", tox_env="py3"):
|
||||
return {
|
||||
"name": "test {}".format(docker_tag.replace(":", "")),
|
||||
"image": docker_tag,
|
||||
"environment": {
|
||||
"TOXENV": tox_env,
|
||||
},
|
||||
"commands": [
|
||||
"{} -V".format(python_cmd),
|
||||
"pip install tox",
|
||||
"tox",
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
# Builds a notify step that will notify when the previous step changes
|
||||
def notify_step():
|
||||
return {
|
||||
"name": "notify",
|
||||
"image": "drillster/drone-email",
|
||||
"settings": {
|
||||
"host": {
|
||||
"from_secret": "SMTP_HOST",
|
||||
},
|
||||
"username": {
|
||||
"from_secret": "SMTP_USER",
|
||||
},
|
||||
"password": {
|
||||
"from_secret": "SMTP_PASS",
|
||||
},
|
||||
"from": "drone@iamthefij.com",
|
||||
},
|
||||
"when": {
|
||||
"status": [
|
||||
"changed",
|
||||
"failure",
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
# Builds a notify pipeline that will notify when a dependency fails
|
||||
def notify(depends_on=None):
|
||||
if not depends_on:
|
||||
depends_on = ["tests"]
|
||||
|
||||
return [{
|
||||
"kind": "pipeline",
|
||||
"name": "notify",
|
||||
"depends_on": depends_on,
|
||||
"trigger": {"status": ["failure"]},
|
||||
"steps": [notify_step()]
|
||||
}]
|
||||
|
||||
|
||||
# Push package to pypi
|
||||
def push_to_pypi():
|
||||
return [{
|
||||
"kind": "pipeline",
|
||||
"name": "deploy to pypi",
|
||||
"depends_on": ["tests"],
|
||||
"workspace": get_workspace(),
|
||||
"trigger": {
|
||||
"event": ["tag"],
|
||||
"ref": [
|
||||
"refs/heads/master",
|
||||
"refs/tags/v*",
|
||||
],
|
||||
},
|
||||
"steps": [
|
||||
{
|
||||
"name": "push to test pypi",
|
||||
"image": "python:3",
|
||||
"environment": {
|
||||
"TWINE_USERNAME": {
|
||||
"from_secret": "PYPI_USERNAME",
|
||||
},
|
||||
"TWINE_PASSWORD": {
|
||||
"from_secret": "TEST_PYPI_PASSWORD",
|
||||
},
|
||||
},
|
||||
"commands": ["make upload-test"],
|
||||
},
|
||||
{
|
||||
"name": "push to pypi",
|
||||
"image": "python:3",
|
||||
"environment": {
|
||||
"TWINE_USERNAME": {
|
||||
"from_secret": "PYPI_USERNAME",
|
||||
},
|
||||
"TWINE_PASSWORD": {
|
||||
"from_secret": "PYPI_PASSWORD",
|
||||
},
|
||||
},
|
||||
"commands": ["make upload"],
|
||||
"when": {
|
||||
"event": ["tag"],
|
||||
},
|
||||
},
|
||||
]
|
||||
}]
|
||||
|
||||
# vim: ft=python
|
141
.gitignore
vendored
Normal file
141
.gitignore
vendored
Normal file
@ -0,0 +1,141 @@
|
||||
# ---> Python
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# 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/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
.pybuilder/
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
# 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.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# Cython debug symbols
|
||||
cython_debug/
|
||||
|
||||
tags
|
26
.pre-commit-config.yaml
Normal file
26
.pre-commit-config.yaml
Normal file
@ -0,0 +1,26 @@
|
||||
---
|
||||
default_language_version:
|
||||
python: python3.8
|
||||
repos:
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 20.8b1
|
||||
hooks:
|
||||
- id: black
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v3.4.0
|
||||
hooks:
|
||||
- id: check-added-large-files
|
||||
- id: check-merge-conflict
|
||||
- id: debug-statements
|
||||
- id: end-of-file-fixer
|
||||
- id: trailing-whitespace
|
||||
- id: name-tests-test
|
||||
exclude: tests/(common.py|util.py|(helpers|integration/factories)/(.+).py)
|
||||
- repo: https://github.com/asottile/reorder_python_imports
|
||||
rev: v2.4.0
|
||||
hooks:
|
||||
- id: reorder-python-imports
|
||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||
rev: v0.800
|
||||
hooks:
|
||||
- id: mypy
|
19
LICENSE
Normal file
19
LICENSE
Normal file
@ -0,0 +1,19 @@
|
||||
MIT License Copyright (c) 2021 iamthefij
|
||||
|
||||
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 (including the next
|
||||
paragraph) 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.
|
116
Makefile
Normal file
116
Makefile
Normal file
@ -0,0 +1,116 @@
|
||||
OPEN_CMD := $(shell type xdg-open &> /dev/null && echo 'xdg-open' || echo 'open')
|
||||
NAME := unhacs
|
||||
ENV := env
|
||||
|
||||
.PHONY: default
|
||||
default: test
|
||||
|
||||
# Creates virtualenv
|
||||
$(ENV):
|
||||
python3 -m venv $(ENV)
|
||||
|
||||
# Install package and dependencies in virtualenv
|
||||
$(ENV)/bin/$(NAME): $(ENV)
|
||||
$(ENV)/bin/pip install -r requirements-dev.txt
|
||||
|
||||
# Install tox into virtualenv for running tests
|
||||
$(ENV)/bin/tox: $(ENV)
|
||||
$(ENV)/bin/pip install tox
|
||||
|
||||
# Install wheel for building packages
|
||||
$(ENV)/bin/wheel: $(ENV)
|
||||
$(ENV)/bin/pip install wheel
|
||||
|
||||
# Install twine for uploading packages
|
||||
$(ENV)/bin/twine: $(ENV)
|
||||
$(ENV)/bin/pip install twine
|
||||
|
||||
# Installs dev requirements to virtualenv
|
||||
.PHONY: devenv
|
||||
devenv: $(ENV)/bin/$(NAME)
|
||||
|
||||
# Generates a smaller env for running tox, which builds it's own env
|
||||
.PHONY: test-env
|
||||
test-env: $(ENV)/bin/tox
|
||||
|
||||
# Generates a small build env for building and uploading dists
|
||||
.PHONY: build-env
|
||||
build-env: $(ENV)/bin/twine $(ENV)/bin/wheel
|
||||
|
||||
# Runs package
|
||||
.PHONY: run
|
||||
run: $(ENV)/bin/$(NAME)
|
||||
$(ENV)/bin/$(NAME)
|
||||
|
||||
# Runs tests with tox
|
||||
.PHONY: test
|
||||
test: $(ENV)/bin/tox
|
||||
$(ENV)/bin/tox
|
||||
|
||||
# Builds wheel for package to upload
|
||||
.PHONY: build
|
||||
build: $(ENV)/bin/wheel
|
||||
$(ENV)/bin/python setup.py sdist
|
||||
$(ENV)/bin/python setup.py bdist_wheel
|
||||
|
||||
# Verify that the python version matches the git tag so we don't push bad shas
|
||||
.PHONY: verify-tag-version
|
||||
verify-tag-version:
|
||||
$(eval TAG_NAME = $(shell [ -n "$(DRONE_TAG)" ] && echo $(DRONE_TAG) || git describe --tags --exact-match))
|
||||
test "v$(shell python setup.py -V)" = "$(TAG_NAME)"
|
||||
|
||||
# Uses twine to upload to pypi
|
||||
.PHONY: upload
|
||||
upload: verify-tag-version build $(ENV)/bin/twine
|
||||
$(ENV)/bin/twine upload dist/*
|
||||
|
||||
# Uses twine to upload to test pypi
|
||||
.PHONY: upload-test
|
||||
upload-test: verify-tag-version build $(ENV)/bin/twine
|
||||
$(ENV)/bin/twine upload --repository-url https://test.pypi.org/legacy/ dist/*
|
||||
|
||||
# Cleans all build, runtime, and test artifacts
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -fr ./build *.egg-info ./htmlcov ./.coverage ./.pytest_cache ./.tox
|
||||
find . -name '*.pyc' -delete
|
||||
find . -name '__pycache__' -delete
|
||||
|
||||
# Cleans dist and env
|
||||
.PHONY: dist-clean
|
||||
dist-clean: clean
|
||||
rm -fr ./dist $(ENV)
|
||||
|
||||
# Install pre-commit hooks
|
||||
.PHONY: install-hooks
|
||||
install-hooks: devenv
|
||||
$(ENV)/bin/pre-commit install -f --install-hooks
|
||||
|
||||
# Generates test coverage
|
||||
.coverage:
|
||||
$(ENV)/bin/tox
|
||||
|
||||
# Builds coverage html
|
||||
htmlcov/index.html: .coverage
|
||||
$(ENV)/bin/coverage html
|
||||
|
||||
# Opens coverage html in browser (on macOS and some Linux systems)
|
||||
.PHONY: open-coverage
|
||||
open-coverage: htmlcov/index.html
|
||||
$(OPEN_CMD) htmlcov/index.html
|
||||
|
||||
# Cleans out docs
|
||||
.PHONY: docs-clean
|
||||
docs-clean:
|
||||
rm -fr docs/build/* docs/source/code/*
|
||||
|
||||
# Builds docs
|
||||
docs/build/html/index.html:
|
||||
$(ENV)/bin/tox -e docs
|
||||
|
||||
# Shorthand for building docs
|
||||
.PHONY: docs
|
||||
docs: docs/build/html/index.html
|
||||
|
||||
.PHONY: clean-all
|
||||
clean-all: clean dist-clean docs-clean
|
7
README.md
Normal file
7
README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# unhacs
|
||||
|
||||
A command line alternative to the "Home Assistant Community Store", aka HACS
|
||||
|
||||
## Original repo
|
||||
|
||||
Originally hosted at https://git.iamthefij.com/iamthefij/unhacs.git
|
52
docs/source/conf.py
Normal file
52
docs/source/conf.py
Normal file
@ -0,0 +1,52 @@
|
||||
# Configuration file for the Sphinx documentation builder.
|
||||
#
|
||||
# This file only contains a selection of the most common options. For a full
|
||||
# list see the documentation:
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
||||
|
||||
# -- Path setup --------------------------------------------------------------
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#
|
||||
# import os
|
||||
# import sys
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
project = 'unhacs'
|
||||
copyright = '2021, iamthefij'
|
||||
author = 'iamthefij'
|
||||
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This pattern also affects html_static_path and html_extra_path.
|
||||
exclude_patterns = []
|
||||
|
||||
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#
|
||||
html_theme = 'alabaster'
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
20
docs/source/index.rst
Normal file
20
docs/source/index.rst
Normal file
@ -0,0 +1,20 @@
|
||||
.. unhacs documentation master file, created by
|
||||
sphinx-quickstart on Fri Feb 5 15:06:05 2021.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
Welcome to unhacs's documentation!
|
||||
========================================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Contents:
|
||||
|
||||
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
4
requirements-dev.txt
Normal file
4
requirements-dev.txt
Normal file
@ -0,0 +1,4 @@
|
||||
-e .
|
||||
pytest
|
||||
coverage
|
||||
pre-commit
|
45
setup.py
Normal file
45
setup.py
Normal file
@ -0,0 +1,45 @@
|
||||
from codecs import open
|
||||
from os import path
|
||||
|
||||
from setuptools import find_packages
|
||||
from setuptools import setup
|
||||
|
||||
here = path.abspath(path.dirname(__file__))
|
||||
|
||||
# Get the long description from the README file
|
||||
with open(path.join(here, "README.md"), encoding="utf-8") as f:
|
||||
long_description = f.read()
|
||||
|
||||
setup(
|
||||
name="unhacs",
|
||||
version="0.0.0",
|
||||
description="A command line alternative to the "Home Assistant Community Store", aka HACS",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
url="https://git.iamthefij.com/iamthefij/unhacs.git",
|
||||
download_url=("https://git.iamthefij.com/iamthefij/unhacs.git/archive/master.tar.gz"),
|
||||
author="iamthefij",
|
||||
author_email="",
|
||||
classifiers=[
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.5",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
],
|
||||
keywords="",
|
||||
packages=find_packages(
|
||||
exclude=[
|
||||
"contrib",
|
||||
"docs",
|
||||
"examples",
|
||||
"scripts",
|
||||
"tests",
|
||||
]
|
||||
),
|
||||
install_requires=[],
|
||||
entry_points={
|
||||
"console_scripts": [
|
||||
"unhacs=unhacs:main",
|
||||
],
|
||||
},
|
||||
)
|
17
tox.ini
Normal file
17
tox.ini
Normal file
@ -0,0 +1,17 @@
|
||||
[tox]
|
||||
envlist = py3,pypy3
|
||||
|
||||
[testenv]
|
||||
deps =
|
||||
-rrequirements-dev.txt
|
||||
commands =
|
||||
coverage erase
|
||||
coverage run --source=unhacs/ -m pytest --capture=no -vv {posargs:tests}
|
||||
coverage report -m --fail-under 70
|
||||
pre-commit run --all-files
|
||||
|
||||
[testenv:pre-commit]
|
||||
deps =
|
||||
pre-commit
|
||||
commands =
|
||||
pre-commit {posargs}
|
Loading…
Reference in New Issue
Block a user