diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 937e109..18fa12b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ exclude: ".yarn/|yarn.lock|\\.min\\.(css|js)$" repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.6.0 hooks: - id: check-added-large-files - id: check-builtin-literals @@ -14,7 +14,7 @@ repos: - id: mixed-line-ending - id: trailing-whitespace - repo: https://github.com/adamchainz/django-upgrade - rev: 1.13.0 + rev: 1.17.0 hooks: - id: django-upgrade args: [--target-version, "3.2"] @@ -22,25 +22,22 @@ repos: rev: v0.3.1 hooks: - id: absolufy-imports - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: "v0.0.272" + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: "v0.4.4" hooks: - id: ruff - - repo: https://github.com/psf/black - rev: 23.3.0 - hooks: - - id: black + - id: ruff-format - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.0-alpha.9-for-vscode + rev: v3.1.0 hooks: - id: prettier args: [--list-different, --no-semi] exclude: "^conf/|.*\\.html$" - repo: https://github.com/tox-dev/pyproject-fmt - rev: 0.11.2 + rev: 2.1.3 hooks: - id: pyproject-fmt - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.13 + rev: v0.18 hooks: - id: validate-pyproject diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5877c11..2388d49 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,8 @@ Change log `Next version`_ ~~~~~~~~~~~~~~~ +- Added ``./manage.py f3dumpdata -`` which allows reading JSON data from stdin. + 0.6 (2023-06-12) ~~~~~~~~~~~~~~~~ diff --git a/feincms3_data/management/commands/f3loaddata.py b/feincms3_data/management/commands/f3loaddata.py index 8f1d2db..11a456f 100644 --- a/feincms3_data/management/commands/f3loaddata.py +++ b/feincms3_data/management/commands/f3loaddata.py @@ -1,4 +1,5 @@ import json +import sys from django.core.management.base import BaseCommand @@ -22,8 +23,11 @@ def add_arguments(self, parser): def handle(self, *dumps, **options): for dump in dumps: - with open(dump, encoding="utf-8") as f: - data = json.load(f) + if dump == "-": + data = json.loads(sys.stdin.read()) + else: + with open(dump, encoding="utf-8") as f: + data = json.load(f) load_dump( data, progress=self.stderr.write if options["verbosity"] >= 2 else silence, diff --git a/pyproject.toml b/pyproject.toml index 41cf779..696a5f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,9 +7,9 @@ requires = [ [project] name = "feincms3-data" readme = "README.rst" -license = {text = "BSD-3-Clause"} +license = { text = "BSD-3-Clause" } authors = [ - { name = "Matthias Kestenholz", email = "mk@feinheit.ch" }, + { name = "Matthias Kestenholz", email = "mk@feinheit.ch" }, ] requires-python = ">=3.8" classifiers = [ @@ -24,6 +24,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development", "Topic :: Software Development :: Libraries :: Application Frameworks", @@ -32,22 +33,26 @@ dynamic = [ "version", ] dependencies = [ - "Django>=3.2", + "django>=3.2", ] -[project.optional-dependencies] -tests = [ +optional-dependencies.tests = [ "coverage", ] -[project.urls] -Homepage = "https://github.com/matthiask/feincms3-data/" +urls.Homepage = "https://github.com/matthiask/feincms3-data/" [tool.hatch.version] path = "feincms3_data/__init__.py" [tool.ruff] +target-version = "py38" + +fix = true +show-fixes = true extend-select = [ # pyflakes, pycodestyle - "F", "E", "W", + "F", + "E", + "W", # mmcabe "C90", # isort @@ -89,21 +94,12 @@ extend-ignore = [ # No line length errors "E501", ] -fix = true -show-fixes = true -target-version = "py38" - -[tool.ruff.isort] -combine-as-imports = true -lines-after-imports = 2 - -[tool.ruff.mccabe] -max-complexity = 15 - -[tool.ruff.per-file-ignores] -"*/migrat*/*" = [ +mccabe.max-complexity = 15 +per-file-ignores."*/migrat*/*" = [ # Allow using PascalCase model names in migrations "N806", # Ignore the fact that migration files are invalid module names "N999", ] +isort.combine-as-imports = true +isort.lines-after-imports = 2