1
0
mirror of https://github.com/enpaul/kodak.git synced 2024-11-23 15:07:13 +00:00

Rename project to imagemuck

This commit is contained in:
Ethan Paul 2021-05-05 13:48:02 -04:00
parent 6a7662ae0f
commit d92b53a60c
No known key found for this signature in database
GPG Key ID: D0E2CBF1245E92BF
31 changed files with 116 additions and 116 deletions

2
.gitignore vendored
View File

@ -16,7 +16,7 @@ dist/
docs/_build/
docs/modules.rst
docs/dehance*.rst
docs/imagemuck*.rst
.vscode/
.idea/

View File

@ -32,7 +32,7 @@ repos:
name: reorder-python-imports
entry: reorder-python-imports
args:
- "--unclassifiable-application-module=dehance"
- "--unclassifiable-application-module=imagemuck"
language: system
types: [python]

View File

@ -1,7 +1,7 @@
# Dehance makefile
# ImageMuck makefile
# You can set these variables from the command line
PROJECT = dehance
PROJECT = imagemuck
.PHONY: help
# Put it first so that "make" without argument is like "make help"

View File

@ -1,4 +1,4 @@
# dehance
# imagemuck
HTTP server for handling image uploads and thumbnail generation.

View File

@ -1,19 +0,0 @@
from typing import Tuple
from dehance.resources._shared import DehanceResource
from dehance.resources._shared import ResponseBody
from dehance.resources._shared import ResponseHeaders
from dehance.resources.image import Image
from dehance.resources.image import ImageUpload
from dehance.resources.openapi import OpenAPI
from dehance.resources.thumbnail import ThumbnailResize
from dehance.resources.thumbnail import ThumbnailScale
RESOURCES: Tuple[DehanceResource, ...] = (
ImageUpload,
Image,
OpenAPI,
ThumbnailScale,
ThumbnailResize,
)

View File

@ -12,7 +12,7 @@ from pathlib import Path
BASE_DIR = Path(__file__).parent.resolve()
ABOUT = {}
with open(Path(BASE_DIR, "..", "dehance", "__about__.py")) as infile:
with open(Path(BASE_DIR, "..", "imagemuck", "__about__.py")) as infile:
exec(infile.read(), ABOUT)

View File

@ -1,11 +1,11 @@
Dehance
ImageMuck
=========
.. toctree::
:maxdepth: 2
:caption: Contents:
API Reference <dehance>
API Reference <imagemuck>

View File

@ -1,9 +1,9 @@
"""Programatically accessible project metadata"""
__title__ = "dehance"
__title__ = "imagemuck"
__version__ = "0.1.0"
__authors__ = ["Ethan Paul <24588726+enpaul@users.noreply.github.com>"]
__license__ = "MIT"
__summary__ = "HTTP server for uploading images and generating thumbnails"
__url__ = "https://github.com/mocproject/dehance/"
__url__ = "https://github.com/mocproject/imagemuck/"

View File

@ -1,12 +1,12 @@
"""Development server stub entrypoint
Flask comes with a built-in development server. This entrypoint allows ``dehance``
Flask comes with a built-in development server. This entrypoint allows ``imagemuck``
to be run directly to run the development server and expose some simple config options for ease of
access. Run the below command to start the server:
::
python -m dehance
python -m imagemuck
In addition to the helpful CLI flags, the Flask development server run by this module will also
load any ``.env`` files in the current working directory when running the application.
@ -17,7 +17,7 @@ load any ``.env`` files in the current working directory when running the applic
import argparse
import sys
from dehance.application import APPLICATION
from imagemuck.application import APPLICATION
# pylint: disable=invalid-name

View File

@ -1,11 +1,11 @@
import flask
from dehance import __about__
from dehance import configuration
from dehance import constants
from dehance import database
from dehance import exceptions
from dehance.resources import ResponseHeaders
from imagemuck import __about__
from imagemuck import configuration
from imagemuck import constants
from imagemuck import database
from imagemuck import exceptions
from imagemuck.resources import ResponseHeaders
def make_the_tea() -> None:
@ -23,7 +23,7 @@ def initialize_database() -> None:
database.initialize(flask.current_app.appconfig)
class DehanceRequest(flask.Request):
class ImageMuckRequest(flask.Request):
"""Extend the default Flask request object to add custom application state settings"""
def make_response_headers(self) -> ResponseHeaders:
@ -40,14 +40,14 @@ class DehanceRequest(flask.Request):
}
class DehanceFlask(flask.Flask):
class ImageMuckFlask(flask.Flask):
"""Extend the default Flask object to add the custom application config
There's probably an easier/more kosher way to do this, but ¯\\_(ツ)_/¯
"""
request_class = DehanceRequest
request_class = ImageMuckRequest
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.appconfig: configuration.DehanceConfig = configuration.load()
self.appconfig: configuration.ImageMuckConfig = configuration.load()

View File

@ -1,12 +1,12 @@
import flask_restful
from dehance import resources
from dehance._server import DehanceFlask
from dehance._server import initialize_database
from dehance._server import make_the_tea
from imagemuck import resources
from imagemuck._server import ImageMuckFlask
from imagemuck._server import initialize_database
from imagemuck._server import make_the_tea
APPLICATION = DehanceFlask(__name__)
APPLICATION = ImageMuckFlask(__name__)
API = flask_restful.Api(APPLICATION, catch_all_404s=True)

View File

@ -8,7 +8,7 @@ from typing import Dict
from typing import Optional
from typing import Tuple
from dehance import constants
from imagemuck import constants
def _default_sqlite_pragmas() -> Dict[str, Any]:
@ -31,7 +31,7 @@ def _default_sqlite_pragmas() -> Dict[str, Any]:
@dataclass
class _DBSqliteConfig:
path: Path = Path.cwd() / "dehance.db"
path: Path = Path.cwd() / "imagemuck.db"
pragmas: Dict[str, Any] = field(default_factory=_default_sqlite_pragmas)
@classmethod
@ -51,7 +51,7 @@ class _DBMariaConfig:
username: str = "root"
password: Optional[str] = None
port: int = 3306
schema: str = "dehance"
schema: str = "imagemuck"
@classmethod
def build(cls):
@ -106,7 +106,7 @@ class _UploadConfig:
@dataclass
class DehanceConfig:
class ImageMuckConfig:
database: _DBConfig = field(default_factory=_DBConfig.build)
upload: _UploadConfig = field(default_factory=_UploadConfig.build)
storage_path: Path = Path.cwd()
@ -120,6 +120,6 @@ class DehanceConfig:
)
def load() -> DehanceConfig:
def load() -> ImageMuckConfig:
return DehanceConfig.build()
return ImageMuckConfig.build()

View File

@ -7,7 +7,7 @@ class SupportedDatabaseBackend(enum.Enum):
SQLITE = enum.auto()
HTTP_HEADER_RESPONSE_VERSION = "x-dehance-version"
HTTP_HEADER_RESPONSE_VERSION = "x-imagemuck-version"
HTTP_HEADER_RESPONSE_DIGEST = "Digest"

View File

@ -3,18 +3,18 @@ from typing import Tuple
import peewee
from dehance import constants
from dehance.configuration import DehanceConfig
from dehance.database._shared import DehanceModel
from dehance.database._shared import INTERFACE as interface
from dehance.database.image import ImageRecord
from dehance.database.thumbnail import ThumbnailRecord
from imagemuck import constants
from imagemuck.configuration import ImageMuckConfig
from imagemuck.database._shared import ImageMuckModel
from imagemuck.database._shared import INTERFACE as interface
from imagemuck.database.image import ImageRecord
from imagemuck.database.thumbnail import ThumbnailRecord
MODELS: Tuple[DehanceModel, ...] = (ImageRecord, ThumbnailRecord)
MODELS: Tuple[ImageMuckModel, ...] = (ImageRecord, ThumbnailRecord)
def initialize(config: DehanceConfig):
def initialize(config: ImageMuckConfig):
"""Initialize the database interface
Defining the database as an

View File

@ -7,7 +7,7 @@ import peewee
INTERFACE = peewee.DatabaseProxy()
class DehanceModel(peewee.Model):
class ImageMuckModel(peewee.Model):
class Meta: # pylint: disable=too-few-public-methods,missing-class-docstring
database = INTERFACE

View File

@ -4,10 +4,10 @@ from typing import List
import peewee
from dehance.database._shared import DehanceModel
from imagemuck.database._shared import ImageMuckModel
class ImageRecord(DehanceModel):
class ImageRecord(ImageMuckModel):
"""Database record for"""
width = peewee.IntegerField(null=False)

View File

@ -1,10 +1,10 @@
import peewee
from dehance.database._shared import DehanceModel
from dehance.database.image import ImageRecord
from imagemuck.database._shared import ImageMuckModel
from imagemuck.database.image import ImageRecord
class ThumbnailRecord(DehanceModel):
class ThumbnailRecord(ImageMuckModel):
parent = peewee.ForeignKeyField(ImageRecord)
width = peewee.IntegerField(null=False)

View File

@ -2,13 +2,13 @@
::
DehanceException
ImageMuckException
+-- ClientError
+-- ServerError
"""
class DehanceException(Exception):
class ImageMuckException(Exception):
"""Whomp whomp, something went wrong
But seriously, don't ever raise this exception
@ -17,7 +17,7 @@ class DehanceException(Exception):
status: int
class ClientError(DehanceException):
class ClientError(ImageMuckException):
"""Error while processing client side input"""
status = 400
@ -29,7 +29,7 @@ class ImageResourceDeletedError(ClientError):
status = 410
class ServerError(DehanceException):
class ServerError(ImageMuckException):
"""Error while processing server side data"""
status = 500

View File

@ -0,0 +1,19 @@
from typing import Tuple
from imagemuck.resources._shared import ImageMuckResource
from imagemuck.resources._shared import ResponseBody
from imagemuck.resources._shared import ResponseHeaders
from imagemuck.resources.image import Image
from imagemuck.resources.image import ImageUpload
from imagemuck.resources.openapi import OpenAPI
from imagemuck.resources.thumbnail import ThumbnailResize
from imagemuck.resources.thumbnail import ThumbnailScale
RESOURCES: Tuple[ImageMuckResource, ...] = (
ImageUpload,
Image,
OpenAPI,
ThumbnailScale,
ThumbnailResize,
)

View File

@ -31,7 +31,7 @@ class ResponseTuple(NamedTuple):
headers: ResponseHeaders
class DehanceResource(flask_restful.Resource):
class ImageMuckResource(flask_restful.Resource):
"""Extension of the default :class:`flask_restful.Resource` class
Add a couple of useful things to the default resource class:

View File

@ -4,13 +4,13 @@ import uuid
import flask
from dehance import constants
from dehance import database
from dehance import exceptions
from dehance.resources._shared import DehanceResource
from imagemuck import constants
from imagemuck import database
from imagemuck import exceptions
from imagemuck.resources._shared import ImageMuckResource
class ImageUpload(DehanceResource):
class ImageUpload(ImageMuckResource):
routes = ("/image/",)
@ -45,7 +45,7 @@ class ImageUpload(DehanceResource):
return None, 201
class Image(DehanceResource):
class Image(ImageMuckResource):
routes = ("/image/<string:image_id>.jpeg",)

View File

@ -2,12 +2,12 @@ from pathlib import Path
from ruamel.yaml import YAML
from dehance.resources._shared import DehanceResource
from imagemuck.resources._shared import ImageMuckResource
yaml = YAML(typ="safe")
class OpenAPI(DehanceResource):
class OpenAPI(ImageMuckResource):
routes = ("/openapi.json",)

View File

@ -1,7 +1,7 @@
from dehance.resources._shared import DehanceResource
from imagemuck.resources._shared import ImageMuckResource
class ThumbnailScale(DehanceResource):
class ThumbnailScale(ImageMuckResource):
routes = ("/thumb/<string:image_id>/scale/<int:scale_width>.jpg",)
@ -9,7 +9,7 @@ class ThumbnailScale(DehanceResource):
raise NotImplementedError
class ThumbnailResize(DehanceResource):
class ThumbnailResize(ImageMuckResource):
routes = ("/thumb/<string:image_id>/size/<int:width>x<int:height>.jpg",)

View File

@ -2,9 +2,9 @@
openapi: "3.0.2"
info:
version: 0.1.0
title: Dehance
title: ImageMuck
description: >-
Dehance is a simple HTTP server that allows users to upload
ImageMuck is a simple HTTP server that allows users to upload
images and retrieve them at a later time. In addition, it
supports generating (and caching) scaled versions of the
uploaded images for use as thumbnails.
@ -13,7 +13,7 @@ info:
url: https://mit-license.org/
x-anchors:
DefaultHeaders: &headers-default
x-dehance-version:
x-imagemuck-version:
$ref: "#/components/headers/Version"
OptionsResponses: &responses-options
'204':

36
poetry.lock generated
View File

@ -115,7 +115,7 @@ stevedore = ">=1.20.0"
[[package]]
name = "black"
version = "21.4b2"
version = "21.5b0"
description = "The uncompromising code formatter."
category = "dev"
optional = false
@ -467,7 +467,7 @@ testing = ["packaging", "pep517", "importlib-resources (>=1.3)"]
[[package]]
name = "ipython"
version = "7.23.0"
version = "7.23.1"
description = "IPython: Productive Interactive Computing"
category = "dev"
optional = false
@ -953,7 +953,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
[[package]]
name = "pygments"
version = "2.8.1"
version = "2.9.0"
description = "Pygments is a syntax highlighting package written in Python."
category = "dev"
optional = false
@ -1159,7 +1159,7 @@ python-versions = "!=3.0,!=3.1,!=3.2,!=3.3,>=2.6"
[[package]]
name = "six"
version = "1.15.0"
version = "1.16.0"
description = "Python 2 and 3 compatibility utilities"
category = "main"
optional = false
@ -1328,7 +1328,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
[[package]]
name = "tox"
version = "3.23.0"
version = "3.23.1"
description = "tox is a generic virtualenv management and test command line tool"
category = "dev"
optional = false
@ -1410,7 +1410,7 @@ brotli = ["brotlipy (>=0.6.0)"]
[[package]]
name = "virtualenv"
version = "20.4.4"
version = "20.4.5"
description = "Virtual Python Environment builder"
category = "dev"
optional = false
@ -1526,8 +1526,8 @@ bandit = [
{file = "bandit-1.7.0.tar.gz", hash = "sha256:8a4c7415254d75df8ff3c3b15cfe9042ecee628a1e40b44c15a98890fbfc2608"},
]
black = [
{file = "black-21.4b2-py3-none-any.whl", hash = "sha256:bff7067d8bc25eb21dcfdbc8c72f2baafd9ec6de4663241a52fb904b304d391f"},
{file = "black-21.4b2.tar.gz", hash = "sha256:fc9bcf3b482b05c1f35f6a882c079dc01b9c7795827532f4cc43c0ec88067bbc"},
{file = "black-21.5b0-py3-none-any.whl", hash = "sha256:0e80435b8a88f383c9149ae89d671eb2095b72344b0fe8a1d61d2ff5110ed173"},
{file = "black-21.5b0.tar.gz", hash = "sha256:9dc2042018ca10735366d944c2c12d9cad6dec74a3d5f679d09384ea185d9943"},
]
blacken-docs = [
{file = "blacken_docs-1.10.0-py2.py3-none-any.whl", hash = "sha256:149197a0b17e83121fc10aca9eda1417728fdccebde930a6722f97d87ed30f4b"},
@ -1741,8 +1741,8 @@ importlib-metadata = [
{file = "importlib_metadata-1.7.0.tar.gz", hash = "sha256:90bb658cdbbf6d1735b6341ce708fc7024a3e14e99ffdc5783edea9f9b077f83"},
]
ipython = [
{file = "ipython-7.23.0-py3-none-any.whl", hash = "sha256:3455b020a895710c4366e8d1b326e5ee6aa684607907fc96895e7b8359569f49"},
{file = "ipython-7.23.0.tar.gz", hash = "sha256:69178f32bf9c6257430b6f592c3ae230c32861a1966d2facec454e09078e232d"},
{file = "ipython-7.23.1-py3-none-any.whl", hash = "sha256:f78c6a3972dde1cc9e4041cbf4de583546314ba52d3c97208e5b6b2221a9cb7d"},
{file = "ipython-7.23.1.tar.gz", hash = "sha256:714810a5c74f512b69d5f3b944c86e592cee0a5fb9c728e582f074610f6cf038"},
]
ipython-genutils = [
{file = "ipython_genutils-0.2.0-py2.py3-none-any.whl", hash = "sha256:72dd37233799e619666c9f639a9da83c34013a73e8bbc79a7a6348d93c61fab8"},
@ -2020,8 +2020,8 @@ pycparser = [
{file = "pycparser-2.20.tar.gz", hash = "sha256:2d475327684562c3a96cc71adf7dc8c4f0565175cf86b6d7a404ff4c771f15f0"},
]
pygments = [
{file = "Pygments-2.8.1-py3-none-any.whl", hash = "sha256:534ef71d539ae97d4c3a4cf7d6f110f214b0e687e92f9cb9d2a3b0d3101289c8"},
{file = "Pygments-2.8.1.tar.gz", hash = "sha256:2656e1a6edcdabf4275f9a3640db59fd5de107d88e8663c5d4e9a0fa62f77f94"},
{file = "Pygments-2.9.0-py3-none-any.whl", hash = "sha256:d66e804411278594d764fc69ec36ec13d9ae9147193a1740cd34d272ca383b8e"},
{file = "Pygments-2.9.0.tar.gz", hash = "sha256:a18f47b506a429f6f4b9df81bb02beab9ca21d0a5fee38ed15aef65f0545519f"},
]
pylev = [
{file = "pylev-1.3.0-py2.py3-none-any.whl", hash = "sha256:1d29a87beb45ebe1e821e7a3b10da2b6b2f4c79b43f482c2df1a1f748a6e114e"},
@ -2179,8 +2179,8 @@ shellingham = [
{file = "shellingham-1.4.0.tar.gz", hash = "sha256:4855c2458d6904829bd34c299f11fdeed7cfefbf8a2c522e4caea6cd76b3171e"},
]
six = [
{file = "six-1.15.0-py2.py3-none-any.whl", hash = "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"},
{file = "six-1.15.0.tar.gz", hash = "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"},
{file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"},
{file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"},
]
smmap = [
{file = "smmap-4.0.0-py2.py3-none-any.whl", hash = "sha256:a9a7479e4c572e2e775c404dcd3080c8dc49f39918c2cf74913d30c4c478e3c2"},
@ -2235,8 +2235,8 @@ tomlkit = [
{file = "tomlkit-0.7.0.tar.gz", hash = "sha256:ac57f29693fab3e309ea789252fcce3061e19110085aa31af5446ca749325618"},
]
tox = [
{file = "tox-3.23.0-py2.py3-none-any.whl", hash = "sha256:e007673f3595cede9b17a7c4962389e4305d4a3682a6c5a4159a1453b4f326aa"},
{file = "tox-3.23.0.tar.gz", hash = "sha256:05a4dbd5e4d3d8269b72b55600f0b0303e2eb47ad5c6fe76d3576f4c58d93661"},
{file = "tox-3.23.1-py2.py3-none-any.whl", hash = "sha256:b0b5818049a1c1997599d42012a637a33f24c62ab8187223fdd318fa8522637b"},
{file = "tox-3.23.1.tar.gz", hash = "sha256:307a81ddb82bd463971a273f33e9533a24ed22185f27db8ce3386bff27d324e3"},
]
tox-poetry-installer = [
{file = "tox-poetry-installer-0.7.0.tar.gz", hash = "sha256:409560bbaa6910475f224c2d1541b8c8d6215209bda395cd28c9307e8cbb861d"},
@ -2288,8 +2288,8 @@ urllib3 = [
{file = "urllib3-1.26.4.tar.gz", hash = "sha256:e7b021f7241115872f92f43c6508082facffbd1c048e3c6e2bb9c2a157e28937"},
]
virtualenv = [
{file = "virtualenv-20.4.4-py2.py3-none-any.whl", hash = "sha256:a935126db63128861987a7d5d30e23e8ec045a73840eeccb467c148514e29535"},
{file = "virtualenv-20.4.4.tar.gz", hash = "sha256:09c61377ef072f43568207dc8e46ddeac6bcdcaf288d49011bda0e7f4d38c4a2"},
{file = "virtualenv-20.4.5-py2.py3-none-any.whl", hash = "sha256:73b4186ee7e08ffd1a96cd5d60e5a946132f8ce4736e8f209eda3a6c35b2ceb8"},
{file = "virtualenv-20.4.5.tar.gz", hash = "sha256:e82dbb66e0d6ecf626f037df256f185571da552007bfa9f3f317216f5f3aac1c"},
]
wcwidth = [
{file = "wcwidth-0.2.5-py2.py3-none-any.whl", hash = "sha256:beb4802a9cebb9144e99086eff703a642a13d6a0052920003a230f3294bbe784"},

View File

@ -1,17 +1,17 @@
[tool.poetry]
name = "dehance"
name = "imagemuck"
version = "0.1.0"
license = "MIT"
authors = ["Ethan Paul <24588726+enpaul@users.noreply.github.com>"]
description = "HTTP server for uploading images and generating thumbnails"
repository = "https://github.com/mocproject/dehance/"
repository = "https://github.com/mocproject/imagemuck/"
packages = [
{include = "dehance"},
{include = "imagemuck"},
{include = "tests", format = "sdist"}
]
include = [
"dehance/py.typed",
"dehance/resources/openapi.yaml"
"imagemuck/py.typed",
"imagemuck/resources/openapi.yaml"
]
keywords = ["flask", "image", "thumbnail", "hosting"]
readme = "README.md"

View File

@ -3,7 +3,7 @@ from pathlib import Path
import toml
from dehance import __about__
from imagemuck import __about__
def test_about():

10
tox.ini
View File

@ -16,7 +16,7 @@ locked_deps =
pytest-cov
toml
commands =
pytest --cov={envsitepackagesdir}/dehance --cov-config {toxinidir}/.coveragerc --cov-report term-missing {toxinidir}/tests/
pytest --cov={envsitepackagesdir}/imagemuck --cov-config {toxinidir}/.coveragerc --cov-report term-missing {toxinidir}/tests/
[testenv:static]
description = Static formatting and quality enforcement
@ -35,8 +35,8 @@ locked_deps =
pylint
commands =
pre-commit run --all-files
pylint --rcfile {toxinidir}/.pylintrc {toxinidir}/dehance/
mypy --ignore-missing-imports --no-strict-optional {toxinidir}/dehance/
pylint --rcfile {toxinidir}/.pylintrc {toxinidir}/imagemuck/
mypy --ignore-missing-imports --no-strict-optional {toxinidir}/imagemuck/
[testenv:static-tests]
description = Static formatting and quality enforcement for the tests
@ -60,7 +60,7 @@ locked_deps =
safety
poetry
commands =
bandit --recursive --quiet {toxinidir}/dehance/
bandit --recursive --quiet {toxinidir}/imagemuck/
bandit --recursive --quiet --skip B101 {toxinidir}/tests/
poetry export --format requirements.txt --output {envtmpdir}/requirements.txt --without-hashes --dev
safety check --bare --file {envtmpdir}/requirements.txt
@ -72,5 +72,5 @@ locked_deps =
sphinx
sphinx-autodoc-typehints
commands =
sphinx-apidoc --no-toc --output-dir {toxinidir}/docs/ {toxinidir}/dehance/
sphinx-apidoc --no-toc --output-dir {toxinidir}/docs/ {toxinidir}/imagemuck/
sphinx-build -W -b html {toxinidir}/docs/ {toxinidir}/docs/_build