Merge functions from other python files
this is a dirty way to merge functions from other python files into one python file in order to deploy fast.
install merge_functions
using python 3.9
pip install merge_functions
pip install astunparse=1.6.3
how to use
if you want to import from current directory python file, you need set environment:
if you current path is: ~/code or D:\code
mac or linux:
export PYTHONPATH=~/code
windows
set PYTHONPATH=D:\code
help info
mf -h
simple example:
mf -i main.py -m demo
this will import need functions and classes
mf -i main.py -m demo -a
- -i: input file
- -m: modules or keywords in modules
- -a: get all code from source file
then, demo's functions will merge into one.py
PS: the code you need merge from extra module must in from ... import ... statements
main.py below
from demo import add, subtract, multiply, divide
import json
def run():
a, b = 3, 4
result1 = add(a, b)
result2 = subtract(a, b)
result3 = multiply(a, b)
result4 = divide(a, b)
result_dict = {
"result1": result1,
"result2": result2,
"result3": result3,
"result4": result4,
}
print(json.dumps(result_dict))
if __name__ == "__main__":
run()
demo.py below
def add(a, b):
return a + b
def subtract(a, b):
return a - b
def multiply(a, b):
return a * b
def divide(a, b):
return a / b if b else 0
Pycharm settings
External tools settings
Program
$PyInterpreterDirectory$/mf.exe
Arguments
-i $FilePath$ -m utils -a
Working directory
$ProjectFileDir$
Advanced Options
Synchronize files after exection
Open console for tool output
Metadata
Release files for merge_functions 0.0.10
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 | |
|---|---|---|---|---|
| merge_functions-0.0.10.tar.gz | 5.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| merge_functions-0.0.10-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.2 kB
Release files / merge_functions-0.0.10.tar.gz
| Download URL | merge_functions-0.0.10.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
22882643bd7977b0690006b93f6eccf202113d6d234a9af0e55e83acbbcd8a0d
|
|
BLAKE2b-256 checksum How to use checksums |
77dda819e88d74b956df0d8a2286dab103a9f6b28a72a2dd630df0bf9be893ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.9.7 Darwin/23.6.0
|
Release files / merge_functions-0.0.10-py3-none-any.whl
| Download URL | merge_functions-0.0.10-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
75b9f6fb9fb497d7588bc0b2ba1da166f622648a4de606d286194e3cd81eebcf
|
|
BLAKE2b-256 checksum How to use checksums |
fc70ea4e0858c4be00ebc17cd0e380015e437e3e892a9b21174b626ced2317dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.9.7 Darwin/23.6.0
|
Security for merge_functions 0.0.10
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.