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


Python Bill.extras["full_text"]方法代码示例

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


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

示例1: scrape

# 需要导入模块: from pupa.scrape import Bill [as 别名]
# 或者: from pupa.scrape.Bill import extras["full_text"] [as 别名]
    def scrape(self):
        for agenda_item in self.agendaItems(date_from=self.start_date, date_to=self.end_date):
            # TODO: Add agenda_item type to OCD
            leg_type = "bill"

            title = agenda_item["Title"].replace("\n", " ")
            title_re = re.compile(
                "^(.+?)(?: - (?:by )?((?:Deputy )?Mayor|Councillor) (.+), seconded by ((?:Deputy )?Mayor|Councillor) (.+))?$"
            )
            title, primary_role, primary_sponsor, secondary_role, secondary_sponsor = re.match(title_re, title).groups()

            b = Bill(
                identifier=agenda_item["Item No."],
                title=title,
                legislative_session=None,
                classification=leg_type,
                from_organization={"name": self.jurisdiction.name},
            )
            b.add_source(agenda_item["url"], note="web")

            if primary_sponsor and secondary_sponsor:
                b.add_sponsorship(primary_sponsor, "mover", "person", True)
                b.add_sponsorship(secondary_sponsor, "seconder", "person", False)

            # TODO: Fake session for now
            b.legislative_session = "2014-2018"

            agenda_item_versions = self.agendaItemVersions(agenda_item["url"])

            # Use one version's full_text (will be most recent)
            b.extras["full_text"] = agenda_item_versions[0]["full_text"]

            for version in agenda_item_versions:
                action_date = self.toDate(version["date"])

                if "Summary" in version["sections"]:
                    # TODO: Investigate whether these vary between versions, as
                    # we perhaps don't need to add one for each
                    b.add_abstract(version["sections"]["Summary"], note="", date=action_date)

                if not version["action"]:
                    continue
                if re.match(r"\d+:\d+ [A|P]M", version["action"]):
                    continue

                action_description = version["action"]
                responsible_org = version["responsible_org"]
                action_class = ACTION_CLASSIFICATION.get(version["action"])

                def is_recommendation(version):
                    return any("Recommendations" in s for s in version["sections"].keys())

                if responsible_org == "City Council":
                    responsible_org = self.jurisdiction.name
                else:
                    if action_class == "passage":
                        action_class = "committee-passage"

                        if is_recommendation(version):
                            action_class = "committee-passage-favorable"

                b.add_action(
                    action_description, action_date, organization={"name": responsible_org}, classification=action_class
                )

            yield b
开发者ID:tor-councilmatic,项目名称:scrapers-ca,代码行数:68,代码来源:bills.py


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