def preprocess_notice(document_number): """Preprocess notice XML. Either fetch from the Federal Register or read a notice from disk. Apply some common transformations to it and output the resulting file(s). There may be more than one as documents might be split if they have multiple effective dates.""" meta = federalregister.meta_data( document_number, ["effective_on", "full_text_xml_url", "publication_date", "volume"] ) notice_xmls = list(notice_xmls_for_url(document_number, meta["full_text_xml_url"])) deps = dependency.Graph() for notice_xml in notice_xmls: file_name = document_number notice_xml.published = meta["publication_date"] notice_xml.fr_volume = meta["volume"] if len(notice_xmls) > 1: effective_date = notice_xml.derive_effective_date() file_name = split_doc_num(document_number, effective_date.isoformat()) elif meta.get("effective_on"): notice_xml.effective = meta["effective_on"] else: notice_xml.derive_effective_date() notice_xml.version_id = file_name notice_entry = entry.Notice(file_name) notice_entry.write(notice_xml) if notice_xml.source_is_local: deps.add(str(notice_entry), notice_xml.source)
def preprocess_notice(document_number): """Preprocess notice XML. Either fetch from the Federal Register or read a notice from disk. Apply some common transformations to it and output the resulting file(s). There may be more than one as documents might be split if they have multiple effective dates.""" meta = federalregister.meta_data( document_number, [ "agencies", "docket_ids", "effective_on", "cfr_references", "comments_close_on", "full_text_xml_url", "html_url", "publication_date", "regulation_id_numbers", "volume" ]) notice_xmls = list(notice_xmls_for_url(document_number, meta['full_text_xml_url'])) deps = dependency.Graph() for notice_xml in notice_xmls: notice_xml.published = meta['publication_date'] notice_xml.fr_volume = meta['volume'] if meta.get('html_url'): notice_xml.fr_html_url = meta['html_url'] if meta.get("comments_close_on"): notice_xml.comments_close_on = meta["comments_close_on"] if meta.get('regulation_id_numbers'): notice_xml.rins = meta['regulation_id_numbers'] if meta.get('docket_ids'): notice_xml.docket_ids = meta['docket_ids'] notice_xml.set_agencies(meta.get('agencies', [])) cfr_refs = convert_cfr_refs(meta.get('cfr_references', [])) if cfr_refs: notice_xml.cfr_refs = cfr_refs file_name = document_number if len(notice_xmls) > 1: effective_date = notice_xml.derive_effective_date() file_name = split_doc_num(document_number, effective_date.isoformat()) elif meta.get('effective_on'): notice_xml.effective = meta['effective_on'] notice_xml.version_id = file_name notice_xml.derive_where_needed() notice_entry = entry.Notice(file_name) notice_entry.write(notice_xml) if notice_xml.source_is_local: deps.add(str(notice_entry), notice_xml.source)
def test_split_doc_num(self): doc_num = '2013-2222' effective_date = '2014-10-11' self.assertEqual( '2013-2222_20141011', build.split_doc_num(doc_num, effective_date))
def test_split_doc_num(self): doc_num = "2013-2222" effective_date = "2014-10-11" self.assertEqual("2013-2222_20141011", build.split_doc_num(doc_num, effective_date))