本文整理汇总了Python中template_utils.open_output函数的典型用法代码示例。如果您正苦于以下问题:Python open_output函数的具体用法?Python open_output怎么用?Python open_output使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了open_output函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: generate_type_maps
def generate_type_maps(install_dir):
# Collect legacy code
tmp = StringIO()
c_type_maps.gen_length_array(tmp)
with template_utils.open_output(install_dir, "loci/src/of_type_maps.c") as out:
util.render_template(out, "of_type_maps.c", legacy_code=tmp.getvalue())
开发者ID:bjlee72,项目名称:loxigen,代码行数:7,代码来源:codegen.py
示例2: generate
def generate(install_dir):
context = {
'fields': create_fields(),
}
with template_utils.open_output(install_dir, 'wireshark/openflow.lua') as out:
template_utils.render_template(out, "openflow.lua", [templates_dir], context)
开发者ID:FernandoFarias,项目名称:loxigen,代码行数:7,代码来源:__init__.py
示例3: generate_classes
def generate_classes(install_dir):
for uclass in loxi_globals.unified.classes:
with template_utils.open_output(install_dir, "loci/src/%s.c" % uclass.name) as out:
util.render_template(out, "class.c",
push_wire_types_data=push_wire_types_data(uclass))
# Append legacy generated code
c_code_gen.gen_new_function_definitions(out, uclass.name)
c_code_gen.gen_accessor_definitions(out, uclass.name)
开发者ID:Taejun,项目名称:loxigen,代码行数:8,代码来源:codegen.py
示例4: generate_lists
def generate_lists(install_dir):
for cls in of_g.ordered_list_objects:
with template_utils.open_output(install_dir, "loci/src/%s.c" % cls) as out:
util.render_template(out, "class.c",
push_wire_types_data=None)
# Append legacy generated code
c_code_gen.gen_new_function_definitions(out, cls)
c_code_gen.gen_list_accessors(out, cls)
开发者ID:Taejun,项目名称:loxigen,代码行数:8,代码来源:codegen.py
示例5: generate_classes
def generate_classes(install_dir):
for i, chunk in enumerate(chunks(loxi_globals.unified.classes, CLASS_CHUNK_SIZE)):
with template_utils.open_output(install_dir, "loci/src/class%02d.c" % i) as out:
for uclass in chunk:
util.render_template(out, "class.c",
push_wire_types_data=push_wire_types_data(uclass))
# Append legacy generated code
c_code_gen.gen_new_function_definitions(out, uclass.name)
c_code_gen.gen_accessor_definitions(out, uclass.name)
开发者ID:jonstout,项目名称:loxigen,代码行数:9,代码来源:codegen.py
示例6: generate_header_classes
def generate_header_classes(install_dir):
for cls in of_g.standard_class_order:
if cls.find("_header") < 0:
continue
with template_utils.open_output(install_dir, "loci/src/%s.c" % cls) as out:
util.render_template(out, "class.c",
push_wire_types_data=None)
# Append legacy generated code
c_code_gen.gen_new_function_definitions(out, cls)
c_code_gen.gen_accessor_definitions(out, cls)
开发者ID:Taejun,项目名称:loxigen,代码行数:10,代码来源:codegen.py
示例7: generate_classes_header
def generate_classes_header(install_dir):
# Collect legacy code
tmp = StringIO()
c_code_gen.gen_struct_typedefs(tmp)
c_code_gen.gen_new_function_declarations(tmp)
c_code_gen.gen_accessor_declarations(tmp)
with template_utils.open_output(install_dir, "loci/inc/loci/loci_classes.h") as out:
util.render_template(out, "loci_classes.h",
legacy_code=tmp.getvalue())
开发者ID:PuzzyDog,项目名称:loxigen,代码行数:10,代码来源:codegen.py
示例8: generate_strings
def generate_strings(install_dir):
object_id_strs = []
object_id_strs.append("of_object")
object_id_strs.extend(of_g.ordered_messages)
object_id_strs.extend(of_g.ordered_non_messages)
object_id_strs.extend(of_g.ordered_list_objects)
object_id_strs.extend(of_g.ordered_pseudo_objects)
object_id_strs.append("of_unknown_object")
with template_utils.open_output(install_dir, "loci/src/loci_strings.c") as out:
util.render_template(out, "loci_strings.c", object_id_strs=object_id_strs)
开发者ID:kwanggithub,项目名称:loxigen,代码行数:11,代码来源:codegen.py
示例9: generate
def generate(install_dir):
build_of_g.initialize_versions()
build_of_g.build_ordered_classes()
build_of_g.populate_type_maps()
build_of_g.analyze_input()
build_of_g.unify_input()
build_of_g.order_and_assign_object_ids()
for (name, fn) in targets.items():
with template_utils.open_output(install_dir, name) as outfile:
fn(outfile, os.path.basename(name))
c_gen.codegen.generate_classes(install_dir)
c_gen.codegen.generate_header_classes(install_dir)
c_gen.codegen.generate_classes_header(install_dir)
c_gen.codegen.generate_lists(install_dir)
c_gen.codegen.generate_strings(install_dir)
c_gen.codegen.generate_init_map(install_dir)
c_gen.codegen.generate_type_maps(install_dir)
开发者ID:Sovietaced,项目名称:loxigen,代码行数:17,代码来源:lang_c.py
示例10: generate_lists
def generate_lists(install_dir):
# Collect all the lists in use
list_oftypes = set()
for uclass in loxi_globals.unified.classes:
for ofclass in uclass.version_classes.values():
for m in ofclass.members:
if isinstance(m, ir.OFDataMember) and \
loxi_utils.oftype_is_list(m.oftype):
list_oftypes.add(m.oftype)
for oftype in sorted(list(list_oftypes)):
cls, e_cls = loxi_utils_legacy.list_name_extract(oftype)
e_cls = e_cls[:-2]
e_uclass = loxi_globals.unified.class_by_name(e_cls)
with template_utils.open_output(install_dir, "loci/src/%s.c" % cls) as out:
util.render_template(out, "list.c", cls=cls, e_cls=e_cls, e_uclass=e_uclass,
wire_length_get=class_metadata_dict[e_cls].wire_length_get)
# Append legacy generated code
c_code_gen.gen_new_function_definitions(out, cls)
开发者ID:bjlee72,项目名称:loxigen,代码行数:19,代码来源:codegen.py
示例11: generate_class_metadata
def generate_class_metadata(install_dir):
with template_utils.open_output(install_dir, "loci/inc/loci/loci_class_metadata.h") as out:
util.render_template(out, "loci_class_metadata.h")
with template_utils.open_output(install_dir, "loci/src/loci_class_metadata.c") as out:
class_metadata = []
for uclass in loxi_globals.unified.classes:
wire_length_get = 'NULL'
wire_length_set = 'NULL'
wire_type_get = 'NULL'
wire_type_set = 'NULL'
if uclass and not uclass.virtual and uclass.has_type_members:
wire_type_set = '%s_push_wire_types' % uclass.name
if uclass.is_message and uclass.name != "of_header":
wire_length_get = 'of_object_message_wire_length_get'
wire_length_set = 'of_object_message_wire_length_set'
elif uclass.is_action:
wire_length_set = 'of_tlv16_wire_length_set'
wire_length_get = 'of_tlv16_wire_length_get'
wire_type_get = 'of_action_wire_object_id_get'
elif uclass.is_action_id:
wire_length_set = 'of_tlv16_wire_length_set'
wire_length_get = 'of_tlv16_wire_length_get'
wire_type_get = 'of_action_id_wire_object_id_get'
elif uclass.is_instruction:
wire_length_set = 'of_tlv16_wire_length_set'
wire_length_get = 'of_tlv16_wire_length_get'
wire_type_get = 'of_instruction_wire_object_id_get'
elif uclass.is_instanceof('of_instruction_id'):
wire_length_set = 'of_tlv16_wire_length_set'
wire_length_get = 'of_tlv16_wire_length_get'
wire_type_get = 'of_instruction_id_wire_object_id_get'
elif uclass.is_instanceof('of_queue_prop'):
wire_length_set = 'of_tlv16_wire_length_set'
wire_length_get = 'of_tlv16_wire_length_get'
wire_type_get = 'of_queue_prop_wire_object_id_get'
elif uclass.is_instanceof('of_table_feature_prop'):
wire_length_set = 'of_tlv16_wire_length_set'
wire_length_get = 'of_tlv16_wire_length_get'
wire_type_get = 'of_table_feature_prop_wire_object_id_get'
elif uclass.is_instanceof('of_meter_band'):
wire_length_set = 'of_tlv16_wire_length_set'
wire_length_get = 'of_tlv16_wire_length_get'
wire_type_get = 'of_meter_band_wire_object_id_get'
elif uclass.is_instanceof('of_hello_elem'):
wire_length_set = 'of_tlv16_wire_length_set'
wire_length_get = 'of_tlv16_wire_length_get'
wire_type_get = 'of_hello_elem_wire_object_id_get'
elif uclass.is_instanceof('of_bsn_tlv'):
wire_length_set = 'of_tlv16_wire_length_set'
wire_length_get = 'of_tlv16_wire_length_get'
wire_type_get = 'of_bsn_tlv_wire_object_id_get'
elif uclass.is_oxm:
wire_length_get = 'of_oxm_wire_length_get'
wire_type_get = 'of_oxm_wire_object_id_get'
elif uclass.name == "of_packet_queue":
wire_length_get = 'of_packet_queue_wire_length_get'
wire_length_set = 'of_packet_queue_wire_length_set'
elif uclass.name == "of_meter_stats":
wire_length_get = 'of_meter_stats_wire_length_get'
wire_length_set = 'of_meter_stats_wire_length_set'
elif uclass.name in ["of_group_desc_stats_entry", "of_group_stats_entry",
"of_flow_stats_entry", "of_bucket", "of_table_features",
"of_bsn_port_counter_stats_entry", "of_bsn_vlan_counter_stats_entry",
"of_bsn_gentable_entry_desc_stats_entry", "of_bsn_gentable_entry_stats_entry",
"of_bsn_gentable_desc_stats_entry"]:
wire_length_get = "of_u16_len_wire_length_get"
wire_length_set = "of_u16_len_wire_length_set"
elif uclass.name == 'of_match_v3':
wire_length_set = 'of_tlv16_wire_length_set'
wire_length_get = 'of_tlv16_wire_length_get'
wire_type_set = 'of_match_v3_push_wire_types'
class_metadata.append(ClassMetadata(
name=uclass.name,
wire_length_get=wire_length_get,
wire_length_set=wire_length_set,
wire_type_get=wire_type_get,
wire_type_set=wire_type_set))
class_metadata.extend([
ClassMetadata(
name="of_action_header",
wire_length_set='of_tlv16_wire_length_set',
wire_length_get='of_tlv16_wire_length_get',
wire_type_get='of_action_wire_object_id_get',
wire_type_set='NULL'),
ClassMetadata(
name="of_action_id_header",
wire_length_set='of_tlv16_wire_length_set',
wire_length_get='of_tlv16_wire_length_get',
wire_type_get='of_action_id_wire_object_id_get',
wire_type_set='NULL'),
ClassMetadata(
name="of_instruction_header",
wire_length_set='of_tlv16_wire_length_set',
wire_length_get='of_tlv16_wire_length_get',
wire_type_get='of_instruction_wire_object_id_get',
#.........这里部分代码省略.........
开发者ID:kwanggithub,项目名称:loxigen,代码行数:101,代码来源:codegen.py
示例12: generate_init_map
def generate_init_map(install_dir):
with template_utils.open_output(install_dir, "loci/src/loci_init_map.c") as out:
util.render_template(out, "loci_init_map.c", classes=of_g.standard_class_order)
开发者ID:kwanggithub,项目名称:loxigen,代码行数:3,代码来源:codegen.py
示例13: render
def render(name, template_name=None, **ctx):
if template_name is None:
template_name = os.path.basename(name)
with template_utils.open_output(install_dir, name) as out:
util.render_template(out, template_name, **ctx)
开发者ID:sauravdas2,项目名称:loxigen,代码行数:5,代码来源:codegen.py
示例14: generate
def generate(install_dir):
py_gen.codegen.init()
for (name, fn) in targets.items():
with template_utils.open_output(install_dir, name) as outfile:
fn(outfile, os.path.basename(name))
开发者ID:FernandoFarias,项目名称:loxigen,代码行数:5,代码来源:lang_python.py
示例15: generate_class_metadata
def generate_class_metadata(install_dir):
with template_utils.open_output(install_dir, "loci/inc/loci/loci_class_metadata.h") as out:
util.render_template(out, "loci_class_metadata.h")
with template_utils.open_output(install_dir, "loci/src/loci_class_metadata.c") as out:
util.render_template(out, "loci_class_metadata.c", class_metadata=class_metadata)
开发者ID:bjlee72,项目名称:loxigen,代码行数:6,代码来源:codegen.py
注:本文中的template_utils.open_output函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论