本文整理汇总了Python中regparser.notice.build.process_amendments函数的典型用法代码示例。如果您正苦于以下问题:Python process_amendments函数的具体用法?Python process_amendments怎么用?Python process_amendments使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了process_amendments函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_process_amendments_restart_new_section
def test_process_amendments_restart_new_section(self):
xml = u"""
<ROOT>
<REGTEXT PART="104" TITLE="12">
<AMDPAR>
1. In Supplement I to Part 104, comment 22(a) is added
</AMDPAR>
<P>Content</P>
</REGTEXT>
<REGTEXT PART="105" TITLE="12">
<AMDPAR>
3. In § 105.1, revise paragraph (b) to read as follows:
</AMDPAR>
<SECTION>
<SECTNO>§ 105.1</SECTNO>
<SUBJECT>Purpose.</SUBJECT>
<STARS/>
<P>(b) This part carries out.</P>
</SECTION>
</REGTEXT>
</ROOT>"""
notice_xml = etree.fromstring(xml)
notice = {'cfr_parts': ['105']}
build.process_amendments(notice, notice_xml)
self.assertEqual(2, len(notice['amendments']))
c22a, b = notice['amendments']
self.assertEqual(c22a.action, 'POST')
self.assertEqual(b.action, 'PUT')
self.assertEqual(c22a.label, ['104', '22', 'a', 'Interp'])
self.assertEqual(b.label, ['105', '1', 'b'])
开发者ID:adderall,项目名称:regulations-parser,代码行数:32,代码来源:notice_build_tests.py
示例2: test_process_amendments_multiple_in_same_parent
def test_process_amendments_multiple_in_same_parent(self):
xml = u"""
<REGTEXT PART="105" TITLE="12">
<AMDPAR>
1. In § 105.1, revise paragraph (b) to read as follows:
</AMDPAR>
<AMDPAR>2. Also, revise paragraph (c):</AMDPAR>
<SECTION>
<SECTNO>§ 105.1</SECTNO>
<SUBJECT>Purpose.</SUBJECT>
<STARS/>
<P>(b) This part carries out.</P>
<P>(c) More stuff</P>
</SECTION>
</REGTEXT>"""
notice_xml = etree.fromstring(xml)
notice = {"cfr_parts": ["105"]}
build.process_amendments(notice, notice_xml)
self.assertEqual(notice["changes"].keys(), ["105-1-b", "105-1-c"])
changes = notice["changes"]["105-1-b"][0]
self.assertEqual(changes["action"], "PUT")
self.assertEqual(changes["node"]["text"].strip(), u"(b) This part carries out.")
changes = notice["changes"]["105-1-c"][0]
self.assertEqual(changes["action"], "PUT")
self.assertTrue(changes["node"]["text"].strip(), u"(c) More stuff")
开发者ID:EricSchles,项目名称:regulations-parser,代码行数:28,代码来源:notice_build_tests.py
示例3: test_process_amendments_multiple_in_same_parent
def test_process_amendments_multiple_in_same_parent(self):
with self.tree.builder("REGTEXT", PART="105", TITLE="12") as regtext:
regtext.AMDPAR(u"1. In § 105.1, revise paragraph (b) to read as "
"follows:")
regtext.AMDPAR("2. Also, revise paragraph (c):")
with regtext.SECTION() as section:
section.SECTNO(u"§ 105.1")
section.SUBJECT("Purpose.")
section.STARS()
section.P("(b) This part carries out.")
section.P("(c) More stuff")
notice = {'cfr_parts': ['105']}
build.process_amendments(notice, self.tree.render_xml())
self.assertEqual(notice['changes'].keys(), ['105-1-b', '105-1-c'])
changes = notice['changes']['105-1-b'][0]
self.assertEqual(changes['action'], 'PUT')
self.assertEqual(changes['node']['text'].strip(),
u'(b) This part carries out.')
changes = notice['changes']['105-1-c'][0]
self.assertEqual(changes['action'], 'PUT')
self.assertTrue(changes['node']['text'].strip(),
u'(c) More stuff')
开发者ID:theresaanna,项目名称:regulations-parser,代码行数:25,代码来源:notice_build_tests.py
示例4: test_process_amendments_multiple_in_same_parent
def test_process_amendments_multiple_in_same_parent(self):
xml = u"""
<REGTEXT PART="105" TITLE="12">
<AMDPAR>
1. In § 105.1, revise paragraph (b) to read as follows:
</AMDPAR>
<AMDPAR>2. Also, revise paragraph (c):</AMDPAR>
<SECTION>
<SECTNO>§ 105.1</SECTNO>
<SUBJECT>Purpose.</SUBJECT>
<STARS/>
<P>(b) This part carries out.</P>
<P>(c) More stuff</P>
</SECTION>
</REGTEXT>"""
notice_xml = etree.fromstring(xml)
notice = {'cfr_parts': ['105']}
build.process_amendments(notice, notice_xml)
self.assertEqual(notice['changes'].keys(), ['105-1-b', '105-1-c'])
changes = notice['changes']['105-1-b'][0]
self.assertEqual(changes['action'], 'PUT')
self.assertEqual(changes['node']['text'].strip(),
u'(b) This part carries out.')
changes = notice['changes']['105-1-c'][0]
self.assertEqual(changes['action'], 'PUT')
self.assertTrue(changes['node']['text'].strip(),
u'(c) More stuff')
开发者ID:adderall,项目名称:regulations-parser,代码行数:30,代码来源:notice_build_tests.py
示例5: test_process_amendments_mix_regs
def test_process_amendments_mix_regs(self):
"""Some notices apply to multiple regs. For now, just ignore the
sections not associated with the reg we're focused on"""
with XMLBuilder("ROOT") as ctx:
with ctx.REGTEXT(PART="105", TITLE="12"):
ctx.AMDPAR(u"3. In § 105.1, revise paragraph (a) to read as "
u"follows:")
with ctx.SECTION():
ctx.SECTNO(u"§ 105.1")
ctx.SUBJECT("105Purpose.")
ctx.P("(a) 105Content")
with ctx.REGTEXT(PART="106", TITLE="12"):
ctx.AMDPAR(u"3. In § 106.3, revise paragraph (b) to read as "
u"follows:")
with ctx.SECTION():
ctx.SECTNO(u"§ 106.3")
ctx.SUBJECT("106Purpose.")
ctx.P("(b) Content")
ParseAMDPARs().transform(ctx.xml)
notice = {'cfr_parts': ['105', '106']}
build.process_amendments(notice, ctx.xml)
self.assertEqual(2, len(notice['changes']))
self.assertTrue('105-1-a' in notice['changes'])
self.assertTrue('106-3-b' in notice['changes'])
开发者ID:cmc333333,项目名称:regulations-parser,代码行数:26,代码来源:notice_build_tests.py
示例6: test_process_amendments_subpart
def test_process_amendments_subpart(self):
notice = {'cfr_parts': ['105']}
build.process_amendments(notice, self.new_subpart_xml())
self.assertTrue('105-Subpart-B' in notice['changes'].keys())
self.assertTrue('105-30-a' in notice['changes'].keys())
self.assertTrue('105-30' in notice['changes'].keys())
开发者ID:theresaanna,项目名称:regulations-parser,代码行数:7,代码来源:notice_build_tests.py
示例7: test_process_amendments_context
def test_process_amendments_context(self):
"""Context should carry over between REGTEXTs"""
xml = u"""
<ROOT>
<REGTEXT TITLE="12">
<AMDPAR>
3. In § 106.1, revise paragraph (a) to read as follows:
</AMDPAR>
</REGTEXT>
<REGTEXT TITLE="12">
<AMDPAR>
3. Add appendix C
</AMDPAR>
</REGTEXT>
</ROOT>
"""
notice_xml = etree.fromstring(xml)
notice = {'cfr_parts': ['105', '106']}
build.process_amendments(notice, notice_xml)
self.assertEqual(2, len(notice['amendments']))
amd1, amd2 = notice['amendments']
self.assertEqual(['106', '1', 'a'], amd1.label)
self.assertEqual(['106', 'C'], amd2.label)
开发者ID:adderall,项目名称:regulations-parser,代码行数:25,代码来源:notice_build_tests.py
示例8: test_process_amendments_mix_regs
def test_process_amendments_mix_regs(self):
"""Some notices apply to multiple regs. For now, just ignore the
sections not associated with the reg we're focused on"""
xml = u"""
<ROOT>
<REGTEXT PART="105" TITLE="12">
<AMDPAR>
3. In § 105.1, revise paragraph (a) to read as follows:
</AMDPAR>
<SECTION>
<SECTNO>§ 105.1</SECTNO>
<SUBJECT>105Purpose.</SUBJECT>
<P>(a) 105Content</P>
</SECTION>
</REGTEXT>
<REGTEXT PART="106" TITLE="12">
<AMDPAR>
3. In § 106.3, revise paragraph (b) to read as follows:
</AMDPAR>
<SECTION>
<SECTNO>§ 106.3</SECTNO>
<SUBJECT>106Purpose.</SUBJECT>
<P>(b) Content</P>
</SECTION>
</REGTEXT>
</ROOT>
"""
notice_xml = etree.fromstring(xml)
notice = {'cfr_parts': ['105', '106']}
build.process_amendments(notice, notice_xml)
self.assertEqual(2, len(notice['changes']))
self.assertTrue('105-1-a' in notice['changes'])
self.assertTrue('106-3-b' in notice['changes'])
开发者ID:adderall,项目名称:regulations-parser,代码行数:35,代码来源:notice_build_tests.py
示例9: test_process_amendments_restart_new_section
def test_process_amendments_restart_new_section(self):
with XMLBuilder("ROOT") as ctx:
with ctx.REGTEXT(PART="104", TITLE="12"):
ctx.AMDPAR("1. In Supplement I to Part 104, comment "
"22(a) is added")
ctx.P("Content")
with ctx.REGTEXT(PART="105", TITLE="12"):
ctx.AMDPAR(u"3. In § 105.1, revise paragraph (b) to read as "
u"follows:")
with ctx.SECTION():
ctx.SECTNO(u"§ 105.1")
ctx.SUBJECT("Purpose.")
ctx.STARS()
ctx.P("(b) This part carries out.")
ParseAMDPARs().transform(ctx.xml)
notice = {'cfr_parts': ['105']}
build.process_amendments(notice, ctx.xml)
self.assertEqual(2, len(notice['amendments']))
c22a, b = notice['amendments']
self.assertEqual(c22a.action, 'POST')
self.assertEqual(b.action, 'PUT')
self.assertEqual(c22a.label, ['104', '22', 'a', 'Interp'])
self.assertEqual(b.label, ['105', '1', 'b'])
开发者ID:cmc333333,项目名称:regulations-parser,代码行数:25,代码来源:notice_build_tests.py
示例10: test_process_amendments_multiple_in_same_parent
def test_process_amendments_multiple_in_same_parent(self):
with XMLBuilder("REGTEXT", PART="105", TITLE="12") as ctx:
ctx.AMDPAR(u"1. In § 105.1, revise paragraph (b) to read as "
u"follows:")
ctx.AMDPAR("2. Also, revise paragraph (c):")
with ctx.SECTION():
ctx.SECTNO(u"§ 105.1")
ctx.SUBJECT("Purpose.")
ctx.STARS()
ctx.P("(b) This part carries out.")
ctx.P("(c) More stuff")
ParseAMDPARs().transform(ctx.xml)
notice = {'cfr_parts': ['105']}
build.process_amendments(notice, ctx.xml)
self.assertItemsEqual(notice['changes'].keys(), ['105-1-b', '105-1-c'])
changes = notice['changes']['105-1-b'][0]
self.assertEqual(changes['action'], 'PUT')
self.assertEqual(changes['node']['text'].strip(),
u'(b) This part carries out.')
changes = notice['changes']['105-1-c'][0]
self.assertEqual(changes['action'], 'PUT')
self.assertTrue(changes['node']['text'].strip(),
u'(c) More stuff')
开发者ID:cmc333333,项目名称:regulations-parser,代码行数:26,代码来源:notice_build_tests.py
示例11: test_process_amendments_mix_regs
def test_process_amendments_mix_regs(self):
"""Some notices apply to multiple regs. For now, just ignore the
sections not associated with the reg we're focused on"""
with self.tree.builder("ROOT") as root:
with root.REGTEXT(PART="105", TITLE="12") as regtext:
regtext.AMDPAR(u"3. In § 105.1, revise paragraph (a) to read "
"as follows:")
with regtext.SECTION() as section:
section.SECTNO(u"§ 105.1")
section.SUBJECT("105Purpose.")
section.P("(a) 105Content")
with root.REGTEXT(PART="106", TITLE="12") as regtext:
regtext.AMDPAR(u"3. In § 106.3, revise paragraph (b) to read "
"as follows:")
with regtext.SECTION() as section:
section.SECTNO(u"§ 106.3")
section.SUBJECT("106Purpose.")
section.P("(b) Content")
notice = {'cfr_parts': ['105', '106']}
build.process_amendments(notice, self.tree.render_xml())
self.assertEqual(2, len(notice['changes']))
self.assertTrue('105-1-a' in notice['changes'])
self.assertTrue('106-3-b' in notice['changes'])
开发者ID:theresaanna,项目名称:regulations-parser,代码行数:25,代码来源:notice_build_tests.py
示例12: test_process_amendments_section
def test_process_amendments_section(self):
xml = u"""
<REGTEXT PART="105" TITLE="12">
<AMDPAR>
3. In § 105.1, revise paragraph (b) to read as follows:
</AMDPAR>
<SECTION>
<SECTNO>§ 105.1</SECTNO>
<SUBJECT>Purpose.</SUBJECT>
<STARS/>
<P>(b) This part carries out.</P>
</SECTION>
</REGTEXT>
"""
notice_xml = etree.fromstring(xml)
notice = {'cfr_part': '105'}
build.process_amendments(notice, notice_xml)
self.assertEqual(notice['changes'].keys(), ['105-1-b'])
changes = notice['changes']['105-1-b'][0]
self.assertEqual(changes['action'], 'PUT')
self.assertTrue(changes['node']['text'].startswith(
u'(b) This part carries out.'))
开发者ID:jposi,项目名称:regulations-parser,代码行数:25,代码来源:notice_build_tests.py
示例13: test_multiple_changes
def test_multiple_changes(self):
""" A notice can have two modifications to a paragraph. """
xml = u"""
<ROOT>
<REGTEXT PART="106" TITLE="12">
<AMDPAR>
2. Designate §§ 106.1 through 106.3 as subpart A under the heading.
</AMDPAR>
</REGTEXT>
<REGTEXT PART="106" TITLE="12">
<AMDPAR>
3. In § 106.2, revise the introductory text to read as follows:
</AMDPAR>
<SECTION>
<SECTNO>§ 106.2</SECTNO>
<SUBJECT> Definitions </SUBJECT>
<P> Except as otherwise provided, the following apply. </P>
</SECTION>
</REGTEXT>
</ROOT>
"""
notice_xml = etree.fromstring(xml)
notice = {'cfr_parts': ['106']}
build.process_amendments(notice, notice_xml)
self.assertEqual(2, len(notice['changes']['106-2']))
开发者ID:adderall,项目名称:regulations-parser,代码行数:28,代码来源:notice_build_tests.py
示例14: test_process_amendments_subpart
def test_process_amendments_subpart(self):
xml = self.new_subpart_xml()
notice_xml = etree.fromstring(xml)
notice = {"cfr_parts": ["105"]}
build.process_amendments(notice, notice_xml)
self.assertTrue("105-Subpart-B" in notice["changes"].keys())
self.assertTrue("105-30-a" in notice["changes"].keys())
self.assertTrue("105-30" in notice["changes"].keys())
开发者ID:EricSchles,项目名称:regulations-parser,代码行数:10,代码来源:notice_build_tests.py
示例15: test_process_amendments_no_nodes
def test_process_amendments_no_nodes(self):
with self.tree.builder("ROOT") as root:
with root.REGTEXT(PART="104", TITLE="12") as regtext:
regtext.AMDPAR(u"1. In § 104.13, paragraph (b) is removed")
notice = {'cfr_parts': ['104']}
build.process_amendments(notice, self.tree.render_xml())
self.assertEqual(1, len(notice['amendments']))
delete = notice['amendments'][0]
self.assertEqual(delete.action, 'DELETE')
self.assertEqual(delete.label, ['104', '13', 'b'])
开发者ID:theresaanna,项目名称:regulations-parser,代码行数:12,代码来源:notice_build_tests.py
示例16: test_process_amendments_no_nodes
def test_process_amendments_no_nodes(self):
with XMLBuilder("ROOT") as ctx:
with ctx.REGTEXT(PART="104", TITLE="12"):
ctx.AMDPAR(u"1. In § 104.13, paragraph (b) is removed")
ParseAMDPARs().transform(ctx.xml)
notice = {'cfr_parts': ['104']}
build.process_amendments(notice, ctx.xml)
self.assertEqual(1, len(notice['amendments']))
delete = notice['amendments'][0]
self.assertEqual(delete.action, 'DELETE')
self.assertEqual(delete.label, ['104', '13', 'b'])
开发者ID:cmc333333,项目名称:regulations-parser,代码行数:13,代码来源:notice_build_tests.py
示例17: test_process_amendments_markerless
def test_process_amendments_markerless(self):
with self.tree.builder("REGTEXT", PART="105", TITLE="12") as regtext:
regtext.AMDPAR(u"1. Revise [label:105-11-p5] as blah")
with regtext.SECTION() as section:
section.SECTNO(u"§ 105.11")
section.SUBJECT("Purpose.")
section.STARS()
section.P("Some text here")
notice = {'cfr_parts': ['105']}
build.process_amendments(notice, self.tree.render_xml())
self.assertEqual(notice['changes'].keys(), ['105-11-p5'])
changes = notice['changes']['105-11-p5'][0]
self.assertEqual(changes['action'], 'PUT')
开发者ID:theresaanna,项目名称:regulations-parser,代码行数:15,代码来源:notice_build_tests.py
示例18: test_introductory_text
def test_introductory_text(self):
""" Sometimes notices change just the introductory text of a paragraph
(instead of changing the entire paragraph tree). """
with self.tree.builder("REGTEXT", PART="106", TITLE="12") as regtext:
regtext.AMDPAR(u"3. In § 106.2, revise the introductory text to "
"read as follows:")
with regtext.SECTION() as section:
section.SECTNO(u"§ 106.2")
section.SUBJECT(" Definitions ")
section.P(" Except as otherwise provided, the following "
"apply. ")
notice = {'cfr_parts': ['106']}
build.process_amendments(notice, self.tree.render_xml())
self.assertEqual('[text]', notice['changes']['106-2'][0]['field'])
开发者ID:theresaanna,项目名称:regulations-parser,代码行数:15,代码来源:notice_build_tests.py
示例19: test_introductory_text
def test_introductory_text(self):
""" Sometimes notices change just the introductory text of a paragraph
(instead of changing the entire paragraph tree). """
with XMLBuilder("REGTEXT", PART="106", TITLE="12") as ctx:
ctx.AMDPAR(u"3. In § 106.2, revise the introductory text to read "
u"as follows:")
with ctx.SECTION():
ctx.SECTNO(u"§ 106.2")
ctx.SUBJECT(" Definitions ")
ctx.P(" Except as otherwise provided, the following apply. ")
ParseAMDPARs().transform(ctx.xml)
notice = {'cfr_parts': ['106']}
build.process_amendments(notice, ctx.xml)
self.assertEqual('[text]', notice['changes']['106-2'][0]['field'])
开发者ID:cmc333333,项目名称:regulations-parser,代码行数:15,代码来源:notice_build_tests.py
示例20: test_process_amendments_markerless
def test_process_amendments_markerless(self):
with XMLBuilder("REGTEXT", PART="105", TITLE="12") as ctx:
ctx.AMDPAR(u"1. Revise [label:105-11-p5] as blah")
with ctx.SECTION():
ctx.SECTNO(u"§ 105.11")
ctx.SUBJECT("Purpose.")
ctx.STARS()
ctx.P("Some text here")
ParseAMDPARs().transform(ctx.xml)
notice = {'cfr_parts': ['105']}
build.process_amendments(notice, ctx.xml)
self.assertItemsEqual(notice['changes'].keys(), ['105-11-p5'])
changes = notice['changes']['105-11-p5'][0]
self.assertEqual(changes['action'], 'PUT')
开发者ID:cmc333333,项目名称:regulations-parser,代码行数:16,代码来源:notice_build_tests.py
注:本文中的regparser.notice.build.process_amendments函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论