lilliepy_import
lilliepy_import is a Python package that provides utility functions for dynamically importing modules and components. It is designed to make it easy to set a component directory and load specific functions or classes dynamically.
Features
- Dynamically set a component folder using
Importer. - Import specific functions or classes from files in the component folder with
_import. - Supports dynamic module imports with error handling.
Installation
To install the package, use pip:
pip install lilliepy_import
Usage
Setting the Component Folder
First, set the component folder where your modules are stored:
from lilliepy_import import Importer
# Set the component folder
Importer("components")
Importing a Function or Class
You can then dynamically import a specific function or class:
from lilliepy_import import _import
# Dynamically import a function or class
try:
my_function = _import("my_module.py", "my_function")
if my_function:
my_function() # Call the imported function
else:
print("Function not found in the module.")
except Exception as e:
print(f"Error: {e}")
Example
Assume the following directory structure:
project/
├── components/
│ └── my_module.py
└── main.py
my_module.py:
from reactpy import component, html
@component
def my_function():
return html.h1("yo")
main.py:
from lilliepy_import import Importer, _import
# Set the component folder
Importer("components")
# Import and call the function
func = _import("my_module.py", "my_function")
if func:
func()
When you run main.py, the output will be:
Hello from my_function!
Error Handling
- Raises a
ValueErrorif the component folder is not set before calling_import. - Raises a
FileNotFoundErrorif the specified file does not exist. - Handles cases where the function or class is not found in the module.
License
This project is licensed under the MIT License.
Metadata
Release files for lilliepy-import 1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lilliepy_import-1.4.tar.gz | 2.9 kB | Without provenance | Details for lilliepy_import-1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lilliepy_import-1.4-py3-none-any.whl | Python 3 | none | any | Details for lilliepy_import-1.4-py3-none-any.whl |
Total release size: 5.9 kB
Release files / lilliepy_import-1.4.tar.gz
| Download URL | lilliepy_import-1.4.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e6a4aaee4227c800b3ae2350ce2e15f7f8ff4b73b5f19a40eb56d3ff21ee222b
|
|
BLAKE2b-256 checksum How to use checksums |
1768c1d6746b1305fd2f4161ebbb476d81daafa109295fc471d91a61c04e6431
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / lilliepy_import-1.4-py3-none-any.whl
| Download URL | lilliepy_import-1.4-py3-none-any.whl |
|---|---|
| Size | 3.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c0c4a74c751961dced722e50af4d5824feb7a445749398df805f8e8de1cc9d0b
|
|
BLAKE2b-256 checksum How to use checksums |
edcac4bcdf18f858f93ff75ce62d8ce032c4d13a2b40362dcb0a4ce3e93cdf32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Security for lilliepy-import 1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.