-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e901155
commit ededb08
Showing
14 changed files
with
582 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto | ||
*.py eol=lf | ||
*.sh text eol=lf | ||
*.bat text eol=crlf | ||
*.patch text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: Python package | ||
|
||
on: | ||
push: | ||
branches: [ "devel" ] | ||
pull_request: | ||
branches: [ "devel" ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Build python package | ||
run: make build install | ||
- name: Analysing the code with pylint | ||
run: make pylint | ||
- name: Lint with flake8 | ||
run: make flake8 | ||
# - name: Test with pytest | ||
# run: make pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
# 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/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
.pypirc | ||
|
||
# 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/ | ||
.stestr | ||
.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 | ||
|
||
# poetry | ||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. | ||
# This is especially recommended for binary packages to ensure reproducibility, and is more | ||
# commonly ignored for libraries. | ||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control | ||
#poetry.lock | ||
|
||
# pdm | ||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. | ||
#pdm.lock | ||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it | ||
# in version control. | ||
# https://pdm.fming.dev/#use-with-ide | ||
.pdm.toml | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm | ||
__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/ | ||
|
||
# PyCharm | ||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can | ||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore | ||
# and can be added to the global gitignore or merged into this file. For a more nuclear | ||
# option (not recommended) you can uncomment the following to ignore the entire idea folder. | ||
#.idea/ | ||
|
||
# example | ||
example/docker-compose.yml | ||
example/*/docker-compose.yml | ||
example/modify/*.yml.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[MASTER] | ||
disable= | ||
C0114, # missing-module-docstring | ||
C0115, # missing-class-docstring | ||
C0116, # missing-function-docstring |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"[python]": { | ||
"editor.defaultFormatter": "ms-python.autopep8", | ||
// "editor.defaultFormatter": "ms-python.black-formatter", | ||
}, | ||
"python.analysis.importFormat": "relative", | ||
"python.analysis.typeCheckingMode": "basic", | ||
"python.testing.unittestEnabled": true, | ||
"autopep8.args": [ | ||
"--ignore-local-config", | ||
], | ||
"flake8.args": [ | ||
"--max-line-length=79", | ||
"--ignore=C901,E117,E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E251,E402,H202,H216,H405,W503,W504,W605", | ||
], | ||
"pylint.args": [ | ||
"--errors-only" | ||
], | ||
"isort.check": true, | ||
"isort.args": [ | ||
"--force-alphabetical-sort-within-sections", | ||
"--force-sort-within-sections", | ||
"--force-single-line-imports", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
MAKEFLAGS += --always-make | ||
|
||
all: build reinstall test | ||
|
||
|
||
clean-cover: | ||
rm -rf cover .coverage | ||
|
||
clean-tox: clean-cover | ||
rm -rf .stestr .tox | ||
|
||
clean: build-clean clean-tox | ||
|
||
|
||
upgrade: | ||
pip3 install -i https://pypi.org/simple --upgrade dockloader | ||
|
||
|
||
upload: | ||
xpip-upload --config-file .pypirc dist/* | ||
|
||
|
||
build-clean: | ||
xpip-build --debug setup --clean | ||
build-install-requirements: | ||
pip3 install -r requirements.txt xpip.build | ||
build: build-clean build-install-requirements | ||
xpip-build --debug setup --all | ||
|
||
|
||
install: | ||
pip3 install dist/*.whl | ||
uninstall: | ||
pip3 uninstall -y casm | ||
reinstall: uninstall | ||
pip3 install --force-reinstall --no-deps dist/*.whl | ||
|
||
|
||
prepare-test: | ||
pip3 install --upgrade pylint flake8 pytest | ||
|
||
pylint: | ||
pylint $$(git ls-files casm/*.py test/*.py example/*.py) | ||
|
||
flake8: | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
|
||
pytest: | ||
pytest | ||
|
||
test: prepare-test pylint flake8 pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# coding:utf-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# coding:utf-8 | ||
|
||
from urllib.parse import urljoin | ||
|
||
__project__ = "dockloader" | ||
__version__ = "0.1.alpha.1" | ||
__description__ = "Docker Image Downloader." | ||
__url_home__ = "https://github.com/podboy/dockloader/" | ||
__url_code__ = __url_home__ | ||
__url_docs__ = __url_home__ | ||
__url_bugs__ = urljoin(__url_home__, "issues") | ||
|
||
# author | ||
__author__ = "Mingzhe Zou" | ||
__author_email__ = "zoumingzhe@outlook.com" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# coding:utf-8 | ||
|
||
import re | ||
from typing import Optional | ||
from urllib.parse import urlparse | ||
|
||
|
||
def pull() -> bool: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# coding:utf-8 | ||
|
||
|
||
from argparse import FileType | ||
from io import TextIOWrapper | ||
from typing import List | ||
from typing import Optional | ||
from typing import Sequence | ||
from typing import Set | ||
|
||
from xarg import add_command | ||
from xarg import argp | ||
from xarg import commands | ||
from xarg import run_command | ||
|
||
from .attribute import __description__ | ||
from .attribute import __project__ | ||
from .attribute import __url_home__ | ||
from .attribute import __version__ | ||
from .parser import Tag | ||
|
||
|
||
@add_command("pull", description="pull image") | ||
def add_cmd_pull(_arg: argp): | ||
_arg.add_argument("-f", "--file", dest="images_file", | ||
type=FileType("r", encoding="UTF-8"), | ||
help="the file for pulling images", | ||
nargs=1, metavar="FILE") | ||
_arg.add_argument(type=str, dest="images", help="the name for pulling", | ||
nargs="*", default=[], metavar="IMAGE") | ||
|
||
|
||
@run_command(add_cmd_pull) | ||
def run_cmd_pull(cmds: commands) -> int: | ||
images: Set[str] = set(cmds.args.images) | ||
images_file: Optional[TextIOWrapper] = cmds.args.images_file[0] | ||
if images_file is not None: | ||
for line in images_file: | ||
images.add(line.strip()) | ||
images_tag: List[Tag] = [Tag.parse(image) for image in images] | ||
cmds.logger.info("Pulling images:") | ||
for tag in images_tag: | ||
cmds.logger.info(f"\t{tag.name}") | ||
# cmds.dockloader.pull(tag) | ||
return 0 | ||
|
||
|
||
@add_command(__project__) | ||
def add_cmd(_arg: argp): | ||
pass | ||
|
||
|
||
@run_command(add_cmd, add_cmd_pull) | ||
def run_cmd(cmds: commands) -> int: | ||
return 0 | ||
|
||
|
||
def main(argv: Optional[Sequence[str]] = None) -> int: | ||
cmds = commands() | ||
cmds.version = __version__ | ||
return cmds.run( | ||
root=add_cmd, | ||
argv=argv, | ||
description=__description__, | ||
epilog=f"For more, please visit {__url_home__}.") |
Oops, something went wrong.