packaged for pypi
This commit is contained in:
parent
c46521ae81
commit
0cad9c91c3
7 changed files with 264 additions and 71 deletions
177
.gitignore
vendored
Normal file
177
.gitignore
vendored
Normal file
|
@ -0,0 +1,177 @@
|
||||||
|
typings/
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# UV
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
||||||
|
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||||
|
# commonly ignored for libraries.
|
||||||
|
#uv.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/latest/usage/project/#working-with-version-control
|
||||||
|
.pdm.toml
|
||||||
|
.pdm-python
|
||||||
|
.pdm-build/
|
||||||
|
|
||||||
|
# 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/
|
||||||
|
|
||||||
|
# Ruff stuff:
|
||||||
|
.ruff_cache/
|
||||||
|
|
||||||
|
# PyPI configuration file
|
||||||
|
.pypirc
|
||||||
|
|
1
.python-version
Normal file
1
.python-version
Normal file
|
@ -0,0 +1 @@
|
||||||
|
3.11
|
|
@ -1,5 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
||||||
sudo cp "$SCRIPT_DIR/mailfmt" /usr/bin/mailfmt
|
|
||||||
echo "mailfmt has been installed to /usr/bin/mailfmt."
|
|
|
@ -16,35 +16,35 @@ import sys
|
||||||
import re
|
import re
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
paragraph: list[str] = []
|
|
||||||
skipping = False
|
|
||||||
squash = True
|
|
||||||
prev_is_parbreak = False
|
|
||||||
out_stream = sys.stdout
|
|
||||||
reflow = True
|
|
||||||
width = 74
|
|
||||||
break_long_words = False
|
|
||||||
replace_whitespace = True
|
|
||||||
markdown_safe = False
|
|
||||||
|
|
||||||
in_signoff = False
|
def main() -> None:
|
||||||
in_signature = False
|
paragraph: list[str] = []
|
||||||
|
skipping = False
|
||||||
|
squash = True
|
||||||
|
prev_is_parbreak = False
|
||||||
|
out_stream = sys.stdout
|
||||||
|
reflow = True
|
||||||
|
width = 74
|
||||||
|
break_long_words = False
|
||||||
|
replace_whitespace = True
|
||||||
|
markdown_safe = False
|
||||||
|
|
||||||
|
in_signoff = False
|
||||||
|
in_signature = False
|
||||||
|
|
||||||
def pprint(string: str):
|
def pprint(string: str):
|
||||||
if markdown_safe and (in_signoff or in_signature) and string:
|
if markdown_safe and (in_signoff or in_signature) and string:
|
||||||
string += " \\"
|
string += " \\"
|
||||||
if not squash:
|
if not squash:
|
||||||
print(string, file=out_stream)
|
print(string, file=out_stream)
|
||||||
else:
|
else:
|
||||||
parbreak = not string
|
parbreak = not string
|
||||||
global prev_is_parbreak
|
nonlocal prev_is_parbreak
|
||||||
if skipping or not (parbreak and prev_is_parbreak):
|
if skipping or not (parbreak and prev_is_parbreak):
|
||||||
print(string, file=out_stream)
|
print(string, file=out_stream)
|
||||||
prev_is_parbreak = parbreak
|
prev_is_parbreak = parbreak
|
||||||
|
|
||||||
|
def wrap(text: str):
|
||||||
def wrap(text: str):
|
|
||||||
return textwrap.wrap(
|
return textwrap.wrap(
|
||||||
text,
|
text,
|
||||||
width=width,
|
width=width,
|
||||||
|
@ -52,8 +52,7 @@ def wrap(text: str):
|
||||||
replace_whitespace=replace_whitespace,
|
replace_whitespace=replace_whitespace,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def flush_paragraph():
|
||||||
def flush_paragraph():
|
|
||||||
if paragraph:
|
if paragraph:
|
||||||
if reflow:
|
if reflow:
|
||||||
joined = " ".join(paragraph)
|
joined = " ".join(paragraph)
|
||||||
|
@ -65,11 +64,9 @@ def flush_paragraph():
|
||||||
pprint(wrapped_line)
|
pprint(wrapped_line)
|
||||||
paragraph.clear()
|
paragraph.clear()
|
||||||
|
|
||||||
|
signoff_cache: str = ""
|
||||||
|
|
||||||
signoff_cache: str = ""
|
def check_signoff(line: str) -> bool:
|
||||||
|
|
||||||
|
|
||||||
def check_signoff(line: str) -> bool:
|
|
||||||
if not line:
|
if not line:
|
||||||
return False
|
return False
|
||||||
words = line.split()
|
words = line.split()
|
||||||
|
@ -86,8 +83,6 @@ def check_signoff(line: str) -> bool:
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description='Formatter for plain text email.\n"--no-*" options are NOT passed by default.',
|
description='Formatter for plain text email.\n"--no-*" options are NOT passed by default.',
|
||||||
epilog="""
|
epilog="""
|
||||||
|
@ -228,4 +223,8 @@ Contact: daniel@ficd.ca
|
||||||
if out_stream is not None:
|
if out_stream is not None:
|
||||||
out_stream.close()
|
out_stream.close()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
||||||
# pyright: basic
|
# pyright: basic
|
17
pyproject.toml
Normal file
17
pyproject.toml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
[project]
|
||||||
|
name = "mailfmt"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = "Add your description here"
|
||||||
|
readme = "README.md"
|
||||||
|
authors = [
|
||||||
|
{ name = "Daniel Fichtinger", email = "daniel@ficd.ca" }
|
||||||
|
]
|
||||||
|
requires-python = ">=3.11"
|
||||||
|
dependencies = []
|
||||||
|
|
||||||
|
[project.scripts]
|
||||||
|
mailfmt = "mailfmt:main"
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["hatchling"]
|
||||||
|
build-backend = "hatchling.build"
|
|
@ -1,4 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
sudo rm /usr/bin/mailfmt
|
|
||||||
echo "mailfmt has been uninstalled."
|
|
8
uv.lock
generated
Normal file
8
uv.lock
generated
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
version = 1
|
||||||
|
revision = 2
|
||||||
|
requires-python = ">=3.11"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mailfmt"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = { editable = "." }
|
Loading…
Add table
Add a link
Reference in a new issue