{ "info": { "author": "Jeff Buttars", "author_email": "jeff@jeffbuttars.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3 :: Only", "Topic :: Internet :: WWW/HTTP" ], "description": "

\n

API Star AutoApp

\n

\n\n

\n Easily manage and compose API Star projects\n

\n\n

\n CircleCI Test Status\n \n \"PyPI\n \n\n

\n\n\n---\n\n\nAutomatically orchestrates [API Star](https://docs.apistar.com/) projects with sub modules using an\n`app` based pattern.\n\n\n* [Features](#features)\n* [Quickstart](#quickstart)\n* [Install](#install)\n* [Anatomy](#anatomy)\n * [Example project structure](#example-project-structure)\n* [Docs](#docs)\n * [AutoApp](#autoapp)\n * [AutoASyncApp](#autoasyncapp)\n * [app_args](#app_args)\n * [Print Helper](#print-helper)\n * [include](#include)\n * [route](#route)\n * [routes](#routes)\n * [components](#components)\n* [TODO](#todo)\n\n---\n\n## Features\n\n\n* Automatically build URLs based on your project's structure.\n * Autoapp [Includes routes](https://docs.apistar.com/api-guide/routing/#routing-in-larger-projects)\n from apps in your project creating the appropriate URL based on the\n filesystem path from the projects root `app.py` file.\n* Automatically collect [event_hooks](https://docs.apistar.com/api-guide/event-hooks/) and [component](https://docs.apistar.com/api-guide/dependency-injection/) lists from apps and consolidate them\n together to build the [App](https://docs.apistar.com/api-guide/applications/)/[ASyncApp](https://docs.apistar.com/api-guide/applications/) with.\n* Easily add external packages that support the `app.py` layout. \n ex: `AutoApp(apps=['apistar_websocket'])`\n* Allow an ordered priority list of apps by their path string to control the order of items\n in the [event_hooks](https://docs.apistar.com/api-guide/event-hooks/) and [component](https://docs.apistar.com/api-guide/dependency-injection/) lists as well as control import order.\n\n\n---\n\n## Quickstart\n\nJust use `AutoApp` or `AutoASyncApp` in place of [App](https://docs.apistar.com/api-guide/applications/) and [ASyncApp](https://docs.apistar.com/api-guide/applications/) respectively\n\n```python\nfrom apistar-autoapp import AutoApp\n\nasync def welcome() -> dict:\n return {'msg': 'hello'}\n\n\nroutes = [\n Route('/', 'GET', handler=welcome, name='welcome'),\n]\n\napp = AutoApp(\n routes=routes,\n)\n\n\nif __name__ == '__main__':\n app.serve('127.0.0.1', 8000, debug=True)\n```\n\nAn ASync application that uses the `apistar-websocket` package. To use the external library simply\nlist it in the `apps` parameter. \nNOTE: packages listed in `apps` must support the `app.py`\nlayout.\n```python\nfrom apistar-autoapp import AutoASyncApp\n\nasync def welcome() -> dict:\n return {'msg': 'hello'}\n\n\nroutes = [\n Route('/', 'GET', handler=welcome, name='welcome'),\n]\n\napp = AutoASyncApp(\n apps=['apistar_websocket'],\n routes=routes,\n)\n\n\nif __name__ == '__main__':\n app.serve('127.0.0.1', 8000, debug=True)\n```\n\n---\n\n## Install\n\n pip install apistar-autoapp\n\nor for [Pipenv](https://docs.pipenv.org/) users\n\n pipenv install apistar-autoapp\n\n\n---\n\n## Anatomy\n\nFor a package to be considered an 'app' it must contain a file named `app.py` in it's top directory. The\n`app.py` file can be empty. It's in the `app.py` file where you expose what your app\nprovides to the [API Star](https://docs.apistar.com/) configuration. Autoapp will look\nfor three attributes on the `app.py` module and if they're found add them to the [API Star](https://docs.apistar.com/)\nconfiguration at startup. \n\nThe attributes must be lists and named:\n\n routes\n components\n event_hooks\n\nFor example, a simple app that only exposes it's routes could be:\n\n`app.py`:\n\n from .handlers import routes\n\nOr an app that exposes it's routes, event_hooks and components:\n\n\n`app.py`:\n\n from .handlers import routes\n from .components import components\n from .event_hooks import event_hooks\n\n\nAnd of course if you have a simple app you can have all of your code in the `app.py` and\nthen have module variables defined by your application code.\n\nA simple app:\n\n```python\nfrom apistar import App, Route\n\n\ndef homepage() -> str:\n return '

Homepage

'\n\n\nroutes = [\n Route('/', method='GET', handler=homepage),\n]\n```\n\n### Example project structure\n\n```\n\nproject/\n app.py\n v1/\n app.py\n ...\n endpointOne/\n app.py\n ...\n endpointTwo/\n app.py\n ...\n```\n\nIf the `v1/app.py` file is empty and each of the `endpoint*` apps exposes a single root URL, `/`, route the\nroute URLs created for the project, via [Includes](https://docs.apistar.com/api-guide/routing/#routing-in-larger-projects)\nwould be:\n\n /v1/endpointOne\n /v1/endpointTwo\n\nAnd if `endpointOne` had another route for the URL `/users`, you'd then have:\n\n /v1/endpointOne\n /v1/endpointOne/users\n /v1/endpointTwo\n\n---\n\n## Docs\n\n### AutoApp\n\n AutoApp(project_dir: str = None,\n priority_apps: list = None,\n print_results: bool = False,\n **kwargs) -> App\n\nParameters:\n\n (Optional)\n apps: A list of packages to add to your App. Use this for packages outside or your App/project.\n Packages listed in the apps list must be on your PYTHON_PATH.\n\n (Optional)\n project_dir: The directory from which apistar-autoapp will look for a project root.\n This is autodetected if not used and you normally won't use this parameter.\n\n (Optional)\n priority_apps: A list of apps, by their import path, that will be imported before all\n other apps found by apistar-autoapp and imported in the order they are given.\n\n (Optional)\n print_results: Print the results of the configuration created by apistar-autoapp to\n the console.\n\n kwargs: These are the arguments you'd normally pass to App or ASyncApp. If you pass\n any of the arguments: routes, components or event_hooks, they will be given precedence\n and listed before any of the corresponding values created by autoapp.\n\n### AutoASyncApp\n\nThe same as [AutoApp](#autoapp) but creates a project using [ASyncApp](https://docs.apistar.com/api-guide/applications/)\n\n AutoASyncApp(project_dir: str = None,\n priority_apps: list = None,\n print_results: bool = False,\n **kwargs) -> ASyncApp\n\n\n### app_args\n\n app_args(project_dir: str = None,\n priority_apps: list = None,\n print_results: bool = False,\n **kwargs) -> dict:\n\n`app_args` is the same as AutoApp and AutoASyncApp except it returns a dictionary of arguments\nthat are intended for use by [App](https://docs.apistar.com/api-guide/applications/) or [ASyncApp](https://docs.apistar.com/api-guide/applications/).\n\nIn fact [AutoApp](#autoapp) is just:\n\n```python\ndef AutoApp(**kwargs) -> App:\n return App(**app_args(**kwargs))\n```\n\nSo if you want to do something with the data from autoapp before creating your App it's easy:\n\n```python\nkwargs = app_args(...)\n# Do something with kwargs\n# ...\napp = App(**kwargs)\n```\n\n\n### Print helper\n\nThere are some printing helpers for internal use by apistar-autoapp but are exposed for use by other\nmodules. There is a `Printer` class the uses `print` by default but can use any function that\naccepts a string in it's place.\n\n```python\nfrom apistar_autoapp.printer import Printer\n\npr = Printer()\n\n# Or if you want to your own print function, like a logger:\npr = Printer(printer=logger.info)\n\n...\n\n# to print out a list of routes:\npr.routes(routes)\n```\n\n\n#### include\nPrints an [Include](https://docs.apistar.com/api-guide/routing/#routing-in-larger-projects) instance to the console as well as all of it's [Routes](https://docs.apistar.com/api-guide/routing/) in the form:\n\n Include: \n \nex:\n\nInclude: /v2/welcome v2:welcome\n Route: GET /, welcome\n app.welcome() -> dict:\n\n#### route\nPrints a [Route](https://docs.apistar.com/api-guide/routing/) instance to the console in the form:\n\n Route: , \n \nex:\n\n Route: GET /, welcome\n app.welcome() -> dict:\n\n#### routes\n\nPrints a list of [Routes](https://docs.apistar.com/api-guide/routing/) and [Includes](https://docs.apistar.com/api-guide/routing/#routing-in-larger-projects) using `print_route` and `print_include` in the form:\n\n Routes:\n [\n or ,\n ...\n ]\n\nex:\n\n Routes:\n Route: GET /, welcome\n app.welcome() -> dict:\n Include: /v2/home v2:home\n Route: GET /v2/home/, list\n v2.home.handlers.list_homes() -> list:\n ...\n\n\n#### components\nPrints a list of [components](https://docs.apistar.com/api-guide/dependency-injection/) in the form:\n\n\n Components:\n \n resolve() -> :\nex:\n\n Components:\n WebSocketComponent\n resolve(self, scope: ASGIScope, send: ASGISend, receive: ASGIReceive, app: App) -> WebSocket:\n\n---\n\n## TODO\n\n* Allow any package with an `app.py` file that is importable to be used with Autoapp\n* Add the ability to have a list of excluded apps that will not be imported by Autoapp\n* Add printer for `event_hooks`", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/jeffbuttars/apistar-autoapp", "keywords": "", "license": "Apache License 2.0", "maintainer": "", "maintainer_email": "", "name": "apistar-autoapp", "package_url": "https://pypi.org/project/apistar-autoapp/", "platform": "", "project_url": "https://pypi.org/project/apistar-autoapp/", "project_urls": { "Homepage": "https://github.com/jeffbuttars/apistar-autoapp" }, "release_url": "https://pypi.org/project/apistar-autoapp/0.6.1/", "requires_dist": null, "requires_python": "", "summary": "Automatically import APIStar sub apps", "version": "0.6.1" }, "last_serial": 4540078, "releases": { "0.5.0": [ { "comment_text": "", "digests": { "md5": "609d1c5c6ed28fac477a0ea70e0a456b", "sha256": "9144131ad732577cfdfb801dccee65c3cfadded4338033c23ba03300e1b47c99" }, "downloads": -1, "filename": "apistar-autoapp-0.5.0.tar.gz", "has_sig": false, "md5_digest": "609d1c5c6ed28fac477a0ea70e0a456b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4261, "upload_time": "2018-05-22T15:04:17", "url": "https://files.pythonhosted.org/packages/08/3d/a9d3c8df8fdeb02389435e871a9fe8a0af2c01629828ca4de07f614a0f93/apistar-autoapp-0.5.0.tar.gz" } ], "0.5.1": [ { "comment_text": "", "digests": { "md5": "8e3b814344c0a66a4fbc27cd01e2b9f8", "sha256": "4137edbd75633456a31bd17599190bbeea3a9fddc167afbbe892f6df38248a13" }, "downloads": -1, "filename": "apistar-autoapp-0.5.1.tar.gz", "has_sig": false, "md5_digest": "8e3b814344c0a66a4fbc27cd01e2b9f8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4255, "upload_time": "2018-05-22T15:27:24", "url": "https://files.pythonhosted.org/packages/c3/65/a72de6dce5a9ec78a840c5be7eba905b6157445bd331b91a0f8c71f4d4df/apistar-autoapp-0.5.1.tar.gz" } ], "0.5.2": [ { "comment_text": "", "digests": { "md5": "5521eb357a8c15d3bc14f2d4e5262455", "sha256": "59d5c14aa296ab9e111538c69de1c9491017e9bf59ef8dc254241ff4b3484c2b" }, "downloads": -1, "filename": "apistar-autoapp-0.5.2.tar.gz", "has_sig": false, "md5_digest": "5521eb357a8c15d3bc14f2d4e5262455", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5635, "upload_time": "2018-05-23T16:27:43", "url": "https://files.pythonhosted.org/packages/1c/23/c679cc47d00cdd0346c9f3d8946f01c6251fd7b66f607d3397327eb5d306/apistar-autoapp-0.5.2.tar.gz" } ], "0.5.3": [ { "comment_text": "", "digests": { "md5": "75895a856bddbe6a127fc5945dea3be4", "sha256": "5d45d54027e8035e959bda168af783de28ba740a88665577221cd2b96ce2c027" }, "downloads": -1, "filename": "apistar-autoapp-0.5.3.tar.gz", "has_sig": false, "md5_digest": "75895a856bddbe6a127fc5945dea3be4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6886, "upload_time": "2018-05-26T18:13:58", "url": "https://files.pythonhosted.org/packages/8f/09/a9c3393b8a39408cfe42f277d12b3c7c60f25beb5767ce34d3118161431c/apistar-autoapp-0.5.3.tar.gz" } ], "0.5.4": [ { "comment_text": "", "digests": { "md5": "2fbf325b2f3535c5a79826a64babed40", "sha256": "d3665449b6c106ae8b1118752f23cb7917079c39c34fca27b44882369a6dfb76" }, "downloads": -1, "filename": "apistar-autoapp-0.5.4.tar.gz", "has_sig": false, "md5_digest": "2fbf325b2f3535c5a79826a64babed40", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7943, "upload_time": "2018-05-26T18:17:44", "url": "https://files.pythonhosted.org/packages/5f/fa/d8bcb33adce8248603c9d29ed361911fac9d777d4d0040011a605e6d9072/apistar-autoapp-0.5.4.tar.gz" } ], "0.5.5": [ { "comment_text": "", "digests": { "md5": "1c3de33b203b13c741fda570c530a5dd", "sha256": "90340a68863b3119eac1d2faa4dac0f5331973c04236ca1a7fea3e7a412b5b6a" }, "downloads": -1, "filename": "apistar-autoapp-0.5.5.tar.gz", "has_sig": false, "md5_digest": "1c3de33b203b13c741fda570c530a5dd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8102, "upload_time": "2018-05-31T17:48:27", "url": "https://files.pythonhosted.org/packages/0a/1c/a4722fa1c887e71b7b0a9e3216d60a0b41e6251e693d3ecf6375c54be0dc/apistar-autoapp-0.5.5.tar.gz" } ], "0.6.0": [ { "comment_text": "", "digests": { "md5": "a2eedfe8d2e0fe53ee1cd9d81d66023b", "sha256": "0c28ab3fd26563367ca0422fc2cc66f0310250f019d91425ae3c1898d48b7f01" }, "downloads": -1, "filename": "apistar-autoapp-0.6.0.tar.gz", "has_sig": false, "md5_digest": "a2eedfe8d2e0fe53ee1cd9d81d66023b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8531, "upload_time": "2018-06-01T16:18:32", "url": "https://files.pythonhosted.org/packages/ec/43/d00b4294338b05df16e325b69321d01e50eaaab0d5ad7b3343e1023ebfb2/apistar-autoapp-0.6.0.tar.gz" } ], "0.6.1": [ { "comment_text": "", "digests": { "md5": "798abf6940f9f0e1be3e331b6775a6eb", "sha256": "1127a95f4798c9a2a7dc6bb1da08531462843c4c771e0137fcef1089c787b6f5" }, "downloads": -1, "filename": "apistar-autoapp-0.6.1.tar.gz", "has_sig": false, "md5_digest": "798abf6940f9f0e1be3e331b6775a6eb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8637, "upload_time": "2018-11-28T20:09:48", "url": "https://files.pythonhosted.org/packages/76/21/6c90ea4e2d390a15dfb5138ce5d16937fbe16b181602193308628971a67d/apistar-autoapp-0.6.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "798abf6940f9f0e1be3e331b6775a6eb", "sha256": "1127a95f4798c9a2a7dc6bb1da08531462843c4c771e0137fcef1089c787b6f5" }, "downloads": -1, "filename": "apistar-autoapp-0.6.1.tar.gz", "has_sig": false, "md5_digest": "798abf6940f9f0e1be3e331b6775a6eb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8637, "upload_time": "2018-11-28T20:09:48", "url": "https://files.pythonhosted.org/packages/76/21/6c90ea4e2d390a15dfb5138ce5d16937fbe16b181602193308628971a67d/apistar-autoapp-0.6.1.tar.gz" } ] }