def __init__(self, cfr_title, cfr_part, doc_number):
        self.cfr_title = cfr_title
        self.cfr_part = cfr_part
        self.doc_number = doc_number
        self.writer = api_writer.Client()

        self.notices = fetch_notices(self.cfr_title, self.cfr_part,
                                     only_final=True)
        modify_effective_dates(self.notices)
        #   Only care about final
        self.notices = [n for n in self.notices if 'effective_on' in n]
        self.eff_notices = group_by_eff_date(self.notices)
Exemple #2
0
    def __init__(self, cfr_title, cfr_part, doc_number):
        self.cfr_title = cfr_title
        self.cfr_part = cfr_part
        self.doc_number = doc_number
        self.writer = api_writer.Client()

        self.notices = fetch_notices(self.cfr_title,
                                     self.cfr_part,
                                     only_final=True)
        modify_effective_dates(self.notices)
        #   Only care about final
        self.notices = [n for n in self.notices if 'effective_on' in n]
        self.eff_notices = group_by_eff_date(self.notices)
    def test_modify_effective_dates(self):
        outdated = {
            "document_number": "outdated",
            "effective_on": "2001-01-01",
            "publication_date": "2000-12-12",
            "fr_volume": 12,
            "meta": {
                "start_page": 500,
                "end_page": 600,
                "type": "Rule",
                "dates": "Has an effective date of January 1, " + "2001",
            },
        }
        unaltered = {
            "document_number": "unaltered",
            "effective_on": "2001-01-01",
            "publication_date": "2000-12-20",
            "fr_volume": 12,
            "meta": {"start_page": 800, "end_page": 900, "type": "Rule", "dates": "Effective date of January 1, 2001"},
        }
        proposal = {
            "document_number": "proposal",
            "publication_date": "2000-12-21",
            "fr_volume": 12,
            "meta": {
                "start_page": 1100,
                "end_page": 1200,
                "type": "Proposed Rule",
                "dates": "We are thinking about delaying the " + "effective date of 12 FR 501 to March 3, " + "2003",
            },
        }
        changer = {
            "document_number": "changer",
            "publication_date": "2000-12-31",
            "effective_on": "2000-12-31",
            "fr_volume": 12,
            "meta": {
                "start_page": 9000,
                "end_page": 9005,
                "type": "Rule",
                "dates": "The effective date of 12 FR 501 has " + "been delayed until March 3, 2003",
            },
        }

        delays.modify_effective_dates([outdated, unaltered, proposal, changer])

        self.assertEqual("2003-03-03", outdated["effective_on"])
        self.assertEqual("2001-01-01", unaltered["effective_on"])
        self.assertFalse("effective_on" in proposal)
        self.assertEqual("2000-12-31", changer["effective_on"])
    def build_notices(self, checkpoint=True):
        for result in self.notices_json:
            notice = self.build_single_notice(result, checkpoint)
            self.notices.extend(notice)
        modify_effective_dates(self.notices)
        #   Only care about final
        self.notices = [n for n in self.notices if 'effective_on' in n]
        self.eff_notices = group_by_eff_date(self.notices)

        self.eff_notices = self.checkpointer.checkpoint(
            "effective-notices",
            lambda: notices_for_cfr_part(self.cfr_title, self.cfr_part))
        self.notices = []
        for notice_group in self.eff_notices.values():
            self.notices.extend(notice_group)
    def build_notices(self, checkpoint=True):
        for result in self.notices_json:
            notice = self.build_single_notice(result, checkpoint)
            self.notices.extend(notice)
        modify_effective_dates(self.notices)
        #   Only care about final
        self.notices = [n for n in self.notices if "effective_on" in n]
        self.eff_notices = group_by_eff_date(self.notices)

        self.eff_notices = self.checkpointer.checkpoint(
            "effective-notices", lambda: notices_for_cfr_part(self.cfr_title, self.cfr_part)
        )
        self.notices = []
        for notice_group in self.eff_notices.values():
            self.notices.extend(notice_group)
    def test_modify_effective_dates(self):
        outdated = {'document_number': 'outdated',
                    'effective_on': '2001-01-01',
                    'publication_date': '2000-12-12',
                    'fr_volume': 12,
                    'meta': {'start_page': 500,
                             'end_page': 600,
                             'type': 'Rule',
                             'dates': 'Has an effective date of January 1, '
                                      + '2001'}}
        unaltered = {'document_number': 'unaltered',
                     'effective_on': '2001-01-01',
                     'publication_date': '2000-12-20',
                     'fr_volume': 12,
                     'meta': {'start_page': 800,
                              'end_page': 900,
                              'type': 'Rule',
                              'dates': 'Effective date of January 1, 2001'}}
        proposal = {'document_number': 'proposal',
                    'publication_date': '2000-12-21',
                    'fr_volume': 12,
                    'meta': {
                        'start_page': 1100,
                        'end_page': 1200,
                        'type': 'Proposed Rule',
                        'dates': 'We are thinking about delaying the '
                                 + 'effective date of 12 FR 501 to March 3, '
                                 + '2003'}}
        changer = {'document_number': 'changer',
                   'publication_date': '2000-12-31',
                   'effective_on': '2000-12-31',
                   'fr_volume': 12,
                   'meta': {'start_page': 9000,
                            'end_page': 9005,
                            'type': 'Rule',
                            'dates': 'The effective date of 12 FR 501 has ' +
                                     'been delayed until March 3, 2003'}}

        delays.modify_effective_dates([outdated, unaltered, proposal, changer])

        self.assertEqual('2003-03-03', outdated['effective_on'])
        self.assertEqual('2001-01-01', unaltered['effective_on'])
        self.assertFalse('effective_on' in proposal)
        self.assertEqual('2000-12-31', changer['effective_on'])
    def test_modify_effective_dates(self):
        outdated = {'document_number': 'outdated',
                    'effective_on': '2001-01-01',
                    'publication_date': '2000-12-12',
                    'fr_volume': 12,
                    'meta': {'start_page': 500,
                             'end_page': 600,
                             'type': 'Rule',
                             'dates': 'Has an effective date of January 1, ' +
                                      '2001'}}
        unaltered = {'document_number': 'unaltered',
                     'effective_on': '2001-01-01',
                     'publication_date': '2000-12-20',
                     'fr_volume': 12,
                     'meta': {'start_page': 800,
                              'end_page': 900,
                              'type': 'Rule',
                              'dates': 'Effective date of January 1, 2001'}}
        proposal = {'document_number': 'proposal',
                    'publication_date': '2000-12-21',
                    'fr_volume': 12,
                    'meta': {
                        'start_page': 1100,
                        'end_page': 1200,
                        'type': 'Proposed Rule',
                        'dates': 'We are thinking about delaying the ' +
                                 'effective date of 12 FR 501 to March 3, ' +
                                 '2003'}}
        changer = {'document_number': 'changer',
                   'publication_date': '2000-12-31',
                   'effective_on': '2000-12-31',
                   'fr_volume': 12,
                   'meta': {'start_page': 9000,
                            'end_page': 9005,
                            'type': 'Rule',
                            'dates': 'The effective date of 12 FR 501 has ' +
                                     'been delayed until March 3, 2003'}}

        delays.modify_effective_dates([outdated, unaltered, proposal, changer])

        self.assertEqual('2003-03-03', outdated['effective_on'])
        self.assertEqual('2001-01-01', unaltered['effective_on'])
        self.assertFalse('effective_on' in proposal)
        self.assertEqual('2000-12-31', changer['effective_on'])
def first_notice_and_xml(title, part):
    """Find the first annual xml and its associated notice"""
    notices = [build_notice(title, part, n, do_process_xml=False)
               for n in fetch_notice_json(title, part, only_final=True)
               if n['full_text_xml_url'] and n['effective_on']]
    modify_effective_dates(notices)

    notices = sorted(notices,
                     key=lambda n: (n['effective_on'], n['publication_date']))

    years = {}
    for n in notices:
        year = annual_edition_for(title, n)
        years[year] = n

    for year, notice in sorted(years.iteritems()):
        volume = find_volume(year, title, part)
        if volume:
            part_xml = volume.find_part_xml(part)
            if part_xml is not None:
                return (notice, part_xml)
Exemple #9
0
def first_notice_and_xml(title, part):
    """Find the first annual xml and its associated notice"""
    notices = [
        build_notice(title, part, n, do_process_xml=False)
        for n in fetch_notice_json(title, part, only_final=True)
        if n['full_text_xml_url'] and n['effective_on']
    ]
    modify_effective_dates(notices)

    notices = sorted(notices,
                     key=lambda n: (n['effective_on'], n['publication_date']))

    years = {}
    for n in notices:
        year = annual_edition_for(title, n)
        years[year] = n

    for year, notice in sorted(years.iteritems()):
        volume = find_volume(year, title, part)
        if volume:
            part_xml = volume.find_part_xml(part)
            if part_xml is not None:
                return (notice, part_xml)
Exemple #10
0
def notices_for_cfr_part(title, part):
    """Retrieves all final notices for a title-part pair, orders them, and
    returns them as a dict[effective_date_str] -> list(notices)"""
    notices = fetch_notices(title, part, only_final=True)
    modify_effective_dates(notices)
    return group_by_eff_date(notices)
def notices_for_cfr_part(title, part):
    """Retrieves all final notices for a title-part pair, orders them, and
    returns them as a dict[effective_date_str] -> list(notices)"""
    notices = fetch_notices(title, part, only_final=True)
    modify_effective_dates(notices)
    return group_by_eff_date(notices)