mirror of
https://github.com/entropia/paperless-asn-qr-codes.git
synced 2024-06-13 02:00:00 +00:00
Compare commits
6 commits
41d255fd1e
...
00fd2ff102
Author | SHA1 | Date | |
---|---|---|---|
00fd2ff102 | |||
4d7c9d57bf | |||
c6a82af9d9 | |||
244e464724 | |||
62fd868966 | |||
eb5f3a784a |
87
.github/workflows/publish.yaml
vendored
Normal file
87
.github/workflows/publish.yaml
vendored
Normal file
|
@ -0,0 +1,87 @@
|
|||
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
|
||||
# based on https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows
|
||||
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build distribution 📦
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # fetch all history for tags, allowing to build proper dev version
|
||||
- run: pipx install hatch
|
||||
- run: hatch build
|
||||
- name: Store the distribution packages
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: python-package-distributions
|
||||
path: dist/
|
||||
|
||||
publish-to-pypi:
|
||||
name: >-
|
||||
Publish Python 🐍 distribution 📦 to PyPI
|
||||
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' # only publish to PyPI on tag pushes or dev version for main
|
||||
needs:
|
||||
- build
|
||||
runs-on: ubuntu-latest
|
||||
environment:
|
||||
name: pypi
|
||||
url: https://pypi.org/p/paperless-asn-qr-codes
|
||||
permissions:
|
||||
id-token: write # IMPORTANT: mandatory for trusted publishing
|
||||
|
||||
steps:
|
||||
- name: Download all the dists
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: python-package-distributions
|
||||
path: dist/
|
||||
- name: Publish distribution 📦 to PyPI
|
||||
uses: pypa/gh-action-pypi-publish@release/v1
|
||||
|
||||
github-release:
|
||||
name: >-
|
||||
Sign the Python 🐍 distribution 📦 with Sigstore
|
||||
and upload them to GitHub Release
|
||||
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
|
||||
needs:
|
||||
- publish-to-pypi
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
contents: write # IMPORTANT: mandatory for making GitHub Releases
|
||||
id-token: write # IMPORTANT: mandatory for sigstore
|
||||
|
||||
steps:
|
||||
- name: Download all the dists
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: python-package-distributions
|
||||
path: dist/
|
||||
- name: Sign the dists with Sigstore
|
||||
uses: sigstore/gh-action-sigstore-python@v1.2.3
|
||||
with:
|
||||
inputs: >-
|
||||
./dist/*.tar.gz
|
||||
./dist/*.whl
|
||||
- name: Create GitHub Release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
run: >-
|
||||
gh release create
|
||||
'${{ github.ref_name }}'
|
||||
--repo '${{ github.repository }}'
|
||||
--notes ""
|
||||
- name: Upload artifact signatures to GitHub Release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
# Upload to GitHub Release using the `gh` CLI.
|
||||
# `dist/` contains the built packages, and the
|
||||
# sigstore-produced signatures and certificates.
|
||||
run: >-
|
||||
gh release upload
|
||||
'${{ github.ref_name }}' dist/**
|
||||
--repo '${{ github.repository }}'
|
296
.gitignore
vendored
296
.gitignore
vendored
|
@ -1,3 +1,295 @@
|
|||
# test PDF files
|
||||
*.pdf
|
||||
/dist
|
||||
__pycache__
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/python
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=python
|
||||
|
||||
### Python ###
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
.pybuilder/
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
# For a library or package, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# .python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# poetry
|
||||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||
# commonly ignored for libraries.
|
||||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||
#poetry.lock
|
||||
|
||||
# pdm
|
||||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||
#pdm.lock
|
||||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
||||
# in version control.
|
||||
# https://pdm.fming.dev/#use-with-ide
|
||||
.pdm.toml
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# Cython debug symbols
|
||||
cython_debug/
|
||||
|
||||
# PyCharm
|
||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
|
||||
### Python Patch ###
|
||||
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
|
||||
poetry.toml
|
||||
|
||||
# ruff
|
||||
.ruff_cache/
|
||||
|
||||
# LSP config files
|
||||
pyrightconfig.json
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/python
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/pycharm
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=pycharm
|
||||
|
||||
### PyCharm ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# SonarLint plugin
|
||||
.idea/sonarlint/
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
### PyCharm Patch ###
|
||||
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
|
||||
|
||||
# *.iml
|
||||
# modules.xml
|
||||
# .idea/misc.xml
|
||||
# *.ipr
|
||||
|
||||
# Sonarlint plugin
|
||||
# https://plugins.jetbrains.com/plugin/7973-sonarlint
|
||||
.idea/**/sonarlint/
|
||||
|
||||
# SonarQube Plugin
|
||||
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
|
||||
.idea/**/sonarIssues.xml
|
||||
|
||||
# Markdown Navigator plugin
|
||||
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
|
||||
.idea/**/markdown-navigator.xml
|
||||
.idea/**/markdown-navigator-enh.xml
|
||||
.idea/**/markdown-navigator/
|
||||
|
||||
# Cache file creation bug
|
||||
# See https://youtrack.jetbrains.com/issue/JBR-2257
|
||||
.idea/$CACHE_FILE$
|
||||
|
||||
# CodeStream plugin
|
||||
# https://plugins.jetbrains.com/plugin/12206-codestream
|
||||
.idea/codestream.xml
|
||||
|
||||
# Azure Toolkit for IntelliJ plugin
|
||||
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
|
||||
.idea/**/azureSettings.xml
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/pycharm
|
8
.idea/.gitignore
vendored
Normal file
8
.idea/.gitignore
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
36
.idea/inspectionProfiles/Project_Default.xml
Normal file
36
.idea/inspectionProfiles/Project_Default.xml
Normal file
|
@ -0,0 +1,36 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ignoredPackages">
|
||||
<value>
|
||||
<list size="7">
|
||||
<item index="0" class="java.lang.String" itemvalue="fonttools" />
|
||||
<item index="1" class="java.lang.String" itemvalue="decorator" />
|
||||
<item index="2" class="java.lang.String" itemvalue="data" />
|
||||
<item index="3" class="java.lang.String" itemvalue="funcsigs" />
|
||||
<item index="4" class="java.lang.String" itemvalue="pyusb" />
|
||||
<item index="5" class="java.lang.String" itemvalue="pyserial" />
|
||||
<item index="6" class="java.lang.String" itemvalue="Pillow" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||
<option name="ignoredErrors">
|
||||
<list>
|
||||
<option value="N806" />
|
||||
</list>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ignoredIdentifiers">
|
||||
<list>
|
||||
<option value="str.reverse" />
|
||||
<option value="qr_hessenberg.wrapper.execution_times" />
|
||||
</list>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
7
.idea/misc.xml
Normal file
7
.idea/misc.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Black">
|
||||
<option name="sdkName" value="Python 3.11 (paperless-asn-qr-codes)" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (paperless-asn-qr-codes)" project-jdk-type="Python SDK" />
|
||||
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/paperless-asn-qr-codes.iml" filepath="$PROJECT_DIR$/.idea/paperless-asn-qr-codes.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
14
.idea/paperless-asn-qr-codes.iml
Normal file
14
.idea/paperless-asn-qr-codes.iml
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.idea/sonarlint" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Python 3.11 (paperless-asn-qr-codes)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="PyDocumentationSettings">
|
||||
<option name="format" value="PLAIN" />
|
||||
<option name="myDocStringFormat" value="Plain" />
|
||||
</component>
|
||||
</module>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -24,6 +24,8 @@ positional arguments:
|
|||
options:
|
||||
-h, --help show this help message and exit
|
||||
--format {averyL4731,avery5160,avery5161,avery5163,avery5167,avery5371}, -f {averyL4731,avery5160,avery5161,avery5163,avery5167,avery5371}
|
||||
--digits DIGITS, -d DIGITS
|
||||
Number of digits in the ASN (default: 7, produces 'ASN0000001')
|
||||
--border, -b Display borders around labels, useful for debugging the printer alignment
|
||||
```
|
||||
|
||||
|
@ -39,6 +41,7 @@ options:
|
|||
|
||||
- `-h`, `--help`: Shows the help message
|
||||
- `-f`, `--format`: Selects the format of the output sheet (see [Supported Sheets](#supported-sheets))
|
||||
- `-d`, `--digits`: Specifies the number of digits in the ASN (e.g. for the default number 7, the ASN will look like 'ASN0000001')
|
||||
- `-b`, `--border`: Generates the borders around the labels to help debug alignment issues (see [Tips & Tricks](#tips--tricks))
|
||||
|
||||
## Supported Sheets
|
||||
|
|
|
@ -27,6 +27,7 @@ class LabelInfo:
|
|||
gutter_size: tuple[float, float]
|
||||
margin: tuple[float, float]
|
||||
pagesize: tuple[float, float]
|
||||
textsize: float
|
||||
|
||||
|
||||
labelInfo: dict[str, LabelInfo] = {
|
||||
|
@ -37,6 +38,7 @@ labelInfo: dict[str, LabelInfo] = {
|
|||
gutter_size=(2.5 * mm, 0),
|
||||
margin=(9 * mm, 13.5 * mm),
|
||||
pagesize=A4,
|
||||
textsize=2 * mm,
|
||||
),
|
||||
# 2.6 x 1 address labels
|
||||
"avery5160": LabelInfo(
|
||||
|
@ -46,6 +48,7 @@ labelInfo: dict[str, LabelInfo] = {
|
|||
gutter_size=(11, 0),
|
||||
margin=(14, 36),
|
||||
pagesize=LETTER,
|
||||
textsize=2 * mm,
|
||||
),
|
||||
"avery5161": LabelInfo(
|
||||
labels_horizontal=2,
|
||||
|
@ -54,6 +57,7 @@ labelInfo: dict[str, LabelInfo] = {
|
|||
gutter_size=(0, 0),
|
||||
margin=(18, 36),
|
||||
pagesize=LETTER,
|
||||
textsize=2 * mm,
|
||||
),
|
||||
# 4 x 2 address labels
|
||||
"avery5163": LabelInfo(
|
||||
|
@ -63,6 +67,7 @@ labelInfo: dict[str, LabelInfo] = {
|
|||
gutter_size=(0, 0),
|
||||
margin=(18, 36),
|
||||
pagesize=LETTER,
|
||||
textsize=2 * mm,
|
||||
),
|
||||
# 1.75 x 0.5 return address labels
|
||||
"avery5167": LabelInfo(
|
||||
|
@ -72,6 +77,7 @@ labelInfo: dict[str, LabelInfo] = {
|
|||
gutter_size=(0.3 * inch, 0),
|
||||
margin=(0.3 * inch, 0.5 * inch),
|
||||
pagesize=LETTER,
|
||||
textsize=2 * mm,
|
||||
),
|
||||
# 3.5 x 2 business cards
|
||||
"avery5371": LabelInfo(
|
||||
|
@ -81,7 +87,19 @@ labelInfo: dict[str, LabelInfo] = {
|
|||
gutter_size=(0, 0),
|
||||
margin=(54, 36),
|
||||
pagesize=LETTER,
|
||||
textsize=2 * mm,
|
||||
),
|
||||
# generic uncut A4 label paper
|
||||
# (slightly larger for bad scanners & printers)
|
||||
"genericA4large": LabelInfo(
|
||||
labels_horizontal=5,
|
||||
labels_vertical=14,
|
||||
label_size=(40 * mm, 20 * mm),
|
||||
gutter_size=(0 * mm, 0),
|
||||
margin=(5 * mm, 4 * mm),
|
||||
pagesize=A4,
|
||||
textsize=3 * mm,
|
||||
)
|
||||
}
|
||||
|
||||
RETURN_ADDRESS = 5167
|
||||
|
@ -94,6 +112,7 @@ class AveryLabel:
|
|||
self.across = data.labels_horizontal
|
||||
self.down = data.labels_vertical
|
||||
self.size = data.label_size
|
||||
self.textsize = data.textsize
|
||||
self.labelsep = (
|
||||
self.size[0] + data.gutter_size[0],
|
||||
self.size[1] + data.gutter_size[1],
|
||||
|
@ -158,7 +177,7 @@ class AveryLabel:
|
|||
canv.setLineWidth(0.25)
|
||||
canv.rect(0, 0, self.size[0], self.size[1])
|
||||
if callable(thing):
|
||||
thing(canv, self.size[0], self.size[1], *args)
|
||||
thing(canv, self.size[0], self.size[1], self.textsize, *args)
|
||||
elif isinstance(thing, str):
|
||||
canv.doForm(thing)
|
||||
canv.restoreState()
|
||||
|
@ -172,6 +191,6 @@ class AveryLabel:
|
|||
if self.debug:
|
||||
canv.setLineWidth(0.25)
|
||||
canv.rect(0, 0, self.size[0], self.size[1])
|
||||
func(canv, self.size[0], self.size[1], chunk)
|
||||
func(canv, self.size[0], self.size[1], self.textsize, chunk)
|
||||
canv.restoreState()
|
||||
self.advance()
|
||||
|
|
|
@ -6,14 +6,15 @@ from reportlab_qrcode import QRCodeImage
|
|||
from paperless_asn_qr_codes import avery_labels
|
||||
|
||||
|
||||
def render(c, x, y):
|
||||
def render(c, x, y, textsize):
|
||||
global startASN
|
||||
barcode_value = f"ASN{startASN:07d}"
|
||||
global digits
|
||||
barcode_value = f"ASN{startASN:0{digits}d}"
|
||||
startASN = startASN + 1
|
||||
|
||||
qr = QRCodeImage(barcode_value, size=y * 0.9)
|
||||
qr.drawOn(c, 1 * mm, y * 0.05)
|
||||
c.setFont("Helvetica", 2 * mm)
|
||||
c.setFont("Helvetica", textsize)
|
||||
c.drawString(y, (y - 2 * mm) / 2, barcode_value)
|
||||
|
||||
|
||||
|
@ -27,6 +28,9 @@ def main():
|
|||
parser.add_argument(
|
||||
"--format", "-f", choices=avery_labels.labelInfo.keys(), default="averyL4731"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--digits", "-d", default=7, help="Number of digits in the ASN (default: 7, produces 'ASN0000001')", type=int
|
||||
)
|
||||
parser.add_argument(
|
||||
"--border",
|
||||
"-b",
|
||||
|
@ -35,7 +39,9 @@ def main():
|
|||
)
|
||||
args = parser.parse_args()
|
||||
global startASN
|
||||
global digits
|
||||
startASN = int(args.start_asn)
|
||||
digits = int(args.digits)
|
||||
label = avery_labels.AveryLabel(args.format, args.border)
|
||||
label.open(args.output_file)
|
||||
# by default, we render all labels possible on a single sheet
|
||||
|
|
|
@ -11,6 +11,7 @@ license = "GPL-3.0"
|
|||
keywords = []
|
||||
authors = [
|
||||
{ name = "Jan Christian Grünhage", email = "jan.christian@gruenhage.xyz" },
|
||||
{ name = "margau", email = "dev@marvingaube.de" },
|
||||
]
|
||||
classifiers = [
|
||||
"Development Status :: 4 - Beta",
|
||||
|
|
Loading…
Reference in a new issue