Skip to main content

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_directory_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.

Release files for bw-projects 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bw-projects 2.1.0
File Size Uploaded
bw-projects-2.1.0.tar.gz 11.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bw-projects 2.1.0
File Interpreter ABI Platform
bw_projects-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.7 kB

Release files / bw-projects-2.1.0.tar.gz

Download URL bw-projects-2.1.0.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
31bf2c8be9b4ecc7f3b151d0d9f75123309ebb87062f601efab19778604876b2
BLAKE2b-256 checksum
How to use checksums
c8c2b1d446ad67b01dde916e036544fdc579f44f127715fdc1c77cee6b4c82b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bw_projects-2.1.0-py3-none-any.whl

Download URL bw_projects-2.1.0-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
574307736f87a94b7bf612ec5bfca59fa6b40d86e1e011fcc67f7fdffd55f1e8
BLAKE2b-256 checksum
How to use checksums
26e7ee0727d9728edc041f0cb4c35fff807d7adb85adf641dfe6013f370e7d23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

2.0.1

2 release files

1.0.0

2 release files

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page