diff --git a/.github/workflows/static.yaml b/.github/workflows/static.yaml index 720a6ec0..b690b285 100644 --- a/.github/workflows/static.yaml +++ b/.github/workflows/static.yaml @@ -12,11 +12,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v4 with: - python-version: 3.9 + python-version: 3.11 - name: Install dependencies run: | python -m pip install --upgrade pip @@ -26,7 +26,7 @@ jobs: black --check codex_of_the_damned tests - name: Lint run: | - flake8 + ruff check --output-format github - name: Test run: | pytest diff --git a/Makefile b/Makefile index 0d188219..2e6ac15d 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,11 @@ .PHONY: po-update po-compile po release test update po-update: - python setup.py extract_messages - python setup.py update_catalog + pybabel extract --charset=utf-8 -c "TRANSLATORS:" -w 120 -k lazy_gettext -F babel.cfg -o messages.pot codex_of_the_damned + pybabel update -l fr -w 120 --init-missing -i messages.pot -d codex_of_the_damned/translations po-compile: - python setup.py compile_catalog + pybabel compile -D messages -d codex_of_the_damned/translations po: po-update po-compile @@ -14,6 +14,8 @@ release: pip install -e ".[dev]" test: + black --check codex_of_the_damned tests + ruff check pytest update: diff --git a/codex_of_the_damned/__init__.py b/codex_of_the_damned/__init__.py index 20cf066e..c56c86cc 100644 --- a/codex_of_the_damned/__init__.py +++ b/codex_of_the_damned/__init__.py @@ -261,9 +261,9 @@ def index(lang_code=None, page=None): ) image_name, _ = re.subn(r"""\s|,|\.|-|—|'|:|\(|\)|"|!""", "", image_name) context["og_image"] = f"http://static.krcg.org/card/{image_name}.jpg" - context[ - "og_image_secure" - ] = f"https://static.krcg.org/card/{image_name}.jpg" + context["og_image_secure"] = ( + f"https://static.krcg.org/card/{image_name}.jpg" + ) context["og_description"] = "Official card text and rulings" context["og_title"] = card context["og_image_dimensions"] = ["358", "500"] @@ -382,9 +382,11 @@ def display_card(): def card(name, display_name=None): return markupsafe.Markup( '{name}'.format( - data_name=f' data-name="{name}"' - if display_name or re.search(r" |-", name) - else "", + data_name=( + f' data-name="{name}"' + if display_name or re.search(r" |-", name) + else "" + ), # replace spaces and hyphens with non-breakable versions in card names name=(display_name or name).replace(" ", " ").replace("-", "‑"), ) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..d6994a57 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,51 @@ +[build-system] +requires = ["setuptools>=68", "setuptools_scm>=8", "babel>=2"] +build-backend = "setuptools.build_meta" + +[project] +name = "codex-of-the-damned" +dynamic = ["version"] +authors = [ + { name = "Lionel Panhaleux", email = "lionel.panhaleux+codex@gmail.com" }, +] +description = "Website on VTES Strategy, cards rulings and TWD search interface" +keywords = ["vtes", "Vampire: The Eternal Struggle", "CCG", "TWD", "TWDA"] +readme = "README.md" +requires-python = ">=3.11" +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Development Status :: 5 - Production/Stable", + "Natural Language :: English", + "Operating System :: OS Independent", + "Framework :: Flask", + "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", +] +dependencies = ["flask>=3", "flask-babel>=4", "unidecode>=1", "Jinja2>=3"] + +[project.optional-dependencies] +dev = [ + "black>=24", + "clipboard>=0", + "ipython>=8", + "pytest>=8", + "requests>=2", + "ruff>=0", + "zest.releaser[recommended]>=9", +] + +[project.urls] +Homepage = "https://codex-of-the-damned.org" +Repository = "https://github.com/lionel-panhaleux/codex-of-the-damned" + +[tool.setuptools.packages.find] +include = ["codex_of_the_damned*"] + +# required for dynamic version +[tool.setuptools_scm] + +[tool.zest-releaser] +create-wheel = true + +[tool.pytest] +junit_duration_report = "call" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 21feb0c9..00000000 --- a/setup.cfg +++ /dev/null @@ -1,79 +0,0 @@ -[metadata] -name = codex-of-the-damned -version = 1.64.dev0 -author = lionelpx -author_email = lionel.panhaleux+codex@gmail.com -url = http://github.com/lionel-panhaleux/codex-of-the-damned -description="Website on VTES Strategy, cards rulings and TWD search interface.", -long_description = file: README.md -long_description_content_type = text/markdown -license = "MIT" -keywords = vampire vtes ccg twd -classifiers = - Development Status :: 4 - Beta - Intended Audience :: Other Audience - Natural Language :: English - Operating System :: OS Independent - Environment :: Console - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.8 - Topic :: Other/Nonlisted Topic - -[options] -zip_safe = True -include_package_data = True -packages = find: -setup_requires = - babel - setuptools -install_requires = - flask - flask-babel - unidecode - Jinja2 - -[options.entry_points] -console_scripts = - codex = codex_of_the_damned:main - -[options.extras_require] -dev = - black - clipboard - flake8 - ipython - pytest - requests - zest.releaser[recommended] - -[flake8] -max-line-length = 88 -exclude = build, dist, .eggs -ignore = E203, W503 - -[bdist_wheel] -python-tag = py3 - -[distutils] -index-servers = pypi - -[extract_messages] -keywords = lazy_gettext -charset = utf-8 -add-comments = TRANSLATORS: -width = 120 -mapping-file = babel.cfg -input-dirs = codex_of_the_damned -output-file = messages.pot - -[update_catalog] -width = 120 -input-file = messages.pot -output-dir = codex_of_the_damned/translations - -[compile_catalog] -domain = messages -directory = codex_of_the_damned/translations - -[zest.releaser] -create-wheel = yes diff --git a/setup.py b/setup.py deleted file mode 100755 index 738075be..00000000 --- a/setup.py +++ /dev/null @@ -1,36 +0,0 @@ -import setuptools -import setuptools.command.develop -import setuptools.command.install - - -class WithCompile: - def run(self): - from babel.messages.frontend import compile_catalog - - compiler = compile_catalog(self.distribution) - option_dict = self.distribution.get_option_dict("compile_catalog") - compiler.domain = option_dict["domain"][1:] - compiler.directory = option_dict["directory"][1] - compiler.run() - super().run() - - -class InstallWithCompile(WithCompile, setuptools.command.install.install): - pass - - -class DevelopWithCompile(WithCompile, setuptools.command.develop.develop): - pass - - -class SDistWithCompile(WithCompile, setuptools.command.sdist.sdist): - pass - - -setuptools.setup( - cmdclass={ - "install": InstallWithCompile, - "develop": DevelopWithCompile, - "sdist": SDistWithCompile, - } -)