Skip to main content

This is a library to manage subdirectories.

Project description

bw_projects

PyPI Status Python Version License

Tests Codecov

pre-commit 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 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. The SQLite file is in the base_directory, and project data is stored in subdirectories. By default, platformdirs is used to create the base_directory, though this can be overridden.

Installation

Via pip or conda (conda-forge channel).

Depends on:

Usage

Initializing the ProjectsManager

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

## 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")
## 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

## 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
## 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_project_name("Компьютер")
project
>> kompiuter
## Create a project without activating it:
projects_manager.create_project("<project_name>")
## Create a project and activate it:
projects_manager.create_project("<project_name>", activate=True)
## Iterate over projects:
for project in projects_manager:
	print(project.name, project.attributes)
## Activate a project:
projects_manager.activate("<project_name>")
## Delete a project from SQLite database and deleting the directory:
projects_manager.delete_project("<project_name>")
## 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.

License

Distributed under the terms of the BSD-2-Clause license, bw_projects is free and open source software.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bw-projects-2.0.1.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

bw_projects-2.0.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file bw-projects-2.0.1.tar.gz.

File metadata

  • Download URL: bw-projects-2.0.1.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for bw-projects-2.0.1.tar.gz
Algorithm Hash digest
SHA256 5ac870103c3b8b84bc7a43e07c938fc1932fd3d40d34f1ffc04b02212dcaa88f
MD5 6aa4ad8773f6d232180ed47eb4457d43
BLAKE2b-256 5db2700a61753afbfd1304ed14dcc09b07775e733175a4a515c01dd7a2cd0906

See more details on using hashes here.

File details

Details for the file bw_projects-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: bw_projects-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for bw_projects-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eebb457097527ea5e752525bb79233430dad2529cd0fc70ad1d6933712f54eb7
MD5 924761304a07e14aa61752e43112e237
BLAKE2b-256 19ef58af315bc15f9a57f6e263152c2306766c9e1d43288e05aaaec50e3d7b2b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page