{"id":21203232,"url":"https://github.com/mon4ter/fashionable","last_synced_at":"2025-03-14T22:42:31.783Z","repository":{"id":45943532,"uuid":"148993734","full_name":"mon4ter/fashionable","owner":"mon4ter","description":"Decorate your project with some fashionable supermodels","archived":false,"fork":false,"pushed_at":"2021-11-25T19:28:32.000Z","size":110,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-21T15:51:46.443Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mon4ter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-16T12:32:54.000Z","updated_at":"2021-11-25T19:28:06.000Z","dependencies_parsed_at":"2022-09-26T18:50:38.779Z","dependency_job_id":null,"html_url":"https://github.com/mon4ter/fashionable","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mon4ter%2Ffashionable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mon4ter%2Ffashionable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mon4ter%2Ffashionable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mon4ter%2Ffashionable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mon4ter","download_url":"https://codeload.github.com/mon4ter/fashionable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243658152,"owners_count":20326464,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T20:22:36.977Z","updated_at":"2025-03-14T22:42:31.001Z","avatar_url":"https://github.com/mon4ter.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fashionable\n[![PyPI version](https://img.shields.io/pypi/v/fashionable.svg)](https://pypi.org/project/fashionable)\n[![Python version](https://img.shields.io/pypi/pyversions/fashionable.svg)](https://pypi.org/project/fashionable)\n[![Build Status](https://travis-ci.org/mon4ter/fashionable.svg?branch=master)](https://travis-ci.org/mon4ter/fashionable)\n[![codecov](https://codecov.io/gh/mon4ter/fashionable/branch/master/graph/badge.svg)](https://codecov.io/gh/mon4ter/fashionable)\n\nDecorate your project with some fashionable supermodels.\n\n### Decorator example\n```python\nfrom typing import Set\n\nfrom fashionable import fashionable\n\n@fashionable\ndef bits_to_binary_like(bits: Set[int], length: int = 8) -\u003e int:\n    bits.add(0)\n    return ''.join(str(int(b in bits)) for b in range(length, 0, -1))\n\nbits_to_binary_like('334455')  # 11100\n```\n\n### Model example\n```python\nfrom typing import List, Optional\n\nfrom fashionable import Attribute, Model\n\n\nclass Project(Model):\n    id = Attribute(str, max=32)\n    name = Attribute(str)\n    organization = Attribute(Optional[str])\n    domain = Attribute(Optional[str])\n    links = Attribute(Optional[List[str]])\n    \nproject = Project(1, 'Test')\n```\n\n### Supermodel example with Sanic\n```python\nfrom typing import List, Optional\n\nfrom fashionable import Attribute, Supermodel\nfrom sanic import Sanic\nfrom sanic.response import json, HTTPResponse\n\napp = Sanic()\napp.db = ...\n\nclass Project(Supermodel):\n    _ttl = 300\n    id = Attribute(str, max=32)\n    name = Attribute(str)\n    organization = Attribute(Optional[str])\n    domain = Attribute(Optional[str])\n    links = Attribute(Optional[List[str]])\n    \n    @staticmethod\n    async def _create(raw: dict):\n        await app.db.project_create(raw)\n\n    @staticmethod\n    async def _get(id_: str) -\u003e Optional[dict]:\n        return await app.db.project_get(id_)\n\n    @staticmethod\n    async def _update(id_: str, raw: dict):\n        await app.db.project_update(id_, raw)\n\n    @staticmethod\n    async def _delete(id_: str):\n        await app.db.project_delete(id_)\n\n\n@app.get('/project/\u003cid_\u003e')\nasync def project_get(request, id_):\n    project = await Project.get(id_)\n    return json(project)\n\n\n@app.post('/project')\nasync def project_create(request):\n    project = await Project.create(**request.json)\n    return json(\n        project,\n        status=201,\n        headers={'Location': '/project/' + project.id},\n    )\n\n\n@app.put('/project/\u003cid_\u003e')\nasync def project_update(request, id_):\n    project = await Project.get(id_, fresh=True)\n    await project.update(**request.json)\n    return json(project)\n\n\n@app.delete('/project/\u003cid_\u003e')\nasync def project_delete(request, id_):\n    project = await Project.get(id_, fresh=True)\n    await project.delete()\n    return HTTPResponse(status=204)\n\n\nif __name__ == '__main__':\n    app.run(host='0.0.0.0', port=8000)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmon4ter%2Ffashionable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmon4ter%2Ffashionable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmon4ter%2Ffashionable/lists"}