def process_titles(self, obj, node): titles = [] for elem in node.xpath('./titles/title'): text = unicode(elem.text) if elem.text else None titles.append((elem.get('type'), elem.get('as'), text)) obj.titles = titles obj.title = get_primary_bill_title(obj, titles)
def process_titles(self, obj, node): titles = [] for elem in node.xpath('./titles/title'): text = unicode(elem.text) if elem.text else None titles.append((elem.get('type') + ("-partial" if elem.get("partial") == "1" else ""), elem.get('as'), text)) obj.titles = titles # let the XML override the displayed bill number (American Memory bills) n = unicode(node.xpath('string(bill-number)')) if not n: n = None obj.title = get_primary_bill_title(obj, titles, override_number=n)
def process_titles(self, obj, node): titles = [] for elem in node.xpath('./titles/title'): text = unicode(elem.text) if elem.text else None titles.append((elem.get('type') + ("-partial" if elem.get("partial") == "1" else ""), elem.get('as'), text)) obj.titles = titles # let the XML override the displayed bill number (American Memory bills) n = unicode(node.xpath('string(bill-number)')) if not n: n = None obj.title = get_primary_bill_title(obj, titles, override_number=n)
def test_title_calculation(self): bill = BillMockup(congress=112, bill_type=BillType.house_bill, number=525) # Simple test titles = (('short', 'abc', 'title1'),) self.assertEqual('H.R. 525: title1', get_primary_bill_title(bill, titles)) # Should be first title amoung titles with as="abc" titles = (('short', 'abc', 'title1'), ('short', 'abc', 'title2')) self.assertEqual('H.R. 525: title1', get_primary_bill_title(bill, titles)) # Should be title with short type titles = (('popular', 'abc', 'title1'), ('short', 'abc', 'title2')) self.assertEqual('H.R. 525: title2', get_primary_bill_title(bill, titles)) # Should be title with short type titles = (('popular', 'abc', 'title1'), ('short', 'abc', 'title2'), ('short', 'abc', 'title3')) self.assertEqual('H.R. 525: title2', get_primary_bill_title(bill, titles)) # Should be first title in group of title with as=abc2 titles = (('short', 'abc', 'title1'), ('short', 'abc', 'title2'), ('short', 'abc2', 'title3'), ('short', 'abc2', 'title4')) self.assertEqual('H.R. 525: title3', get_primary_bill_title(bill, titles)) # Should be title with official type titles = (('short', 'abc', 'title1'), ('official', 'abc', 'title2')) self.assertEqual('title2', get_secondary_bill_title(bill, titles)) # Should be None titles = (('official', 'abc', 'title2'),) self.assertEqual(None, get_secondary_bill_title(bill, titles))
def title_no_number(self): """The title of the bill without the number.""" return get_primary_bill_title(self, self.titles, with_number=False)