本文整理汇总了Python中person.models.Person.find_surname_initials方法的典型用法代码示例。如果您正苦于以下问题:Python Person.find_surname_initials方法的具体用法?Python Person.find_surname_initials怎么用?Python Person.find_surname_initials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类person.models.Person
的用法示例。
在下文中一共展示了Person.find_surname_initials方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_find_by_surname_initials
# 需要导入模块: from person.models import Person [as 别名]
# 或者: from person.models.Person import find_surname_initials [as 别名]
def test_find_by_surname_initials(self):
p_found = Person.find_surname_initials('Balkenende', 'J.P.')
self.assertEqual(p_found, self.p1)
p_found = Person.find_surname_initials('Balkenende', 'J.')
self.assertEqual(p_found, self.p2)
p_found = Person.find_surname_initials('Balkenende', '')
self.assertEqual(p_found, None)
p_found = Person.find_surname_initials('van der Steur', 'J.P.')
self.assertEqual(p_found, None)
p_found = Person.find_surname_initials('Koşer Kaya', 'F.')
self.assertEqual(p_found, self.p5)
示例2: find
# 需要导入模块: from person.models import Person [as 别名]
# 或者: from person.models.Person import find_surname_initials [as 别名]
def find(surname, initials='', date=None):
person = Person.find_surname_initials(surname, initials)
if date:
members = ParliamentMember.find_at_date(person, date)
else:
members = ParliamentMember.objects.filter(person=person).order_by('-joined')
if members.exists():
return members[0]
logger.info('ParliamentMember not found for: ' + str(surname) + ' (' + initials + ')')
return None
示例3: create_submitter
# 需要导入模块: from person.models import Person [as 别名]
# 或者: from person.models.Person import find_surname_initials [as 别名]
def create_submitter(document, submitter, date):
# TODO: fix this ugly if else mess
has_initials = len(submitter.split('.')) > 1
initials = ''
if has_initials:
initials, surname, surname_prefix = parse_name_surname_initials(submitter)
else:
surname, surname_prefix = parse_surname_comma_surname_prefix(submitter)
if initials == 'C.S.': # this is an abbreviation used in old metadata to indicate 'and usual others'
initials = ''
person = Person.find_surname_initials(surname=surname, initials=initials)
if surname == 'JAN JACOB VAN DIJK': # 'Jan Jacob van Dijk' and ' Jasper van Dijk' have the same surname and initials, to solve this they have included the forename in the surname
person = Person.objects.filter(forename='Jan Jacob', surname_prefix='van', surname='Dijk', initials='J.J.')[0]
if surname == 'JASPER VAN DIJK':
person = Person.objects.filter(forename='Jasper', surname_prefix='van', surname='Dijk', initials='J.J.')[0]
if surname == 'JAN DE VRIES':
person = Person.objects.filter(forename='Jan', surname_prefix='de', surname='Vries', initials='J.M.')[0]
if not person:
active_persons = SubmitterFactory.get_active_persons(date)
persons_similar = active_persons.filter(surname__iexact=surname).exclude(initials='').exclude(forename='')
if persons_similar.count() == 1:
person = persons_similar[0]
if not person:
if surname == '' and initials == '':
persons = Person.objects.filter(surname='', initials='', forename='')
if persons:
person = persons[0]
if not person:
persons = Person.objects.filter(surname__iexact=surname, initials__iexact=initials)
if persons:
person = persons[0]
if not person:
logger.warning('Cannot find person: ' + str(surname) + ' ' + str(initials) + '. Creating new person!')
person = Person.objects.create(surname=surname, surname_prefix=surname_prefix, initials=initials)
party_members = PartyMember.get_at_date(person, date)
party_slug = ''
if party_members:
party_slug = party_members[0].party.slug
submitter, created = Submitter.objects.get_or_create(person=person, document=document, party_slug=party_slug)
return submitter
示例4: create_travels
# 需要导入模块: from person.models import Person [as 别名]
# 或者: from person.models.Person import find_surname_initials [as 别名]
def create_travels(max_items=None):
travels = Api.get_items(PersoonReis, max_items=max_items)
if len(travels) < 1000:
logger.error('Only {} gifts found. This is unexpected. Skip re-creating gifts.'.format(len(travels)))
Travel.objects.all().delete()
TravelPersonPosition.objects.all().delete()
for travel in travels:
person = Person.find_surname_initials(travel.persoon.achternaam, travel.persoon.initialen)
if person is None:
logger.warning('No person found for travel: {}'.format(travel.id))
continue
if travel.van is None or travel.tot_en_met is None:
logger.warning('No date found for travel: {}'.format(travel.id))
continue
Travel.objects.create(
person=person,
destination=travel.bestemming,
purpose=travel.doel,
paid_by=travel.betaald_door,
date_begin=travel.van,
date_end=travel.tot_en_met,
)
示例5: create_gifts
# 需要导入模块: from person.models import Person [as 别名]
# 或者: from person.models.Person import find_surname_initials [as 别名]
def create_gifts(max_items=None):
gifts = Api.get_items(PersoonGeschenk, max_items=max_items)
if len(gifts) < 1000:
logger.error('Only {} gifts found. This is unexpected. Skip re-creating gifts.'.format(len(gifts)))
Gift.objects.all().delete()
PersonPosition.objects.all().delete()
for gift in gifts:
value = find_gift_value(gift.omschrijving)
gift_type = find_gift_type(gift.omschrijving)
person = Person.find_surname_initials(gift.persoon.achternaam, gift.persoon.initialen)
if person is None:
logger.warning('No person found for gift: {}'.format(gift.id))
continue
if gift.datum is None:
logger.warning('No date found for gift: {}'.format(gift.id))
continue
Gift.objects.create(
person=person,
value_euro=value,
description=gift.omschrijving,
date=gift.datum,
type=gift_type,
)
示例6: test_find_surname_multiple
# 需要导入模块: from person.models import Person [as 别名]
# 或者: from person.models.Person import find_surname_initials [as 别名]
def test_find_surname_multiple(self):
p_found = Person.find_surname_initials('Grapperhaus', 'F.B.J.')
self.assertEqual(p_found, self.p9)