static code extractor for Python
Project description
Github |
|
Pypi |
|
ReadTheDocs |
Liberator is a Python library that “liberates” (i.e. statically extracts) class / function source code from an existing python library into a single standalone module.
It works by statically parsing the code for the class / function definition and then recursively parsing and extracting all missing dependencies.
Here is an example. Say that you want to use the find_exe function from ubelt, but you don’t want to depend on ubelt itself, you can extract the minimal code necessary to define the fine_exe function in a new standalone module via:
# Create a Liberator instance to manage construction of
# the new standalone code.
from liberator.core import Liberator
lib = Liberator()
# Pass the liberator object the function you want to expose
# You can add more than one function this way.
import ubelt as ub
lib.add_dynamic(ub.find_exe)
# Tell liberator about the library that you dont want to depend on,
# any (statically findable) external references to that library will be
# vendored into the new liberated code.
lib.expand(['ubelt'])
# Finally access the "current source code" which will
# have the self-contained version of the "liberated" utility.
print(lib.current_sourcecode())
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
Built Distribution
File details
Details for the file liberator-0.0.3.tar.gz
.
File metadata
- Download URL: liberator-0.0.3.tar.gz
- Upload date:
- Size: 66.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
f2df9c2682675c3af20ba39a2918a1064cfe174a01f67a96ced8e7cd28d387a9
|
|
MD5 |
e513d793515dad2b0de8fc2884fc12f0
|
|
BLAKE2b-256 |
65ce582c6103a9c29ec7a735c1de7e666be9b42b366a5b151c4fb5b0c6ded18e
|
File details
Details for the file liberator-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: liberator-0.0.3-py3-none-any.whl
- Upload date:
- Size: 21.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
5236faea006f61f13b9a430bc1abbd4c790027fac398397cd30c4696c46fb338
|
|
MD5 |
60d9d8d068d304240f42167ad83709d6
|
|
BLAKE2b-256 |
1f0d3b5c4aff53b612c94218c38d660acfc79933f4b5f979a349d8edb626bc35
|