Esempio n. 1
0
 def test_guess_format(self):
     formats = [
         ('x.csv', 'csv'),
         ('z.json', 'json'),
         ('x.csv.xz', 'xz'),
         ('x.csv.gz', 'gz'),
         ('x.csv.bz2', 'bz2'),
         ('xy.zip', 'zip'),
         ('xy.7z', '7z'),
         ('xy.tar', 'tar'),
         ('xy.rar', 'rar'),
         ('xy.db', 'sqlite3'),
         ('xy.xlsx', 'xlsx'),
         ('y.h5', 'hdf5'),
     ]
     for path, fmt in formats:
         eq_(meta.guess_format(path), fmt)
         eq_(meta.guess_format(path, True), fmt)
Esempio n. 2
0
 def test_guess_format(self):
     formats = [
         ('x.csv', 'csv'),
         ('z.json', 'json'),
         ('x.csv.xz', 'xz'),
         ('x.csv.gz', 'gz'),
         ('x.csv.bz2', 'bz2'),
         ('xy.zip', 'zip'),
         ('xy.7z', '7z'),
         ('xy.tar', 'tar'),
         ('xy.rar', 'rar'),
         ('xy.db', 'sqlite3'),
         ('xy.xlsx', 'xlsx'),
         ('y.h5', 'hdf5'),
     ]
     for path, fmt in formats:
         eq_(meta.guess_format(path), fmt)
         eq_(meta.guess_format(path, True), fmt)
Esempio n. 3
0
 def test_extract_archive(self):
     mapping = [
         ({'xy.zip', 'xy.7z', 'xy.rar', 'xy.tar'}, {'x.csv', 'y.csv', 'z.json'}),
         ({'x.csv.xz', 'x.csv.gz', 'x.csv.bz2'}, {'x.csv'}),
         ({'xy.tar.xz', 'xy.tar.gz', 'xy.tar.bz2'}, {'xy.tar'}),
     ]
     for archives, files in mapping:
         for archive in archives:
             target = meta.filename(archive, self.root)
             meta.extract_archive(archive, target, meta.guess_format(archive))
             eq_(set(os.listdir(target)), files)
Esempio n. 4
0
 def test_extract_archive(self):
     mapping = [
         ({'xy.zip', 'xy.7z', 'xy.rar',
           'xy.tar'}, {'x.csv', 'y.csv', 'z.json'}),
         ({'x.csv.xz', 'x.csv.gz', 'x.csv.bz2'}, {'x.csv'}),
         ({'xy.tar.xz', 'xy.tar.gz', 'xy.tar.bz2'}, {'xy.tar'}),
     ]
     for archives, files in mapping:
         for archive in archives:
             target = meta.filename(archive, self.root)
             meta.extract_archive(archive, target,
                                  meta.guess_format(archive))
             eq_(set(os.listdir(target)), files)