Exemplo n.º 1
0
 def __init__(self, block_size, channel_config, output_location):
     self.seen_rows = 0
     #Accumulators bypassed if we are just doing single values
     if block_size == 1:
         channel_config = copy.deepcopy(channel_config)
         channel_config['accumulators'] = ['LastVal']
     self.block_size = block_size
     self.accumulators = [accumulators(accum) for accum in channel_config['accumulators']]
     self.encoder = encoders(channel_config['encoder'])
     self.encoder.start(output_location, channel_config, block_size)
Exemplo n.º 2
0
    def testFixedLengthB64(self):
        e = encoders({'FixedLengthB64':{'length':3, 'range':[0,100]}})
        e.start(self.my_dir, {'name':'quango', 'accumulators':['Bob', 'Bill']}, 42)
        e.write([1,2,3])
        e.write([4,5,float('nan')])
        e.write([-20,500,None, float('Inf'), float('-Inf')])
        e.finish()
        self.assertFileExists('quango_00000042.data')
        self.assertFileContents(
            "Ao9BR7B64Cj1DMz~~~AAA--2~~~~~~~~~",
            'quango_00000042.data')
        self.assertFileExists('quango_00000042.yaml')
        self.assertFileContents(
            """accumulators: [Bob, Bill]
block_size: 42
name: quango
""",
            'quango_00000042.yaml')
Exemplo n.º 3
0
    def testTabDelimited(self):
        e = encoders('TabDelimited')
        e.start(self.my_dir, {'name':'quango', 'accumulators':['Bob', 'Bill']}, 42)
        e.write([1,2,3])
        e.write([4,5,None])
        e.finish()
        self.assertFileExists('quango_00000042.data')
        self.assertFileContents(
        """Bob	Bill
1	2	3
4	5	None
""",
            'quango_00000042.data')
        self.assertFileExists('quango_00000042.yaml')
        self.assertFileContents(
        """accumulators: [Bob, Bill]
block_size: 42
name: quango
""",
        'quango_00000042.yaml')
Exemplo n.º 4
0
 def test_dynamic_load(self):
     e = encoders('TabDelimited')
     self.assertEqual(type(e), encoders.TabDelimited)
     e = encoders({'TabDelimited':{'test':'foobar'}})
     self.assertEqual(e.test, 'foobar')