# bw_projects
[![PyPI](https://img.shields.io/pypi/v/bw_projects.svg)][pypi status]
[![Status](https://img.shields.io/pypi/status/bw_projects.svg)][pypi status]
[![Python Version](https://img.shields.io/pypi/pyversions/bw_projects)][pypi status]
[![License](https://img.shields.io/pypi/l/bw_projects)][license]
<!-- [![Read the documentation at https://bw_projects.readthedocs.io/](https://img.shields.io/readthedocs/bw_projects/latest.svg?label=Read%20the%20Docs)][read the docs] -->
[![Tests](https://github.com/brightway-lca/bw_projects/actions/workflows/python-test.yml/badge.svg)][tests]
[![Codecov](https://codecov.io/gh/brightway-lca/bw_projects/branch/main/graph/badge.svg?token=ZVWBCITI4A)][codecov]
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)][pre-commit]
[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)][black]
[pypi status]: https://pypi.org/project/bw_projects/
<!-- [read the docs]: https://bw_projects.readthedocs.io/ -->
[tests]: https://github.com/brightway-lca/bw_projects/actions?workflow=Tests
[codecov]: https://codecov.io/gh/brightway-lca/bw_projects
[pre-commit]: https://github.com/pre-commit/pre-commit
[black]: https://github.com/psf/black
This is a library to manage subdirectories, so that work on a project can be isolated from other projects. It is designed for use with the [Brightway life cycle assessment](https://brightway.dev/) software framework, but has no dependencies on Brightway and can be used on its own.
Project metadata is stored in SQLite using the [Peewee ORM](http://docs.peewee-orm.com/en/latest/). The SQLite file is in the `base_directory`, and project data is stored in subdirectories. By default, [platformdirs](https://github.com/platformdirs/platformdirs) is used to create the `base_directory`, though this can be overridden.
## Installation
Via pip or conda (`conda-forge` channel).
Depends on:
* [peewee](http://docs.peewee-orm.com/en/latest/)
* [platformdirs](https://github.com/platformdirs/platformdirs)
* [python_slugify](https://github.com/un33k/python-slugify)
## Usage
### Initializing the ProjectsManager
```python
from bw_projects import ProjectsManager # This doesn't create anything yet
projects_manager = ProjectsManager() # This gets default config and initializes directories and database
```
### Overriding defaults
```python
## You can override default directory by providing a base directory in constructor
## You can also override the default database name
from bw_projects import ProjectsManager
projects_manager = ProjectsManager(dir_base_data="<path/to/your/base/directory>", database_name="projects.db")
```
```python
## You can also override configurations of default directory
from bw_projects import Configuration, ProjectsManager
config = Configuration(
app_name: str = "Brightway3",
app_author: str = "pycla",
)
projects_manager = ProjectsManager(config=config)
```
### Callbacks
```python
## You can setup callbacks on projects creation, activation and deletion
from bw_projects import ProjectsManager
def callback_activate_project(manager: ProjectsManager, name: str, attributes: Dict[str, str], dir_path: str):
print(f"Manager with {len(manager)} projects activated project {name} with {attributes} and {dir_path}.")
projects_manager = ProjectsManager(callbacks_activate_project=callback_activate_project)
```
### Project management
| :exclamation: Project names may be changed when creating projects |
|---------------------------------------------------------------------|
```python
## Before calling any project-management feature, the project name is slugified
## You can get the new name of the project by running:
project = projects_manager.get_clean_directory_name("Компьютер")
project
>> kompiuter
```
```python
## Create a project without activating it:
projects_manager.create_project("<project_name>")
```
```python
## Create a project and activate it:
projects_manager.create_project("<project_name>", activate=True)
```
```python
## Iterate over projects:
for project in projects_manager:
print(project.name, project.attributes)
```
```python
## Activate a project:
projects_manager.activate("<project_name>")
```
```python
## Delete a project from SQLite database and deleting the directory:
projects_manager.delete_project("<project_name>")
```
```python
## Delete a project from SQLite database without deleting the directory:
projects_manager.delete_project("<project_name>", delete_dir=False)
```
## Contributing
Contributions are very welcome.
To learn more, see the [Contributor Guide][Contributor Guide].
## License
Distributed under the terms of the [BSD-2-Clause license][License],
_bw_projects_ is free and open source software.
## Issues
If you encounter any problems,
please [file an issue][Issue Tracker] along with a detailed description.
<!-- github-only -->
[License]: https://github.com/brightway-lca/bw_projects/blob/main/LICENSE
[Contributor Guide]: https://github.com/brightway-lca/bw_projects/blob/main/CONTRIBUTING.md
[Issue Tracker]: https://github.com/brightway-lca/bw_projects/issues
Raw data
{
"_id": null,
"home_page": "https://github.com/brightway-lca/brightway-projects",
"name": "bw-projects",
"maintainer": "Shantanu",
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "<baali@muse-amuse.in>",
"keywords": "\"brightway\",\"development\"",
"author": "Shantanu",
"author_email": "<baali@muse-amuse.in>",
"download_url": "https://files.pythonhosted.org/packages/c8/c2/b1d446ad67b01dde916e036544fdc579f44f127715fdc1c77cee6b4c82b7/bw-projects-2.1.0.tar.gz",
"platform": "any",
"description": "# bw_projects\n\n[![PyPI](https://img.shields.io/pypi/v/bw_projects.svg)][pypi status]\n[![Status](https://img.shields.io/pypi/status/bw_projects.svg)][pypi status]\n[![Python Version](https://img.shields.io/pypi/pyversions/bw_projects)][pypi status]\n[![License](https://img.shields.io/pypi/l/bw_projects)][license]\n\n<!-- [![Read the documentation at https://bw_projects.readthedocs.io/](https://img.shields.io/readthedocs/bw_projects/latest.svg?label=Read%20the%20Docs)][read the docs] -->\n[![Tests](https://github.com/brightway-lca/bw_projects/actions/workflows/python-test.yml/badge.svg)][tests]\n[![Codecov](https://codecov.io/gh/brightway-lca/bw_projects/branch/main/graph/badge.svg?token=ZVWBCITI4A)][codecov]\n\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)][pre-commit]\n[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)][black]\n\n[pypi status]: https://pypi.org/project/bw_projects/\n<!-- [read the docs]: https://bw_projects.readthedocs.io/ -->\n[tests]: https://github.com/brightway-lca/bw_projects/actions?workflow=Tests\n[codecov]: https://codecov.io/gh/brightway-lca/bw_projects\n[pre-commit]: https://github.com/pre-commit/pre-commit\n[black]: https://github.com/psf/black\n\nThis is a library to manage subdirectories, so that work on a project can be isolated from other projects. It is designed for use with the [Brightway life cycle assessment](https://brightway.dev/) software framework, but has no dependencies on Brightway and can be used on its own.\n\nProject metadata is stored in SQLite using the [Peewee ORM](http://docs.peewee-orm.com/en/latest/). The SQLite file is in the `base_directory`, and project data is stored in subdirectories. By default, [platformdirs](https://github.com/platformdirs/platformdirs) is used to create the `base_directory`, though this can be overridden.\n\n## Installation\n\nVia pip or conda (`conda-forge` channel).\n\nDepends on:\n\n* [peewee](http://docs.peewee-orm.com/en/latest/)\n* [platformdirs](https://github.com/platformdirs/platformdirs)\n* [python_slugify](https://github.com/un33k/python-slugify)\n\n## Usage\n\n### Initializing the ProjectsManager\n\n```python\nfrom bw_projects import ProjectsManager # This doesn't create anything yet\n\n\nprojects_manager = ProjectsManager() # This gets default config and initializes directories and database\n```\n\n### Overriding defaults\n\n```python\n## You can override default directory by providing a base directory in constructor\n## You can also override the default database name\nfrom bw_projects import ProjectsManager\n\nprojects_manager = ProjectsManager(dir_base_data=\"<path/to/your/base/directory>\", database_name=\"projects.db\")\n```\n\n```python\n## You can also override configurations of default directory\nfrom bw_projects import Configuration, ProjectsManager\n\nconfig = Configuration(\n \t\t\tapp_name: str = \"Brightway3\",\n \tapp_author: str = \"pycla\",\n\t\t)\nprojects_manager = ProjectsManager(config=config)\n```\n\n### Callbacks\n\n```python\n## You can setup callbacks on projects creation, activation and deletion\nfrom bw_projects import ProjectsManager\n\ndef callback_activate_project(manager: ProjectsManager, name: str, attributes: Dict[str, str], dir_path: str):\n\tprint(f\"Manager with {len(manager)} projects activated project {name} with {attributes} and {dir_path}.\")\n\nprojects_manager = ProjectsManager(callbacks_activate_project=callback_activate_project)\n```\n\n### Project management\n\n| :exclamation: Project names may be changed when creating projects |\n|---------------------------------------------------------------------|\n```python\n## Before calling any project-management feature, the project name is slugified\n## You can get the new name of the project by running:\nproject = projects_manager.get_clean_directory_name(\"\u041a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\")\nproject\n>> kompiuter\n```\n\n```python\n## Create a project without activating it:\nprojects_manager.create_project(\"<project_name>\")\n```\n\n```python\n## Create a project and activate it:\nprojects_manager.create_project(\"<project_name>\", activate=True)\n```\n\n```python\n## Iterate over projects:\nfor project in projects_manager:\n\tprint(project.name, project.attributes)\n```\n\n```python\n## Activate a project:\nprojects_manager.activate(\"<project_name>\")\n```\n\n```python\n## Delete a project from SQLite database and deleting the directory:\nprojects_manager.delete_project(\"<project_name>\")\n```\n\n```python\n## Delete a project from SQLite database without deleting the directory:\nprojects_manager.delete_project(\"<project_name>\", delete_dir=False)\n```\n\n## Contributing\n\nContributions are very welcome.\nTo learn more, see the [Contributor Guide][Contributor Guide].\n\n## License\n\nDistributed under the terms of the [BSD-2-Clause license][License],\n_bw_projects_ is free and open source software.\n\n## Issues\n\nIf you encounter any problems,\nplease [file an issue][Issue Tracker] along with a detailed description.\n\n\n<!-- github-only -->\n\n[License]: https://github.com/brightway-lca/bw_projects/blob/main/LICENSE\n[Contributor Guide]: https://github.com/brightway-lca/bw_projects/blob/main/CONTRIBUTING.md\n[Issue Tracker]: https://github.com/brightway-lca/bw_projects/issues\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "This is a library to manage subdirectories.",
"version": "2.1.0",
"project_urls": {
"Homepage": "https://github.com/brightway-lca/brightway-projects",
"source": "https://github.com/brightway-lca/brightway-projects",
"tracker": "https://github.com/brightway-lca/brightway-projects/issues"
},
"split_keywords": [
"\"brightway\"",
"\"development\""
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "26e7ee0727d9728edc041f0cb4c35fff807d7adb85adf641dfe6013f370e7d23",
"md5": "7f4f903defd6de68ba9c4d77c729be89",
"sha256": "574307736f87a94b7bf612ec5bfca59fa6b40d86e1e011fcc67f7fdffd55f1e8"
},
"downloads": -1,
"filename": "bw_projects-2.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7f4f903defd6de68ba9c4d77c729be89",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 8869,
"upload_time": "2023-08-22T15:58:35",
"upload_time_iso_8601": "2023-08-22T15:58:35.297781Z",
"url": "https://files.pythonhosted.org/packages/26/e7/ee0727d9728edc041f0cb4c35fff807d7adb85adf641dfe6013f370e7d23/bw_projects-2.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c8c2b1d446ad67b01dde916e036544fdc579f44f127715fdc1c77cee6b4c82b7",
"md5": "d63ee5fa850b773b3a8f13b1bf44abb5",
"sha256": "31bf2c8be9b4ecc7f3b151d0d9f75123309ebb87062f601efab19778604876b2"
},
"downloads": -1,
"filename": "bw-projects-2.1.0.tar.gz",
"has_sig": false,
"md5_digest": "d63ee5fa850b773b3a8f13b1bf44abb5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 11831,
"upload_time": "2023-08-22T15:58:46",
"upload_time_iso_8601": "2023-08-22T15:58:46.760897Z",
"url": "https://files.pythonhosted.org/packages/c8/c2/b1d446ad67b01dde916e036544fdc579f44f127715fdc1c77cee6b4c82b7/bw-projects-2.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-22 15:58:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "brightway-lca",
"github_project": "brightway-projects",
"github_not_found": true,
"lcname": "bw-projects"
}