예제 #1
0
 def test_add_footnotes(self):
     xml = """
     <ROOT>
         <P>Some text</P>
         <FTNT>
             <P><SU>21</SU>Footnote text</P>
         </FTNT>
         <FTNT>
             <P><SU>43</SU>This has a<PRTPAGE P="2222" />break</P>
         </FTNT>
         <FTNT>
             <P><SU>98</SU>This one has<E T="03">emph</E>tags</P>
         </FTNT>
     </ROOT>"""
     notice = {}
     build.add_footnotes(notice, etree.fromstring(xml))
     self.assertEqual(
         notice, {
             'footnotes': {
                 '21': 'Footnote text',
                 '43': 'This has a break',
                 '98':
                 'This one has <em data-original="E-03">emph</em> tags'
             }
         })
 def test_add_footnotes(self):
     xml = """
     <ROOT>
         <P>Some text</P>
         <FTNT>
             <P><SU>21</SU>Footnote text</P>
         </FTNT>
         <FTNT>
             <P><SU>43</SU>This has a<PRTPAGE P="2222" />break</P>
         </FTNT>
         <FTNT>
             <P><SU>98</SU>This one has<E T="03">emph</E>tags</P>
         </FTNT>
     </ROOT>"""
     notice = {}
     build.add_footnotes(notice, etree.fromstring(xml))
     self.assertEqual(
         notice,
         {
             "footnotes": {
                 "21": "Footnote text",
                 "43": "This has a break",
                 "98": 'This one has <em data-original="E-03">emph</em> tags',
             }
         },
     )
 def test_add_footnotes(self):
     with self.tree.builder("ROOT") as root:
         root.P("Some text")
         with root.FTNT() as ftnt:
             ftnt.P(_xml='<SU>21</SU>Footnote text')
         with root.FTNT() as ftnt:
             ftnt.P(_xml='<SU>43</SU>This has a<PRTPAGE P="2222" />break')
         with root.FTNT() as ftnt:
             ftnt.P(_xml='<SU>98</SU>This one has<E T="03">emph</E>tags')
     notice = {}
     build.add_footnotes(notice, self.tree.render_xml())
     self.assertEqual(notice, {'footnotes': {
         '21': 'Footnote text',
         '43': 'This has a break',
         '98': 'This one has <em data-original="E-03">emph</em> tags'
     }})
 def test_add_footnotes(self):
     with XMLBuilder("ROOT") as ctx:
         ctx.P("Some text")
         ctx.child_from_string(
             '<FTNT><P><SU>21</SU>Footnote text</P></FTNT>')
         ctx.child_from_string(
             '<FTNT><P><SU>43</SU>This has a<PRTPAGE P="2222" />break'
             '</P></FTNT>')
         ctx.child_from_string(
             '<FTNT><P><SU>98</SU>This one has<E T="03">emph</E>tags</P>'
             '</FTNT>')
     notice = {}
     build.add_footnotes(notice, ctx.xml)
     self.assertEqual(notice, {'footnotes': {
         '21': 'Footnote text',
         '43': 'This has a break',
         '98': 'This one has <em data-original="E-03">emph</em> tags'
     }})
예제 #5
0
def transform_notice(notice_xml):
    """The API has a different format for notices than the local XML. We'll
    need to convert and add appropriate fields"""
    as_dict = notice_xml.as_dict()
    as_dict['versions'] = {}
    for cfr_title, cfr_part in notice_xml.cfr_ref_pairs:
        version_dir = entry.Version(cfr_title, cfr_part)
        versions = [(version_dir / id).read() for id in version_dir]
        with_parents = zip(versions, Version.parents_of(versions))
        for version, parent in with_parents:
            if version.identifier == notice_xml.version_id and parent:
                as_dict['versions'][cfr_part] = {"left": parent.identifier,
                                                 "right": version.identifier}

    # @todo - SxS and footnotes aren't used outside of CFPB
    add_footnotes(as_dict, notice_xml.xml)
    if notice_xml.cfr_ref_pairs:
        process_sxs(as_dict, notice_xml.xml)
    return as_dict
예제 #6
0
def transform_notice(notice_xml):
    """The API has a different format for notices than the local XML. We'll
    need to convert and add appropriate fields"""
    as_dict = notice_xml.as_dict()
    as_dict['versions'] = {}
    for cfr_title, cfr_part in notice_xml.cfr_ref_pairs:
        version_dir = entry.Version(cfr_title, cfr_part)
        versions = [v.read() for v in version_dir.sub_entries()]
        with_parents = zip(versions, Version.parents_of(versions))
        for version, parent in with_parents:
            if version.identifier == notice_xml.version_id and parent:
                as_dict['versions'][cfr_part] = {"left": parent.identifier,
                                                 "right": version.identifier}

    # @todo - SxS and footnotes aren't used outside of CFPB
    add_footnotes(as_dict, notice_xml.xml)
    if notice_xml.cfr_ref_pairs:
        process_sxs(as_dict, notice_xml.xml)
    return as_dict
 def test_add_footnotes(self):
     xml = """
     <ROOT>
         <P>Some text</P>
         <FTNT>
             <P><SU>21</SU>Footnote text</P>
         </FTNT>
         <FTNT>
             <P><SU>43</SU>This has a<PRTPAGE P="2222" />break</P>
         </FTNT>
         <FTNT>
             <P><SU>98</SU>This one has<E T="03">emph</E>tags</P>
         </FTNT>
     </ROOT>"""
     notice = {}
     build.add_footnotes(notice, etree.fromstring(xml))
     self.assertEqual(notice, {'footnotes': {
         '21': 'Footnote text',
         '43': 'This has a break',
         '98': 'This one has <em data-original="E-03">emph</em> tags'
     }})