@defer.inlineCallbacks
def gen_macro_helper(line, template=None):
    args = shlex.split(line)
    if template is None:
        fname = args[0]
        template_name = args[1]
        argstart = 2
    else:
        fname = args[0]
        template_name = template
        argstart = 1
    if template_name not in MacroTemplate.template_list():
        raise PappyException('%s is not a valid template name' % template_name)
    script_str = yield MacroTemplate.fill_template_args(template_name, args[argstart:])
    fname = MacroTemplate.template_filename(template_name, fname)
    with open(fname, 'wc') as f:
        f.write(script_str)
    print 'Wrote script to %s' % fname
dataset/ETHPy150Open roglew/pappy-proxy/pappyproxy/plugins/macrocmds.py/gen_macro_helper/original