コード例 #1
0
ファイル: ga.py プロジェクト: m4h7/juriscraper
 def _get_case_dates(self):
     case_dates = []
     for e in self.html.xpath(self.base_path):
         s = ' '.join(e.xpath(".//text()"))
         case_date = parse_dates(s)[0]
         case_dates.extend([case_date] * int(e.xpath("count(./following::ul[1]//li)")))
     return case_dates
コード例 #2
0
 def _get_case_dates(self):
     case_dates = []
     for e in self.html.xpath(self.base_path):
         s = ' '.join(e.xpath(".//text()"))
         case_date = parse_dates(s)[0]
         case_dates.extend([case_date] *
                           int(e.xpath("count(./following::ul[1]//li)")))
     return case_dates
コード例 #3
0
 def test_various_date_extractions(self):
     test_pairs = (
         # Dates separated by semicolons and JUMP words
         ('February 5, 1980; March 14, 1980 and May 28, 1980.', [
             datetime.datetime(1980, 2, 5, 0, 0),
             datetime.datetime(1980, 3, 14, 0, 0),
             datetime.datetime(1980, 5, 28, 0, 0)
         ]),
         # Misspelled month value.
         ('Febraury 17, 1945', [datetime.datetime(1945, 2, 17, 0, 0)]),
         ('Sepetmber 19 1924', [datetime.datetime(1924, 9, 19)]),
         # Using 'Term' as an indicator.
         ('November Term 2004.', [datetime.datetime(2004, 11, 01)]),
         (u'April 26, 1961.[†]', [datetime.datetime(1961, 4, 26)]),
     )
     for pair in test_pairs:
         dates = parse_dates(pair[0])
         self.assertEqual(dates, pair[1])
コード例 #4
0
ファイル: tests.py プロジェクト: UIKit0/juriscraper
 def test_various_date_extractions(self):
     test_pairs = (
         # Dates separated by semicolons and JUMP words
         ('February 5, 1980; March 14, 1980 and May 28, 1980.',
          [datetime.datetime(1980, 2, 5, 0, 0),
           datetime.datetime(1980, 3, 14, 0, 0),
           datetime.datetime(1980, 5, 28, 0, 0)]),
         # Misspelled month value.
         ('Febraury 17, 1945',
          [datetime.datetime(1945, 2, 17, 0, 0)]),
         ('Sepetmber 19 1924',
          [datetime.datetime(1924, 9, 19)]),
         # Using 'Term' as an indicator.
         ('November Term 2004.',
          [datetime.datetime(2004, 11, 01)]),
         (u'April 26, 1961.[†]',
          [datetime.datetime(1961, 4, 26)]),
     )
     for pair in test_pairs:
         dates = parse_dates(pair[0])
         self.assertEqual(dates, pair[1])