Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
sumpfork authored Mar 20, 2024
2 parents 20ce3b4 + 0a86220 commit 8412bca
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 80 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ jobs:
sudo apt update
sudo apt install python3-icu
- name: Lint
run: pre-commit run --all-files
run: pre-commit run --all-files --show-diff-on-failure -v
- name: Test
run: pytest
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install -e .[dev]
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
python -m build sdist bdist_wheel
twine upload dist/*
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ default_language_version:
python: python3
repos:
- repo: https://github.com/psf/black
rev: 23.1.0
rev: 24.3.0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-json
- id: pretty-format-json
args: [--autofix, --no-ensure-ascii, --indent=4]
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
rev: 7.0.0
hooks:
- id: flake8
args: [--max-line-length=120, "--ignore=E203,W503"]
additional_dependencies: [flake8-bugbear]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ The library will be installed as `domdiv` with the main entry point being `domdi

## Developing

Install requirements via `pip install -r requirements.txt`. Then, run `pre-commit install`. You can use `python setup.py develop` to install the `dominion_dividers` script so that it calls your checked out code, enabling you to run edited code without having to perform an install every time.
Install requirements via `pip install -r requirements.txt`. Then, run `pre-commit install`. You can use `pip install -e .[dev]` to install the `dominion_dividers` script so that it calls your checked out code, enabling you to run edited code without having to perform an install every time. This also installs needed dev dependencies.

Feel free to comment on boardgamegeek at <https://boardgamegeek.com/thread/926575/web-page-generate-tabbed-dividers> or file issues on github (<https://github.com/sumpfork/dominiontabs/issues>).

Tests can be run (and their dependencies installed) via `python setup.py test`, which will also happen if/when you push a branch or make a PR.
Tests can be run (and their dependencies installed) via `pip install .[dev]` and then `doit test`. They will also run if/when you push a branch or make a PR.

## Image Sources

Expand Down
9 changes: 3 additions & 6 deletions dodo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import distutils.core
import glob
import os

Expand Down Expand Up @@ -48,15 +47,13 @@ def task_build():
files = [
fname
for fname in glob_no_dirs("src/domdiv/**/*")
+ glob.glob("card_db_src/**/*.json" + "setup.py")
+ glob.glob("card_db_src/**/*.json" + "pyproject.toml")
if os.path.isfile(fname)
]
return {
"file_dep": files,
"task_dep": ["update_languages"],
"actions": [
lambda: True if distutils.core.run_setup("setup.py", "sdist") else False
],
"actions": ["pip install -e .[dev]", "python -m build"],
}


Expand All @@ -66,4 +63,4 @@ def task_make_bgg_release():

def task_test():
files = glob_no_dirs("src/domdiv/**")
return {"file_dep": files, "actions": ["python setup.py test"]}
return {"file_dep": files, "actions": ["pip install -e .[dev]", "pytest"]}
32 changes: 30 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@

[build-system]
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.3", "pytest-runner"]
requires = ["setuptools>=61", "setuptools_scm[toml]>=6"]
build-backend = "setuptools.build_meta"

[project]
name = "domdiv"
dynamic = ["version"]
dependencies = ["reportlab", "Pillow", "configargparse"]
description = "Divider Generation for the Dominion Card Game"
keywords = ["boardgame", "cardgame", "dividers"]
authors = [{ name = "Peter Gorniak", email = "[email protected]" }]
readme = "README.md"

[project.urls]
"Say Thanks" = "https://boardgamegeek.com/thread/926575/web-page-generate-tabbed-dividers"
"Source" = "https://github.com/sumpfork/dominiontabs"
"Issue Tracker" = "https://github.com/sumpfork/dominiontabs/issues"
"Homepage" = "http://domtabs.sandflea.org"

[project.optional-dependencies]
dev = ["build", "twine", "pre-commit", "doit", "pytest"]

[project.scripts]
dominion_dividers = "domdiv.main:main"
domdiv_update_language = "domdiv.tools.update_language:run"
domdiv_bgg_release = "domdiv.tools.bgg_release:make_bgg_release"
domdiv_dedupe_cards = "domdiv.tools.cleanup_language_dupes:main"

[tools.setuptools_scm]
[tool.setuptools_scm]
# doing this break CI as the version file gets written when just `get_version` is called
# version_file = "src/domdiv/_version.py"
32 changes: 0 additions & 32 deletions setup.py

This file was deleted.

76 changes: 45 additions & 31 deletions src/domdiv/draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ def __init__(
0 # Exact Centre special case, so swapping is still exact centre
)
elif CardPlot.tabNumber == 1:
self.tabIndex = (
self.tabIndexBack
) = 1 # There is only one tab, so can only use 1 for both sides
self.tabIndex = self.tabIndexBack = (
1 # There is only one tab, so can only use 1 for both sides
)
elif 1 <= self.tabIndex <= CardPlot.tabNumber:
self.tabIndexBack = CardPlot.tabNumber + 1 - self.tabIndex
else:
Expand Down Expand Up @@ -703,9 +703,11 @@ def registerFonts(self):
pdfmetrics.registerFont(
TTFont(
font,
fontpath
if is_local
else pkg_resources.resource_filename("domdiv", fontpath),
(
fontpath
if is_local
else pkg_resources.resource_filename("domdiv", fontpath)
),
)
)
registered[font] = fontpath
Expand Down Expand Up @@ -860,9 +862,7 @@ def drawPanelOutline(
line = (
plotter.LINE
if lineType.lower() == "line"
else plotter.DOT
if lineType.lower() == "dot"
else NO_LINE
else plotter.DOT if lineType.lower() == "dot" else NO_LINE
)
# lines ending at a midpoint (no dots)
midline = NO_LINE if line == plotter.DOT else line
Expand Down Expand Up @@ -1086,9 +1086,7 @@ def tabHeight(panelStyle, panelHeight):
return (
panelHeight
if panelStyle in ["tab", "strap"]
else item.tabHeight
if panelStyle == "folder"
else 0.0
else item.tabHeight if panelStyle == "folder" else 0.0
)

headTabHeight = tabHeight(self.options.head, headHeight)
Expand Down Expand Up @@ -1767,11 +1765,15 @@ def drawTab(self, item, panel=None, backside=False):
side = (
CardPlot.CENTRE
if self.options.tab_name_align == "centre" or self.wantCentreTab(card)
else CardPlot.LEFT
if self.options.tab_name_align == "left"
else CardPlot.RIGHT
if self.options.tab_name_align == "right"
else item.getClosestSide(backside=backside)
else (
CardPlot.LEFT
if self.options.tab_name_align == "left"
else (
CardPlot.RIGHT
if self.options.tab_name_align == "right"
else item.getClosestSide(backside=backside)
)
)
)

# calculate x position and write text
Expand Down Expand Up @@ -2245,24 +2247,36 @@ def calculatePages(self, cards):
options.headHeight = (
0.0
if options.head == "none"
else options.head_height * cm
if options.head_height
else options.dividerBaseHeight + options.labelHeight
if options.head == "folder"
else options.dividerBaseHeight
if options.head == "cover"
else options.labelHeight # tab or strap
else (
options.head_height * cm
if options.head_height
else (
options.dividerBaseHeight + options.labelHeight
if options.head == "folder"
else (
options.dividerBaseHeight
if options.head == "cover"
else options.labelHeight
)
)
) # tab or strap
)
options.tailHeight = (
0.0
if options.tail in ["none", "tab"] # not a real tab
else options.tail_height * cm
if options.tail_height
else options.dividerBaseHeight + options.labelHeight
if options.tail == "folder"
else options.dividerBaseHeight
if options.tail == "cover"
else options.labelHeight # strap
else (
options.tail_height * cm
if options.tail_height
else (
options.dividerBaseHeight + options.labelHeight
if options.tail == "folder"
else (
options.dividerBaseHeight
if options.tail == "cover"
else options.labelHeight
)
)
) # strap
)

# Set Height
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[tox]
envlist = py39
isolated_build = True

[testenv]
deps = pytest
Expand Down

0 comments on commit 8412bca

Please sign in to comment.