Skip to content

Commit 5675c9d

Browse files
committed
feat: zbase32 implementation
0 parents  commit 5675c9d

File tree

13 files changed

+1553
-0
lines changed

13 files changed

+1553
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.202.5/containers/python-3/.devcontainer/base.Dockerfile
2+
3+
# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster
4+
ARG VARIANT="3.10-bullseye"
5+
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
6+
7+
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
8+
ARG NODE_VERSION="none"
9+
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
10+
11+
# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
12+
# COPY requirements.txt /tmp/pip-tmp/
13+
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
14+
# && rm -rf /tmp/pip-tmp
15+
16+
# [Optional] Uncomment this section to install additional OS packages.
17+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
18+
# && apt-get -y install --no-install-recommends <your-package-list-here>
19+
20+
# [Optional] Uncomment this line to install global node packages.
21+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
22+
23+
RUN su vscode -c "curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python -" 2>&1
24+
25+
ENV PATH=$HOME/.local/bin:$PATH

.devcontainer/devcontainer.json

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.202.5/containers/python-3
3+
{
4+
"name": "Python 3",
5+
"runArgs": [
6+
"--init"
7+
],
8+
"build": {
9+
"dockerfile": "Dockerfile",
10+
"context": "..",
11+
"args": {
12+
// Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6
13+
// Append -bullseye or -buster to pin to an OS version.
14+
// Use -bullseye variants on local on arm64/Apple Silicon.
15+
"VARIANT": "3.10-bullseye",
16+
// Options
17+
"NODE_VERSION": "none"
18+
}
19+
},
20+
// Set *default* container specific settings.json values on container create.
21+
"settings": {
22+
"files.exclude": {
23+
"**/.git": true,
24+
"**/.DS_Store": true,
25+
"**/__pycache__": true,
26+
".mypy_cache": true,
27+
".pytest_cache": true,
28+
".coverage": true,
29+
},
30+
"files.autoSave": "onFocusChange",
31+
"editor.codeActionsOnSave": {
32+
"source.organizeImports": true
33+
},
34+
"editor.formatOnSave": true,
35+
"python.pythonPath": "/usr/local/bin/python",
36+
"python.languageServer": "Pylance",
37+
"python.linting.enabled": true,
38+
"python.linting.pylintEnabled": true,
39+
"python.formatting.provider": "black",
40+
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
41+
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
42+
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
43+
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
44+
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
45+
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
46+
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
47+
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
48+
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint",
49+
"python.venvFolders": [
50+
"~/.cache/pypoetry/virtualenvs/"
51+
],
52+
"python.sortImports.args": [
53+
"--profile",
54+
"black"
55+
],
56+
},
57+
// Add the IDs of extensions you want installed when the container is created.
58+
"extensions": [
59+
"ms-python.python",
60+
"ms-python.vscode-pylance",
61+
"bungcip.better-toml"
62+
],
63+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
64+
// "forwardPorts": [],
65+
// Use 'postCreateCommand' to run commands after the container is created.
66+
"postCreateCommand": "make setup",
67+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
68+
"remoteUser": "vscode",
69+
"features": {
70+
"git": "os-provided",
71+
"github-cli": "latest",
72+
}
73+
}

.github/workflow/ci.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: zbase32 ci
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
container: python:3.9
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
17+
- name: install poetry
18+
run: curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python -
19+
20+
- name: update path
21+
run: echo "$HOME/.poetry/bin" >> $GITHUB_PATH
22+
23+
- name: setup and run tests
24+
run: make setup ci

.gitignore

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# IPython
81+
profile_default/
82+
ipython_config.py
83+
84+
# pyenv
85+
.python-version
86+
87+
# pipenv
88+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91+
# install all needed dependencies.
92+
#Pipfile.lock
93+
94+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95+
__pypackages__/
96+
97+
# Celery stuff
98+
celerybeat-schedule
99+
celerybeat.pid
100+
101+
# SageMath parsed files
102+
*.sage.py
103+
104+
# Environments
105+
.env
106+
.venv
107+
env/
108+
venv/
109+
ENV/
110+
env.bak/
111+
venv.bak/
112+
113+
# Spyder project settings
114+
.spyderproject
115+
.spyproject
116+
117+
# Rope project settings
118+
.ropeproject
119+
120+
# mkdocs documentation
121+
/site
122+
123+
# mypy
124+
.mypy_cache/
125+
.dmypy.json
126+
dmypy.json
127+
128+
# Pyre type checker
129+
.pyre/

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
minimum_pre_commit_version: '2.9.0'
2+
repos:
3+
- repo: https://github.com/Zac-HD/shed
4+
rev: 0.4.2
5+
hooks:
6+
- id: shed
7+
args: [--refactor, --py39-plus]
8+
types_or: [python, markdown, rst]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Artisan of Code
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
bootstrap:
2+
poetry install
3+
poetry run pre-commit install --install-hooks
4+
5+
ci:
6+
poetry run black --check src tests
7+
poetry run flake8 --max-line-length 88 --ignore E203
8+
poetry run mypy src tests
9+
poetry run pylint src tests
10+
poetry run pytest -Werror --tb=short --cov=zbase32 --cov-branch --cov-report=term-missing:skip-covered --cov-fail-under=100
11+
12+
console:
13+
poetry run python
14+
15+
format:
16+
poetry run shed --py39-plus --refactor src/**/*.py tests/*.py README.md
17+
18+
server: update
19+
exit
20+
21+
setup: bootstrap
22+
23+
test:
24+
poetry run black --check src tests
25+
poetry run flake8 --max-line-length 88 --ignore E203
26+
poetry run mypy src tests
27+
poetry run pylint src tests
28+
poetry run pytest -Werror --tb=short --cov=zbase32 --cov-branch --cov-report=term-missing:skip-covered --cov-fail-under=100
29+
30+
update: bootstrap
31+
32+
.PHONY: bootstrap ci console format server setup test update

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# zbase32
2+
3+
A human-oriented base-32 encoding.
4+
5+
## 🛠 Installing
6+
7+
## poetry
8+
9+
```
10+
poetry add python-zbase32
11+
```
12+
13+
## pip
14+
15+
```
16+
pip install python-zbase32
17+
```
18+
19+
## 🎓 Usage
20+
21+
```pycon
22+
>>> import zbase32
23+
>>> zbase32.encode(b"asdasd")
24+
'cf3seamuco'
25+
>>> zbase32.decode("cf3seamu")
26+
b"asdas"
27+
```
28+
29+
## 🔧 Development
30+
31+
| Command | Description |
32+
| ----------------- | ------------------------------------- |
33+
| `make bootstrap` | install project dependencies |
34+
| `make ci` | run continuous integration tasks |
35+
| `make console` | open a repl console |
36+
| `make format` | format all source files |
37+
| `make setup` | setup the project after a `git clone` |
38+
| `make test` | run the applications test suite |
39+
| `make update` | update the project after a `git pull` |
40+
41+
## ⚖️ Licence
42+
43+
This project is licensed under the [MIT licence](http://dan.mit-license.org/).
44+
45+
All documentation and images are licenced under the
46+
[Creative Commons Attribution-ShareAlike 4.0 International License][cc_by_sa].
47+
48+
[cc_by_sa]: https://creativecommons.org/licenses/by-sa/4.0/
49+
50+
## 📝 Meta
51+
52+
This project uses [Semantic Versioning](http://semver.org/).

0 commit comments

Comments
 (0)