pythonguts
If your project depends on some external python projects and you want to make some changes in external functions/methods and then copy/paste these changes automatically - this package may help you.
There is a tool editpy wich we will discuss.
Same tool aimed at editing cpp files is also available as cppguts
Installation
pythonguts is available at PyPI:
pip install pythonguts
The idea behind editpy tool
editpy uses astor to find replaceable functions and replaces matching functions.
To find common function editpy checks:
- are they both functions?
- do they both have the same name?
- do they both have the same args?
- do they both have the same parent (i.e. classname for example)?
Example
original function/method definition file dest.py:
class MyClass:
def my_method(self, i: float, j: int, k: float) -> float:
return 0
def foo(i: float) -> float:
return i
def bar():
return 0
# this function stays unchanged
def unchanged():
return 0
new function/method definition file src.py:
class MyClass:
def my_method(self, i: float, j: int, k: float) -> float:
print('new definition')
return 0
def foo(i: float) -> float:
print('new definition')
return i
def bar():
print('new definition')
return 0
Run:
editpy --src-file=src.py --dest-file=dest.py --oldfile-keep
--oldfile-keep (default) is used to keep the original file (it will be renamed by adding _OLD_N suffix). Otherwise use --oldfile-delete to delete the original file.
Another option is to run the test (though the test deletes all the generated files so you better take a look in /tests dir):
python -m unittest pythonguts.tests.test_pythonguts
Metadata
Release files for pythonguts 0.2.0
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 | |
|---|---|---|---|---|
| pythonguts-0.2.0.tar.gz | 5.7 kB | Without provenance | Details |
Release files / pythonguts-0.2.0.tar.gz
| Download URL | pythonguts-0.2.0.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4259427a669fe14b16e7a0be7e17650f32e25dfa985dca6a588210308dc538a7
|
|
BLAKE2b-256 checksum How to use checksums |
f5b7073059df1592350b01aef50866d97821c5c803023b3462909edb12bb0e88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.7
|
Security for pythonguts 0.2.0
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.