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

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.1.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

bw_projects-2.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for bw-projects-2.1.0.tar.gz
Algorithm Hash digest
SHA256 31bf2c8be9b4ecc7f3b151d0d9f75123309ebb87062f601efab19778604876b2
MD5 d63ee5fa850b773b3a8f13b1bf44abb5
BLAKE2b-256 c8c2b1d446ad67b01dde916e036544fdc579f44f127715fdc1c77cee6b4c82b7

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for bw_projects-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 574307736f87a94b7bf612ec5bfca59fa6b40d86e1e011fcc67f7fdffd55f1e8
MD5 7f4f903defd6de68ba9c4d77c729be89
BLAKE2b-256 26e7ee0727d9728edc041f0cb4c35fff807d7adb85adf641dfe6013f370e7d23

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