diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9c5c0033..e04cbcec 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,11 +20,13 @@ repos: - id: yesqa additional_dependencies: &flake8_deps - flake8-bugbear + - flake8-builtins - flake8-comprehensions - flake8-implicit-str-concat - flake8-pie - flake8-pyproject - flake8-pytest-style + - flake8-requirements - flake8-simplify - flake8-unused-arguments - flake8-use-pathlib @@ -36,6 +38,12 @@ repos: - id: pyupgrade args: [--py38-plus] + - repo: https://github.com/MarcoGorelli/absolufy-imports + rev: v0.3.1 + hooks: + - id: absolufy-imports + exclude: ^tests/ + - repo: https://github.com/PyCQA/isort rev: 5.10.1 hooks: diff --git a/README.md b/README.md index 13e2814c..6e57b031 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,6 @@ yay -S python-images-upload-cli | [fastpic](https://fastpic.org/) | - | `https://i120.fastpic.org/big/2022/0730/d9/{id}.png` | | [filecoffee](https://file.coffee/) | - | `https://file.coffee/u/{id}.png` | | [freeimage](https://freeimage.host/) | - | `https://iili.io/{id}.png` | -| [geekpic](https://geekpic.net/) | - | `https://s01.geekpic.net/{id}.png` | | [gyazo](https://gyazo.com/) | + | `https://i.gyazo.com/{id}.png` | | [imageban](https://imageban.ru/) | + | `https://i2.imageban.ru/out/2022/07/30/{id}.png` | | [imgbb](https://imgbb.com/) | + | `https://i.ibb.co/{id}/image.png` | @@ -58,7 +57,7 @@ Usage: images-upload-cli [OPTIONS] IMAGES... Upload images via APIs. Options: - -h, --hosting [catbox|fastpic|filecoffee|freeimage|geekpic|gyazo|imageban|imgbb|imgchest|imgur|pictshare|pixeldrain|pixhost|ptpimg|screenshotting|smms|sxcu|telegraph|up2sha|uplio|uploadcare] + -h, --hosting [catbox|fastpic|filecoffee|freeimage|gyazo|imageban|imgbb|imgchest|imgur|pictshare|pixeldrain|pixhost|ptpimg|screenshotting|smms|sxcu|telegraph|up2sha|uplio|uploadcare] [default: imgur] -b, --bbcode Add bbcode tags. -t, --thumbnail Add caption thumbnail and bbcode tags. diff --git a/poetry.lock b/poetry.lock index cf1534e3..87d0dafd 100755 --- a/poetry.lock +++ b/poetry.lock @@ -131,7 +131,7 @@ toml = ["tomli"] [[package]] name = "distlib" -version = "0.3.5" +version = "0.3.6" description = "Distribution utilities" category = "dev" optional = false @@ -180,7 +180,7 @@ pyflakes = ">=2.5.0,<2.6.0" [[package]] name = "flake8-bugbear" -version = "22.8.22" +version = "22.8.23" description = "A plugin for flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle." category = "dev" optional = false @@ -193,6 +193,20 @@ flake8 = ">=3.0.0" [package.extras] dev = ["coverage", "hypothesis", "hypothesmith (>=0.2)", "pre-commit"] +[[package]] +name = "flake8-builtins" +version = "1.5.3" +description = "Check for python builtins being used as variables or parameters." +category = "dev" +optional = false +python-versions = "*" + +[package.dependencies] +flake8 = "*" + +[package.extras] +test = ["coverage", "coveralls", "mock", "pytest", "pytest-cov"] + [[package]] name = "flake8-comprehensions" version = "3.10.0" @@ -261,6 +275,18 @@ python-versions = ">=3.6.2,<4.0.0" [package.dependencies] flake8-plugin-utils = ">=1.3.2,<2.0.0" +[[package]] +name = "flake8-requirements" +version = "1.6.0" +description = "Package requirements checker, plugin for flake8" +category = "dev" +optional = false +python-versions = "*" + +[package.dependencies] +flake8 = ">=2.0.0" +toml = ">=0.7.0" + [[package]] name = "flake8-simplify" version = "0.19.3" @@ -770,7 +796,7 @@ testing = ["coverage (>=6.2)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7 [metadata] lock-version = "1.1" python-versions = "^3.8" -content-hash = "1d00dcac2a8ef866174b14db4966128b0576d0a9e8be1330cd2c75f819e258e6" +content-hash = "db8c26a9e2ccffd6ca8bef0a4f1d01947ca8afac228a8f208c292c5a903a5555" [metadata.files] astor = [ @@ -880,13 +906,20 @@ coverage = [ {file = "coverage-6.4.4-pp36.pp37.pp38-none-any.whl", hash = "sha256:f67cf9f406cf0d2f08a3515ce2db5b82625a7257f88aad87904674def6ddaec1"}, {file = "coverage-6.4.4.tar.gz", hash = "sha256:e16c45b726acb780e1e6f88b286d3c10b3914ab03438f32117c4aa52d7f30d58"}, ] -distlib = [] +distlib = [ + {file = "distlib-0.3.6-py2.py3-none-any.whl", hash = "sha256:f35c4b692542ca110de7ef0bea44d73981caeb34ca0b9b6b2e6d7790dda8f80e"}, + {file = "distlib-0.3.6.tar.gz", hash = "sha256:14bad2d9b04d3a36127ac97f30b12a19268f211063d8f8ee4f47108896e11b46"}, +] dparse = [] filelock = [] flake8 = [] flake8-bugbear = [ - {file = "flake8-bugbear-22.8.22.tar.gz", hash = "sha256:1d240736dc93ecad9ff21e1d521283b9461d132b3ff2170569bd5ff3dacda385"}, - {file = "flake8_bugbear-22.8.22-py3-none-any.whl", hash = "sha256:b5718bf5d0d28a4cfd15054f4706fc2936f7339ed8366b919a1979eb5df50764"}, + {file = "flake8-bugbear-22.8.23.tar.gz", hash = "sha256:de0717d11124a082118dd08387b34fd86b2721642ec2d8e92be66cfa5ea7c445"}, + {file = "flake8_bugbear-22.8.23-py3-none-any.whl", hash = "sha256:1b0ebe0873d1cd55bf9f1588bfcb930db339018ef44a3981a26532daa9fd14a8"}, +] +flake8-builtins = [ + {file = "flake8-builtins-1.5.3.tar.gz", hash = "sha256:09998853b2405e98e61d2ff3027c47033adbdc17f9fe44ca58443d876eb00f3b"}, + {file = "flake8_builtins-1.5.3-py2.py3-none-any.whl", hash = "sha256:7706babee43879320376861897e5d1468e396a40b8918ed7bccf70e5f90b8687"}, ] flake8-comprehensions = [ {file = "flake8-comprehensions-3.10.0.tar.gz", hash = "sha256:181158f7e7aa26a63a0a38e6017cef28c6adee71278ce56ce11f6ec9c4905058"}, @@ -909,6 +942,9 @@ flake8-pytest-style = [ {file = "flake8-pytest-style-1.6.0.tar.gz", hash = "sha256:c1175713e9e11b78cd1a035ed0bca0d1e41d09c4af329a952750b61d4194ddac"}, {file = "flake8_pytest_style-1.6.0-py3-none-any.whl", hash = "sha256:5fedb371a950e9fe0e0e6bfc854be7d99151271208f34cd2cc517681ece27780"}, ] +flake8-requirements = [ + {file = "flake8_requirements-1.6.0-py2.py3-none-any.whl", hash = "sha256:8c1b31ac71b7c5c17de60d1e1c111cea91a73cc9362146ad7125b1cce305605d"}, +] flake8-simplify = [] flake8-unused-arguments = [] flake8-use-pathlib = [] diff --git a/pyproject.toml b/pyproject.toml index 17535556..a8cd745d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "images-upload-cli" -version = "1.0.3" +version = "1.0.4" description = "Upload images via APIs" authors = ["DeadNews "] license = "MIT" @@ -26,11 +26,13 @@ bandit = "^1.7.4" black = "^22.3.0" flake8 = "^5.0.4" flake8-bugbear = "^22.4.25" +flake8-builtins = "^1.5.3" flake8-comprehensions = "^3.10.0" flake8-implicit-str-concat = "^0.3.0" flake8-pie = "^0.16.0" flake8-pyproject = "^1.1.0" flake8-pytest-style = "^1.6.0" +flake8-requirements = "^1.6.0" flake8-simplify = "^0.19.3" flake8-unused-arguments = "^0.0.11" flake8-use-pathlib = "^0.3.0" @@ -65,6 +67,9 @@ ignore = [ "PIE803", # Use lazy % formatting in logging functions. "W503", # Line break occurred before a binary operator. ] +per-file-ignores = [ + "tests/*: I900", # Package is not listed as a requirement. +] [tool.mypy] disallow_untyped_defs = true @@ -100,11 +105,5 @@ mypy = "mypy ." flake8 = "flake8 ." bandit = "bandit -c pyproject.toml -r ." safety = "safety check --bare" - -[tool.poe.tasks.ci] -help = "CI sequence" -sequence = ["isort", "black", "mypy", "flake8", "bandit", "safety"] - -[tool.poe.tasks.pc] -help = "pre-commit" -cmd = "pre-commit run --all-files" +ci.sequence = ["isort", "black", "mypy", "flake8", "bandit", "safety"] +pc = "pre-commit run --all-files" diff --git a/src/images_upload_cli/__init__.py b/src/images_upload_cli/__init__.py index eb03506c..29f909cf 100755 --- a/src/images_upload_cli/__init__.py +++ b/src/images_upload_cli/__init__.py @@ -1,5 +1,5 @@ #!/usr/bin/env python # flake8: noqa F401 -from .upload import HOSTINGS, UPLOAD, UploadError -from .util import make_thumbnail +from images_upload_cli.upload import HOSTINGS, UPLOAD, UploadError +from images_upload_cli.util import make_thumbnail diff --git a/src/images_upload_cli/__main__.py b/src/images_upload_cli/__main__.py index 6e8f07d2..60a1ac5b 100755 --- a/src/images_upload_cli/__main__.py +++ b/src/images_upload_cli/__main__.py @@ -2,7 +2,7 @@ """ Entry point for cli, enables execution with `python -m images_upload_cli` """ -from .cli import cli +from images_upload_cli.cli import cli if __name__ == "__main__": cli() diff --git a/src/images_upload_cli/cli.py b/src/images_upload_cli/cli.py index 4927eee3..05d05627 100755 --- a/src/images_upload_cli/cli.py +++ b/src/images_upload_cli/cli.py @@ -7,8 +7,8 @@ from dotenv import load_dotenv from pyperclip import copy -from .upload import HOSTINGS, UPLOAD -from .util import get_config_path, kdialog, make_thumbnail +from images_upload_cli.upload import HOSTINGS, UPLOAD +from images_upload_cli.util import get_config_path, kdialog, make_thumbnail @click.command(context_settings={"show_default": True}) diff --git a/src/images_upload_cli/upload.py b/src/images_upload_cli/upload.py index 9494ab52..b960384b 100755 --- a/src/images_upload_cli/upload.py +++ b/src/images_upload_cli/upload.py @@ -1,7 +1,6 @@ #!/usr/bin/env python from __future__ import annotations -from base64 import b64encode from collections.abc import Callable from os import getenv from re import search @@ -9,7 +8,7 @@ from requests import get, post -from .util import get_env_val, get_img_ext +from images_upload_cli.util import get_env_val, get_img_ext class UploadError(Exception): @@ -75,17 +74,6 @@ def freeimage_upload(img: bytes) -> str: return response.json()["image"]["url"] -def geekpic_upload(img: bytes) -> str: - response = post( - url="https://geekpic.net/client.php", - data={"image": b64encode(img)}, - ) - if not response.ok: - raise UploadError(response.json()) - - return response.json()["link"] - - def gyazo_upload(img: bytes) -> str: key = get_env_val("GYAZO_TOKEN") @@ -321,7 +309,6 @@ def uploadcare_upload(img: bytes) -> str: "fastpic": fastpic_upload, "filecoffee": filecoffee_upload, "freeimage": freeimage_upload, - "geekpic": geekpic_upload, "gyazo": gyazo_upload, "imageban": imageban_upload, "imgbb": imgbb_upload,