当前位置: 首页>>代码示例>>Python>>正文


Python OrderedDict.setdefault方法代码示例

本文整理汇总了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()
开发者ID:ericjsolis,项目名称:danapeerlab,代码行数:10,代码来源:multicompare.py

示例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
开发者ID:mkechagia,项目名称:stack-traces,代码行数:47,代码来源:parsing_st.py


注:本文中的odict.OrderedDict.setdefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。