Esempio n. 1
0
    def test_zu2(self):
        def parse_time(s):
            return time.strptime(s, '%m/%d/%Y %H%M')

        def key_func(s):
            time_s = ' '.join(s.split(',', 3)[:2])
            return parse_time(time_s)

        io = StringIO.StringIO(ZU2)
        sortedfile.bisect_seek_left(io, parse_time('10/01/2004 0952'),
            key=key_func)
        self.assertEqual([], list(io))

        it = sortedfile.iter_inclusive(io,
            x=parse_time('09/30/2002 0328'),
            y=parse_time('09/30/2002 0332'),
            key=key_func)
        self.assertEqual(5, len(list(it)))
Esempio n. 2
0
    def test_zu2(self):
        def parse_time(s):
            return time.strptime(s, '%m/%d/%Y %H%M')

        def key_func(s):
            time_s = ' '.join(s.split(',', 3)[:2])
            return parse_time(time_s)

        io = StringIO.StringIO(ZU2)
        sortedfile.bisect_seek_left(io,
                                    parse_time('10/01/2004 0952'),
                                    key=key_func)
        self.assertEqual([], list(io))

        it = sortedfile.iter_inclusive(io,
                                       x=parse_time('09/30/2002 0328'),
                                       y=parse_time('09/30/2002 0332'),
                                       key=key_func)
        self.assertEqual(5, len(list(it)))
Esempio n. 3
0
 def test(n, x):
     sortedfile.bisect_seek_left(io, x, key=int)
     self.assertEqual(n, io.tell())
Esempio n. 4
0
 def test(n, x):
     sortedfile.bisect_seek_left(io, x, key=int)
     self.assertEqual(n, io.tell())