Example #1
0
    def test_chunk(self):
        content = io.StringIO("Iñtërnâtiônàližætiøn")
        nt.assert_equal("Iñtër", next(ft.chunk(content, 5)))
        nt.assert_equal("nâtiônàližætiøn", next(ft.chunk(content)))

        url = "http://google.com"
        body = '<!doctype html><html itemtype="http://schema.org/page">'
        responses.add(responses.GET, url=url, body=body)
        r = requests.get(url, stream=True)

        # http://docs.python-requests.org/en/latest/api/
        # The chunk size is the number of bytes it should read into
        # memory. This is not necessarily the length of each item returned
        # as decoding can take place.
        nt.assert_equal(20, len(next(ft.chunk(r.iter_content, 20, 29, 200))))
        nt.assert_equal(55, len(next(ft.chunk(r.iter_content))))
Example #2
0
    def gen_groups(self, records, chunksize=None):
        """Generate the QIF groups"""
        for chnk in chunk(records, chunksize):
            keyfunc = self.id if self.is_split else self.account

            for gee in group(chnk, keyfunc):
                yield gee
Example #3
0
    def test_chunk(self):
        content = io.StringIO('Iñtërnâtiônàližætiøn')
        nt.assert_equal('Iñtër', next(ft.chunk(content, 5)))
        nt.assert_equal('nâtiônàližætiøn', next(ft.chunk(content)))

        url = 'http://google.com'
        body = '<!doctype html><html itemtype="http://schema.org/page">'
        responses.add(responses.GET, url=url, body=body)
        r = requests.get(url, stream=True)

        # http://docs.python-requests.org/en/latest/api/
        # The chunk size is the number of bytes it should read into
        # memory. This is not necessarily the length of each item returned
        # as decoding can take place.
        nt.assert_equal(20, len(next(ft.chunk(r.iter_content, 20, 29, 200))))
        nt.assert_equal(55, len(next(ft.chunk(r.iter_content))))
Example #4
0
    def gen_groups(self, records, chunksize=None):
        """ Generate the QIF groups """
        for chnk in chunk(records, chunksize):
            keyfunc = self.id if self.is_split else self.account

            for gee in group(chnk, keyfunc):
                yield gee
Example #5
0
    def gen_groups(self, records, chunksize=None):
        for chnk in chunk(records, chunksize):
            cleansed = [
                {k: next(xmlize([v])) for k, v in c.items()} for c in chnk]
            keyfunc = self.id if self.is_split else self.account

            for g in group(cleansed, keyfunc):
                yield g
Example #6
0
    def gen_groups(self, records, chunksize=None):
        """ Generate the OFX groups """
        for chnk in chunk(records, chunksize):
            cleansed = [
                {k: next(xmlize([v])) for k, v in c.items()} for c in chnk]
            keyfunc = self.id if self.is_split else self.account

            for gee in group(cleansed, keyfunc):
                yield gee