本文整理汇总了Python中pupa.scrape.Event.add_person方法的典型用法代码示例。如果您正苦于以下问题:Python Event.add_person方法的具体用法?Python Event.add_person怎么用?Python Event.add_person使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pupa.scrape.Event
的用法示例。
在下文中一共展示了Event.add_person方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: scrape_meeting_notice
# 需要导入模块: from pupa.scrape import Event [as 别名]
# 或者: from pupa.scrape.Event import add_person [as 别名]
def scrape_meeting_notice(self, chamber, item, url):
# Since Event Name is not provided for all mettings.
event_name = str(item['CommitteeName'])
# 04/25/2012 03:00:00 PM
fmt = "%m/%d/%y %I:%M %p"
start_time = dt.datetime.strptime(str(item['MeetingDateTime']), fmt)
location_name = str(item['AddressAliasNickname'])
event = Event(location_name=location_name,
start_date=self._tz.localize(start_time),
name=event_name,
description='Committee Meeting Status: {}'
.format(item['CommitteeMeetingStatusName'])
)
event.add_source(url)
event.add_committee(name=str(item['CommitteeName']), id=item['CommitteeId'])
page_url = ("http://legis.delaware.gov/json/MeetingNotice/"
"GetCommitteeMeetingItems?committeeMeetingId={}".format(
item['CommitteeMeetingId'])
)
event.add_source(page_url)
page_data = self.post(page_url).json()['Data']
for item in page_data:
event.add_agenda_item(description=str(item['ItemDescription']))
event.add_person(name=str(item['PrimarySponsorShortName']),
id=str(item['PrimarySponsorPersonId']),
note='Sponsor')
yield event
示例2: test_full_event
# 需要导入模块: from pupa.scrape import Event [as 别名]
# 或者: from pupa.scrape.Event import add_person [as 别名]
def test_full_event():
j = Jurisdiction.objects.create(id='jid', division_id='did')
event = ScrapeEvent(name="America's Birthday", start_time="2014-07-04", location="America",
all_day=True)
event.add_person("George Washington")
event.add_media_link("fireworks", "http://example.com/fireworks.mov")
EventImporter('jid').import_data([event.as_dict()])
示例3: ge
# 需要导入模块: from pupa.scrape import Event [as 别名]
# 或者: from pupa.scrape.Event import add_person [as 别名]
def ge():
event = ScrapeEvent(
name="America's Birthday",
start_time="2014-07-04T05:00Z",
location_name="America",
timezone="America/New_York",
all_day=True)
event.add_person("George Washington")
return event
示例4: scrape
# 需要导入模块: from pupa.scrape import Event [as 别名]
# 或者: from pupa.scrape.Event import add_person [as 别名]
def scrape(self):
page = self.lxmlize(calurl)
events = page.xpath("//table[@class='agenda-body']//tr")[1:]
for event in events:
comit_url = event.xpath(
".//a[contains(@href, '/Pages/comm-info.aspx?c=')]")
if len(comit_url) != 1:
raise Exception
comit_url = comit_url[0]
who = self.scrape_participants(comit_url.attrib['href'])
tds = event.xpath("./*")
date = tds[0].text_content().strip()
cttie = tds[1].text_content().strip()
_chamber, cttie = [x.strip() for x in cttie.split(" - ", 1)]
info = tds[2]
name = info.xpath("./a[contains(@href, 'raw')]")[0]
notice = name.attrib['href']
name = name.text
time, where = info.xpath("./i/text()")
what = tds[3].text_content()
what = what.replace("Items: ", "")
if "(None)" in what:
continue
what = [x.strip() for x in what.split(";")]
when = ", ".join([date, str(dt.datetime.now().year), time])
when = dt.datetime.strptime(when, "%a %b %d, %Y, %I:%M %p")
event = Event(
name=name,
location_name=where,
start_date=self._tz.localize(when),
)
event.add_source(calurl)
event.add_committee(cttie, note='host')
event.add_document("notice", notice, media_type='application/pdf')
for entry in what:
item = event.add_agenda_item(entry)
if entry.startswith('AB') or entry.startswith('SB'):
item.add_bill(entry)
for thing in who:
event.add_person(thing['name'])
yield event
示例5: scrape_chamber
# 需要导入模块: from pupa.scrape import Event [as 别名]
# 或者: from pupa.scrape.Event import add_person [as 别名]
def scrape_chamber(self, chamber):
grouped_hearings = defaultdict(list)
for hearing in self.session.query(CACommitteeHearing):
location = self.session.query(CALocation).filter_by(
location_code=hearing.location_code)[0].description
date = self._tz.localize(hearing.hearing_date)
chamber_abbr = location[0:3]
event_chamber = {'Asm': 'lower', 'Sen': 'upper'}[chamber_abbr]
if event_chamber != chamber:
continue
grouped_hearings[(location, date)].append(hearing)
for ((location, date), hearings) in grouped_hearings.items():
# Get list of bill_ids from the database.
bill_ids = [hearing.bill_id for hearing in hearings]
bills = ["%s %s" % re.match(r'\d+([^\d]+)(\d+)', bill).groups()
for bill in bill_ids]
# Dereference the committee_nr number and get display name.
msg = 'More than one committee meeting at (location, date) %r'
msg = msg % ((location, date),)
assert len(set(hearing.committee_nr for hearing in hearings)) == 1, msg
committee_name = _committee_nr[hearings.pop().committee_nr]
desc = 'Committee Meeting: ' + committee_name
event = Event(
name=desc,
start_date=date,
location_name=committee_name,
)
for bill_id in bills:
if 'B' in bill_id:
type_ = 'bill'
else:
type_ = 'resolution'
item = event.add_agenda_item('consideration')
item.add_bill(bill_id, note=type_)
event.add_person(committee_name + ' Committee', note='host')
event.add_source('ftp://www.leginfo.ca.gov/pub/bill/')
yield event
示例6: get_events
# 需要导入模块: from pupa.scrape import Event [as 别名]
# 或者: from pupa.scrape.Event import add_person [as 别名]
def get_events(self):
"http://app.toronto.ca/tmmis/getAdminReport.do?function=prepareMeetingScheduleReport"
"http://app.toronto.ca/tmmis/getAdminReport.do?function=prepareMemberAttendanceReport"
# scrape attendance
tmpdir = tempfile.mkdtemp()
page = self.lxmlize("http://app.toronto.ca/tmmis/getAdminReport.do?function=prepareMemberAttendanceReport")
members = page.xpath('//td[@class="inputText"]/select[@name="memberId"]/option')
for member in members:
post = {
"function": "getMemberAttendanceReport",
"download": "csv",
"exportPublishReportId": 1,
"termId": 4,
"memberId": member.attrib["value"],
"decisionBodyId": 0,
}
r = self.post("http://app.toronto.ca/tmmis/getAdminReport.do", data=post)
if r.headers["content-type"] != "application/vnd.ms-excel":
continue
attendance_file = open(tmpdir + "/" + member.text + ".csv", "w")
attendance_file.write(r.text)
attendance_file.close()
# scrape events
post = {
"function": "getMeetingScheduleReport",
"download": "csv",
"exportPublishReportId": 3,
"termId": 4,
"decisionBodyId": 0,
}
r = self.post("http://app.toronto.ca/tmmis/getAdminReport.do", data=post)
empty = []
meeting_file = open("meetings.csv", "w")
meeting_file.write(r.text)
meeting_file.close()
with open("meetings.csv", "rb") as csvfile:
csvfile = csv.reader(csvfile, delimiter=",")
next(csvfile)
committee = ""
agenda_items = []
for row in csvfile:
name = row[0]
when = row[2]
when = dt.datetime.strptime(when, "%Y-%m-%d")
location = row[5]
if name != committee:
committee = name
agenda_items = find_items(committee)
e = Event(name=name, session=self.session, when=when, location=location)
attendees = find_attendees(tmpdir, row)
if len(attendees) == 0:
empty.append(row)
for attendee in find_attendees(tmpdir, row):
e.add_person(attendee)
e.add_source("http://app.toronto.ca/tmmis/getAdminReport.do?function=prepareMeetingScheduleReport")
for item in agenda_items:
if item["date"].date() == when.date():
i = e.add_agenda_item(item["description"])
i.add_committee(committee)
i["order"] = item["order"]
for link in item["links"]:
i.add_media_link(link["name"], link["url"], on_duplicate="ignore")
if "notes" in item:
i["notes"] = [item["notes"]]
yield e
shutil.rmtree(tmpdir)
os.remove("meetings.csv")