本文整理汇总了Python中pupa.scrape.Event.extras['office_name']方法的典型用法代码示例。如果您正苦于以下问题:Python Event.extras['office_name']方法的具体用法?Python Event.extras['office_name']怎么用?Python Event.extras['office_name']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pupa.scrape.Event
的用法示例。
在下文中一共展示了Event.extras['office_name']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: transform_parse
# 需要导入模块: from pupa.scrape import Event [as 别名]
# 或者: from pupa.scrape.Event import extras['office_name'] [as 别名]
def transform_parse(self, parsed_form, response):
_source = {
"url": response.url,
"note": json.dumps({'office_name': parsed_form['office_name'],
'termination_date': parsed_form['termination_date'],
'lobbying_eligibility_date': parsed_form['lobbying_eligibility_date'],
'name': parsed_form['employee_name']},
sort_keys=True)
}
_disclosure = Disclosure(
effective_date=datetime.strptime(
parsed_form['termination_date'],
'%Y-%m-%d').replace(tzinfo=UTC),
timezone='America/New_York',
submitted_date=datetime.strptime(
parsed_form['termination_date'],
'%Y-%m-%d').replace(tzinfo=UTC),
classification="post_employment",
)
_disclosure.add_authority(name=self.authority.name,
type=self.authority._type,
id=self.authority._id)
_disclosure.extras['office_name'] = parsed_form["office_name"]
_registrant = Person(
name=parsed_form['employee_name'],
source_identified=True
)
_office = Organization(
name=parsed_form['office_name'],
classification='office',
parent_id=self.jurisdiction._house,
source_identified=True
)
_office.add_member(
_registrant,
role='employee',
label='employee for {n}'.format(n=_office.name),
end_date=parsed_form['termination_date'],
)
_disclosure.add_registrant(name=_registrant.name,
type=_registrant._type,
id=_registrant._id)
_post_employment_event = Event(
name="{rn} - {rt}, {o} (via {a})".format(rn=_registrant.name,
rt="post-employment period",
o=_office.name,
a="House Clerk"),
timezone='America/New_York',
location='United States',
start_time=datetime.strptime(
parsed_form['termination_date'],
'%Y-%m-%d').replace(tzinfo=UTC),
end_time=datetime.strptime(
parsed_form['lobbying_eligibility_date'],
'%Y-%m-%d').replace(tzinfo=UTC),
classification='post_employment'
)
_post_employment_event.add_participant(type=_registrant._type,
id=_registrant._id,
name=_registrant.name,
note="registrant")
_post_employment_event.extras['office_name'] = parsed_form["office_name"]
_disclosure.add_disclosed_event(
name=_post_employment_event.name,
type=_post_employment_event._type,
classification=_post_employment_event.classification,
id=_post_employment_event._id
)
_post_employment_event.add_source(**_source)
yield _post_employment_event
_office.add_source(**_source)
yield _office
_registrant.add_source(**_source)
yield _registrant
_disclosure.add_source(**_source)
yield _disclosure