-
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
Showing
20 changed files
with
1,017 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,64 @@ | ||
name: CI | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build-package: | ||
runs-on: ubuntu-latest | ||
concurrency: | ||
group: ${{ github.event_name }}-${{ github.workflow }}-${{ github.ref_name }}-build | ||
cancel-in-progress: true | ||
timeout-minutes: 20 | ||
container: | ||
image: ghcr.io/thombashi/python-ci:3.11 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- run: make build | ||
|
||
lint: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
concurrency: | ||
group: ${{ github.event_name }}-${{ github.workflow }}-${{ github.ref_name }}-lint | ||
cancel-in-progress: true | ||
timeout-minutes: 20 | ||
container: | ||
image: ghcr.io/thombashi/python-ci:3.11 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- run: make check | ||
|
||
unit-test: | ||
runs-on: ${{ matrix.os }} | ||
concurrency: | ||
group: ${{ github.event_name }}-${{ github.workflow }}-${{ github.ref_name }}-ut-${{ matrix.os }}-${{ matrix.python-version }} | ||
cancel-in-progress: true | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10", "3.11"] | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
timeout-minutes: 20 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: pip | ||
cache-dependency-path: | | ||
**/*requirements.txt | ||
setup.py | ||
tox.ini | ||
- run: make setup-ci | ||
|
||
- name: Run tests | ||
run: tox -e py |
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,121 @@ | ||
# 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 | ||
|
||
# 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 | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# 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/ | ||
|
||
# User settings | ||
_sandbox/ | ||
*_profile | ||
Untitled.ipynb |
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 @@ | ||
include LICENSE | ||
include README.rst | ||
include tox.ini | ||
|
||
recursive-include requirements * | ||
recursive-include test * | ||
|
||
global-exclude __pycache__/* | ||
global-exclude *.pyc |
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,49 @@ | ||
PYTHON := python3 | ||
|
||
AUTHOR := thombashi | ||
PACKAGE := pathvalidate-cli | ||
|
||
BUILD_WORK_DIR := _work | ||
PKG_BUILD_DIR := $(BUILD_WORK_DIR)/$(PACKAGE) | ||
|
||
|
||
.PHONY: build-remote | ||
build-remote: clean | ||
@mkdir -p $(BUILD_WORK_DIR) | ||
@cd $(BUILD_WORK_DIR) && \ | ||
git clone https://github.com/$(AUTHOR)/$(PACKAGE).git --depth 1 && \ | ||
cd $(PACKAGE) && \ | ||
$(PYTHON) -m tox -e build | ||
ls -lh $(PKG_BUILD_DIR)/dist/* | ||
|
||
.PHONY: build | ||
build: clean | ||
$(PYTHON) -m tox -e build | ||
ls -lh dist/* | ||
|
||
.PHONY: check | ||
check: | ||
$(PYTHON) -m tox -e lint | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf $(BUILD_WORK_DIR) | ||
$(PYTHON) -m tox -e clean | ||
|
||
.PHONY: fmt | ||
fmt: | ||
$(PYTHON) -m tox -e fmt | ||
|
||
.PHONY: release | ||
release: | ||
$(PYTHON) setup.py release --sign --verbose | ||
$(MAKE) clean | ||
|
||
.PHONY: setup-ci | ||
setup-ci: | ||
$(PYTHON) -m pip install -q --disable-pip-version-check --upgrade tox | ||
|
||
.PHONY: setup | ||
setup: setup-ci | ||
$(PYTHON) -m pip install -q --disable-pip-version-check --upgrade -e .[test] releasecmd | ||
$(PYTHON) -m pip check |
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,64 @@ | ||
.. contents:: **pathvalidate-cli** | ||
:backlinks: top | ||
:depth: 2 | ||
|
||
|
||
Summary | ||
============================================ | ||
|
||
pathvalidate-cli is a command line interface for `pathvalidate <https://github.com/thombashi/pathvalidate>`__ library. | ||
|
||
|
||
Installation | ||
============================================ | ||
:: | ||
|
||
pip install pathvalidate-cli | ||
|
||
|
||
Usage | ||
============================================ | ||
|
||
:: | ||
|
||
$ pathvalidate sanitize 'fi:l*e/p"a?t>h|.t<xt' | ||
file/path.txt | ||
$ pathvalidate --filename sanitize 'fi:l*e/p"a?t>h|.t<xt' | ||
filepath.txt | ||
|
||
$ pathvalidate validate 'fi:l*e/p"a?t>h|.t<xt' | ||
[PV1100] invalid characters found: invalids=(':', '*', '"', '?', '>', '|', '<'), value='fi:l*e/p"a?t>h|.t<xt', platform=Windows | ||
|
||
Command Help | ||
-------------------------------------------- | ||
|
||
:: | ||
|
||
Usage: pathvalidate [OPTIONS] COMMAND [ARGS]... | ||
|
||
Options: | ||
--version Show the version and exit. | ||
--debug For debug print. | ||
-q, --quiet Suppress execution log messages. | ||
--filename Consider inputs as filenames. | ||
--max-len, --max-bytes BYTES Maximum byte counts of file paths. -1: same | ||
value with the platform limitation. [default: | ||
-1] | ||
--platform PLATFORM Execution platform name (case-insensitive). | ||
Valid platform specifiers are | ||
Linux/Windows/macOS. Valid special values are: | ||
POSIX, universal (a) auto: automatically | ||
detects the execution platform. (b) universal: | ||
platform independent. [default: universal] | ||
-v, --verbose Verbosity level [default: 0] | ||
-h, --help Show this message and exit. | ||
|
||
Commands: | ||
error Print error reasons. | ||
sanitize Sanitize file paths. | ||
validate Validate file paths. | ||
|
||
|
||
Dependencies | ||
============================================ | ||
Python 3.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 @@ | ||
from .__version__ import __author__, __copyright__, __email__, __license__, __version__ |
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 @@ | ||
__author__ = "Tsuyoshi Hombashi" | ||
__copyright__ = f"Copyright 2023, {__author__}" | ||
__license__ = "MIT License" | ||
__version__ = "0.0.1" | ||
__maintainer__ = __author__ | ||
__email__ = "tsuyoshi.hombashi@gmail.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,4 @@ | ||
from typing import Final | ||
|
||
|
||
MODULE_NAME: Final[str] = "pathvalidate-cli" |
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,43 @@ | ||
import sys | ||
from typing import Final | ||
|
||
from loguru import logger | ||
|
||
from ._const import MODULE_NAME | ||
|
||
|
||
class LogLevel: | ||
DEBUG: Final[str] = "DEBUG" | ||
INFO: Final[str] = "INFO" | ||
QUIET: Final[str] = "QUIET" | ||
|
||
|
||
logger.disable(MODULE_NAME) | ||
|
||
|
||
def set_logger(is_enable: bool, propagation_depth: int = 1) -> None: | ||
if is_enable: | ||
logger.enable(MODULE_NAME) | ||
else: | ||
logger.disable(MODULE_NAME) | ||
|
||
|
||
def initialize_logger(name: str, log_level: str) -> None: | ||
logger.remove() | ||
|
||
if log_level == LogLevel.QUIET: | ||
logger.disable(name) | ||
return | ||
|
||
if log_level == LogLevel.DEBUG: | ||
log_format = ( | ||
"<level>{level: <8}</level> | " | ||
"<cyan>{name}</cyan>:" | ||
"<cyan>{function}</cyan>:" | ||
"<cyan>{line}</cyan> - <level>{message}</level>" | ||
) | ||
else: | ||
log_format = "<level>[{level}]</level> {message}" | ||
|
||
logger.add(sys.stderr, colorize=True, format=log_format, level=log_level) | ||
logger.enable(name) |
Oops, something went wrong.