From feb196d31da9573c7844c09f6b166fd6796df5ec Mon Sep 17 00:00:00 2001 From: Kieran W <41634689+FredHappyface@users.noreply.github.com> Date: Sun, 25 Jun 2023 23:44:25 +0100 Subject: [PATCH] rel 2022.1.1 --- CHANGELOG.md | 5 + README.md | 38 +++++++- documentation/reference/MODULES.md | 11 --- documentation/reference/README.md | 7 +- .../reference/sigstickers/caching.md | 40 +++++--- .../reference/sigstickers/downloader.md | 91 ++++++++++++------- documentation/reference/sigstickers/index.md | 29 ++++-- documentation/reference/sigstickers/module.md | 8 +- pyproject.toml | 52 ++++++----- requirements.txt | 6 +- sigstickers/downloader.py | 5 +- tests/test_main.py | 8 +- 12 files changed, 192 insertions(+), 108 deletions(-) delete mode 100644 documentation/reference/MODULES.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e84ab2..a049a6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ All major and minor version changes will be documented in this file. Details of patch-level version changes can be found in [commit messages](../../commits/master). +## 2022.1.1 - 2022/06/25 + +- Fix: use `os.makedirs` instead of `os.mkdir` +- Update pre-commit + ## 2022.1 - 2022/04/11 - Tests and code improvements diff --git a/README.md b/README.md index 32c7409..8093b0b 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [![PyPI Total Downloads](https://img.shields.io/badge/dynamic/json?style=for-the-badge&label=total%20downloads&query=%24.total_downloads&url=https%3A%2F%2Fapi.pepy.tech%2Fapi%2Fprojects%2Fsigstickers)](https://pepy.tech/project/sigstickers) [![PyPI Version](https://img.shields.io/pypi/v/sigstickers.svg?style=for-the-badge)](https://pypi.org/project/sigstickers) - + # SigStickers - Signal Sticker Downloader Project Icon @@ -34,6 +34,8 @@ Download sticker packs from Signal - [How to run](#how-to-run) - [Windows](#windows) - [Linux/ MacOS](#linux-macos) +- [Building](#building) +- [Testing](#testing) - [Download Project](#download-project) - [Clone](#clone) - [Using The Command Line](#using-the-command-line) @@ -108,8 +110,8 @@ Head to https://pypi.org/project/sigstickers/ for more info ### Built for -This program has been written for Python versions 3.7 - 3.10 and has been tested with both 3.7 and -3.10 +This program has been written for Python versions 3.8 - 3.11 and has been tested with both 3.8 and +3.11 ## Install Python on Windows @@ -169,6 +171,36 @@ version. - File `python3.x [file]` or `./[file]` +## Building + +This project uses https://github.com/FHPythonUtils/FHMake to automate most of the building. This +command generates the documentation, updates the requirements.txt and builds the library artefacts + +Note the functionality provided by fhmake can be approximated by the following + +```sh +handsdown --cleanup -o documentation/reference +poetry export -f requirements.txt --output requirements.txt +poetry export -f requirements.txt --with dev --output requirements_optional.txt +poetry build +``` + +`fhmake audit` can be run to perform additional checks + +## Testing + +For testing with the version of python used by poetry use + +```sh +poetry run pytest +``` + +Alternatively use `tox` to run tests over python 3.8 - 3.11 + +```sh +tox +``` + ## Download Project ### Clone diff --git a/documentation/reference/MODULES.md b/documentation/reference/MODULES.md deleted file mode 100644 index 8052d0c..0000000 --- a/documentation/reference/MODULES.md +++ /dev/null @@ -1,11 +0,0 @@ -# Sigstickers Modules - -> Auto-generated documentation modules index. - -Full list of [Sigstickers](README.md#sigstickers-index) project modules. - -- [Sigstickers Index](README.md#sigstickers-index) -- [Sigstickers](sigstickers/index.md#sigstickers) - - [Module](sigstickers/module.md#module) - - [Caching](sigstickers/caching.md#caching) - - [Downloader](sigstickers/downloader.md#downloader) diff --git a/documentation/reference/README.md b/documentation/reference/README.md index 8052d0c..07f7430 100644 --- a/documentation/reference/README.md +++ b/documentation/reference/README.md @@ -1,10 +1,9 @@ -# Sigstickers Modules +# Sigstickers Index -> Auto-generated documentation modules index. +> Auto-generated documentation index. -Full list of [Sigstickers](README.md#sigstickers-index) project modules. +A full list of `Sigstickers` project modules. -- [Sigstickers Index](README.md#sigstickers-index) - [Sigstickers](sigstickers/index.md#sigstickers) - [Module](sigstickers/module.md#module) - [Caching](sigstickers/caching.md#caching) diff --git a/documentation/reference/sigstickers/caching.md b/documentation/reference/sigstickers/caching.md index 87e58c6..104e67b 100644 --- a/documentation/reference/sigstickers/caching.md +++ b/documentation/reference/sigstickers/caching.md @@ -1,20 +1,18 @@ # Caching -> Auto-generated documentation for [sigstickers.caching](../../../sigstickers/caching.py) module. +[Sigstickers Index](../README.md#sigstickers-index) / +[Sigstickers](./index.md#sigstickers) / +Caching -Sticker caching functionality used by the downloader. +> Auto-generated documentation for [sigstickers.caching](../../../sigstickers/caching.py) module. -- [Sigstickers](../README.md#sigstickers-index) / [Modules](../MODULES.md#sigstickers-modules) / [Sigstickers](index.md#sigstickers) / Caching - - [createConverted](#createconverted) - - [verifyConverted](#verifyconverted) +- [Caching](#caching) + - [createConverted](#createconverted) + - [verifyConverted](#verifyconverted) ## createConverted -[[find in source code]](../../../sigstickers/caching.py#L52) - -```python -def createConverted(packName: str, data: dict): -``` +[Show source in caching.py:52](../../../sigstickers/caching.py#L52) Write cache data to a file identified by packName @@ -23,14 +21,19 @@ Write cache data to a file identified by packName - `packName` *str* - name of the sticker pack eg. "DonutTheDog" - `data` *dict* - packName cache data to write to cache -## verifyConverted - -[[find in source code]](../../../sigstickers/caching.py#L14) +#### Signature ```python -def verifyConverted(packName: str) -> bool: +def createConverted(packName: str, data: dict): + ... ``` + + +## verifyConverted + +[Show source in caching.py:14](../../../sigstickers/caching.py#L14) + Verify the cache for a packName eg. "DonutTheDog". Uses the cache "version" to call the verify function for that version @@ -41,3 +44,12 @@ to call the verify function for that version #### Returns - `bool` - if the converted cache has been verified + +#### Signature + +```python +def verifyConverted(packName: str) -> bool: + ... +``` + + diff --git a/documentation/reference/sigstickers/downloader.md b/documentation/reference/sigstickers/downloader.md index 320edd5..532a09e 100644 --- a/documentation/reference/sigstickers/downloader.md +++ b/documentation/reference/sigstickers/downloader.md @@ -1,23 +1,21 @@ # Downloader -> Auto-generated documentation for [sigstickers.downloader](../../../sigstickers/downloader.py) module. +[Sigstickers Index](../README.md#sigstickers-index) / +[Sigstickers](./index.md#sigstickers) / +Downloader -Sticker download and convert functions used by the module entry point. +> Auto-generated documentation for [sigstickers.downloader](../../../sigstickers/downloader.py) module. -- [Sigstickers](../README.md#sigstickers-index) / [Modules](../MODULES.md#sigstickers-modules) / [Sigstickers](index.md#sigstickers) / Downloader - - [assureDirExists](#assuredirexists) - - [convertPack](#convertpack) - - [convertWithPIL](#convertwithpil) - - [downloadPack](#downloadpack) - - [saveSticker](#savesticker) +- [Downloader](#downloader) + - [assureDirExists](#assuredirexists) + - [convertPack](#convertpack) + - [convertWithPIL](#convertwithpil) + - [downloadPack](#downloadpack) + - [saveSticker](#savesticker) ## assureDirExists -[[find in source code]](../../../sigstickers/downloader.py#L19) - -```python -def assureDirExists(directory: str, root: str) -> str: -``` +[Show source in downloader.py:19](../../../sigstickers/downloader.py#L19) Make the dir if not exists @@ -30,14 +28,19 @@ Make the dir if not exists - `str` - the full path -## convertPack - -[[find in source code]](../../../sigstickers/downloader.py#L115) +#### Signature ```python -async def convertPack(swd: str, packName: str, noCache=False): +def assureDirExists(directory: str, root: str) -> str: + ... ``` + + +## convertPack + +[Show source in downloader.py:112](../../../sigstickers/downloader.py#L112) + Convert the webp images into png and gif images #### Arguments @@ -46,14 +49,19 @@ Convert the webp images into png and gif images - `packName` *str* - name of the sticker pack (for cache + logging) - `noCache` *bool, optional* - set to true to disable cache. Defaults to False. -## convertWithPIL - -[[find in source code]](../../../sigstickers/downloader.py#L94) +#### Signature ```python -def convertWithPIL(inputFile: str) -> str: +async def convertPack(swd: str, packName: str, noCache=False): + ... ``` + + +## convertWithPIL + +[Show source in downloader.py:91](../../../sigstickers/downloader.py#L91) + Convert the webp file to png #### Arguments @@ -64,18 +72,19 @@ Convert the webp file to png - `str` - path to input file -## downloadPack - -[[find in source code]](../../../sigstickers/downloader.py#L57) +#### Signature ```python -async def downloadPack( - packId: str, - packKey: str, - cwd: str = os.getcwd(), -) -> tuple[str, str]: +def convertWithPIL(inputFile: str) -> str: + ... ``` + + +## downloadPack + +[Show source in downloader.py:54](../../../sigstickers/downloader.py#L54) + Download a sticker pack. #### Arguments @@ -89,14 +98,21 @@ c957a57000626a2dc3cb69bf0e79c91c6b196b74d4d6ca1cbb830d3ad0ad4e36 - `tuple[str,` *str]* - sticker working directory and pack title -## saveSticker - -[[find in source code]](../../../sigstickers/downloader.py#L38) +#### Signature ```python -def saveSticker(sticker: Sticker, path: str) -> str: +async def downloadPack( + packId: str, packKey: str, cwd: str = os.getcwd() +) -> tuple[str, str]: + ... ``` + + +## saveSticker + +[Show source in downloader.py:35](../../../sigstickers/downloader.py#L35) + Save a sticker #### Arguments @@ -107,3 +123,12 @@ Save a sticker #### Returns - `str` - the filepath the file was written to + +#### Signature + +```python +def saveSticker(sticker: Sticker, path: str) -> str: + ... +``` + + diff --git a/documentation/reference/sigstickers/index.md b/documentation/reference/sigstickers/index.md index d391280..c64ed48 100644 --- a/documentation/reference/sigstickers/index.md +++ b/documentation/reference/sigstickers/index.md @@ -1,22 +1,31 @@ # Sigstickers -> Auto-generated documentation for [sigstickers](../../../sigstickers/__init__.py) module. +[Sigstickers Index](../README.md#sigstickers-index) / +Sigstickers -Download sticker packs from Signal +> Auto-generated documentation for [sigstickers](../../../sigstickers/__init__.py) module. -- [Sigstickers](../README.md#sigstickers-index) / [Modules](../MODULES.md#sigstickers-modules) / Sigstickers - - [cli](#cli) - - Modules - - [Module](module.md#module) - - [Caching](caching.md#caching) - - [Downloader](downloader.md#downloader) +- [Sigstickers](#sigstickers) + - [cli](#cli) + - [Modules](#modules) ## cli -[[find in source code]](../../../sigstickers/__init__.py#L13) +[Show source in __init__.py:13](../../../sigstickers/__init__.py#L13) + +cli entry point + +#### Signature ```python def cli(): + ... ``` -cli entry point + + +## Modules + +- [Module](./module.md) +- [Caching](./caching.md) +- [Downloader](./downloader.md) \ No newline at end of file diff --git a/documentation/reference/sigstickers/module.md b/documentation/reference/sigstickers/module.md index d76be56..d8f539d 100644 --- a/documentation/reference/sigstickers/module.md +++ b/documentation/reference/sigstickers/module.md @@ -1,7 +1,9 @@ # Module -> Auto-generated documentation for [sigstickers.__main__](../../../sigstickers/__main__.py) module. +[Sigstickers Index](../README.md#sigstickers-index) / +[Sigstickers](./index.md#sigstickers) / +Module -entry point for python -m sigstickers +> Auto-generated documentation for [sigstickers.__main__](../../../sigstickers/__main__.py) module. -- [Sigstickers](../README.md#sigstickers-index) / [Modules](../MODULES.md#sigstickers-modules) / [Sigstickers](index.md#sigstickers) / Module +- [Module](#module) diff --git a/pyproject.toml b/pyproject.toml index 4a2e123..8c5361f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "sigstickers" -version = "2022.1" +version = "2022.1.1" license = "mit" description = "Download sticker packs from Signal" authors = ["FredHappyface"] @@ -13,7 +13,7 @@ classifiers = [ "Programming Language :: Python :: Implementation :: CPython", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities", - "Topic :: Multimedia :: Graphics" + "Topic :: Multimedia :: Graphics", ] homepage = "https://github.com/FHPythonUtils/SigStickers" repository = "https://github.com/FHPythonUtils/SigStickers" @@ -22,9 +22,9 @@ readme = "README.md" [tool.poetry.dependencies] python = "^3.7" -Pillow = "<10,>=9.1.0" -signalstickers-client = "<4,>=3.1.0" -emoji = "<2,>=1.7.0" +Pillow = "<10,>=9.5.0" +signalstickers-client = "<4,>=3.2.0" +emoji = "<3,>=2.5.1" [tool.poetry.scripts] sigstickers = "sigstickers:cli" @@ -35,6 +35,18 @@ coverage = "^6.3.2" handsdown = "^1.1.0" pylint = "^2.13.5" +[tool.black] +line-length = 100 +target-version = ["py38"] + +[tool.isort] +profile = "black" +indent = "Tab" + +[tool.pydocstyle] +convention = "google" +ignore = "D205,D415" + [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" @@ -50,24 +62,22 @@ variable-naming-style = "camelCase" indent-string = "\t" [tool.pylint.master] -ignore-patterns = "test_.*?py" +ignore-paths = ["tests"] [tool.pylint.messages_control] enable = ["F", "E", "W", "R", "C"] -disable = [ - "pointless-string-statement", - "superfluous-parens", - "bad-continuation" -] +disable = ["pointless-string-statement", "superfluous-parens"] -[tool.black] -line-length = 100 -target-version = ["py37"] - -[tool.isort] -profile = "black" -indent = "Tab" +[tool.tox] +legacy_tox_ini = """ +[tox] +env_list = + py311 + py310 + py39 + py38 -[tool.pydocstyle] -convention = "google" -ignore = "D205,D415" +[testenv] +deps = pytest +commands = pytest tests +""" diff --git a/requirements.txt b/requirements.txt index 71fac13..c8ae5ee 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -Pillow<10,>=9.1.0 -emoji<2,>=1.7.0 -signalstickers-client<4,>=3.1.0 +Pillow<10,>=9.5.0 +emoji<3,>=2.5.1 +signalstickers-client<4,>=3.2.0 diff --git a/sigstickers/downloader.py b/sigstickers/downloader.py index 17f3c14..6f9892d 100644 --- a/sigstickers/downloader.py +++ b/sigstickers/downloader.py @@ -27,10 +27,7 @@ def assureDirExists(directory: str, root: str) -> str: str: the full path """ fullPath = opj(root, directory) - if os.path.isdir(fullPath): - pass - else: - os.mkdir(fullPath) + os.makedirs(fullPath, exist_ok=True) return fullPath diff --git a/tests/test_main.py b/tests/test_main.py index e436798..523a728 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -23,12 +23,16 @@ def test_downloadPack(): - swd, packName = asyncio.run(downloader.downloadPack(packs[0]["packId"], packs[0]["packKey"], cwd)) + swd, packName = asyncio.run( + downloader.downloadPack(packs[0]["packId"], packs[0]["packKey"], cwd) + ) assert swd.replace("\\", "/"), packName == (f"{cwd}/downloads/DonutTheDog", "DonutTheDog") assert len(list(Path(f"{cwd}/downloads/DonutTheDog/webp").iterdir())) == packs[0]["len"] def test_convertPack(): - swd, packName = asyncio.run(downloader.downloadPack(packs[0]["packId"], packs[0]["packKey"], cwd)) + swd, packName = asyncio.run( + downloader.downloadPack(packs[0]["packId"], packs[0]["packKey"], cwd) + ) asyncio.run(downloader.convertPack(swd, packName, noCache=True)) assert len(list(Path(f"{cwd}/downloads/DonutTheDog/png").iterdir())) == packs[0]["len"]