generated from BastiTee/python-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,405 additions
and
325 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"python.analysis.extraPaths": [ | ||
"my_module", | ||
"kindle_to_markdown", | ||
"tests", | ||
".venv/bin/python" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,45 @@ | ||
# python-boilerplate  | ||
# Kindle Annotations to Markdown | ||
|
||
> A best-practices template project for Python modules | ||
> A simple program to convert Kindle HTML annotations to a Markdown file | ||
## Setup | ||
## Features | ||
|
||
- Create a new repository [using this template](https://github.com/BastiTee/python-boilerplate/generate). | ||
- Make sure that `python` is installed and available on system path. I recommend using [`pyenv`](https://github.com/pyenv/pyenv). Note that Python 2 is _not_ supported. It's end of life was on January 1st, 2020. | ||
- Make sure [`poetry`](https://python-poetry.org/) is installed. This usually just means `python -m pip install poetry`. | ||
- Rename the project using [the provided script](rename_template.sh): `./rename_template.sh`. | ||
- Run `make` to initialize the project configuration and build everything. | ||
- Refer to [the Makefile](Makefile) to learn about the various operations available. Most of them are just facades for `poetry`. | ||
- Conversion of page bookmarks, text highlights, and notes to Markdown | ||
- Included reference positions of annotations | ||
- Automatic detection of annotation file's language | ||
|
||
## Features | ||
## Usage | ||
|
||
```shell | ||
$ kindle_to_markdown --help | ||
Usage: kindle_to_markdown [OPTIONS] | ||
|
||
A simple program to convert Kindle HTML annotations to a Markdown file. | ||
|
||
Options: | ||
-i, --input-file PATH Path to the Kindle annotations HTML file. | ||
[required] | ||
-o, --output-file PATH Path to the Markdown file. | ||
-p, --print-only Only print Markdown to the console. | ||
--help Show this message and exit. | ||
``` | ||
|
||
## Installation | ||
|
||
### From PyPi | ||
|
||
```shell | ||
pip install kindle-to-markdown | ||
``` | ||
|
||
### From Source | ||
|
||
Prerequisites: | ||
|
||
- `python` in a [supported version](pyproject.toml) available on your path. | ||
- Package manager `poetry` installed (e.g., `python -m pip install poetry`) | ||
|
||
- Basic project/module organization according to <https://packaging.python.org> | ||
- Makefile bootstrapping script | ||
- [poetry](https://python-poetry.org/) with virtual environments and project builds | ||
- [black](https://github.com/psf/black) code formatting | ||
- Unit testing with [pytest](https://docs.pytest.org/en/latest/) | ||
- Linting ([flake8](http://flake8.pycqa.org)) and code formatting ([autopep8](https://github.com/hhatto/autopep8)) support | ||
- [isort](https://pypi.org/project/isort/) support for automated import sorting | ||
- [mpyp](https://pypi.org/project/mypy/) support for type checking | ||
- Publishing to PyPi.org | ||
- [vscode](https://code.visualstudio.com/) editor configuration including plugin recommendations, debugging support, unit test discovery and on-save formatting | ||
- [Github actions](https://github.com/BastiTee/python-boilerplate/actions) continuous integration with multi-python testing | ||
- Executable script so after package installation you can run from the CLI using `my_module_cli` | ||
|
||
## Resources | ||
|
||
- <http://packaging.python.org/> | ||
- <https://packaging.python.org/en/latest/distributing.html> | ||
- <https://pypi.org/> | ||
- <https://github.com/pypa/sampleproject> | ||
- <https://www.python.org/dev/peps/> | ||
- <https://www.python.org/dev/peps/pep-0008/> | ||
- <https://www.kennethreitz.org/essays/why-you-should-use-vs-code-if-youre-a-python-developer> | ||
- <https://code.visualstudio.com/docs/python/python-tutorial> | ||
|
||
## Future ideas and todos | ||
|
||
- Embed flake8 config into `pyproject.toml` once they support it ([see](https://github.com/PyCQA/flake8/issues/234)) | ||
- Use cookiecutter instead of [shell script](./rename_template.sh) (it does work fine at the moment though) | ||
|
||
## Licensing | ||
|
||
This project is licensed under [Apache License 2.0](LICENSE.txt). | ||
```shell | ||
make | ||
poetry run python -m kindle_to_markdown --help | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
if [ -z "$1" ]; then | ||
echo "No Kindle annotations HTML provided." | ||
exit 1 | ||
fi | ||
|
||
ifile="$( cd "$(dirname "$1")"; pwd )/$(basename "$1")" | ||
ofile="$(dirname "$ifile")/$(basename "$ifile" .html ).md" | ||
echo -e "$ifile\n>> $ofile" | ||
|
||
cd "$( cd "$( dirname "$0" )"; pwd )" | ||
|
||
poetry run python \ | ||
-m kindle_to_markdown \ | ||
-i "$ifile" -o "$ofile" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Module init-file.""" |
Oops, something went wrong.