mirror of
https://github.com/captn3m0/pystitcher.git
synced 2024-09-19 21:57:09 +00:00
switch to hatch, drop setup.{py,cfg}
pyscaffold is still sticking to setup.cfg, so upgrade to hatch instead, because it let me import the cfg to pyproject.toml Can probably drop hatch down the line
This commit is contained in:
parent
3452509af7
commit
cb38ef2f1b
@ -1,22 +0,0 @@
|
||||
# Read the Docs configuration file
|
||||
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
||||
|
||||
# Required
|
||||
version: 2
|
||||
|
||||
# Build documentation in the docs/ directory with Sphinx
|
||||
sphinx:
|
||||
configuration: docs/conf.py
|
||||
|
||||
# Build documentation with MkDocs
|
||||
#mkdocs:
|
||||
# configuration: mkdocs.yml
|
||||
|
||||
# Optionally build your docs in additional formats such as PDF
|
||||
formats:
|
||||
- pdf
|
||||
|
||||
python:
|
||||
version: 3.8
|
||||
install:
|
||||
- requirements: docs/requirements.txt
|
118
README.md
Normal file
118
README.md
Normal file
@ -0,0 +1,118 @@
|
||||
# pystitcher
|
||||
|
||||
pystitcher stitches your PDF files together, generating nice
|
||||
customizable bookmarks for you using a declarative input in the form of
|
||||
a markdown file. It is written in pure python and uses
|
||||
[PyPDF3](https://pypi.org/project/PyPDF3/) for reading and writing PDF
|
||||
files.
|
||||
|
||||
## Installation
|
||||
|
||||
You can install it easily using [pipx](https://pypa.github.io/pipx/):
|
||||
|
||||
pipx install pystitcher
|
||||
|
||||
The Wiki has [Alternative Installation
|
||||
Instructions](https://github.com/captn3m0/pystitcher/wiki/Installation).
|
||||
|
||||
## Description
|
||||
|
||||
pystitcher is a command line tool, with very few cli options:
|
||||
|
||||
```
|
||||
usage: pystitcher [-h] [--version] [-v] [--cleanup | --no-cleanup] spine.md output.pdf
|
||||
|
||||
Stitch PDF files together
|
||||
|
||||
positional arguments:
|
||||
spine.md Input markdown file
|
||||
output.pdf Output PDF file
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
--version show program's version number and exit
|
||||
-v, --verbose log more things
|
||||
--cleanup, --no-cleanup
|
||||
Delete temporary files (default: True)
|
||||
```
|
||||
|
||||
Given this input:
|
||||
|
||||
```markdown
|
||||
existing_bookmarks: remove
|
||||
title: Complete Guide to the Personal Data Protection Bill
|
||||
author: Medianama
|
||||
keywords: privacy, surveillance, personal data protection
|
||||
subject: Personal Data Protection Bill
|
||||
# A Complete Guide to the Personal Data Protection Bill
|
||||
|
||||
- [Cover](cover.pdf)
|
||||
|
||||
# The Bills
|
||||
|
||||
- [Personal Data Protection Bill, 2019](https://example.com/2019-bill.pdf)
|
||||
- [Personal Data Protection Bill, 2018](https://example.com/2018-bill.pdf)
|
||||
|
||||
# Other key reading material
|
||||
|
||||
- [Srikrishna Committee Report](2.a.pdf)
|
||||
- [Dvara Research's Personal Data Protection Bill](2.b.pdf)
|
||||
- [MP Shashi Tharoor's Data Protection Bill](2.c.pdf)
|
||||
- [MP Jay Panda's Data Protection Bill](2.d.pdf)
|
||||
- [SaveOurPrivacy.in bill](2.e.pdf)
|
||||
- [TRAI recommendations on privacy](2.f1.pdf)
|
||||
- [Comments on TRAI recommendations on privacy](2.f2.pdf)
|
||||
```
|
||||
Will generate a PDF with proper bookmarks:
|
||||
|
||||
![image](https://i.imgur.com/qPVpZGt.png)
|
||||
|
||||
And the correct metadata:
|
||||
```yaml
|
||||
Title: Complete Guide to the Personal Data Protection Bill
|
||||
Subject: Personal Data Protection Bill
|
||||
Keywords: privacy, surveillance, personal data protection
|
||||
Author: Medianama
|
||||
Creator: pystitcher/1.0.0
|
||||
Producer: pystitcher/1.0.0
|
||||
```
|
||||
Configuration options can be specified with Meta data at the top of the
|
||||
file.
|
||||
|
||||
- **fit**: Default fit of the bookmark. Can be overwritten per bookmark See
|
||||
[wiki](https://github.com/captn3m0/pystitcher/wiki/Zoom-Levels)
|
||||
for more details.
|
||||
- **author**: PDF Author
|
||||
- **keywords**: PDF Keywords
|
||||
- **subject**: PDF Subject
|
||||
- **title**: PDF Title. If left unspecified, first Heading (h1) in the document is used.
|
||||
- **existing_bookmarks**: What to do with existing bookmarks in individual
|
||||
files. Options are `keep`, `flatten`, and `remove`. See[docs]
|
||||
(https://github.com/captn3m0/pystitcher/wiki/Existing-Bookmarks) for more
|
||||
details.
|
||||
|
||||
Additionally, PDF links specified in markdown can have attributes to
|
||||
alter the PDFs before merging. The below attribute will rotate the
|
||||
second PDF file by 90 degrees clockwise before merging:
|
||||
|
||||
[Part 1](1.pdf)
|
||||
[Part 2](2.pdf){: rotate="90"}
|
||||
|
||||
And the below attribute will merge only pages 2 to 5, both inclusive,
|
||||
from the second PDF file:
|
||||
|
||||
[Part 1](1.pdf)
|
||||
[Part 2](2.pdf){: start=2 end=5}
|
||||
|
||||
The list of available attributes are:
|
||||
|
||||
Attribute|Notes
|
||||
---------|-----
|
||||
rotate|Rotate the PDF. Valid values are 90, 180, 270
|
||||
start|Start page number for PDF page selection
|
||||
end|End page number for PDF page selection
|
||||
|
||||
## Documentation
|
||||
|
||||
Additional documentation is maintained on the [project
|
||||
wiki](https://github.com/captn3m0/pystitcher/wiki) on GitHub.
|
@ -1,8 +1,55 @@
|
||||
[build-system]
|
||||
# AVOID CHANGING REQUIRES: IT WILL BE UPDATED BY PYSCAFFOLD!
|
||||
requires = ["setuptools>=46.1.0", "setuptools_scm[toml]>=5", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
requires = ["hatchling","hatch-vcs"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[tool.setuptools_scm]
|
||||
# See configuration details in https://github.com/pypa/setuptools_scm
|
||||
version_scheme = "no-guess-dev"
|
||||
[project]
|
||||
name = "pystitcher"
|
||||
dynamic = ["version"]
|
||||
description = "Stitch together a PDF file from multiple sources in a declarative manner"
|
||||
readme = {file = "README.md", content-type = "text/markdown"}
|
||||
license = "MIT"
|
||||
requires-python = ">=3.9"
|
||||
authors = [
|
||||
{ name = "Nemo", email = "python@captnemo.in" },
|
||||
]
|
||||
classifiers = [
|
||||
"Development Status :: 4 - Beta",
|
||||
"Programming Language :: Python",
|
||||
]
|
||||
dependencies = [
|
||||
"html5lib>=1.1",
|
||||
"importlib-metadata; python_version<\"3.8\"",
|
||||
"Markdown>=3.6",
|
||||
"PyPDF3>=1.0.6",
|
||||
"validators>=0.33.0",
|
||||
]
|
||||
|
||||
[project.optional-dependencies]
|
||||
testing = [
|
||||
"pytest",
|
||||
"pytest-cov",
|
||||
"setuptools",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
pystitcher = "pystitcher.skeleton:run"
|
||||
|
||||
[project.urls]
|
||||
Changelog = "https://github.com/captn3m0/pystitcher/blob/main/CHANGELOG.md"
|
||||
Documentation = "https://github.com/captn3m0/pystitcher/wiki"
|
||||
Homepage = "https://github.com/captn3m0/pystitcher"
|
||||
Source = "https://github.com/captn3m0/pystitcher"
|
||||
Tracker = "https://github.com/captn3m0/pystitcher/issues"
|
||||
|
||||
[tool.hatch.version]
|
||||
source = "vcs"
|
||||
[tool.hatch.build.hooks.vcs]
|
||||
version-file = "src/pystitcher/_version.py"
|
||||
|
||||
[tool.hatch.build.targets.sdist]
|
||||
include = [
|
||||
"/src",
|
||||
]
|
||||
|
||||
[tool.hatch.envs.default]
|
||||
installer = "uv"
|
||||
|
127
setup.cfg
127
setup.cfg
@ -1,127 +0,0 @@
|
||||
# This file is used to configure your project.
|
||||
# Read more about the various options under:
|
||||
# http://setuptools.readthedocs.io/en/latest/setuptools.html#configuring-setup-using-setup-cfg-files
|
||||
|
||||
[metadata]
|
||||
name = pystitcher
|
||||
description = Stitch together a PDF file from multiple sources in a declarative manner
|
||||
author = Nemo
|
||||
author_email = python@captnemo.in
|
||||
license = MIT
|
||||
long_description = file: README.rst
|
||||
long_description_content_type = text/x-rst; charset=UTF-8
|
||||
url = https://github.com/captn3m0/pystitcher
|
||||
# Add here related links, for example:
|
||||
project_urls =
|
||||
Documentation = https://github.com/captn3m0/pystitcher/wiki
|
||||
Source = https://github.com/captn3m0/pystitcher
|
||||
Changelog = https://github.com/captn3m0/pystitcher/blob/main/CHANGELOG.md
|
||||
Tracker = https://github.com/captn3m0/pystitcher/issues
|
||||
|
||||
# Change if running only on Windows, Mac or Linux (comma-separated)
|
||||
platforms = any
|
||||
|
||||
# Add here all kinds of additional classifiers as defined under
|
||||
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||
classifiers =
|
||||
Development Status :: 4 - Beta
|
||||
Programming Language :: Python
|
||||
|
||||
|
||||
[options]
|
||||
zip_safe = False
|
||||
packages = find_namespace:
|
||||
include_package_data = True
|
||||
package_dir =
|
||||
=src
|
||||
|
||||
# Require a min/specific Python version (comma-separated conditions)
|
||||
python_requires = >=3.7
|
||||
|
||||
# PyPDF3: Read and write PDF files
|
||||
# Markdown: Render input markdown file to HTML
|
||||
# html5lib: Parse HTML file to generate bookmarks
|
||||
# validators: Validate URL for fetching external PDF
|
||||
install_requires =
|
||||
importlib-metadata; python_version<"3.8"
|
||||
PyPDF3>=1.0.4
|
||||
Markdown>=3.3.4
|
||||
html5lib>=1.1
|
||||
validators>=0.18.1
|
||||
|
||||
[options.packages.find]
|
||||
where = src
|
||||
exclude =
|
||||
tests
|
||||
|
||||
[options.extras_require]
|
||||
# Add here additional requirements for extra features, to install with:
|
||||
# `pip install pystitcher[PDF]` like:
|
||||
# PDF = ReportLab; RXP
|
||||
|
||||
# Add here test requirements (semicolon/line-separated)
|
||||
testing =
|
||||
setuptools
|
||||
pytest
|
||||
pytest-cov
|
||||
|
||||
[options.entry_points]
|
||||
# Add here console scripts like:
|
||||
# console_scripts =
|
||||
# script_name = pystitcher.module:function
|
||||
# For example:
|
||||
console_scripts =
|
||||
pystitcher = pystitcher.skeleton:run
|
||||
# And any other entry points, for example:
|
||||
# pyscaffold.cli =
|
||||
# awesome = pyscaffoldext.awesome.extension:AwesomeExtension
|
||||
|
||||
[tool:pytest]
|
||||
# Specify command line options as you would do when invoking pytest directly.
|
||||
# e.g. --cov-report html (or xml) for html/xml output or --junitxml junit.xml
|
||||
# in order to write a coverage file that can be read by Jenkins.
|
||||
# CAUTION: --cov flags may prohibit setting breakpoints while debugging.
|
||||
# Comment those flags to avoid this py.test issue.
|
||||
addopts = --verbose
|
||||
# --cov pystitcher --cov-report term-missing
|
||||
|
||||
norecursedirs =
|
||||
dist
|
||||
build
|
||||
.tox
|
||||
testpaths = tests
|
||||
# Use pytest markers to select/deselect specific tests
|
||||
# markers =
|
||||
# slow: mark tests as slow (deselect with '-m "not slow"')
|
||||
# system: mark end-to-end system tests
|
||||
|
||||
[bdist_wheel]
|
||||
# Use this option if your package is pure-python
|
||||
universal = 1
|
||||
|
||||
[devpi:upload]
|
||||
# Options for the devpi: PyPI server and packaging tool
|
||||
# VCS export must be deactivated since we are using setuptools-scm
|
||||
no_vcs = 1
|
||||
formats = bdist_wheel
|
||||
|
||||
[flake8]
|
||||
# Some sane defaults for the code style checker flake8
|
||||
max_line_length = 88
|
||||
extend_ignore = E203, W503
|
||||
# ^ Black-compatible
|
||||
# E203 and W503 have edge cases handled by black
|
||||
exclude =
|
||||
.tox
|
||||
build
|
||||
dist
|
||||
.eggs
|
||||
docs/conf.py
|
||||
|
||||
[pyscaffold]
|
||||
# PyScaffold's parameters when the project was created.
|
||||
# This will be used when updating. Do not change!
|
||||
version = 4.0.2
|
||||
package = pystitcher
|
||||
extensions =
|
||||
no_tox
|
21
setup.py
21
setup.py
@ -1,21 +0,0 @@
|
||||
"""
|
||||
Setup file for pystitcher.
|
||||
Use setup.cfg to configure your project.
|
||||
|
||||
This file was generated with PyScaffold 4.0.2.
|
||||
PyScaffold helps you to put up the scaffold of your new Python project.
|
||||
Learn more under: https://pyscaffold.org/
|
||||
"""
|
||||
from setuptools import setup
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
setup(use_scm_version={"version_scheme": "no-guess-dev"})
|
||||
except: # noqa
|
||||
print(
|
||||
"\n\nAn error occurred while building the project, "
|
||||
"please ensure you have the most updated version of setuptools, "
|
||||
"setuptools_scm and wheel with:\n"
|
||||
" pip install -U setuptools setuptools_scm wheel\n\n"
|
||||
)
|
||||
raise
|
16
src/pystitcher/_version.py
Normal file
16
src/pystitcher/_version.py
Normal file
@ -0,0 +1,16 @@
|
||||
# file generated by setuptools_scm
|
||||
# don't change, don't track in version control
|
||||
TYPE_CHECKING = False
|
||||
if TYPE_CHECKING:
|
||||
from typing import Tuple, Union
|
||||
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
||||
else:
|
||||
VERSION_TUPLE = object
|
||||
|
||||
version: str
|
||||
__version__: str
|
||||
__version_tuple__: VERSION_TUPLE
|
||||
version_tuple: VERSION_TUPLE
|
||||
|
||||
__version__ = version = '1.0.5.dev2+g9a37aa7.d20240812'
|
||||
__version_tuple__ = version_tuple = (1, 0, 5, 'dev2', 'g9a37aa7.d20240812')
|
Loading…
Reference in New Issue
Block a user