initial import
This commit is contained in:
parent
7451e933c1
commit
85c8afa405
10
README.md
10
README.md
|
@ -1,2 +1,10 @@
|
|||
# bandcamp-importer
|
||||
Process Bandcamp downloads and import into Plex
|
||||
|
||||
Auto-generated by poetry-slam.
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
bandcamp_importer --help
|
||||
```
|
||||
|
|
54
pyproject.toml
Normal file
54
pyproject.toml
Normal file
|
@ -0,0 +1,54 @@
|
|||
[tool.poetry]
|
||||
name = "bandcamp-importer"
|
||||
version = "1.0"
|
||||
description = "bandcamp-importer: automatically generated by poetry-slam."
|
||||
authors = ["evilchili <evilchili@gmail.com>"]
|
||||
readme = "README.md"
|
||||
packages = [
|
||||
{include = "*", from = "src"},
|
||||
]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.10"
|
||||
python-dotenv = "^0.21.0"
|
||||
rich = "^13.7.0"
|
||||
typer = "^0.9.0"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
pytest = "^8.1.1"
|
||||
pytest-cov = "^5.0.0"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
||||
|
||||
[tool.poetry.scripts]
|
||||
bandcamp_importer = "bandcamp_importer.cli:app"
|
||||
|
||||
|
||||
### SLAM
|
||||
|
||||
[tool.black]
|
||||
line-length = 120
|
||||
target-version = ['py310']
|
||||
|
||||
[tool.isort]
|
||||
multi_line_output = 3
|
||||
line_length = 120
|
||||
include_trailing_comma = true
|
||||
|
||||
[tool.autoflake]
|
||||
check = false # return error code if changes are needed
|
||||
in-place = true # make changes to files instead of printing diffs
|
||||
recursive = true # drill down directories recursively
|
||||
remove-all-unused-imports = true # remove all unused imports (not just those from the standard library)
|
||||
ignore-init-module-imports = true # exclude __init__.py when removing unused imports
|
||||
remove-duplicate-keys = true # remove all duplicate keys in objects
|
||||
remove-unused-variables = true # remove unused variables
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
log_cli_level = "DEBUG"
|
||||
addopts = "--cov=src --cov-report=term-missing"
|
||||
|
||||
### ENDSLAM
|
0
src/bandcamp_importer/__init__.py
Normal file
0
src/bandcamp_importer/__init__.py
Normal file
57
src/bandcamp_importer/cli.py
Normal file
57
src/bandcamp_importer/cli.py
Normal file
|
@ -0,0 +1,57 @@
|
|||
import io
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
import typer
|
||||
from dotenv import load_dotenv
|
||||
from rich.logging import RichHandler
|
||||
|
||||
CONFIG_DEFAULTS = """
|
||||
# bandcamp-importer Defaults
|
||||
|
||||
LOG_LEVEL=INFO
|
||||
"""
|
||||
|
||||
app = typer.Typer()
|
||||
app_state = dict(
|
||||
config_file=Path("~/.config/bandcamp-importer.conf").expanduser(),
|
||||
)
|
||||
|
||||
logger = logging.getLogger("bandcamp_importer.cli")
|
||||
|
||||
|
||||
@app.callback(invoke_without_command=True)
|
||||
def main(
|
||||
context: typer.Context,
|
||||
verbose: bool = typer.Option(False, help="Enable verbose output."),
|
||||
log_level: str = typer.Option("error", help=" Set the log level."),
|
||||
config_file: Optional[Path] = typer.Option(
|
||||
app_state["config_file"],
|
||||
help="Path to the bandcamp_importer configuration file",
|
||||
),
|
||||
):
|
||||
"""
|
||||
Configure the execution environment with global parameters.
|
||||
"""
|
||||
app_state["config_file"] = config_file
|
||||
load_dotenv(stream=io.StringIO(CONFIG_DEFAULTS))
|
||||
load_dotenv(app_state["config_file"])
|
||||
|
||||
logging.basicConfig(
|
||||
format="%(message)s",
|
||||
level=getattr(logging, log_level.upper()),
|
||||
handlers=[RichHandler(rich_tracebacks=True, tracebacks_suppress=[typer])],
|
||||
)
|
||||
app_state["verbose"] = verbose
|
||||
|
||||
if context.invoked_subcommand is None:
|
||||
logger.debug("No command specified; invoking default handler.")
|
||||
run(context)
|
||||
|
||||
|
||||
def run(context: typer.Context):
|
||||
"""
|
||||
The default CLI entrypoint is bandcamp_importer.cli.run().
|
||||
"""
|
||||
raise NotImplementedError("Please define bandcamp_importer.cli.run().")
|
7
test/test_bandcamp_importer.py
Normal file
7
test/test_bandcamp_importer.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.xfail
|
||||
def test_tests_are_implemented():
|
||||
print("Yyou have not implemented any tests yet.")
|
||||
assert False
|
8
test/test_bandcamp_importer_cli.py
Normal file
8
test/test_bandcamp_importer_cli.py
Normal file
|
@ -0,0 +1,8 @@
|
|||
import pytest
|
||||
|
||||
from bandcamp_importer import cli
|
||||
|
||||
|
||||
@pytest.mark.xfail
|
||||
def test_tests_are_implemented():
|
||||
assert cli.main()
|
Loading…
Reference in New Issue
Block a user