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


Python Person.kind方法代码示例

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


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

示例1: populate_person

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import kind [as 别名]
def populate_person(root) :
	"""
	Finds instances of Person in root's tree and saves them to the database

	@type root:  Element
	@param root: root of the ElementTree passed in to populate_models()
	@rtype:      N/A
	@return:     function does not return
	"""
	for person in root.findall("Person"):
		temp_person             =                     Person()
		temp_person.person_ID   =             person.get("ID")
		temp_person.name        =           person.get("Name")

		if person.find("Kind") is not None :
			temp_person.kind        =     person.find("Kind").text
		if person.find("Location") is not None :
			temp_person.location    = person.find("Location").text

		for crisis in person.iter("Crisis") :
			temp_relations = Relations()
			check = Relations.objects.filter(crisis_ID = crisis.get("ID"), person_ID = person.get("ID"))
			if len(check) == 0:
				temp_relations.populate(c_id = crisis.get("ID"), p_id = person.get("ID"))
				temp_relations.save()

		for org in person.iter("Org") :
			temp_relations = Relations()
			check = Relations.objects.filter(org_ID = org.get("ID"), person_ID = person.get("ID"))
			if len(check) == 0:
				temp_relations.populate(p_id = person.get("ID"), o_id = org.get("ID"))
				temp_relations.save()

		populate_common(person, person.get("ID"), temp_person)
		temp_person.save()
开发者ID:bblee1002,项目名称:cs373-wcdb,代码行数:37,代码来源:loadModels.py

示例2: merge_people

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import kind [as 别名]
def merge_people(elem):
	"""
	Parses data from "<Person />" tags
	Checks if  entry already exists
	If so, do a merge 
	else, import the model data
	Saves model to mysql database
	"""
	for p in elem :
		person_filter_obj = Person.objects.filter(wcdb_id = p.get('ID'))
		if (len(person_filter_obj) != 0):
			person = person_filter_obj[0]	#if person exists, use it
			person.name = p.get('Name')
		else:					#else make a new one
			person = Person(name = p.get('Name'), wcdb_id = p.get('ID'))
		kind = p.find('Kind')
		location = p.find('Location')
		common = p.find('Common')
		if (kind != None): 
			person.kind = kind.text
		if (location != None):
			person.location = location.text
		if (common != None):
			merge_common(common, person)
		person.save()
开发者ID:luis-3000,项目名称:WorldwideCrisesWebsite,代码行数:27,代码来源:mergeXML.py

示例3: eval_people

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import kind [as 别名]
def eval_people(elem):
	"""
	Parses data from "<Person />" tags
	Stores in Django model
	Saves model to mysql database
	"""
	for p in elem :
		assert p.get('ID') != None
		assert p.get('Name') != None
		person = Person(name = p.get('Name'), wcdb_id = p.get('ID'))
		kind = p.find('Kind')
		location = p.find('Location')
		common = p.find('Common')
		if(kind != None): 
			person.kind = kind.text
		if(location != None):
			person.location = location.text
		if(common != None):
			make_common(common, person)
		person.save()
开发者ID:luis-3000,项目名称:WorldwideCrisesWebsite,代码行数:22,代码来源:importXML.py


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