fashionable
Decorate your project with some fashionable supermodels.
Decorator example
from typing import Set
from fashionable import fashionable
@fashionable
def bits_to_binary_like(bits: Set[int], length: int = 8) -> int:
bits.add(0)
return ''.join(str(int(b in bits)) for b in range(length, 0, -1))
bits_to_binary_like('334455') # 11100
Model example
from typing import List, Optional
from fashionable import Attribute, Model
class Project(Model):
id = Attribute(str, max=32)
name = Attribute(str)
organization = Attribute(Optional[str])
domain = Attribute(Optional[str])
links = Attribute(Optional[List[str]])
project = Project(1, 'Test')
Supermodel example with Sanic
from typing import List, Optional
from fashionable import Attribute, Supermodel
from sanic import Sanic
from sanic.response import json, HTTPResponse
app = Sanic()
app.db = ...
class Project(Supermodel):
_ttl = 300
id = Attribute(str, max=32)
name = Attribute(str)
organization = Attribute(Optional[str])
domain = Attribute(Optional[str])
links = Attribute(Optional[List[str]])
@staticmethod
async def _create(raw: dict):
await app.db.project_create(raw)
@staticmethod
async def _get(id_: str) -> Optional[dict]:
return await app.db.project_get(id_)
@staticmethod
async def _update(id_: str, raw: dict):
await app.db.project_update(id_, raw)
@staticmethod
async def _delete(id_: str):
await app.db.project_delete(id_)
@app.get('/project/<id_>')
async def project_get(request, id_):
project = await Project.get(id_)
return json(project)
@app.post('/project')
async def project_create(request):
project = await Project.create(**request.json)
return json(
project,
status=201,
headers={'Location': '/project/' + project.id},
)
@app.put('/project/<id_>')
async def project_update(request, id_):
project = await Project.get(id_, fresh=True)
await project.update(**request.json)
return json(project)
@app.delete('/project/<id_>')
async def project_delete(request, id_):
project = await Project.get(id_, fresh=True)
await project.delete()
return HTTPResponse(status=204)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8000)
Metadata
Release files for fashionable 0.12.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| fashionable-0.12.3.tar.gz | 11.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fashionable-0.12.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.5 kB
Release files / fashionable-0.12.3.tar.gz
| Download URL | fashionable-0.12.3.tar.gz |
|---|---|
| Size | 11.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7510cd958fa2a679b061d66347ec6b867d151d0d83b8d4449abb9b94edf2725d
|
|
BLAKE2b-256 checksum How to use checksums |
c256c5dd4b837a574593e4df54fc2d33e16da55e3f272be6ed03bb40907415d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
|
Release files / fashionable-0.12.3-py3-none-any.whl
| Download URL | fashionable-0.12.3-py3-none-any.whl |
|---|---|
| Size | 14.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ff1ca2729a392281ed7bddabcd1f649d61e57f7b1884feaefea52d0a88cc6504
|
|
BLAKE2b-256 checksum How to use checksums |
117458f552c630479a662858cdf48b339f7fac8cbd1c014949cc13b4667ed304
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
|
Security for fashionable 0.12.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.