-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate multiple output files with cog #19
Comments
Hi, sorry I didn't get to this. Cog doesn't have a way to do this now, but I might be adding an explicit API to cog, which would make this possible. Did you find another way to do it? |
using-cog-from-within-pythonOverview
Context
Scenario
Problem
Solution
Example
import cogapp
cogscript = cogapp.Cog()
pass
ddcogginfo = dict()
ddcogginfo['prelines'] = 'import random;'
ddcogginfo['fileinpp'] = 'QXP:/path/to/my/file/friantexport.java'
ddcogginfo['outname'] = 'friantexport_new.java'
ddcogginfo['markers'] = '[[cog ]] [[end]]' ## (using the default cog_markup_syntax)
bbselfreplace = True
pass
aacoggopts = list()
aacoggopts += [ 'cog' ] ## specify cog
aacoggopts += [ '-nutf-8' ] ## specify utf-8
aacoggopts += [ '--markers={markers}'.format(**ddcogginfo) ] ## specify cog delimiter syntax
aacoggopts += [ '-p{prelines}'.format(**ddcogginfo) ] ## prepend_generator_source
if(bbselfreplace):
aacoggopts += [ '-r' ] ## self-replace file content
pass
elif(True):
aacoggopts += [ '-o{outname}'.format(**ddcogginfo) ] ## specify outputfile separate from cog_input_file
pass
aacoggopts += [ '--verbosity=2' ] ## 2verbose 1quiet 0silent
aacoggopts += [ ddcogginfo['fileinpp'] ] ## specify cog_input_file
pass
vg3557flesoutt = cogscript.main(aacoggopts)
pass |
This was referenced Mar 11, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it possible to generate multiple output files with cog?
For example I have python dictionary:
MODULE_ACTIONS_DICT = {
"contractors": ["add", "delete", "edit", "find", "get"],
"invoices": ["add", "delete", "download", "edit", "find"],
"expenses": ["find","get"],
........
}
I would like to use cog to create multiple source files, one file per dictionary key and using dictionary values to parametrize those files.
I wonder if cog is right tool for this task... Alternatively I can use jinja2
The text was updated successfully, but these errors were encountered: