def gen_and_write_layers(self, reg_tree, act_info, cache, notices=None):
     if notices is None:
         notices = applicable_notices(self.notices, self.doc_number)
     for ident, layer_class in (('external-citations',
                                 external_citations.ExternalCitationParser),
                                ('meta', meta.Meta),
                                ('analyses',
                                 section_by_section.SectionBySection),
                                ('internal-citations',
                                 internal_citations.InternalCitationParser),
                                ('toc',
                                 table_of_contents.TableOfContentsLayer),
                                ('interpretations',
                                 interpretations.Interpretations),
                                ('terms', terms.Terms),
                                ('paragraph-markers',
                                 paragraph_markers.ParagraphMarkers),
                                ('keyterms', key_terms.KeyTerms),
                                ('formatting', formatting.Formatting),
                                ('graphics', graphics.Graphics)):
         layer = self.checkpointer.checkpoint(
             ident + "-" + self.doc_number, lambda: layer_class(
                 reg_tree, self.cfr_title, self.doc_number, notices,
                 act_info).build(cache.cache_for(ident)))
         self.writer.layer(ident, self.cfr_part,
                           self.doc_number).write(layer)
Exemple #2
0
    def generate_layers(self, reg_tree, act_info, cache, notices=None):
        layers = {}
        if notices is None:
            notices = applicable_notices(self.notices, self.doc_number)
        for ident, layer_class in (
                ('external-citations',
                    external_citations.ExternalCitationParser),
                ('meta', meta.Meta),
                ('analyses', section_by_section.SectionBySection),
                ('internal-citations',
                    internal_citations.InternalCitationParser),
                ('toc', table_of_contents.TableOfContentsLayer),
                ('interpretations', interpretations.Interpretations),
                ('terms', terms.Terms),
                ('paragraph-markers', paragraph_markers.ParagraphMarkers),
                ('keyterms', key_terms.KeyTerms),
                ('formatting', formatting.Formatting),
                ('graphics', graphics.Graphics)):
            layer = self.checkpointer.checkpoint(
                ident + "-" + self.doc_number,
                lambda: layer_class(
                    reg_tree, self.cfr_title, self.doc_number, notices,
                    act_info).build(cache.cache_for(ident)))
            layers[ident] = layer

        return layers
 def gen_and_write_layers(self, reg_tree, act_info, cache, notices=None):
     if notices is None:
         notices = applicable_notices(self.notices, self.doc_number)
     for ident, layer_class in ALL_LAYERS.items():
         layer = self.checkpointer.checkpoint(
             ident + "-" + self.doc_number,
             lambda: layer_class(
                 reg_tree, self.cfr_title, self.doc_number, notices,
                 act_info).build(cache.cache_for(ident)))
         self.writer.layer(ident, self.cfr_part, self.doc_number).write(
             layer)
 def revision_generator(self, reg_tree):
     relevant_notices = []
     for date in sorted(self.eff_notices.keys()):
         relevant_notices.extend(
             n for n in self.eff_notices[date]
             if 'changes' in n and n['document_number'] != self.doc_number)
     for notice in relevant_notices:
         version = notice['document_number']
         old_tree = reg_tree
         merged_changes = self.merge_changes(version, notice['changes'])
         reg_tree = compile_regulation(old_tree, merged_changes)
         notices = applicable_notices(self.notices, version)
         yield notice, old_tree, reg_tree, notices
Exemple #5
0
 def revision_generator(self, reg_tree):
     relevant_notices = []
     for date in sorted(self.eff_notices.keys()):
         relevant_notices.extend(
             n for n in self.eff_notices[date]
             if 'changes' in n and n['document_number'] != self.doc_number)
     for notice in relevant_notices:
         version = notice['document_number']
         old_tree = reg_tree
         merged_changes = self.merge_changes(version, notice['changes'])
         reg_tree = compile_regulation(old_tree, merged_changes)
         notices = applicable_notices(self.notices, version)
         yield notice, old_tree, reg_tree, notices
Exemple #6
0
 def revision_generator(self, reg_tree):
     """Given an initial regulation tree, this will emit (and checkpoint)
     new versions of the tree, along with the notice that caused the
     change. This is a generator, so processing only occurs as needed"""
     for version, merged_changes in self.changes_in_sequence():
         old_tree = reg_tree
         reg_tree = self.checkpointer.checkpoint(
             "compiled-" + version,
             lambda: compile_regulation(old_tree, merged_changes))
         notices = applicable_notices(self.notices, version)
         first_notice = None
         for notice in notices:
             if notice['document_number'] == version:
                 first_notice = notice
         yield first_notice, old_tree, reg_tree, notices
 def revision_generator(self, reg_tree):
     """Given an initial regulation tree, this will emit (and checkpoint)
     new versions of the tree, along with the notice that caused the
     change. This is a generator, so processing only occurs as needed"""
     for version, merged_changes in self.changes_in_sequence():
         old_tree = reg_tree
         reg_tree = self.checkpointer.checkpoint(
             "compiled-" + version,
             lambda: compile_regulation(old_tree, merged_changes))
         notices = applicable_notices(self.notices, version)
         first_notice = None
         for notice in notices:
             if notice['document_number'] == version:
                 first_notice = notice
         yield first_notice, old_tree, reg_tree, notices
 def gen_and_write_layers(self, reg_tree, act_info, cache, notices=None):
     if notices is None:
         notices = applicable_notices(self.notices, self.doc_number)
     for ident, layer_class in (
         ("external-citations", external_citations.ExternalCitationParser),
         ("meta", meta.Meta),
         ("analyses", section_by_section.SectionBySection),
         ("internal-citations", internal_citations.InternalCitationParser),
         ("toc", table_of_contents.TableOfContentsLayer),
         ("interpretations", interpretations.Interpretations),
         ("terms", terms.Terms),
         ("paragraph-markers", paragraph_markers.ParagraphMarkers),
         ("keyterms", key_terms.KeyTerms),
         ("formatting", formatting.Formatting),
         ("graphics", graphics.Graphics),
     ):
         layer = self.checkpointer.checkpoint(
             ident + "-" + self.doc_number,
             lambda: layer_class(reg_tree, self.cfr_title, self.doc_number, notices, act_info).build(
                 cache.cache_for(ident)
             ),
         )
         self.writer.layer(ident, self.cfr_part, self.doc_number).write(layer)