本文整理汇总了Python中pupa.scrape.Organization.extras['Occupation']方法的典型用法代码示例。如果您正苦于以下问题:Python Organization.extras['Occupation']方法的具体用法?Python Organization.extras['Occupation']怎么用?Python Organization.extras['Occupation']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pupa.scrape.Organization
的用法示例。
在下文中一共展示了Organization.extras['Occupation']方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: categorize_data
# 需要导入模块: from pupa.scrape import Organization [as 别名]
# 或者: from pupa.scrape.Organization import extras['Occupation'] [as 别名]
def categorize_data(self, csv_data):
return_objs = []
Contribution = namedtuple('Contribution', self.csv_header_row.replace(' ', '_'))
for line in csv_data.split('\n'): # explicity defining delimiter because otherwise fails in case of single line
if not line:
continue
# cur_obj will be the person or organization that made the contribution
cur_obj = None
contribution = Contribution(*line.split(','))
if contribution.Contributor_Type in self.business_contribution_types:
cur_obj = Organization(contribution.Contributor_Name)
elif contribution.Contributor_Type in self.individual_contribution_types:
cur_obj = Person(contribution.Contributor_Name)
elif contribution.Contributor_Type == 'Unknown/Anonymous':
if contribution.Contributor_Name: #ignoring un-named contributors
#these look like catch-all business contributions
cur_obj = Organization(contribution.Contributor_Name)
if cur_obj:
#we don't set cur_obj in the event that there was an
#anonymous/unknown contribution without a Contribution_Name
#so we need to check that it exists before adding to it
cur_obj.add_source(url=self.search_url)
cur_obj.source_identified = True
if contribution.Contributor_Address:
cur_obj.add_contact_detail(type='address', value=contribution.Contributor_Address)
if contribution.Employer_Name:
cur_obj.extras['Employer'] = contribution.Employer_Name
if contribution.Employer_Occupation:
cur_obj.extras['Occupation'] = contribution.Employer_Occupation
#recipiant_obj is the organization that received the contribution
recipiant_obj = Organization(contribution.Receiving_Committee)
recipiant_obj.extras['Office'] = contribution.Office
recipiant_obj.extras['Filing Period'] = contribution.Filing_Period
recipiant_obj.extras['Fundtype'] = contribution.Fundtype
#transaction is the event linking the donor and recipiant
transaction = Event('Contribution', contribution.Contribution_Date, 'EST', 'Maryland') #EST and Maryland b/c MD
transaction.extras['Contribution Amount'] = contribution.Contribution_Amount
transaction.extras['Contribution Type'] = contribution.Contribution_Type
transaction.add_source(url=self.search_url)
#transaction.source_identified = True
transaction.participants.append(cur_obj.as_dict())
transaction.participants.append(recipiant_obj.as_dict())
yield (cur_obj, recipiant_obj, transaction)
else:
yield []
示例2: categorize_data
# 需要导入模块: from pupa.scrape import Organization [as 别名]
# 或者: from pupa.scrape.Organization import extras['Occupation'] [as 别名]
def categorize_data(self, csv_data):
#Is there a better place to define this?
return_objs = []
Contribution = namedtuple('Contribution', self.csv_header_row.replace(' ', '_'))
for line in csv_data.split('\n'): # explicity defining delimiter because otherwise fails in case of single line
if not line:
continue
cur_obj = None
try:
contribution = Contribution(*line.split(','))
except Exception as e:
import pdb; pdb.set_trace()
if contribution.Contributor_Type in self.business_contribution_types:
cur_obj = Organization(contribution.Contributor_Name)
elif contribution.Contributor_Type in self.individual_contribution_types:
cur_obj = Person(contribution.Contributor_Name)
elif contribution.Contributor_Type == 'Unknown/Anonymous':
if contribution.Contributor_Name: #ignoring un-named contributors
#these look like catch-all business contributions
cur_obj = Organization(contribution.Contributor_Name)
if cur_obj:
cur_obj.add_source(url=self.search_url)
cur_obj.source_identified = True
if contribution.Contributor_Address:
cur_obj.add_contact_detail(type='address', value=contribution.Contributor_Address)
if contribution.Employer_Name:
cur_obj.extras['Employer'] = contribution.Employer_Name
if contribution.Employer_Occupation:
cur_obj.extras['Occupation'] = contribution.Employer_Occupation
recipiant_obj = Organization(contribution.Receiving_Committee)
recipiant_obj.extras['Office'] = contribution.Office
recipiant_obj.extras['Filing Period'] = contribution.Filing_Period
recipiant_obj.extras['Fundtype'] = contribution.Fundtype
transaction = Event('Contribution', contribution.Contribution_Date, 'EST', 'Maryland') #EST and Maryland b/c MD
transaction.extras['Contribution Amount'] = contribution.Contribution_Amount
transaction.extras['Contribution Type'] = contribution.Contribution_Type
transaction.add_source(url=self.search_url)
#transaction.source_identified = True
transaction.participants.append(cur_obj.as_dict())
transaction.participants.append(recipiant_obj.as_dict())
yield (cur_obj, recipiant_obj, transaction)
else:
yield []