Skip to content

Commit

Permalink
Allow reading data from stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed May 22, 2024
1 parent 352d5d2 commit 0bcc5ec
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 55 deletions.
19 changes: 8 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,33 +14,30 @@ 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"]
- repo: https://github.com/MarcoGorelli/absolufy-imports
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
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Change log
`Next version`_
~~~~~~~~~~~~~~~

- Added ``./manage.py f3dumpdata -`` which allows reading JSON data from stdin.


0.6 (2023-06-12)
~~~~~~~~~~~~~~~~
Expand Down
8 changes: 6 additions & 2 deletions feincms3_data/management/commands/f3loaddata.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import sys

from django.core.management.base import BaseCommand

Expand All @@ -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,
Expand Down
78 changes: 36 additions & 42 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]" },
{ name = "Matthias Kestenholz", email = "[email protected]" },
]
requires-python = ">=3.8"
classifiers = [
Expand All @@ -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",
Expand All @@ -32,78 +33,71 @@ 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]
extend-select = [
# pyflakes, pycodestyle
"F", "E", "W",
# mmcabe
"C90",
# isort
"I",
# pep8-naming
"N",
# pyupgrade
"UP",
# flake8-2020
"YTT",
# flake8-boolean-trap
"FBT",
target-version = "py38"

fix = true
show-fixes = true
lint.extend-select = [
# flake8-bugbear
"B",
# flake8-builtins
"A",
# flake8-comprehensions
"C4",
# mmcabe
"C90",
# flake8-django
"DJ",
"E",
# pyflakes, pycodestyle
"F",
# flake8-boolean-trap
"FBT",
# flake8-logging-format
"G",
# flake8-pie
"PIE",
# flake8-simplify
"SIM",
# isort
"I",
# flake8-gettext
"INT",
# pep8-naming
"N",
# pygrep-hooks
"PGH",
# flake8-pie
"PIE",
# pylint
"PL",
# unused noqa
"RUF100",
# flake8-simplify
"SIM",
# pyupgrade
"UP",
"W",
# flake8-2020
"YTT",
]
extend-ignore = [
lint.extend-ignore = [
# Allow zip() without strict=
"B905",
# 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*/*" = [
lint.per-file-ignores."*/migrat*/*" = [
# Allow using PascalCase model names in migrations
"N806",
# Ignore the fact that migration files are invalid module names
"N999",
]
lint.isort.combine-as-imports = true
lint.isort.lines-after-imports = 2
lint.mccabe.max-complexity = 15

0 comments on commit 0bcc5ec

Please sign in to comment.