Skip to content

Commit

Permalink
Dev (#24)
Browse files Browse the repository at this point in the history
- Remove geekpic (shutdown)
- Add absolufy-import
- Add flake8-builtins
- Add flake8-requirements
  • Loading branch information
DeadNews authored Aug 29, 2022
1 parent d05caa9 commit 95d4195
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 36 deletions.
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
Expand All @@ -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.
Expand Down
48 changes: 42 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 8 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "MIT"
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
4 changes: 2 additions & 2 deletions src/images_upload_cli/__init__.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/images_upload_cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
4 changes: 2 additions & 2 deletions src/images_upload_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
15 changes: 1 addition & 14 deletions src/images_upload_cli/upload.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#!/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
from urllib.parse import urlparse

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):
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 95d4195

Please sign in to comment.