示例#1
0
 def test_nwise(self):
     """ Test take n. """
     self.assertEquals([(0, ), (1, ), (2, ), (3, )],
                       list(nwise(range(4), n=1)))
     self.assertEquals([(0, 1), (2, 3)], list(nwise(range(4))))
     self.assertEquals([(0, 1, 2), (3, )], list(nwise(range(4), n=3)))
     self.assertEquals([(0, 1, 2, 3)], list(nwise(range(4), n=4)))
示例#2
0
    def run(self):
        _, stopover = tempfile.mkstemp(prefix='siskin-')
        with self.input().open() as handle:
            groups = itertools.groupby(handle.iter_tsv(cols=('archive', 'member')), lambda row: row.archive)
            for archive, items in groups:
                for chunk in nwise(items, n=self.batch):
                    margs = " ".join(["'%s'" % item.member.replace('[', r'\[').replace(']', r'\]') for item in chunk])
                    shellout("unzip -qq -c {archive} {members} >> {output}", archive=archive, members=margs, output=stopover)

        luigi.File(stopover).move(self.output().path)
示例#3
0
 def test_nwise(self):
     """ Test take n. """
     self.assertEquals([(0,), (1,), (2,), (3,)], list(nwise(range(4), n=1)))
     self.assertEquals([(0, 1), (2, 3)], list(nwise(range(4))))
     self.assertEquals([(0, 1, 2), (3,)], list(nwise(range(4), n=3)))
     self.assertEquals([(0, 1, 2, 3)], list(nwise(range(4), n=4)))