Code Generation library written by python. can use bash script, can be extend python code, can use mustache files or can use any string content for any code generation structure.
Project description
code-gen-library
code-gen-library for Python
code-gen-lib pip install
pip install codegenlib
code-gen-lib import package
from codegenlib.enums import MUSTACHE
from codegenlib.templateStreaming import TemplateStreaming
from codegenlib.templateFile import TemplateFile
from codegenlib.templateModule import TemplateModule
using example
code_gen_lib_example.py
code-gen-lib generation from json file
config_json_example.py
## with folder
config_json_with_template_folder_example.py
code-gen-lib generation programming example
You should add your module containing your folder pathname to the 'modules' path. You can add mustache files and template folder/files in your module path
from codegenlib.enums import MUSTACHE
from codegenlib.templateStreaming import TemplateStreaming
from codegenlib.templateFile import TemplateFile
from codegenlib.templateModule import TemplateModule
fileName = "test.swift"
testManagerClassTF = TemplateFile(
name="manager_class_mustache",
dict={"service_name": "OneframeMobile", "request_func": MUSTACHE.PARENT},
output_file="Manager.swift"
)
testGetRequestFuncTF = TemplateFile(
name="request_get_func_mustache",
dict={"result_model_name": "String","function_name": "getTest", "query_path" : '"api/getTest?name=query"', "func_param" : "query:String, "},
output_file=None,
is_child_template=True,
parent_mustache="request_func"
)
testPostRequestFuncTF = TemplateFile(
name="request_post_func_mustache",
dict={"result_model_name": "UserModel", "function_name": "login", "query_path" : '"api/login"', "func_param" : ""},
output_file=None,
is_child_template=True,
parent_mustache="request_func"
)
testManagerClassTF.childTemplateFiles.append(testGetRequestFuncTF)
testManagerClassTF.childTemplateFiles.append(testPostRequestFuncTF)
testModule = TemplateModule(
name="networking-swagger-swift",
templates_files=[testManagerClassTF]
)
tStreaming = TemplateStreaming(
templateModule=testModule
)
tStreaming.execute()
code-gen-lib generation programming example with your json file
this is written module code by json
{
"module" : {
"name" : "oneframe-ios-api-manager",
"templateFolders" : [
{
"source" : "modules/oneframe-ios-api-manager/models",
"outputPath" : "models",
"isOnline" : false
}
],
"templateFiles": [
{
"name": "manager_class_mustache",
"outputFile": "CanikServiceManager.swift",
"isChildTemplate": false
},
{
"name": "learning_class_mustache",
"outputFile": "OneFrameLearning.swift",
"isChildTemplate": false
}
]
}
}
import os
import sys
from codegenlib.parser import Parser
# Own modules
from codegenlib.templateStreaming import TemplateStreaming
pathname = os.path.dirname(sys.argv[0])
# current path
json_file_name = "sample_config_with_template_folder.json"
json_file_path = pathname + "/" + json_file_name
sampleJsonModule = Parser.jsonToTemplateModule(json_file=json_file_path)
sampleJsonModule.outputDirectory = "oneframe-api-ios"
sampleJsonModule.isAppendOutputPath = True
print(sampleJsonModule.getOutputDirectoryPath())
tStreaming = TemplateStreaming(
template_module=sampleJsonModule,
enable_log=False,
)
tStreaming.execute()
Can be Contribution, join us!
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
codegenlib-0.8.0.tar.gz
(14.8 kB
view details)
Built Distribution
File details
Details for the file codegenlib-0.8.0.tar.gz
.
File metadata
- Download URL: codegenlib-0.8.0.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a422f9c55e4c5a230e360dd8314788bda0b83cd40cb78f41f3da1782a8d57da5 |
|
MD5 | a25b0d76cf067ac8ec3879ae6ce11efd |
|
BLAKE2b-256 | fdfa4af40b2cb25d4a5fc8bc572ef72f4f37350ab16fa1aad69e408c6ffc292d |
File details
Details for the file codegenlib-0.8.0-py3-none-any.whl
.
File metadata
- Download URL: codegenlib-0.8.0-py3-none-any.whl
- Upload date:
- Size: 17.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e21897d8314f80429ccc92d95d84f1ad5d6ebc9174ce9fd4e8a3ebf3bfd159b |
|
MD5 | 157456ea8c55767a0b0f3dc68cd3f6ae |
|
BLAKE2b-256 | 457674c3d06080e90c6422acc3dcf8bfd3b7e67b25087816a2651a12433481de |