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


Python Stream.stream方法代码示例

本文整理汇总了Python中Stream.Stream.stream方法的典型用法代码示例。如果您正苦于以下问题:Python Stream.stream方法的具体用法?Python Stream.stream怎么用?Python Stream.stream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stream.Stream的用法示例。


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

示例1: __init__

# 需要导入模块: from Stream import Stream [as 别名]
# 或者: from Stream.Stream import stream [as 别名]
class Filter:
	def __init__(self, inputFilePath, outputFilePath):
		self.inclusionList = []
		self.exclusionList = []
		self.stream = Stream(inputFilePath, 'Letter')
		self.new_shelve_file = outputFilePath

	def inclusionListAdd(self, filterList):
		self.inclusionList += filterList()

	def exclusionListAdd(self, filterList):
		self.exclusionList += filterList()


	def filter(self):
		with ShelveManager(self.new_shelve_file) as new_shelf:
			for index, fields in self.stream.stream():
				#print(str(index))
				if str(index)+'.0'  in self.inclusionList and str(index)+'.0' not in self.exclusionList:
				
					new_shelf[index] = self._get_fields(fields)

	@editLogger('Filtered from Completed List', 'PythonScript')
	def _get_fields(self, fields):
		return fields
开发者ID:lindarriva,项目名称:Letters-Processing,代码行数:27,代码来源:Processor.py

示例2: run_templater

# 需要导入模块: from Stream import Stream [as 别名]
# 或者: from Stream.Stream import stream [as 别名]
def run_templater(inputFile, outputDir, tmpF):
	templateFile = open(tmpF).read() 
	env = jinja2.Environment()
	env.globals.update(sorted=sorted, to_snake=to_snake_case)

	template = env.from_string(templateFile)


	s = Stream(inputFile, 'Letter')
	
	# Dirty counter for well-formedness
	wf = 0
	bf = 0


	for key, item in s.stream():
		templatedText = template.render(item)
		f = open(outputDir+key+".xml", 'w')
		f.write(templatedText)
		f.close()

		# A dirty checker for wellformedness
		try:
			ET.fromstring(templatedText)
			wf += 1
		except Exception as e:
			print(key, " is BAD:: ", e)
			bf += 1

	print('GOOD: ', wf)
	print('BAD: ', bf)
开发者ID:lindarriva,项目名称:Letters-Processing,代码行数:33,代码来源:Templater.py

示例3: getValuesFromFile

# 需要导入模块: from Stream import Stream [as 别名]
# 或者: from Stream.Stream import stream [as 别名]
	def getValuesFromFile(self):
 		stream = Stream(self.filePath, self.column, sheet="ID")
 		
 		for k, v in stream.stream():
 			
 			#print(k)

 			if k != 'None' and v["DATE"] < self.date:
	 			yield str(k) + '.0'
开发者ID:oculardexterity,项目名称:Letters-Processing,代码行数:11,代码来源:Filter.py

示例4: getValuesFromFile

# 需要导入模块: from Stream import Stream [as 别名]
# 或者: from Stream.Stream import stream [as 别名]
	def getValuesFromFile(self):
 		stream = Stream(self.filePath, self.column, sheet="ID NUMBERS")
 		
 		for k, v in stream.stream():
 			if k != 'None' and v['DATE'] < self.date:
	 			yield str(k) + '.0'
开发者ID:lindarriva,项目名称:Letters-Processing,代码行数:8,代码来源:Filter.py

示例5: run_templater

# 需要导入模块: from Stream import Stream [as 别名]
# 或者: from Stream.Stream import stream [as 别名]
def run_templater(inputFile, outputDir, templateFilePath):#, templateFolder):


	print(templateFilePath)
	templateFile = open(templateFilePath).read()


	editors = []
	contributors = []
	wf = 0
	bf = 0
	'''
	letterPlainTemplateFile = open(templateFolder + 'letter_plain.xml').read()
	letterEnvelopeTemplateFile = open(templateFolder + 'letter_envelope.xml').read()
	postcardAMTemplateFile = open(templateFolder + 'postcard_am.xml').read()
	postcardIMTemplateFile = open(templateFolder + 'postcard_im.xml').read()
	'''

	s = Stream(inputFile, 'Letter')
	
	for key, item in s.stream():
		print("Templating item: ", key, "-type ", item["Type"])
		'''
		if item["Type"] == 'Letter':
			print(item["Pages"])
			if [p for k, p in item["Pages"].items() if p["PageType"] == 'EnvelopeType']:
				templateFile = letterEnvelopeTemplateFile
			else:
				templateFile = letterPlainTemplateFile
		elif item["Type"] == 'PostcardAM':
			templateFile = postcardAMTemplateFile
		elif item["Type"] == 'PostcardIM':
			templateFile = postcardIMTemplateFile
		else:
			templateFile = letterPlainTemplateFile




		
		'''
		item["ProcessingVersion"] = "2"

		#print(len(item["Contributor_List"]), set(item["Contributor_List"]))
		new_cont_list = []
		item["Editors"] = []  
		with shelve.open('editorList.shelve') as editor_list:
			
			for editor in item["Contributor_List"]:
				if editor in editor_list and "Python" not in editor:
					if editor_list[editor] != ("Susan Schreibman", "SS"):
						item["Editors"].append(editor_list[editor])
				elif editor != "NULL":
					new_cont_list.append(editor)

		item["Contributor_List"] = new_cont_list

		#contributors += item["Contributor_List"]
		template_log = { 
					'editType': 'TEI template built', 
					'editor': "PythonScript", 
					'datetime': str(datetime.datetime.now())[:-7].replace(" ", "T")}

		item["Edits"].append(template_log)

		item["Edits"] = sorted(item["Edits"], key=lambda f: datetime.datetime.strptime(f['datetime'], "%Y-%m-%dT%H:%M:%S"))

		
		
		#print(templateFile)
	
		env = jinja2.Environment()
		env.globals.update(sorted=sorted, to_snake=to_snake_case,replace_contribs=replace_contrib_names,
			 abstract_split=abstract_split) 

		template = env.from_string(templateFile)


	
	
		#print(item["DocCollection"])
		#print(item["Document_Collection"],"~", item["Document_Number"])
	


		#print(item["Letter"])

		#for k, v in item.items():
		#	print(k, type(k), v)
		if None in item:
			del item[None]

		templatedText = template.render(item)
		f = open(outputDir+key+".xml", 'w')

		#f = open("pagesList.xml", 'a')
		f.write(templatedText)
		f.close()

		# A dirty checker for wellformedness
#.........这里部分代码省略.........
开发者ID:oculardexterity,项目名称:Letters-Processing,代码行数:103,代码来源:Templater.py


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