• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python python_compat.izip函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中python_compat.izip函数的典型用法代码示例。如果您正苦于以下问题:Python izip函数的具体用法?Python izip怎么用?Python izip使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了izip函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: makeEnum

def makeEnum(members = None, cls = None, useHash = True):
	members = members or []
	if cls:
		enumID = md5_hex(str(members) + '!' + cls.__name__)[:4]
	else:
		enumID = md5_hex(str(members))[:4]
		cls = type('Enum_%s_%s' % (enumID, str.join('_', members)), (), {})

	def getValue(idx, name):
		if useHash:
			return idx + int(enumID, 16)
		else:
			return idx
	values = lsmap(getValue, enumerate(members))

	cls.enumNames = members
	cls.enumValues = values
	enumMapNV = dict(izip(imap(str.lower, cls.enumNames), cls.enumValues))
	enumMapVN = dict(izip(cls.enumValues, cls.enumNames))
	if len(enumMapNV) != len(enumMapVN):
		raise APIError('Invalid enum definition!')
	def str2enum(cls, value, *args):
		return enumMapNV.get(value.lower(), *args)
	cls.enum2str = enumMapVN.get
	cls.str2enum = classmethod(str2enum)
	for name, value in izip(cls.enumNames, cls.enumValues):
		setattr(cls, name, value)
	return cls
开发者ID:Fra-nk,项目名称:grid-control,代码行数:28,代码来源:data_structures.py


示例2: _get_just_fun_dict

	def _get_just_fun_dict(self, head, align_str):
		just_fun_dict = {'l': str.ljust, 'r': str.rjust, 'c': str.center}
		# just_fun = {id1: str.center, id2: str.rjust, ...}

		def _get_key_format(head_entry, align_str):
			return (head_entry[0], just_fun_dict[align_str])
		return dict(ismap(_get_key_format, izip(head, align_str)))
开发者ID:grid-control,项目名称:grid-control,代码行数:7,代码来源:table.py


示例3: fill_parameter_content

	def fill_parameter_content(self, pnum, result):
		for (psrc, psrc_len) in izip(self._psrc_list, self._psrc_max_list):
			if psrc_len is not None:
				if pnum < psrc_len:
					psrc.fill_parameter_content(pnum, result)
			else:
				psrc.fill_parameter_content(pnum, result)
开发者ID:mschnepf,项目名称:grid-control,代码行数:7,代码来源:psource_meta.py


示例4: _get_sandbox_file_list

	def _get_sandbox_file_list(self, task, sm_list):
		# Prepare all input files
		dep_list = set(ichain(imap(lambda x: x.get_dependency_list(), [task] + sm_list)))
		dep_fn_list = lmap(lambda dep: resolve_path('env.%s.sh' % dep,
			lmap(lambda pkg: get_path_share('', pkg=pkg), os.listdir(get_path_pkg()))), dep_list)
		task_config_dict = dict_union(self._remote_event_handler.get_mon_env_dict(),
			*imap(lambda x: x.get_task_dict(), [task] + sm_list))
		task_config_dict.update({'GC_DEPFILES': str.join(' ', dep_list),
			'GC_USERNAME': self._token.get_user_name(), 'GC_WMS_NAME': self._name})
		task_config_str_list = DictFormat(escape_strings=True).format(
			task_config_dict, format='export %s%s%s\n')
		vn_alias_dict = dict(izip(self._remote_event_handler.get_mon_env_dict().keys(),
			self._remote_event_handler.get_mon_env_dict().keys()))
		vn_alias_dict.update(task.get_var_alias_map())
		vn_alias_str_list = DictFormat(delimeter=' ').format(vn_alias_dict, format='%s%s%s\n')

		# Resolve wildcards in task input files
		def _get_task_fn_list():
			for fpi in task.get_sb_in_fpi_list():
				matched = glob.glob(fpi.path_abs)
				if matched != []:
					for match in matched:
						yield match
				else:
					yield fpi.path_abs
		return lchain([self._remote_event_handler.get_file_list(), dep_fn_list, _get_task_fn_list(), [
			VirtualFile('_config.sh', sorted(task_config_str_list)),
			VirtualFile('_varmap.dat', sorted(vn_alias_str_list))]])
开发者ID:mschnepf,项目名称:grid-control,代码行数:28,代码来源:wms.py


示例5: discover

	def discover(self):
		tags = ['h_vmem', 'h_cpu', 's_rt']
		reqs = dict(izip(tags, [WMS.MEMORY, WMS.CPUTIME, WMS.WALLTIME]))
		parser = dict(izip(tags, [int, parseTime, parseTime]))

		proc = LocalProcess(self._configExec, '-sql')
		for queue in imap(str.strip, proc.stdout.iter(timeout = 10)):
			proc_q = LocalProcess(self._configExec, '-sq', queue)
			queueInfo = {'name': queue}
			for line in proc_q.stdout.iter(timeout = 10):
				attr, value = lmap(str.strip, line.split(' ', 1))
				if (attr in tags) and (value != 'INFINITY'):
					queueInfo[reqs[attr]] = parser[attr](value)
			proc_q.status_raise(timeout = 0)
			yield queueInfo
		proc.status_raise(timeout = 0)
开发者ID:Fra-nk,项目名称:grid-control,代码行数:16,代码来源:wms_gridengine.py


示例6: _statusReturnLineRead

	def _statusReturnLineRead(self,line):
		try:
			statusReturnValues = line.split()
			# transform output string to dictionary
			jobinfo = dict(izip(self.statusReturnKeys, statusReturnValues))
			# extract GC and WMS ID, check for consistency
			jobID,wmsID=jobinfo['[email protected]'].split('@')
			if (wmsID != jobinfo['wmsid']):
				raise BackendError("Critical! Unable to match jobs in queue! \n CondorID: %s	Expected: %s \n%s" % ( jobinfo['wmsid'], wmsID, line ))
			jobinfo['jobid']=int(jobID)
			del jobinfo['[email protected]']
			# extract Host and Queue data
			if "@" in jobinfo["RemoteHost"]:
				jobinfo['dest'] = jobinfo["RemoteHost"].split("@")[1] + ': /' + jobinfo.get("Queue","")
			else:
				jobinfo['dest'] = jobinfo["RemoteHost"]
			del jobinfo["RemoteHost"]
			if "Queue" in jobinfo:
				del jobinfo["Queue"]
			# convert status to appropriate format
			status = self._statusMap[jobinfo['status']]
			jobinfo['status'] = self._humanMap[jobinfo['status']]
			return ( jobinfo['jobid'], jobinfo['wmsid'], status, jobinfo )
		except Exception:
			raise BackendError('Error reading job info:\n%s' % line)
开发者ID:artus-analysis,项目名称:grid-control,代码行数:25,代码来源:condor_wms.py


示例7: process

	def process(self, dn):
		job_info_dict = None
		try:
			job_info_dict = JobInfoProcessor.process(self, dn)
		except JobResultError:
			logger = logging.getLogger('jobs.results')
			logger.warning('Unable to process job information', exc_info=get_current_exception())
			clear_current_exception()
		if job_info_dict:
			job_data_dict = job_info_dict[JobResult.RAW]
			result = {}

			def get_items_with_key(key_prefix):
				return ifilter(lambda key_value: key_value[0].startswith(key_prefix), job_data_dict.items())

			# parse old job info data format for files
			old_fmt_header = [FileInfo.Hash, FileInfo.NameLocal, FileInfo.NameDest, FileInfo.Path]
			for (file_key, file_data) in get_items_with_key('FILE'):
				file_idx = file_key.replace('FILE', '') or '0'
				result[int(file_idx)] = dict(izip(old_fmt_header, file_data.strip('"').split('  ')))
			# parse new job info data format
			for (file_key, file_data) in get_items_with_key('OUTPUT_FILE'):
				(file_idx, file_prop) = file_key.replace('OUTPUT_FILE_', '').split('_')
				if isinstance(file_data, str):
					file_data = file_data.strip('"')
				file_prop = file_prop.lower().replace('dest', 'namedest').replace('local', 'namelocal')
				result.setdefault(int(file_idx), {})[FileInfo.str2enum(file_prop)] = file_data
			return list(result.values())
开发者ID:grid-control,项目名称:grid-control,代码行数:28,代码来源:output_processor.py


示例8: _acceptLumi

	def _acceptLumi(self, block, fi, idxRuns, idxLumi):
		if (idxRuns is None) or (idxLumi is None):
			return True
		fi_meta = fi[DataProvider.Metadata]
		for (run, lumi) in izip(fi_meta[idxRuns], fi_meta[idxLumi]):
			if selectLumi((run, lumi), self._lumi_filter.lookup(block[DataProvider.Nickname], is_selector = False)):
				return True
开发者ID:artus-analysis,项目名称:grid-control,代码行数:7,代码来源:lumi_proc.py


示例9: fillParameterInfo

	def fillParameterInfo(self, pNum, result):
		for (psource, maxN) in izip(self._psourceList, self._psourceMaxList):
			if maxN is not None:
				if pNum < maxN:
					psource.fillParameterInfo(pNum, result)
			else:
				psource.fillParameterInfo(pNum, result)
开发者ID:thomas-mueller,项目名称:grid-control,代码行数:7,代码来源:psource_meta.py


示例10: _parseTime

	def _parseTime(self, time_str):
		result = 0
		entry_map = {'yea': 365 * 24 * 60 * 60, 'day': 24 * 60 * 60, 'hou': 60 * 60, 'min': 60, 'sec': 1}
		tmp = time_str.split()
		for (entry, value) in izip(imap(lambda x: x[:3], tmp[1::2]), imap(int, tmp[::2])):
			result += entry_map[entry] * value
		return result
开发者ID:Fra-nk,项目名称:grid-control,代码行数:7,代码来源:access_arc.py


示例11: discover

	def discover(self):
		active = False
		keys = [WMS.MEMORY, WMS.CPUTIME, WMS.WALLTIME]
		parser = dict(izip(keys, [int, parse_time, parse_time]))
		proc = LocalProcess(self._exec, '-q')
		for line in proc.stdout.iter(timeout=10):
			if line.startswith('-'):
				active = True
			elif line.startswith(' '):
				active = False
			elif active:
				fields = lmap(str.strip, line.split()[:4])
				queue_dict = {'name': fields[0]}
				for key, value in ifilter(lambda k_v: not k_v[1].startswith('-'), izip(keys, fields[1:])):
					queue_dict[key] = parser[key](value)
				yield queue_dict
		proc.status_raise(timeout=0)
开发者ID:grid-control,项目名称:grid-control,代码行数:17,代码来源:wms_pbs.py


示例12: _bound_metric

	def _bound_metric(self, time_step_list, metric_list, lim_low, lim_high):
		time_step_list_truncated = []
		metric_list_truncated = []
		for time_step, metric in izip(time_step_list, metric_list):
			if lim_low < time_step < lim_high:
				metric_list_truncated.append(metric)
				time_step_list_truncated.append(time_step)
		return (time_step_list_truncated, metric_list_truncated)
开发者ID:grid-control,项目名称:grid-control,代码行数:8,代码来源:report_plot.py


示例13: getQueues

	def getQueues(self):
		queues = {}
		tags = ['h_vmem', 'h_cpu', 's_rt']
		reqs = dict(izip(tags, [WMS.MEMORY, WMS.CPUTIME, WMS.WALLTIME]))
		parser = dict(izip(tags, [int, parseTime, parseTime]))

		proc = LocalProcess(self._configExec, '-sql')
		for queue in imap(str.strip, proc.stdout.iter(timeout = 10)):
			queues[queue] = dict()
			proc_q = LocalProcess(self._configExec, '-sq %s' % queue)
			for line in proc_q.stdout.iter(timeout = 10):
				attr, value = lmap(str.strip, line.split(' ', 1))
				if (attr in tags) and (value != 'INFINITY'):
					queues[queue][reqs[attr]] = parser[attr](value)
			proc_q.status_raise(timeout = 0)
		proc.status_raise(timeout = 0)
		return queues
开发者ID:artus-analysis,项目名称:grid-control,代码行数:17,代码来源:wms_gridengine.py


示例14: truncateData

	def truncateData(self, timeStep, overAllBandwidth, truncFront, truncBack):
		truncatedTimeStep = []
		truncatedOverAllBandwidth = []
		for currentTimeStep, thisBw in izip(timeStep, overAllBandwidth):
			if (currentTimeStep > truncFront) and (currentTimeStep < truncBack):
				truncatedOverAllBandwidth.append(thisBw)
				truncatedTimeStep.append(currentTimeStep)
		return (truncatedTimeStep, truncatedOverAllBandwidth)
开发者ID:artus-analysis,项目名称:grid-control,代码行数:8,代码来源:report_plot.py


示例15: _query

	def _query(self, api, **kwargs):
		key = (self._url, api, tuple(kwargs.items()))
		if key not in SiteDB.queryCache:
			SiteDB.queryCache[key] = self._gjrc.get(api = api, params = kwargs or None)
		data = SiteDB.queryCache[key]
		columns = data['desc']['columns']
		for row in data['result']:
			yield dict(izip(columns, row))
开发者ID:Fra-nk,项目名称:grid-control,代码行数:8,代码来源:sitedb.py


示例16: _parse

	def _parse(self, proc):
		status_iter = proc.stdout.iter(self._timeout)
		head = lmap(lambda x: x.strip('%').lower(), next(status_iter, '').split())
		for entry in imap(str.strip, status_iter):
			job_info = dict(izip(head, ifilter(lambda x: x != '', entry.split(None, len(head) - 1))))
			job_info[CheckInfo.WMSID] = job_info.pop('pid')
			job_info[CheckInfo.RAW_STATUS] = job_info.pop('stat')
			job_info.update({CheckInfo.QUEUE: 'localqueue', CheckInfo.WN: 'localhost'})
			yield job_info
开发者ID:Fra-nk,项目名称:grid-control,代码行数:9,代码来源:wms_host.py


示例17: getQueues

	def getQueues(self):
		(queues, active) = ({}, False)
		keys = [WMS.MEMORY, WMS.CPUTIME, WMS.WALLTIME]
		parser = dict(izip(keys, [int, parseTime, parseTime]))
		proc = LocalProcess(self.statusExec, '-q')
		for line in proc.stdout.iter(timeout = 10):
			if line.startswith('-'):
				active = True
			elif line.startswith(' '):
				active = False
			elif active:
				fields = lmap(str.strip, line.split()[:4])
				queueInfo = {}
				for key, value in ifilter(lambda k_v: not k_v[1].startswith('-'), izip(keys, fields[1:])):
					queueInfo[key] = parser[key](value)
				queues[fields[0]] = queueInfo
		proc.status_raise(timeout = 0)
		return queues
开发者ID:artus-analysis,项目名称:grid-control,代码行数:18,代码来源:wms_pbs.py


示例18: matchRule

	def matchRule(self, src):
		srcValues = lmap(lambda key: src.get(key, None), self._lookup_keys)
		for lookupValues in self._lookup_order:
			match = True
			for (sval, lval, lmatch) in izip(srcValues, lookupValues, self._lookup_functions):
				if sval is not None:
					match = match and (lmatch.matcher(sval, lval) > 0)
			if match:
				return lookupValues
开发者ID:thomas-mueller,项目名称:grid-control,代码行数:9,代码来源:psource_lookup.py


示例19: _iter_datasource_items

	def _iter_datasource_items(self, item, metadata_dict, entries, location_list, obj_dict):
		for block in self._source.get_block_list_cached(show_stats=False):
			metadata_keys = block.get(DataProvider.Metadata, [])
			for fi in block[DataProvider.FileList]:
				metadata_dict['SRC_DATASET'] = block[DataProvider.Dataset]
				metadata_dict['SRC_BLOCK'] = block[DataProvider.BlockName]
				metadata_dict.update(dict(izip(metadata_keys, fi.get(DataProvider.Metadata, []))))
				yield (fi[DataProvider.URL], metadata_dict, fi[DataProvider.NEntries],
					block[DataProvider.Locations], obj_dict)
开发者ID:grid-control,项目名称:grid-control,代码行数:9,代码来源:scanner_basic.py


示例20: initMaxParameters

	def initMaxParameters(self):
		self.quickFill = []
		prev = 1
		for (psource, maxN) in izip(self._psourceList, self._psourceMaxList):
			self.quickFill.append((psource, maxN, prev))
			if maxN:
				prev *= maxN
		maxList = lfilter(lambda n: n is not None, self._psourceMaxList)
		if maxList:
			return reduce(lambda a, b: a * b, maxList)
开发者ID:thomas-mueller,项目名称:grid-control,代码行数:10,代码来源:psource_meta.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python python_compat.lfilter函数代码示例发布时间:2022-05-27
下一篇:
Python python_compat.irange函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap