def render_source(output_dir, package_specs, version):
destination_filename = "<STR_LIT>" % output_dir<EOL>py_template = JENV.get_template(TEMPLATE_NAME)<EOL>stable_msgs = []<EOL>unstable_msgs = []<EOL>prims = []<EOL>for p in sorted(package_specs, key=attrgetter('<STR_LIT>')):<EOL><INDENT>pkg_name = p.identifier<EOL>stable = p.stable<EOL>definitions = p.definitions<EOL>for inc in p.includes:<EOL><INDENT>inc_basename = inc.split("<STR_LIT:.>")[<NUM_LIT:0>]<EOL>for pkg in package_specs:<EOL><INDENT>if pkg.identifier.endswith(inc_basename):<EOL><INDENT>definitions += pkg.definitions<EOL><DEDENT><DEDENT><DEDENT>if pkg_name == "<STR_LIT>":<EOL><INDENT>prims = p.definitions<EOL><DEDENT>for d in p.definitions:<EOL><INDENT>if d.public and d.static and d.sbp_id:<EOL><INDENT>items, size, multiplier= handle_fields(definitions, d.fields, "<STR_LIT>", <NUM_LIT:0>, None)<EOL>adj_size = "<STR_LIT>"<EOL>if multiplier == <NUM_LIT:1>:<EOL><INDENT>adj_size = "<STR_LIT>" % (size - <NUM_LIT:1>) if size > <NUM_LIT:1> else "<STR_LIT:N>"<EOL><DEDENT>elif multiplier:<EOL><INDENT>if multiplier == size:<EOL><INDENT>adj_size = "<STR_LIT>" % multiplier<EOL><DEDENT>else:<EOL><INDENT>adj_size = "<STR_LIT>" % (multiplier, size - multiplier)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>adj_size = "<STR_LIT>" % size<EOL><DEDENT>ti = TableItem(pkg_name, d.identifier, d.sbp_id,<EOL>d.short_desc, d.desc, adj_size, items, p.stable,<EOL>p.description)<EOL>pkg_name = "<STR_LIT>"<EOL>if stable:<EOL><INDENT>stable_msgs.append(ti)<EOL><DEDENT>else:<EOL><INDENT>unstable_msgs.append(ti)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>with open(destination_filename, '<STR_LIT:w>') as f:<EOL><INDENT>f.write(py_template.render(msgs=stable_msgs,<EOL>umsgs=unstable_msgs,<EOL>prims=prims,<EOL>version=version))<EOL><DEDENT>import subprocess<EOL>import os<EOL>os.chdir(output_dir)<EOL>subprocess.call(["<STR_LIT>", "<STR_LIT>",<EOL>"<STR_LIT>", "<STR_LIT>"])<EOL>subprocess.call(["<STR_LIT>", "<STR_LIT>", "<STR_LIT>"])<EOL>
Render and output