automatic acquisition of modules from packages
Project description
acq
What it is?!
This library provides a simple and convenient way to automatically search packages for modules and import them without needing project files to manually import them, which allows for automatic configuration and other useful mechanics within projects.
Installation
You can install this module via pip or your preferred dependency management tool(s):
pip install acq
Usage
In standard Python applications, the tool can be used in the following ways:
from acq import discover
# Import modules 'a' and 'b' from packages "example1" and "example2"
discover('a', 'b', package_names=['example1', 'example2'])
Furthermore, you can extend this functionality to provide you all classes or instances matching a specific class within discovered modules:
from csv import DictReader
from acq import discover
# Import modules 'readers' from packages "example1" and "example2"
# and get any instances, subclasses of, or references to
# DictReader from within them
results = discover(
'readers',
package_names=['example1', 'example2']),
types=(DictReader,),
)
print(list(results.DictReader))
In Django applications, you can automatically import from INSTALLED_APPS via:
from acq.django import discover
# Import views.py for all packages in the INSTALLED_APPS setting
discover('views')
# Import views.py for all packages in an AUTOSEARCH_MODULES setting
discover('views', packages_setting_name='AUTOSEARCH_MODULES')
Contributing
Thank you for considering use of this project, and please feel free to provide any suggestions in pull requests if you have any!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file acq-0.2.2.tar.gz
.
File metadata
- Download URL: acq-0.2.2.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c52155141eae42eac0535ff86f164559e5d2989e034169129f243e24ac77735 |
|
MD5 | 89628ce3f4c2785a2fb2968769231f1a |
|
BLAKE2b-256 | 6b0209ac6f098bec6c67455e71e7ae20f29e38a98a1d456153571efc98b02a6e |