本文整理汇总了Python中odict.OrderedDict.setdefault方法的典型用法代码示例。如果您正苦于以下问题:Python OrderedDict.setdefault方法的具体用法?Python OrderedDict.setdefault怎么用?Python OrderedDict.setdefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类odict.OrderedDict
的用法示例。
在下文中一共展示了OrderedDict.setdefault方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: separate_tables_by_time
# 需要导入模块: from odict import OrderedDict [as 别名]
# 或者: from odict.OrderedDict import setdefault [as 别名]
def separate_tables_by_time(self, tables, time_col):
return [tables], [range(len(tables))]
time_to_tables = OrderedDict()
time_to_idx = OrderedDict()
for i, time in enumerate(time_col):
time_to_tables.setdefault(time, []).append(tables[i])
time_to_idx.setdefault(time, []).append(i)
return time_to_tables.values(), time_to_idx.values()
示例2: keepSTIntoDict
# 需要导入模块: from odict import OrderedDict [as 别名]
# 或者: from odict.OrderedDict import setdefault [as 别名]
def keepSTIntoDict(st_list):
global st_dict
global counter
global ex_counter
global curr_ex_type
global fl_st_counter
# ordered dictionary for the stack trace body
st_dict = OrderedDict([])
# initialise the variables
counter = 0
ex_counter = 0
curr_ex_type = "type"
# for each trace from the stack trace
# check whether it begins with: 1) at, 2) caused by, 3) ...# more, 4) empty line
for i, t in enumerate(st_list):
if re.search("^at\s", st_list[i]):
if processAtTrace(st_list, i) == True:
st_dict.setdefault(curr_ex_type, []).append(keepOnlyMethod(st_list[i]))
else:
break
elif re.search("Caused\s", st_list[i]) and ex_counter > 0:
if (i + 1) < len(st_list):
if checkEndPointExistence(st_list, i + 1, "\.\.\.\s[\d]+\smore") and checkExLevelChain():
newChainedExLevel(st_list, i)
else:
# increase the counter for the filtered stack traces (thrown exception level chain)
fl_st_counter = fl_st_counter + 1
break
elif re.search("\.\.\.\s[\d]+\smore", st_list[i]) and ex_counter > 0:
# remove last method from values of the current exception type
st_dict.setdefault(curr_ex_type, []).remove(keepOnlyMethod(st_list[i - 1]))
# check next trace
if contAfterMoreTrace(st_list, i) == False:
break
# search for empty lines
elif re.search("^\s*$", st_list[i]):
break
# in the beginning of the stack trace we may have trash,
# but we want to continue to the next lines (i.e. next traces)
else:
continue
# return the current stack trace into dictionary
return st_dict