def add_notices(self): """Adds an uneven assortment of notices""" data = {'doc_number': 'v0', 'cfr_title': 11, 'cfr_parts': []} entry.SxS('v0').write(data) data.update(cfr_parts=['1000'], doc_number='v1') entry.SxS('v1').write(data) data.update(cfr_title=12, doc_number='v2') entry.SxS('v2').write(data) data['doc_number'] = 'v3' entry.SxS('v3').write(data)
def previous_sxs(cfr_title, cfr_part, stop_version): """The SxS layer relies on all notices that came before a particular version""" for previous_version in entry.Version(cfr_title, cfr_part): yield entry.SxS(previous_version) if previous_version == stop_version: break
def previous_sxs(cfr_title, cfr_part, stop_version): """The SxS layer relies on all notices that came before a particular version""" sub_entries = entry.FinalVersion(cfr_title, cfr_part).sub_entries() version_ids = [e.path[-1] for e in sub_entries] for previous_version in version_ids: yield entry.SxS(previous_version) if previous_version == stop_version: break
def write_notices(client, only_title, only_part): sxs_dir = entry.SxS() for version_id in sxs_dir: tree = (sxs_dir / version_id).read() title_match = not only_title or tree['cfr_title'] == only_title cfr_parts = map(str, tree['cfr_parts']) part_match = not only_part or str(only_part) in cfr_parts if title_match and part_match: client.notice(version_id).write(tree)
def test_process_creation(self): """If no tree is present, we should build one""" to_patch = 'regparser.commands.current_version.xml_parser' with CliRunner().isolated_filesystem(), patch(to_patch) as xml_parser: entry.Entry('annual', self.title, self.part, self.year).write('<ROOT />') xml_parser.reg_text.build_tree.return_value = {'my': 'tree'} current_version.process_if_needed(self.volume, self.part) tree = entry.Entry('tree', self.title, self.part, self.version_id).read() self.assertEqual(json.loads(tree), {'my': 'tree'}) notice = entry.SxS(self.version_id).read() self.assertEqual(notice['document_number'], self.version_id) self.assertEqual(notice['cfr_parts'], [str(self.part)])
def fetch_sxs(document_number): """Fetch and parse Section-by-Section analyses. DOCUMENT_NUMBER is the identifier associated with a final rule. If a rule has been split, use the split identifiers, a.k.a. version ids""" sxs_entry = entry.SxS(document_number) notice_entry = entry.Notice(document_number) deps = dependency.Graph() deps.add(sxs_entry, notice_entry) deps.validate_for(sxs_entry) # We don't check for staleness as we want to always execute when given a # specific file to process # @todo - break apart processing of SxS. We don't need all of the other # fields notice_xml = notice_entry.read() notice_meta = meta_data(document_number, FULL_NOTICE_FIELDS) notice = build_notice(notice_xml.cfr_titles[0], None, notice_meta, xml_to_process=notice_xml.xml)[0] sxs_entry.write(notice)