本文整理汇总了Python中struct_parser.Compiler.compile_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Compiler.compile_dict方法的具体用法?Python Compiler.compile_dict怎么用?Python Compiler.compile_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类struct_parser.Compiler
的用法示例。
在下文中一共展示了Compiler.compile_dict方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_dict_error
# 需要导入模块: from struct_parser import Compiler [as 别名]
# 或者: from struct_parser.Compiler import compile_dict [as 别名]
def test_dict_error(self):
""" dict error """
the_string = "{'a':1, b:2 "
compiler = Compiler()
try:
compiler.compile_dict(the_string)
except CompilerError, err:
self.assertEqual(err.message, "Expression \"{'a':1, b:2 \" cannot be converted as a dict.")
示例2: test_noquotes_dict
# 需要导入模块: from struct_parser import Compiler [as 别名]
# 或者: from struct_parser.Compiler import compile_dict [as 别名]
def test_noquotes_dict(self):
""" no quotes dict """
the_string = "{ no12: a b , no10:a}"
compiler = Compiler()
the_result = compiler.compile_dict(the_string)
self.assertEqual(the_result, {"no12": "a b", "no10": "a"})
示例3: test_dict_with_list
# 需要导入模块: from struct_parser import Compiler [as 别名]
# 或者: from struct_parser.Compiler import compile_dict [as 别名]
def test_dict_with_list(self):
""" dict with list """
the_string = "{'a':1, b:[1,2,3,4,5] }"
compiler = Compiler()
the_result = compiler.compile_dict(the_string)
self.assertEqual(the_result, {"a": 1, "b": [1, 2, 3, 4, 5]})
示例4: test_simple_dict
# 需要导入模块: from struct_parser import Compiler [as 别名]
# 或者: from struct_parser.Compiler import compile_dict [as 别名]
def test_simple_dict(self):
""" simple dict """
the_string = "{'a':1, b:2 }"
compiler = Compiler()
the_result = compiler.compile_dict(the_string)
self.assertEqual(the_result, {"a": 1, "b": 2})
示例5: test_noquotes_dict
# 需要导入模块: from struct_parser import Compiler [as 别名]
# 或者: from struct_parser.Compiler import compile_dict [as 别名]
def test_noquotes_dict(self):
""" no quotes dict """
the_string = "{ no12: a b , no10:a}"
compiler = Compiler()
the_result = compiler.compile_dict(the_string)
self.assertEqual(the_result,{ 'no12': 'a b' , 'no10':'a'})
示例6: ztest_compile_from_file
# 需要导入模块: from struct_parser import Compiler [as 别名]
# 或者: from struct_parser.Compiler import compile_dict [as 别名]
def ztest_compile_from_file(self):
""" compile from file """
the_file = open('/home/aubert/dev/src-reps/java-balivernes/InfraProfiler/src/sel3_event.traj')
the_string = the_file.read()
compiler = Compiler()
the_result = compiler.compile_dict(the_string)
print(the_result)