This commit is contained in:
CDaut 2024-04-17 21:23:50 +02:00 committed by GitHub
commit 41d255fd1e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 402 additions and 6 deletions

296
.gitignore vendored
View file

@ -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
View 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

View 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>

View 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
View 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
View 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>

View 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
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View file

@ -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()

View file

@ -6,14 +6,14 @@ 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}"
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)