freemt commited on
Commit
141bb9b
0 Parent(s):

First commit

Browse files
.flake8 ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [flake8]
2
+ ignore =
3
+ D203,
4
+ # line too long
5
+ E501
6
+ per-file-ignores =
7
+ # imported but unused
8
+ # __init__.py: F401
9
+ test_*.py: F401
10
+ exclude =
11
+ .git,
12
+ __pycache__,
13
+ docs/source/conf.py,
14
+ old,
15
+ build,
16
+ dist,
17
+ .venv
18
+ pad*.py
19
+ max-complexity = 25
.github/workflows/codeql-analysis.yml- ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL"
13
+
14
+ on:
15
+ push:
16
+ branches: [ master ]
17
+ pull_request:
18
+ # The branches below must be a subset of the branches above
19
+ branches: [ master ]
20
+ schedule:
21
+ - cron: '16 15 * * 2'
22
+
23
+ jobs:
24
+ analyze:
25
+ name: Analyze
26
+ runs-on: ubuntu-latest
27
+
28
+ strategy:
29
+ fail-fast: false
30
+ matrix:
31
+ language: [ 'python' ]
32
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
33
+ # Learn more:
34
+ # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
35
+
36
+ steps:
37
+ - name: Checkout repository
38
+ uses: actions/checkout@v2
39
+
40
+ # Initializes the CodeQL tools for scanning.
41
+ - name: Initialize CodeQL
42
+ uses: github/codeql-action/init@v1
43
+ with:
44
+ languages: ${{ matrix.language }}
45
+ # If you wish to specify custom queries, you can do so here or in a config file.
46
+ # By default, queries listed here will override any specified in a config file.
47
+ # Prefix the list here with "+" to use these queries and those in the config file.
48
+ # queries: ./path/to/local/query, your-org/your-repo/queries@main
49
+
50
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
51
+ # If this step fails, then you should remove it and run the build manually (see below)
52
+ - name: Autobuild
53
+ uses: github/codeql-action/autobuild@v1
54
+
55
+ # ℹ️ Command-line programs to run using the OS shell.
56
+ # 📚 https://git.io/JvXDl
57
+
58
+ # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
59
+ # and modify them (or add more) to build your code if your project
60
+ # uses a compiled language
61
+
62
+ #- run: |
63
+ # make bootstrap
64
+ # make release
65
+
66
+ - name: Perform CodeQL Analysis
67
+ uses: github/codeql-action/analyze@v1
.github/workflows/routine-tests.yml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: pytest
2
+
3
+ on:
4
+ push:
5
+
6
+ jobs:
7
+ flake8-pytest:
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ python-version: [3.8]
12
+ poetry-version: [1.1.2]
13
+ os: [ubuntu-18.04, macos-latest, windows-latest]
14
+ runs-on: ${{ matrix.os }}
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - uses: actions/setup-python@v2
18
+ with:
19
+ python-version: ${{ matrix.python-version }}
20
+ - uses: abatilo/actions-poetry@v2.0.0
21
+ with:
22
+ poetry-version: ${{ matrix.poetry-version }}
23
+ - name: Install packages
24
+ run: poetry install # --no-dev
25
+ - name: Run flake8
26
+ run: |
27
+ poetry run flake8 --exit-zero
28
+ # poetry run pytest
29
+ - name: Run pytest
30
+ run: poetry run pytest tests
.gitignore ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
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
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
98
+ __pypackages__/
99
+
100
+ # Celery stuff
101
+ celerybeat-schedule
102
+ celerybeat.pid
103
+
104
+ # SageMath parsed files
105
+ *.sage.py
106
+
107
+ # Environments
108
+ .env
109
+ .venv
110
+ env/
111
+ venv/
112
+ ENV/
113
+ env.bak/
114
+ venv.bak/
115
+
116
+ # Spyder project settings
117
+ .spyderproject
118
+ .spyproject
119
+
120
+ # Rope project settings
121
+ .ropeproject
122
+
123
+ # mkdocs documentation
124
+ /site
125
+
126
+ # mypy
127
+ .mypy_cache/
128
+ .dmypy.json
129
+ dmypy.json
130
+
131
+ # Pyre type checker
132
+ .pyre/
133
+
134
+ # pytype static type analyzer
135
+ .pytype/
136
+
137
+ # Cython debug symbols
138
+ cython_debug/
139
+ *.bat
140
+ *.swp
141
+ links/
142
+ # .gitignore
143
+ node_modules
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2020 ffreemt
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.
README1.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # bloom-tr
2
+ [![pytest](https://github.com/ffreemt/bloom-tr/actions/workflows/routine-tests.yml/badge.svg)](https://github.com/ffreemt/bloom-tr/actions)[![python](https://img.shields.io/static/v1?label=python+&message=3.8%2B&color=blue)](https://www.python.org/downloads/)[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)[![PyPI version](https://badge.fury.io/py/bloom_tr.svg)](https://badge.fury.io/py/bloom_tr)
3
+
4
+ Translate via Bloom
5
+
6
+ ## Install it
7
+
8
+ ```shell
9
+ pip install bloom-tr
10
+ # pip install git+https://github.com/ffreemt/bloom-tr
11
+ # poetry add git+https://github.com/ffreemt/bloom-tr
12
+ # git clone https://github.com/ffreemt/bloom-tr && cd bloom-tr
13
+ ```
14
+
15
+ ## Use it
16
+ ```python
17
+ from bloom_tr import bloom_tr
18
+
19
+ ```
bloom_tr/__init__.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ """Init."""
2
+ __version__ = "0.1.0a0"
3
+ from .bloom_tr import bloom_tr
4
+
5
+ __all__ = ("bloom_tr",)
bloom_tr/__main__.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Prep __main__.py."""
2
+ # pylint: disable=invalid-name
3
+ from pathlib import Path
4
+ from typing import Optional
5
+
6
+ import logzero
7
+ import typer
8
+ from logzero import logger
9
+ from set_loglevel import set_loglevel
10
+
11
+ from bloom_tr import __version__, bloom_tr
12
+
13
+ logzero.loglevel(set_loglevel())
14
+
15
+ app = typer.Typer(
16
+ name="bloom_tr",
17
+ add_completion=False,
18
+ help="bloom_tr help",
19
+ )
20
+
21
+
22
+ def _version_callback(value: bool) -> None:
23
+ if value:
24
+ typer.echo(f"{app.info.name} v.{__version__} -- ...")
25
+ raise typer.Exit()
26
+
27
+
28
+ @app.command()
29
+ def main(
30
+ version: Optional[bool] = typer.Option( # pylint: disable=(unused-argument
31
+ None,
32
+ "--version",
33
+ "-v",
34
+ "-V",
35
+ help="Show version info and exit.",
36
+ callback=_version_callback,
37
+ is_eager=True,
38
+ ),
39
+ ):
40
+ """Define."""
41
+
42
+
43
+ if __name__ == "__main__":
44
+ app()
bloom_tr/bloom_tr.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ """Define bloom_tr."""
2
+ from logzero import logger
3
+
4
+
5
+ def bloom_tr():
6
+ """Define bloom_tr."""
7
+ logger.debug(" entry ")
nodemon.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "restartable": "rs",
3
+ "ignore": [
4
+ ".venv",
5
+ ".git",
6
+ "node_modules/**/node_modules"
7
+ ],
8
+ "verbose": true,
9
+ "execMap": {
10
+ "js": "node --harmony"
11
+ },
12
+ "watch": [
13
+ "tests",
14
+ "test/fixtures/",
15
+ "test/samples/"
16
+ ],
17
+ "env": {
18
+ "NODE_ENV": "development"
19
+ },
20
+ "ext": "js json py"
21
+ }
package.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "dependencies": {
3
+ "npm-run-all": "^4.1.5"
4
+ },
5
+ "scripts": {
6
+ "start": "pyright && pytest && yarn style",
7
+ "test": "nodemon -w tests -w bloom_tr -x pytest tests",
8
+ "pyright": "nodemon -w bloom_tr -w .venv -e .py -x pyright bloom_tr tests",
9
+ "pytest": "nodemon -w tests -w bloom_tr -e .py -x pytest tests bloom_tr",
10
+ "style": "nodemon -w bloom_tr -w tests -x \"black tests bloom_tr && python -m flake8\"",
11
+ "docstyle": "nodemon -w bloom_tr -w tests -x pydocstyle --convention=google tests bloom_tr",
12
+ "pylint": "nodemon -w bloom_tr -e .py -x pylint bloom_tr",
13
+ "test:bloom_tr": "nodemon -w tests -e .py -x pytest -k bloom_tr tests",
14
+ "publish": "poetry build && poetry publish",
15
+ "black": "black tests bloom_tr",
16
+ "flake8": "flake8 tests bloom_tr",
17
+ "pflake8": "pflake8 tests bloom_tr",
18
+ "pep257": "pep257 tests bloom_tr",
19
+ "final": "run-s docstyle black flake8 pytest"
20
+ }
21
+ }
poetry.toml ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ [virtualenvs]
2
+ create = true
3
+ in-project = true
pylintrc ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ [EXCEPTIONS]
2
+ # C0301 line too long
3
+ # R0801 dup
4
+ # C0103 invalid-name
5
+ # W0612 unused-variable
6
+ # W0611 unused-import
7
+ disable=W0703,R0801,C0103,C0301,W0612,W0611
pyproject.toml ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [tool.poetry]
2
+ name = "bloom_tr"
3
+ version = "0.1.0-alpha.0"
4
+ description = "Translate via Bloom"
5
+ authors = ["ffreemt"]
6
+ license = "MIT"
7
+ readme = "README1.md"
8
+ repository = "https://github.com/ffreemt/bloom-tr"
9
+
10
+ [tool.poetry.dependencies]
11
+ python = "^3.8.3"
12
+ logzero = "^1.7.0"
13
+ set-loglevel = "^0.1.2"
14
+ typer = "^0.4.1"
15
+ icecream = "^2.1.1"
16
+ install = "^1.3.5"
17
+
18
+ [tool.poe.executor]
19
+ type = "poetry"
20
+
21
+ [tool.poe.tasks]
22
+ memo = "echo poe test or poetry run poe test"
23
+ test = "pytest tests"
24
+ pyright = "pyright bloom_tr"
25
+ flake8 = "flake8 bloom_tr --ignore F401,E501,F841"
26
+ check = ["pyright", "flake8"]
27
+ export = "poetry export --without-hashes -f requirements.txt -o requirements.txt"
28
+ build = "poetry build"
29
+ publish = "poetry publish"
30
+ release = ["test", "build", "publish"]
31
+ lint = { cmd = "pylint bloom_tr" }
32
+ isort = "isort tests bloom_tr"
33
+ black = "black tests bloom_tr"
34
+ format = ["isort", "black"]
35
+ docstyle = "pydocstyle --convention=google tests bloom_tr"
36
+ prerelease = {cmd = "poetry version prerelease && sync-version"}
37
+ tunnel = {cmd = "ssh -CN ip_or_hostname_defined_in_hosts -L 9091:127.0.0.1:9091"}
38
+
39
+ [tool.poetry.dev-dependencies]
40
+ pytest = "^7.1"
41
+ flake8 = "^3.9.2"
42
+ isort = "^5.10.1"
43
+ black = "^22.3.0"
44
+ pylint = "^2.14.2"
45
+ pyright = "^1.1.254"
46
+ pydocstyle = "^6.1.1"
47
+ toml = "^0.10.2"
48
+ # tbump = "^6.3.2"
49
+ poethepoet = "^0.10.0"
50
+
51
+ [tool.poetry.scripts]
52
+ "bloom-tr" = "bloom_tr.__main__:app"
53
+
54
+ [build-system]
55
+ requires = ["poetry-core>=1.0.0"]
56
+ build-backend = "poetry.core.masonry.api"
57
+
58
+ [tool.pytest.ini_options]
59
+ minversion = "6.0"
60
+ addopts = "-ra -q --doctest-modules"
61
+ log_cli = true
62
+ testpaths = [
63
+ "tests",
64
+ # "integration",
65
+ ]
66
+
67
+ [tool.black]
68
+ skip-string-normalization = 0
69
+
70
+ [tool.isort]
71
+ profile = "black"
72
+ multi_line_output = 3
pyrightconfig.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "include": ["tests", "bloom_tr"],
3
+ "venvPath": ".venv",
4
+ "reportTypeshedErrors": false,
5
+ "reportMissingImports": true,
6
+ "reportMissingTypeStubs": false,
7
+ "pythonVersion": "3.8",
8
+ "ignore": []
9
+ }
tests/__init__.py ADDED
@@ -0,0 +1 @@
 
1
+ """Init."""
tests/test_bloom_tr.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Test bloom_tr."""
2
+ # pylint: disable=broad-except
3
+ from bloom_tr import __version__
4
+ from bloom_tr import bloom_tr
5
+
6
+
7
+ def test_version():
8
+ """Test version."""
9
+ assert __version__[:3] == "0.1"
10
+
11
+
12
+ def test_sanity():
13
+ """Check sanity."""
14
+ try:
15
+ assert not bloom_tr()
16
+ except Exception:
17
+ assert True