How to use zip method in Playwright Python

Best Python code snippet using playwright-python

test_zipfile.py

Source:test_zipfile.py Github

copy

Full Screen

...80 info = zipfp.getinfo(nm)81 self.assertEqual(info.filename, nm)82 self.assertEqual(info.file_size, len(self.data))83 # Check that testzip doesn't raise an exception84 zipfp.testzip()85 if not isinstance(f, str):86 f.close()87 def test_stored(self):88 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):89 self.zip_test(f, zipfile.ZIP_STORED)90 def zip_open_test(self, f, compression):91 self.make_test_archive(f, compression)92 # Read the ZIP archive93 with zipfile.ZipFile(f, "r", compression) as zipfp:94 zipdata1 = []95 with zipfp.open(TESTFN) as zipopen1:96 while True:97 read_data = zipopen1.read(256)98 if not read_data:99 break100 zipdata1.append(read_data)101 zipdata2 = []102 with zipfp.open("another.name") as zipopen2:103 while True:104 read_data = zipopen2.read(256)105 if not read_data:106 break107 zipdata2.append(read_data)108 self.assertEqual(b''.join(zipdata1), self.data)109 self.assertEqual(b''.join(zipdata2), self.data)110 if not isinstance(f, str):111 f.close()112 def test_open_stored(self):113 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):114 self.zip_open_test(f, zipfile.ZIP_STORED)115 def test_open_via_zip_info(self):116 # Create the ZIP archive117 with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp:118 zipfp.writestr("name", "foo")119 zipfp.writestr("name", "bar")120 with zipfile.ZipFile(TESTFN2, "r") as zipfp:121 infos = zipfp.infolist()122 data = b""123 for info in infos:124 with zipfp.open(info) as zipopen:125 data += zipopen.read()126 self.assertTrue(data == b"foobar" or data == b"barfoo")127 data = b""128 for info in infos:129 data += zipfp.read(info)130 self.assertTrue(data == b"foobar" or data == b"barfoo")131 def zip_random_open_test(self, f, compression):132 self.make_test_archive(f, compression)133 # Read the ZIP archive134 with zipfile.ZipFile(f, "r", compression) as zipfp:135 zipdata1 = []136 with zipfp.open(TESTFN) as zipopen1:137 while True:138 read_data = zipopen1.read(randint(1, 1024))139 if not read_data:140 break141 zipdata1.append(read_data)142 self.assertEqual(b''.join(zipdata1), self.data)143 if not isinstance(f, str):144 f.close()145 def test_random_open_stored(self):146 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):147 self.zip_random_open_test(f, zipfile.ZIP_STORED)148 def test_univeral_readaheads(self):149 f = io.BytesIO()150 data = b'a\r\n' * 16 * 1024151 zipfp = zipfile.ZipFile(f, 'w', zipfile.ZIP_STORED)152 zipfp.writestr(TESTFN, data)153 zipfp.close()154 data2 = b''155 zipfp = zipfile.ZipFile(f, 'r')156 with zipfp.open(TESTFN, 'rU') as zipopen:157 for line in zipopen:158 data2 += line159 zipfp.close()160 self.assertEqual(data, data2.replace(b'\n', b'\r\n'))161 def zip_readline_read_test(self, f, compression):162 self.make_test_archive(f, compression)163 # Read the ZIP archive164 zipfp = zipfile.ZipFile(f, "r")165 with zipfp.open(TESTFN) as zipopen:166 data = b''167 while True:168 read = zipopen.readline()169 if not read:170 break171 data += read172 read = zipopen.read(100)173 if not read:174 break175 data += read176 self.assertEqual(data, self.data)177 zipfp.close()178 if not isinstance(f, str):179 f.close()180 def zip_readline_test(self, f, compression):181 self.make_test_archive(f, compression)182 # Read the ZIP archive183 with zipfile.ZipFile(f, "r") as zipfp:184 with zipfp.open(TESTFN) as zipopen:185 for line in self.line_gen:186 linedata = zipopen.readline()187 self.assertEqual(linedata, line + '\n')188 if not isinstance(f, str):189 f.close()190 def zip_readlines_test(self, f, compression):191 self.make_test_archive(f, compression)192 # Read the ZIP archive193 with zipfile.ZipFile(f, "r") as zipfp:194 with zipfp.open(TESTFN) as zipopen:195 ziplines = zipopen.readlines()196 for line, zipline in zip(self.line_gen, ziplines):197 self.assertEqual(zipline, line + '\n')198 if not isinstance(f, str):199 f.close()200 def zip_iterlines_test(self, f, compression):201 self.make_test_archive(f, compression)202 # Read the ZIP archive203 with zipfile.ZipFile(f, "r") as zipfp:204 with zipfp.open(TESTFN) as zipopen:205 for line, zipline in zip(self.line_gen, zipopen):206 self.assertEqual(zipline, line + '\n')207 if not isinstance(f, str):208 f.close()209 def test_readline_read_stored(self):210 # Issue #7610: calls to readline() interleaved with calls to read().211 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):212 self.zip_readline_read_test(f, zipfile.ZIP_STORED)213 def test_readline_stored(self):214 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):215 self.zip_readline_test(f, zipfile.ZIP_STORED)216 def test_readlines_stored(self):217 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):218 self.zip_readlines_test(f, zipfile.ZIP_STORED)219 def test_iterlines_stored(self):220 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):221 self.zip_iterlines_test(f, zipfile.ZIP_STORED)222 @skipUnless(zlib, "requires zlib")223 def test_deflated(self):224 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):225 self.zip_test(f, zipfile.ZIP_DEFLATED)226 @skipUnless(zlib, "requires zlib")227 def test_open_deflated(self):228 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):229 self.zip_open_test(f, zipfile.ZIP_DEFLATED)230 @skipUnless(zlib, "requires zlib")231 def test_random_open_deflated(self):232 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):233 self.zip_random_open_test(f, zipfile.ZIP_DEFLATED)234 @skipUnless(zlib, "requires zlib")235 def test_readline_read_deflated(self):236 # Issue #7610: calls to readline() interleaved with calls to read().237 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):238 self.zip_readline_read_test(f, zipfile.ZIP_DEFLATED)239 @skipUnless(zlib, "requires zlib")240 def test_readline_deflated(self):241 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):242 self.zip_readline_test(f, zipfile.ZIP_DEFLATED)243 @skipUnless(zlib, "requires zlib")244 def test_readlines_deflated(self):245 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):246 self.zip_readlines_test(f, zipfile.ZIP_DEFLATED)247 @skipUnless(zlib, "requires zlib")248 def test_iterlines_deflated(self):249 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):250 self.zip_iterlines_test(f, zipfile.ZIP_DEFLATED)251 @skipUnless(zlib, "requires zlib")252 def test_low_compression(self):253 """Check for cases where compressed data is larger than original."""254 # Create the ZIP archive255 with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_DEFLATED) as zipfp:256 zipfp.writestr("strfile", '12')257 # Get an open object for strfile258 with zipfile.ZipFile(TESTFN2, "r", zipfile.ZIP_DEFLATED) as zipfp:259 with zipfp.open("strfile") as openobj:260 self.assertEqual(openobj.read(1), b'1')261 self.assertEqual(openobj.read(1), b'2')262 def test_absolute_arcnames(self):263 with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp:264 zipfp.write(TESTFN, "/absolute")265 with zipfile.ZipFile(TESTFN2, "r", zipfile.ZIP_STORED) as zipfp:266 self.assertEqual(zipfp.namelist(), ["absolute"])267 def test_append_to_zip_file(self):268 """Test appending to an existing zipfile."""269 with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp:270 zipfp.write(TESTFN, TESTFN)271 with zipfile.ZipFile(TESTFN2, "a", zipfile.ZIP_STORED) as zipfp:272 zipfp.writestr("strfile", self.data)273 self.assertEqual(zipfp.namelist(), [TESTFN, "strfile"])274 def test_append_to_non_zip_file(self):275 """Test appending to an existing file that is not a zipfile."""276 # NOTE: this test fails if len(d) < 22 because of the first277 # line "fpin.seek(-22, 2)" in _EndRecData278 data = b'I am not a ZipFile!'*10279 with open(TESTFN2, 'wb') as f:280 f.write(data)281 with zipfile.ZipFile(TESTFN2, "a", zipfile.ZIP_STORED) as zipfp:282 zipfp.write(TESTFN, TESTFN)283 with open(TESTFN2, 'rb') as f:284 f.seek(len(data))285 with zipfile.ZipFile(f, "r") as zipfp:286 self.assertEqual(zipfp.namelist(), [TESTFN])287 def test_write_default_name(self):288 """Check that calling ZipFile.write without arcname specified289 produces the expected result."""290 with zipfile.ZipFile(TESTFN2, "w") as zipfp:291 zipfp.write(TESTFN)292 with open(TESTFN, "rb") as f:293 self.assertEqual(zipfp.read(TESTFN), f.read())294 @skipUnless(zlib, "requires zlib")295 def test_per_file_compression(self):296 """Check that files within a Zip archive can have different297 compression options."""298 with zipfile.ZipFile(TESTFN2, "w") as zipfp:299 zipfp.write(TESTFN, 'storeme', zipfile.ZIP_STORED)300 zipfp.write(TESTFN, 'deflateme', zipfile.ZIP_DEFLATED)301 sinfo = zipfp.getinfo('storeme')302 dinfo = zipfp.getinfo('deflateme')303 self.assertEqual(sinfo.compress_type, zipfile.ZIP_STORED)304 self.assertEqual(dinfo.compress_type, zipfile.ZIP_DEFLATED)305 def test_write_to_readonly(self):306 """Check that trying to call write() on a readonly ZipFile object307 raises a RuntimeError."""308 with zipfile.ZipFile(TESTFN2, mode="w") as zipfp:309 zipfp.writestr("somefile.txt", "bogus")310 with zipfile.ZipFile(TESTFN2, mode="r") as zipfp:311 self.assertRaises(RuntimeError, zipfp.write, TESTFN)312 def test_extract(self):313 with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp:314 for fpath, fdata in SMALL_TEST_DATA:315 zipfp.writestr(fpath, fdata)316 with zipfile.ZipFile(TESTFN2, "r") as zipfp:317 for fpath, fdata in SMALL_TEST_DATA:318 writtenfile = zipfp.extract(fpath)319 # make sure it was written to the right place320 if os.path.isabs(fpath):321 correctfile = os.path.join(os.getcwd(), fpath[1:])322 else:323 correctfile = os.path.join(os.getcwd(), fpath)324 correctfile = os.path.normpath(correctfile)325 self.assertEqual(writtenfile, correctfile)326 # make sure correct data is in correct file327 with open(writtenfile, "rb") as f:328 self.assertEqual(fdata.encode(), f.read())329 os.remove(writtenfile)330 # remove the test file subdirectories331 shutil.rmtree(os.path.join(os.getcwd(), 'ziptest2dir'))332 def test_extract_all(self):333 with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp:334 for fpath, fdata in SMALL_TEST_DATA:335 zipfp.writestr(fpath, fdata)336 with zipfile.ZipFile(TESTFN2, "r") as zipfp:337 zipfp.extractall()338 for fpath, fdata in SMALL_TEST_DATA:339 if os.path.isabs(fpath):340 outfile = os.path.join(os.getcwd(), fpath[1:])341 else:342 outfile = os.path.join(os.getcwd(), fpath)343 with open(outfile, "rb") as f:344 self.assertEqual(fdata.encode(), f.read())345 os.remove(outfile)346 # remove the test file subdirectories347 shutil.rmtree(os.path.join(os.getcwd(), 'ziptest2dir'))348 def test_writestr_compression(self):349 zipfp = zipfile.ZipFile(TESTFN2, "w")350 zipfp.writestr("a.txt", "hello world", compress_type=zipfile.ZIP_STORED)351 if zlib:352 zipfp.writestr("b.txt", "hello world", compress_type=zipfile.ZIP_DEFLATED)353 info = zipfp.getinfo('a.txt')354 self.assertEqual(info.compress_type, zipfile.ZIP_STORED)355 if zlib:356 info = zipfp.getinfo('b.txt')357 self.assertEqual(info.compress_type, zipfile.ZIP_DEFLATED)358 def zip_test_writestr_permissions(self, f, compression):359 # Make sure that writestr creates files with mode 0600,360 # when it is passed a name rather than a ZipInfo instance.361 self.make_test_archive(f, compression)362 with zipfile.ZipFile(f, "r") as zipfp:363 zinfo = zipfp.getinfo('strfile')364 self.assertEqual(zinfo.external_attr, 0o600 << 16)365 if not isinstance(f, str):366 f.close()367 def test_writestr_permissions(self):368 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):369 self.zip_test_writestr_permissions(f, zipfile.ZIP_STORED)370 def test_writestr_extended_local_header_issue1202(self):371 with zipfile.ZipFile(TESTFN2, 'w') as orig_zip:372 for data in 'abcdefghijklmnop':373 zinfo = zipfile.ZipInfo(data)374 zinfo.flag_bits |= 0x08 # Include an extended local header.375 orig_zip.writestr(zinfo, data)376 def test_close(self):377 """Check that the zipfile is closed after the 'with' block."""378 with zipfile.ZipFile(TESTFN2, "w") as zipfp:379 for fpath, fdata in SMALL_TEST_DATA:380 zipfp.writestr(fpath, fdata)381 self.assertTrue(zipfp.fp is not None, 'zipfp is not open')382 self.assertTrue(zipfp.fp is None, 'zipfp is not closed')383 with zipfile.ZipFile(TESTFN2, "r") as zipfp:384 self.assertTrue(zipfp.fp is not None, 'zipfp is not open')385 self.assertTrue(zipfp.fp is None, 'zipfp is not closed')386 def test_close_on_exception(self):387 """Check that the zipfile is closed if an exception is raised in the388 'with' block."""389 with zipfile.ZipFile(TESTFN2, "w") as zipfp:390 for fpath, fdata in SMALL_TEST_DATA:391 zipfp.writestr(fpath, fdata)392 try:393 with zipfile.ZipFile(TESTFN2, "r") as zipfp2:394 raise zipfile.BadZipFile()395 except zipfile.BadZipFile:396 self.assertTrue(zipfp2.fp is None, 'zipfp is not closed')397 def test_unicode_filenames(self):398 # bug #10801399 fname = findfile('zip_cp437_header.zip')400 with zipfile.ZipFile(fname) as zipfp:401 for name in zipfp.namelist():402 zipfp.open(name).close()403 def tearDown(self):404 unlink(TESTFN)405 unlink(TESTFN2)406class TestZip64InSmallFiles(unittest.TestCase):407 # These tests test the ZIP64 functionality without using large files,408 # see test_zipfile64 for proper tests.409 def setUp(self):410 self._limit = zipfile.ZIP64_LIMIT411 zipfile.ZIP64_LIMIT = 5412 line_gen = (bytes("Test of zipfile line %d." % i, "ascii")413 for i in range(0, FIXEDTEST_SIZE))414 self.data = b'\n'.join(line_gen)415 # Make a source file with some lines416 with open(TESTFN, "wb") as fp:417 fp.write(self.data)418 def large_file_exception_test(self, f, compression):419 with zipfile.ZipFile(f, "w", compression) as zipfp:420 self.assertRaises(zipfile.LargeZipFile,421 zipfp.write, TESTFN, "another.name")422 def large_file_exception_test2(self, f, compression):423 with zipfile.ZipFile(f, "w", compression) as zipfp:424 self.assertRaises(zipfile.LargeZipFile,425 zipfp.writestr, "another.name", self.data)426 if not isinstance(f, str):427 f.close()428 def test_large_file_exception(self):429 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):430 self.large_file_exception_test(f, zipfile.ZIP_STORED)431 self.large_file_exception_test2(f, zipfile.ZIP_STORED)432 def zip_test(self, f, compression):433 # Create the ZIP archive434 with zipfile.ZipFile(f, "w", compression, allowZip64=True) as zipfp:435 zipfp.write(TESTFN, "another.name")436 zipfp.write(TESTFN, TESTFN)437 zipfp.writestr("strfile", self.data)438 # Read the ZIP archive439 with zipfile.ZipFile(f, "r", compression) as zipfp:440 self.assertEqual(zipfp.read(TESTFN), self.data)441 self.assertEqual(zipfp.read("another.name"), self.data)442 self.assertEqual(zipfp.read("strfile"), self.data)443 # Print the ZIP directory444 fp = io.StringIO()445 zipfp.printdir(fp)446 directory = fp.getvalue()447 lines = directory.splitlines()448 self.assertEqual(len(lines), 4) # Number of files + header449 self.assertIn('File Name', lines[0])450 self.assertIn('Modified', lines[0])451 self.assertIn('Size', lines[0])452 fn, date, time_, size = lines[1].split()453 self.assertEqual(fn, 'another.name')454 self.assertTrue(time.strptime(date, '%Y-%m-%d'))455 self.assertTrue(time.strptime(time_, '%H:%M:%S'))456 self.assertEqual(size, str(len(self.data)))457 # Check the namelist458 names = zipfp.namelist()459 self.assertEqual(len(names), 3)460 self.assertIn(TESTFN, names)461 self.assertIn("another.name", names)462 self.assertIn("strfile", names)463 # Check infolist464 infos = zipfp.infolist()465 names = [i.filename for i in infos]466 self.assertEqual(len(names), 3)467 self.assertIn(TESTFN, names)468 self.assertIn("another.name", names)469 self.assertIn("strfile", names)470 for i in infos:471 self.assertEqual(i.file_size, len(self.data))472 # check getinfo473 for nm in (TESTFN, "another.name", "strfile"):474 info = zipfp.getinfo(nm)475 self.assertEqual(info.filename, nm)476 self.assertEqual(info.file_size, len(self.data))477 # Check that testzip doesn't raise an exception478 zipfp.testzip()479 if not isinstance(f, str):480 f.close()481 def test_stored(self):482 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):483 self.zip_test(f, zipfile.ZIP_STORED)484 @skipUnless(zlib, "requires zlib")485 def test_deflated(self):486 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):487 self.zip_test(f, zipfile.ZIP_DEFLATED)488 def test_absolute_arcnames(self):489 with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED,490 allowZip64=True) as zipfp:491 zipfp.write(TESTFN, "/absolute")492 with zipfile.ZipFile(TESTFN2, "r", zipfile.ZIP_STORED) as zipfp:493 self.assertEqual(zipfp.namelist(), ["absolute"])494 def tearDown(self):495 zipfile.ZIP64_LIMIT = self._limit496 unlink(TESTFN)497 unlink(TESTFN2)498class PyZipFileTests(unittest.TestCase):499 def test_write_pyfile(self):500 with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:501 fn = __file__502 if fn.endswith('.pyc') or fn.endswith('.pyo'):503 path_split = fn.split(os.sep)504 if os.altsep is not None:505 path_split.extend(fn.split(os.altsep))506 if '__pycache__' in path_split:507 fn = imp.source_from_cache(fn)508 else:509 fn = fn[:-1]510 zipfp.writepy(fn)511 bn = os.path.basename(fn)512 self.assertNotIn(bn, zipfp.namelist())513 self.assertTrue(bn + 'o' in zipfp.namelist() or514 bn + 'c' in zipfp.namelist())515 with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:516 fn = __file__517 if fn.endswith(('.pyc', '.pyo')):518 fn = fn[:-1]519 zipfp.writepy(fn, "testpackage")520 bn = "%s/%s" % ("testpackage", os.path.basename(fn))521 self.assertNotIn(bn, zipfp.namelist())522 self.assertTrue(bn + 'o' in zipfp.namelist() or523 bn + 'c' in zipfp.namelist())524 def test_write_python_package(self):525 import email526 packagedir = os.path.dirname(email.__file__)527 with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:528 zipfp.writepy(packagedir)529 # Check for a couple of modules at different levels of the530 # hierarchy531 names = zipfp.namelist()532 self.assertTrue('email/__init__.pyo' in names or533 'email/__init__.pyc' in names)534 self.assertTrue('email/mime/text.pyo' in names or535 'email/mime/text.pyc' in names)536 def test_write_with_optimization(self):537 import email538 packagedir = os.path.dirname(email.__file__)539 # use .pyc if running test in optimization mode,540 # use .pyo if running test in debug mode541 optlevel = 1 if __debug__ else 0542 ext = '.pyo' if optlevel == 1 else '.pyc'543 with TemporaryFile() as t, \544 zipfile.PyZipFile(t, "w", optimize=optlevel) as zipfp:545 zipfp.writepy(packagedir)546 names = zipfp.namelist()547 self.assertIn('email/__init__' + ext, names)548 self.assertIn('email/mime/text' + ext, names)549 def test_write_python_directory(self):550 os.mkdir(TESTFN2)551 try:552 with open(os.path.join(TESTFN2, "mod1.py"), "w") as fp:553 fp.write("print(42)\n")554 with open(os.path.join(TESTFN2, "mod2.py"), "w") as fp:555 fp.write("print(42 * 42)\n")556 with open(os.path.join(TESTFN2, "mod2.txt"), "w") as fp:557 fp.write("bla bla bla\n")558 with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:559 zipfp.writepy(TESTFN2)560 names = zipfp.namelist()561 self.assertTrue('mod1.pyc' in names or 'mod1.pyo' in names)562 self.assertTrue('mod2.pyc' in names or 'mod2.pyo' in names)563 self.assertNotIn('mod2.txt', names)564 finally:565 shutil.rmtree(TESTFN2)566 def test_write_non_pyfile(self):567 with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:568 with open(TESTFN, 'w') as f:569 f.write('most definitely not a python file')570 self.assertRaises(RuntimeError, zipfp.writepy, TESTFN)571 os.remove(TESTFN)572class OtherTests(unittest.TestCase):573 zips_with_bad_crc = {574 zipfile.ZIP_STORED: (575 b'PK\003\004\024\0\0\0\0\0 \213\212;:r'576 b'\253\377\f\0\0\0\f\0\0\0\005\0\0\000af'577 b'ilehello,AworldP'578 b'K\001\002\024\003\024\0\0\0\0\0 \213\212;:'579 b'r\253\377\f\0\0\0\f\0\0\0\005\0\0\0\0'580 b'\0\0\0\0\0\0\0\200\001\0\0\0\000afi'581 b'lePK\005\006\0\0\0\0\001\0\001\0003\000'582 b'\0\0/\0\0\0\0\0'),583 zipfile.ZIP_DEFLATED: (584 b'PK\x03\x04\x14\x00\x00\x00\x08\x00n}\x0c=FA'585 b'KE\x10\x00\x00\x00n\x00\x00\x00\x05\x00\x00\x00af'586 b'ile\xcbH\xcd\xc9\xc9W(\xcf/\xcaI\xc9\xa0'587 b'=\x13\x00PK\x01\x02\x14\x03\x14\x00\x00\x00\x08\x00n'588 b'}\x0c=FAKE\x10\x00\x00\x00n\x00\x00\x00\x05'589 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x01\x00\x00\x00'590 b'\x00afilePK\x05\x06\x00\x00\x00\x00\x01\x00'591 b'\x01\x003\x00\x00\x003\x00\x00\x00\x00\x00'),592 }593 def test_unicode_filenames(self):594 with zipfile.ZipFile(TESTFN, "w") as zf:595 zf.writestr("foo.txt", "Test for unicode filename")596 zf.writestr("\xf6.txt", "Test for unicode filename")597 self.assertIsInstance(zf.infolist()[0].filename, str)598 with zipfile.ZipFile(TESTFN, "r") as zf:599 self.assertEqual(zf.filelist[0].filename, "foo.txt")600 self.assertEqual(zf.filelist[1].filename, "\xf6.txt")601 def test_create_non_existent_file_for_append(self):602 if os.path.exists(TESTFN):603 os.unlink(TESTFN)604 filename = 'testfile.txt'605 content = b'hello, world. this is some content.'606 try:607 with zipfile.ZipFile(TESTFN, 'a') as zf:608 zf.writestr(filename, content)609 except IOError:610 self.fail('Could not append data to a non-existent zip file.')611 self.assertTrue(os.path.exists(TESTFN))612 with zipfile.ZipFile(TESTFN, 'r') as zf:613 self.assertEqual(zf.read(filename), content)614 def test_close_erroneous_file(self):615 # This test checks that the ZipFile constructor closes the file object616 # it opens if there's an error in the file. If it doesn't, the617 # traceback holds a reference to the ZipFile object and, indirectly,618 # the file object.619 # On Windows, this causes the os.unlink() call to fail because the620 # underlying file is still open. This is SF bug #412214.621 #622 with open(TESTFN, "w") as fp:623 fp.write("this is not a legal zip file\n")624 try:625 zf = zipfile.ZipFile(TESTFN)626 except zipfile.BadZipFile:627 pass628 def test_is_zip_erroneous_file(self):629 """Check that is_zipfile() correctly identifies non-zip files."""630 # - passing a filename631 with open(TESTFN, "w") as fp:632 fp.write("this is not a legal zip file\n")633 chk = zipfile.is_zipfile(TESTFN)634 self.assertFalse(chk)635 # - passing a file object636 with open(TESTFN, "rb") as fp:637 chk = zipfile.is_zipfile(fp)638 self.assertTrue(not chk)639 # - passing a file-like object640 fp = io.BytesIO()641 fp.write(b"this is not a legal zip file\n")642 chk = zipfile.is_zipfile(fp)643 self.assertTrue(not chk)644 fp.seek(0, 0)645 chk = zipfile.is_zipfile(fp)646 self.assertTrue(not chk)647 def test_is_zip_valid_file(self):648 """Check that is_zipfile() correctly identifies zip files."""649 # - passing a filename650 with zipfile.ZipFile(TESTFN, mode="w") as zipf:651 zipf.writestr("foo.txt", b"O, for a Muse of Fire!")652 chk = zipfile.is_zipfile(TESTFN)653 self.assertTrue(chk)654 # - passing a file object655 with open(TESTFN, "rb") as fp:656 chk = zipfile.is_zipfile(fp)657 self.assertTrue(chk)658 fp.seek(0, 0)659 zip_contents = fp.read()660 # - passing a file-like object661 fp = io.BytesIO()662 fp.write(zip_contents)663 chk = zipfile.is_zipfile(fp)664 self.assertTrue(chk)665 fp.seek(0, 0)666 chk = zipfile.is_zipfile(fp)667 self.assertTrue(chk)668 def test_non_existent_file_raises_IOError(self):669 # make sure we don't raise an AttributeError when a partially-constructed670 # ZipFile instance is finalized; this tests for regression on SF tracker671 # bug #403871.672 # The bug we're testing for caused an AttributeError to be raised673 # when a ZipFile instance was created for a file that did not674 # exist; the .fp member was not initialized but was needed by the675 # __del__() method. Since the AttributeError is in the __del__(),676 # it is ignored, but the user should be sufficiently annoyed by677 # the message on the output that regression will be noticed678 # quickly.679 self.assertRaises(IOError, zipfile.ZipFile, TESTFN)680 def test_empty_file_raises_BadZipFile(self):681 f = open(TESTFN, 'w')682 f.close()683 self.assertRaises(zipfile.BadZipFile, zipfile.ZipFile, TESTFN)684 with open(TESTFN, 'w') as fp:685 fp.write("short file")686 self.assertRaises(zipfile.BadZipFile, zipfile.ZipFile, TESTFN)687 def test_closed_zip_raises_RuntimeError(self):688 """Verify that testzip() doesn't swallow inappropriate exceptions."""689 data = io.BytesIO()690 with zipfile.ZipFile(data, mode="w") as zipf:691 zipf.writestr("foo.txt", "O, for a Muse of Fire!")692 # This is correct; calling .read on a closed ZipFile should throw693 # a RuntimeError, and so should calling .testzip. An earlier694 # version of .testzip would swallow this exception (and any other)695 # and report that the first file in the archive was corrupt.696 self.assertRaises(RuntimeError, zipf.read, "foo.txt")697 self.assertRaises(RuntimeError, zipf.open, "foo.txt")698 self.assertRaises(RuntimeError, zipf.testzip)699 self.assertRaises(RuntimeError, zipf.writestr, "bogus.txt", "bogus")700 with open(TESTFN, 'w') as f:701 f.write('zipfile test data')702 self.assertRaises(RuntimeError, zipf.write, TESTFN)703 def test_bad_constructor_mode(self):704 """Check that bad modes passed to ZipFile constructor are caught."""705 self.assertRaises(RuntimeError, zipfile.ZipFile, TESTFN, "q")706 def test_bad_open_mode(self):707 """Check that bad modes passed to ZipFile.open are caught."""708 with zipfile.ZipFile(TESTFN, mode="w") as zipf:709 zipf.writestr("foo.txt", "O, for a Muse of Fire!")710 with zipfile.ZipFile(TESTFN, mode="r") as zipf:711 # read the data to make sure the file is there712 zipf.read("foo.txt")713 self.assertRaises(RuntimeError, zipf.open, "foo.txt", "q")714 def test_read0(self):715 """Check that calling read(0) on a ZipExtFile object returns an empty716 string and doesn't advance file pointer."""717 with zipfile.ZipFile(TESTFN, mode="w") as zipf:718 zipf.writestr("foo.txt", "O, for a Muse of Fire!")719 # read the data to make sure the file is there720 with zipf.open("foo.txt") as f:721 for i in range(FIXEDTEST_SIZE):722 self.assertEqual(f.read(0), b'')723 self.assertEqual(f.read(), b"O, for a Muse of Fire!")724 def test_open_non_existent_item(self):725 """Check that attempting to call open() for an item that doesn't726 exist in the archive raises a RuntimeError."""727 with zipfile.ZipFile(TESTFN, mode="w") as zipf:728 self.assertRaises(KeyError, zipf.open, "foo.txt", "r")729 def test_bad_compression_mode(self):730 """Check that bad compression methods passed to ZipFile.open are731 caught."""732 self.assertRaises(RuntimeError, zipfile.ZipFile, TESTFN, "w", -1)733 def test_null_byte_in_filename(self):734 """Check that a filename containing a null byte is properly735 terminated."""736 with zipfile.ZipFile(TESTFN, mode="w") as zipf:737 zipf.writestr("foo.txt\x00qqq", b"O, for a Muse of Fire!")738 self.assertEqual(zipf.namelist(), ['foo.txt'])739 def test_struct_sizes(self):740 """Check that ZIP internal structure sizes are calculated correctly."""741 self.assertEqual(zipfile.sizeEndCentDir, 22)742 self.assertEqual(zipfile.sizeCentralDir, 46)743 self.assertEqual(zipfile.sizeEndCentDir64, 56)744 self.assertEqual(zipfile.sizeEndCentDir64Locator, 20)745 def test_comments(self):746 """Check that comments on the archive are handled properly."""747 # check default comment is empty748 with zipfile.ZipFile(TESTFN, mode="w") as zipf:749 self.assertEqual(zipf.comment, b'')750 zipf.writestr("foo.txt", "O, for a Muse of Fire!")751 with zipfile.ZipFile(TESTFN, mode="r") as zipfr:752 self.assertEqual(zipfr.comment, b'')753 # check a simple short comment754 comment = b'Bravely taking to his feet, he beat a very brave retreat.'755 with zipfile.ZipFile(TESTFN, mode="w") as zipf:756 zipf.comment = comment757 zipf.writestr("foo.txt", "O, for a Muse of Fire!")758 with zipfile.ZipFile(TESTFN, mode="r") as zipfr:759 self.assertEqual(zipf.comment, comment)760 # check a comment of max length761 comment2 = ''.join(['%d' % (i**3 % 10) for i in range((1 << 16)-1)])762 comment2 = comment2.encode("ascii")763 with zipfile.ZipFile(TESTFN, mode="w") as zipf:764 zipf.comment = comment2765 zipf.writestr("foo.txt", "O, for a Muse of Fire!")766 with zipfile.ZipFile(TESTFN, mode="r") as zipfr:767 self.assertEqual(zipfr.comment, comment2)768 # check a comment that is too long is truncated769 with zipfile.ZipFile(TESTFN, mode="w") as zipf:770 zipf.comment = comment2 + b'oops'771 zipf.writestr("foo.txt", "O, for a Muse of Fire!")772 with zipfile.ZipFile(TESTFN, mode="r") as zipfr:773 self.assertEqual(zipfr.comment, comment2)774 def check_testzip_with_bad_crc(self, compression):775 """Tests that files with bad CRCs return their name from testzip."""776 zipdata = self.zips_with_bad_crc[compression]777 with zipfile.ZipFile(io.BytesIO(zipdata), mode="r") as zipf:778 # testzip returns the name of the first corrupt file, or None779 self.assertEqual('afile', zipf.testzip())780 def test_testzip_with_bad_crc_stored(self):781 self.check_testzip_with_bad_crc(zipfile.ZIP_STORED)782 @skipUnless(zlib, "requires zlib")783 def test_testzip_with_bad_crc_deflated(self):784 self.check_testzip_with_bad_crc(zipfile.ZIP_DEFLATED)785 def check_read_with_bad_crc(self, compression):786 """Tests that files with bad CRCs raise a BadZipFile exception when read."""787 zipdata = self.zips_with_bad_crc[compression]788 # Using ZipFile.read()789 with zipfile.ZipFile(io.BytesIO(zipdata), mode="r") as zipf:790 self.assertRaises(zipfile.BadZipFile, zipf.read, 'afile')791 # Using ZipExtFile.read()792 with zipfile.ZipFile(io.BytesIO(zipdata), mode="r") as zipf:793 with zipf.open('afile', 'r') as corrupt_file:794 self.assertRaises(zipfile.BadZipFile, corrupt_file.read)795 # Same with small reads (in order to exercise the buffering logic)796 with zipfile.ZipFile(io.BytesIO(zipdata), mode="r") as zipf:797 with zipf.open('afile', 'r') as corrupt_file:798 corrupt_file.MIN_READ_SIZE = 2799 with self.assertRaises(zipfile.BadZipFile):800 while corrupt_file.read(2):801 pass802 def test_read_with_bad_crc_stored(self):803 self.check_read_with_bad_crc(zipfile.ZIP_STORED)804 @skipUnless(zlib, "requires zlib")805 def test_read_with_bad_crc_deflated(self):806 self.check_read_with_bad_crc(zipfile.ZIP_DEFLATED)807 def check_read_return_size(self, compression):808 # Issue #9837: ZipExtFile.read() shouldn't return more bytes809 # than requested.810 for test_size in (1, 4095, 4096, 4097, 16384):811 file_size = test_size + 1812 junk = b''.join(struct.pack('B', randint(0, 255))813 for x in range(file_size))814 with zipfile.ZipFile(io.BytesIO(), "w", compression) as zipf:815 zipf.writestr('foo', junk)816 with zipf.open('foo', 'r') as fp:817 buf = fp.read(test_size)818 self.assertEqual(len(buf), test_size)819 def test_read_return_size_stored(self):820 self.check_read_return_size(zipfile.ZIP_STORED)821 @skipUnless(zlib, "requires zlib")822 def test_read_return_size_deflated(self):823 self.check_read_return_size(zipfile.ZIP_DEFLATED)824 def test_empty_zipfile(self):825 # Check that creating a file in 'w' or 'a' mode and closing without826 # adding any files to the archives creates a valid empty ZIP file827 zipf = zipfile.ZipFile(TESTFN, mode="w")828 zipf.close()829 try:830 zipf = zipfile.ZipFile(TESTFN, mode="r")831 except zipfile.BadZipFile:832 self.fail("Unable to create empty ZIP file in 'w' mode")833 zipf = zipfile.ZipFile(TESTFN, mode="a")834 zipf.close()835 try:836 zipf = zipfile.ZipFile(TESTFN, mode="r")837 except:838 self.fail("Unable to create empty ZIP file in 'a' mode")839 def test_open_empty_file(self):840 # Issue 1710703: Check that opening a file with less than 22 bytes841 # raises a BadZipFile exception (rather than the previously unhelpful842 # IOError)843 f = open(TESTFN, 'w')844 f.close()845 self.assertRaises(zipfile.BadZipFile, zipfile.ZipFile, TESTFN, 'r')846 def tearDown(self):847 unlink(TESTFN)848 unlink(TESTFN2)849class DecryptionTests(unittest.TestCase):850 """Check that ZIP decryption works. Since the library does not851 support encryption at the moment, we use a pre-generated encrypted852 ZIP file."""853 data = (854 b'PK\x03\x04\x14\x00\x01\x00\x00\x00n\x92i.#y\xef?&\x00\x00\x00\x1a\x00'855 b'\x00\x00\x08\x00\x00\x00test.txt\xfa\x10\xa0gly|\xfa-\xc5\xc0=\xf9y'856 b'\x18\xe0\xa8r\xb3Z}Lg\xbc\xae\xf9|\x9b\x19\xe4\x8b\xba\xbb)\x8c\xb0\xdbl'857 b'PK\x01\x02\x14\x00\x14\x00\x01\x00\x00\x00n\x92i.#y\xef?&\x00\x00\x00'858 b'\x1a\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x01\x00 \x00\xb6\x81'859 b'\x00\x00\x00\x00test.txtPK\x05\x06\x00\x00\x00\x00\x01\x00\x01\x006\x00'860 b'\x00\x00L\x00\x00\x00\x00\x00' )861 data2 = (862 b'PK\x03\x04\x14\x00\t\x00\x08\x00\xcf}38xu\xaa\xb2\x14\x00\x00\x00\x00\x02'863 b'\x00\x00\x04\x00\x15\x00zeroUT\t\x00\x03\xd6\x8b\x92G\xda\x8b\x92GUx\x04'864 b'\x00\xe8\x03\xe8\x03\xc7<M\xb5a\xceX\xa3Y&\x8b{oE\xd7\x9d\x8c\x98\x02\xc0'865 b'PK\x07\x08xu\xaa\xb2\x14\x00\x00\x00\x00\x02\x00\x00PK\x01\x02\x17\x03'866 b'\x14\x00\t\x00\x08\x00\xcf}38xu\xaa\xb2\x14\x00\x00\x00\x00\x02\x00\x00'867 b'\x04\x00\r\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\x00\x00\x00\x00ze'868 b'roUT\x05\x00\x03\xd6\x8b\x92GUx\x00\x00PK\x05\x06\x00\x00\x00\x00\x01'869 b'\x00\x01\x00?\x00\x00\x00[\x00\x00\x00\x00\x00' )870 plain = b'zipfile.py encryption test'871 plain2 = b'\x00'*512872 def setUp(self):873 with open(TESTFN, "wb") as fp:874 fp.write(self.data)875 self.zip = zipfile.ZipFile(TESTFN, "r")876 with open(TESTFN2, "wb") as fp:877 fp.write(self.data2)878 self.zip2 = zipfile.ZipFile(TESTFN2, "r")879 def tearDown(self):880 self.zip.close()881 os.unlink(TESTFN)882 self.zip2.close()883 os.unlink(TESTFN2)884 def test_no_password(self):885 # Reading the encrypted file without password886 # must generate a RunTime exception887 self.assertRaises(RuntimeError, self.zip.read, "test.txt")888 self.assertRaises(RuntimeError, self.zip2.read, "zero")889 def test_bad_password(self):890 self.zip.setpassword(b"perl")891 self.assertRaises(RuntimeError, self.zip.read, "test.txt")892 self.zip2.setpassword(b"perl")893 self.assertRaises(RuntimeError, self.zip2.read, "zero")894 @skipUnless(zlib, "requires zlib")895 def test_good_password(self):896 self.zip.setpassword(b"python")897 self.assertEqual(self.zip.read("test.txt"), self.plain)898 self.zip2.setpassword(b"12345")899 self.assertEqual(self.zip2.read("zero"), self.plain2)900 def test_unicode_password(self):901 self.assertRaises(TypeError, self.zip.setpassword, "unicode")902 self.assertRaises(TypeError, self.zip.read, "test.txt", "python")903 self.assertRaises(TypeError, self.zip.open, "test.txt", pwd="python")904 self.assertRaises(TypeError, self.zip.extract, "test.txt", pwd="python")905class TestsWithRandomBinaryFiles(unittest.TestCase):906 def setUp(self):907 datacount = randint(16, 64)*1024 + randint(1, 1024)908 self.data = b''.join(struct.pack('<f', random()*randint(-1000, 1000))909 for i in range(datacount))910 # Make a source file with some lines911 with open(TESTFN, "wb") as fp:912 fp.write(self.data)913 def tearDown(self):914 unlink(TESTFN)915 unlink(TESTFN2)916 def make_test_archive(self, f, compression):917 # Create the ZIP archive918 with zipfile.ZipFile(f, "w", compression) as zipfp:919 zipfp.write(TESTFN, "another.name")920 zipfp.write(TESTFN, TESTFN)921 def zip_test(self, f, compression):922 self.make_test_archive(f, compression)923 # Read the ZIP archive924 with zipfile.ZipFile(f, "r", compression) as zipfp:925 testdata = zipfp.read(TESTFN)926 self.assertEqual(len(testdata), len(self.data))927 self.assertEqual(testdata, self.data)928 self.assertEqual(zipfp.read("another.name"), self.data)929 if not isinstance(f, str):930 f.close()931 def test_stored(self):932 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):933 self.zip_test(f, zipfile.ZIP_STORED)934 @skipUnless(zlib, "requires zlib")935 def test_deflated(self):936 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):937 self.zip_test(f, zipfile.ZIP_DEFLATED)938 def zip_open_test(self, f, compression):939 self.make_test_archive(f, compression)940 # Read the ZIP archive941 with zipfile.ZipFile(f, "r", compression) as zipfp:942 zipdata1 = []943 with zipfp.open(TESTFN) as zipopen1:944 while True:945 read_data = zipopen1.read(256)946 if not read_data:947 break948 zipdata1.append(read_data)949 zipdata2 = []950 with zipfp.open("another.name") as zipopen2:951 while True:952 read_data = zipopen2.read(256)953 if not read_data:954 break955 zipdata2.append(read_data)956 testdata1 = b''.join(zipdata1)957 self.assertEqual(len(testdata1), len(self.data))958 self.assertEqual(testdata1, self.data)959 testdata2 = b''.join(zipdata2)960 self.assertEqual(len(testdata2), len(self.data))961 self.assertEqual(testdata2, self.data)962 if not isinstance(f, str):963 f.close()964 def test_open_stored(self):965 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):966 self.zip_open_test(f, zipfile.ZIP_STORED)967 @skipUnless(zlib, "requires zlib")968 def test_open_deflated(self):969 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):970 self.zip_open_test(f, zipfile.ZIP_DEFLATED)971 def zip_random_open_test(self, f, compression):972 self.make_test_archive(f, compression)973 # Read the ZIP archive974 with zipfile.ZipFile(f, "r", compression) as zipfp:975 zipdata1 = []976 with zipfp.open(TESTFN) as zipopen1:977 while True:978 read_data = zipopen1.read(randint(1, 1024))979 if not read_data:980 break981 zipdata1.append(read_data)982 testdata = b''.join(zipdata1)983 self.assertEqual(len(testdata), len(self.data))984 self.assertEqual(testdata, self.data)985 if not isinstance(f, str):986 f.close()987 def test_random_open_stored(self):988 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):989 self.zip_random_open_test(f, zipfile.ZIP_STORED)990 @skipUnless(zlib, "requires zlib")991 def test_random_open_deflated(self):992 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):993 self.zip_random_open_test(f, zipfile.ZIP_DEFLATED)994@skipUnless(zlib, "requires zlib")995class TestsWithMultipleOpens(unittest.TestCase):996 def setUp(self):997 # Create the ZIP archive998 with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_DEFLATED) as zipfp:999 zipfp.writestr('ones', '1'*FIXEDTEST_SIZE)1000 zipfp.writestr('twos', '2'*FIXEDTEST_SIZE)1001 def test_same_file(self):1002 # Verify that (when the ZipFile is in control of creating file objects)1003 # multiple open() calls can be made without interfering with each other.1004 with zipfile.ZipFile(TESTFN2, mode="r") as zipf:1005 with zipf.open('ones') as zopen1, zipf.open('ones') as zopen2:1006 data1 = zopen1.read(500)1007 data2 = zopen2.read(500)1008 data1 += zopen1.read(500)1009 data2 += zopen2.read(500)1010 self.assertEqual(data1, data2)1011 def test_different_file(self):1012 # Verify that (when the ZipFile is in control of creating file objects)1013 # multiple open() calls can be made without interfering with each other.1014 with zipfile.ZipFile(TESTFN2, mode="r") as zipf:1015 with zipf.open('ones') as zopen1, zipf.open('twos') as zopen2:1016 data1 = zopen1.read(500)1017 data2 = zopen2.read(500)1018 data1 += zopen1.read(500)1019 data2 += zopen2.read(500)1020 self.assertEqual(data1, b'1'*FIXEDTEST_SIZE)1021 self.assertEqual(data2, b'2'*FIXEDTEST_SIZE)1022 def test_interleaved(self):1023 # Verify that (when the ZipFile is in control of creating file objects)1024 # multiple open() calls can be made without interfering with each other.1025 with zipfile.ZipFile(TESTFN2, mode="r") as zipf:1026 with zipf.open('ones') as zopen1, zipf.open('twos') as zopen2:1027 data1 = zopen1.read(500)1028 data2 = zopen2.read(500)1029 data1 += zopen1.read(500)1030 data2 += zopen2.read(500)1031 self.assertEqual(data1, b'1'*FIXEDTEST_SIZE)1032 self.assertEqual(data2, b'2'*FIXEDTEST_SIZE)1033 def tearDown(self):1034 unlink(TESTFN2)1035class TestWithDirectory(unittest.TestCase):1036 def setUp(self):1037 os.mkdir(TESTFN2)1038 def test_extract_dir(self):1039 with zipfile.ZipFile(findfile("zipdir.zip")) as zipf:1040 zipf.extractall(TESTFN2)1041 self.assertTrue(os.path.isdir(os.path.join(TESTFN2, "a")))1042 self.assertTrue(os.path.isdir(os.path.join(TESTFN2, "a", "b")))1043 self.assertTrue(os.path.exists(os.path.join(TESTFN2, "a", "b", "c")))1044 def test_bug_6050(self):1045 # Extraction should succeed if directories already exist1046 os.mkdir(os.path.join(TESTFN2, "a"))1047 self.test_extract_dir()1048 def test_store_dir(self):1049 os.mkdir(os.path.join(TESTFN2, "x"))1050 zipf = zipfile.ZipFile(TESTFN, "w")1051 zipf.write(os.path.join(TESTFN2, "x"), "x")1052 self.assertTrue(zipf.filelist[0].filename.endswith("x/"))1053 def tearDown(self):1054 shutil.rmtree(TESTFN2)1055 if os.path.exists(TESTFN):1056 unlink(TESTFN)1057class UniversalNewlineTests(unittest.TestCase):1058 def setUp(self):1059 self.line_gen = [bytes("Test of zipfile line %d." % i, "ascii")1060 for i in range(FIXEDTEST_SIZE)]1061 self.seps = ('\r', '\r\n', '\n')1062 self.arcdata, self.arcfiles = {}, {}1063 for n, s in enumerate(self.seps):1064 b = s.encode("ascii")1065 self.arcdata[s] = b.join(self.line_gen) + b1066 self.arcfiles[s] = '%s-%d' % (TESTFN, n)1067 f = open(self.arcfiles[s], "wb")1068 try:1069 f.write(self.arcdata[s])1070 finally:1071 f.close()1072 def make_test_archive(self, f, compression):1073 # Create the ZIP archive1074 with zipfile.ZipFile(f, "w", compression) as zipfp:1075 for fn in self.arcfiles.values():1076 zipfp.write(fn, fn)1077 def read_test(self, f, compression):1078 self.make_test_archive(f, compression)1079 # Read the ZIP archive1080 with zipfile.ZipFile(f, "r") as zipfp:1081 for sep, fn in self.arcfiles.items():1082 with zipfp.open(fn, "rU") as fp:1083 zipdata = fp.read()1084 self.assertEqual(self.arcdata[sep], zipdata)1085 if not isinstance(f, str):1086 f.close()1087 def readline_read_test(self, f, compression):1088 self.make_test_archive(f, compression)1089 # Read the ZIP archive1090 with zipfile.ZipFile(f, "r") as zipfp:1091 for sep, fn in self.arcfiles.items():1092 with zipfp.open(fn, "rU") as zipopen:1093 data = b''1094 while True:1095 read = zipopen.readline()1096 if not read:1097 break1098 data += read1099 read = zipopen.read(5)1100 if not read:1101 break1102 data += read1103 self.assertEqual(data, self.arcdata['\n'])1104 if not isinstance(f, str):1105 f.close()1106 def readline_test(self, f, compression):1107 self.make_test_archive(f, compression)1108 # Read the ZIP archive1109 with zipfile.ZipFile(f, "r") as zipfp:1110 for sep, fn in self.arcfiles.items():1111 with zipfp.open(fn, "rU") as zipopen:1112 for line in self.line_gen:1113 linedata = zipopen.readline()1114 self.assertEqual(linedata, line + b'\n')1115 if not isinstance(f, str):1116 f.close()1117 def readlines_test(self, f, compression):1118 self.make_test_archive(f, compression)1119 # Read the ZIP archive1120 with zipfile.ZipFile(f, "r") as zipfp:1121 for sep, fn in self.arcfiles.items():1122 with zipfp.open(fn, "rU") as fp:1123 ziplines = fp.readlines()1124 for line, zipline in zip(self.line_gen, ziplines):1125 self.assertEqual(zipline, line + b'\n')1126 if not isinstance(f, str):1127 f.close()1128 def iterlines_test(self, f, compression):1129 self.make_test_archive(f, compression)1130 # Read the ZIP archive1131 with zipfile.ZipFile(f, "r") as zipfp:1132 for sep, fn in self.arcfiles.items():1133 with zipfp.open(fn, "rU") as fp:1134 for line, zipline in zip(self.line_gen, fp):1135 self.assertEqual(zipline, line + b'\n')1136 if not isinstance(f, str):1137 f.close()1138 def test_read_stored(self):1139 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):1140 self.read_test(f, zipfile.ZIP_STORED)1141 def test_readline_read_stored(self):1142 # Issue #7610: calls to readline() interleaved with calls to read().1143 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):1144 self.readline_read_test(f, zipfile.ZIP_STORED)1145 def test_readline_stored(self):1146 for f in (TESTFN2, TemporaryFile(), io.BytesIO()):1147 self.readline_test(f, zipfile.ZIP_STORED)1148 def test_readlines_stored(self):...

Full Screen

Full Screen

_constants.py

Source:_constants.py Github

copy

Full Screen

1# Licensed to the Apache Software Foundation (ASF) under one2# or more contributor license agreements. See the NOTICE file3# distributed with this work for additional information4# regarding copyright ownership. The ASF licenses this file5# to you under the Apache License, Version 2.0 (the6# "License"); you may not use this file except in compliance7# with the License. You may obtain a copy of the License at8#9# http://www.apache.org/licenses/LICENSE-2.010#11# Unless required by applicable law or agreed to in writing,12# software distributed under the License is distributed on an13# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY14# KIND, either express or implied. See the License for the15# specific language governing permissions and limitations16# under the License.17# coding: utf-818"""Read text files and load embeddings."""19from __future__ import absolute_import20from __future__ import print_function21UNKNOWN_IDX = 022APACHE_REPO_URL = 'https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/'23GLOVE_PRETRAINED_FILE_SHA1 = \24 {'glove.42B.300d.zip': 'f8e722b39578f776927465b71b231bae2ae8776a',25 'glove.6B.zip': 'b64e54f1877d2f735bdd000c1d7d771e25c7dfdc',26 'glove.840B.300d.zip': '8084fbacc2dee3b1fd1ca4cc534cbfff3519ed0d',27 'glove.twitter.27B.zip': 'dce69c404025a8312c323197347695e81fd529fc'}28GLOVE_PRETRAINED_ARCHIVE_SHA1 = \29 {'glove.42B.300d.txt': '876767977d6bd4d947c0f84d44510677bc94612a',30 'glove.6B.50d.txt': '21bf566a9d27f84d253e0cd4d4be9dcc07976a6d',31 'glove.6B.100d.txt': '16b1dbfaf35476790bd9df40c83e2dfbd05312f1',32 'glove.6B.200d.txt': '17d0355ddaa253e298ede39877d1be70f99d9148',33 'glove.6B.300d.txt': '646443dd885090927f8215ecf7a677e9f703858d',34 'glove.840B.300d.txt': '294b9f37fa64cce31f9ebb409c266fc379527708',35 'glove.twitter.27B.25d.txt':36 '767d80889d8c8a22ae7cd25e09d0650a6ff0a502',37 'glove.twitter.27B.50d.txt':38 '9585f4be97e286339bf0112d0d3aa7c15a3e864d',39 'glove.twitter.27B.100d.txt':40 '1bbeab8323c72332bd46ada0fc3c99f2faaa8ca8',41 'glove.twitter.27B.200d.txt':42 '7921c77a53aa5977b1d9ce3a7c4430cbd9d1207a'}43FAST_TEXT_ARCHIVE_SHA1 = \44 {'crawl-300d-2M.zip': 'bb40313d15837ceecc1e879bc954e9be04b17c3c',45 'wiki.aa.zip': '0d85feb259e17d5258f38b2b615a2b87cd628427',46 'wiki.ab.zip': '7a8c555b9cf3837c9b31c901e9e0142209990365',47 'wiki.ace.zip': '51555fccbe53b726f6c86a84d704c026a78dd02f',48 'wiki.ady.zip': '725d2c30c03001c941ac4084549c55c7f8e1d766',49 'wiki.af.zip': '1a18d34e1b60433b837f5850750a44ca3845323d',50 'wiki.ak.zip': 'daecc2303cfd05bc6c33b24d78c14e0d7f33e3a7',51 'wiki.als.zip': '38851192e0b556e566be6c3c93370abf9867e525',52 'wiki.am.zip': '4576e0121448564b07f448e05e287236343f17c1',53 'wiki.ang.zip': '9c03da3b06d4becef5d387b9a61438b9362fc36a',54 'wiki.an.zip': '170f60bdd161cf8e4b5e018acd7d36e8bfc457a6',55 'wiki.arc.zip': 'c8dad8b00865bf736b087e7b323999ab404bda29',56 'wiki.ar.zip': '34e9869daa463fdc5609040ff33a03e67512e9fd',57 'wiki.arz.zip': '2d2790e11e401d46e1bce2970ee5264d5678a32b',58 'wiki.ast.zip': '1136515e2de556c077324bcd42ffe7f40c8d94c6',59 'wiki.as.zip': 'f9efde3e4ccda4a1e93fa275a3210f74036e9e46',60 'wiki.av.zip': '9f8568a3e094a48de4a3b6bea3bdb6fd7e875a08',61 'wiki.ay.zip': 'f09a422cedc6a0f15fbf30d290febe8057de83db',62 'wiki.azb.zip': 'd8895581050b9fdb5a10dfec3e27910a150b6faf',63 'wiki.az.zip': '2a34c2db872597ba3e345ce8b7db138241f9efbf',64 'wiki.bar.zip': 'd6e40135a6f4ba7a07fab11633034eccb1b05d0a',65 'wiki.bat_smg.zip': '5d08bd04f0515a36723776c0682b3de0f11d4264',66 'wiki.ba.zip': '412ac2f3bf9a605e56e2b0990bb0baed41ddf3b0',67 'wiki.bcl.zip': 'd3717cda357e08390cb57a64e07f5c7b7768d5be',68 'wiki.be.zip': 'b691e63b8080af23cc37f5f2b21b3154e464c425',69 'wiki.bg.zip': '08509a510a95e2a8905c19d83faf40d614d2268b',70 'wiki.bh.zip': 'a812600c6454b779d442b7680e3867e15d895095',71 'wiki.bi.zip': 'd0d4a3f57419424815f77b3951ef9c7336f6adf5',72 'wiki.bjn.zip': '0d81879ff7611380896eac6059bb677a5b3fe308',73 'wiki.bm.zip': 'f3a2a1a8dbc94973a74343c059595a310a66665b',74 'wiki.bn.zip': 'b3bc70520edf3963c2217873ff5c2537d3545650',75 'wiki.bo.zip': '2be9fe7701d6a8501461df7bd98fee26859cf83a',76 'wiki.bpy.zip': 'd44b9267bb4f86e3e43972a6a952cc0ccf90dd3c',77 'wiki.br.zip': '4bfa66f1ea5aa5cad736eccaa211f6025596bcd6',78 'wiki.bs.zip': '40c560c5994ab50485d08eeaffd88740f30236ab',79 'wiki.bug.zip': 'bc7cd87bb067ac477000259cd4f95f45bfb6e4df',80 'wiki.bxr.zip': '8396fd67ef53f3123540766788a0db54734c4f1a',81 'wiki.ca.zip': '8f5d3caf0f5d223b2771ec44f7e620e396974fb2',82 'wiki.cbk_zam.zip': '0af3be50823b564433455d10c8753df88461458f',83 'wiki.cdo.zip': '19024215aa0c13872c027fc6127b5d7506198b5f',84 'wiki.ceb.zip': '96374428bf36a43983ba4307d7f6fb5ab52a6c6a',85 'wiki.ce.zip': 'b27f1a8da448bc9315e15d4261519c64f00de8eb',86 'wiki.cho.zip': '20944e34c2b58f14adb849dd5a6f5168c7affdea',87 'wiki.chr.zip': 'b7f41ee3fa76e933e0b5ad6b793c507fc19afe98',88 'wiki.chy.zip': '4ef66004a609c724fd7d8aab2877f7634323d43f',89 'wiki.ch.zip': '7f73678b685c9b5f5d6eea9bc00322cfc18d40cb',90 'wiki.ckb.zip': 'b7db2805526ad8bed878af257b32ca9ba814855f',91 'wiki.co.zip': '1b9e19b11763cb87ca00520dbdd6ada565547c9c',92 'wiki.crh.zip': '792003bae25c4471d25721440002c983fa5af020',93 'wiki.cr.zip': '875e4aa0de8a829e57f6c8e13d43cac5103210de',94 'wiki.csb.zip': 'fa776014c4c83487d7cb2485bd08eaf6739d9dca',95 'wiki.cs.zip': 'dca18cb80460522cd281ccc3c9922cf2b3c08b81',96 'wiki.cu.zip': 'ed23b48ba3193181a358d7a73005afa7655a4fc3',97 'wiki.cv.zip': '27ccd50942c9c218e00365ee293fa0c3087a7646',98 'wiki.cy.zip': '78940d5be2969b82c99f785bda2ac5f4e18e149c',99 'wiki.da.zip': 'a45077d9d73328bd6a96efdba1b31ed9a3639dcd',100 'wiki.de.zip': '0d9e4bf80100b46237dcb73cfefe390103e7e827',101 'wiki.diq.zip': '0eef7d9e2f0ce3f100a22dc8fcede9449e466528',102 'wiki.dsb.zip': '903cd80550931effba1d4e52a19c22592837d11c',103 'wiki.dv.zip': '3fa06719641ff33ac8a5439d330a8108521da1e7',104 'wiki.dz.zip': '8bf3937971c3c996493c30b264cb8268627d7bd6',105 'wiki.ee.zip': 'e66bc50013d884fe69f4f67ba44af2e34fe97927',106 'wiki.el.zip': '3015f358036658fb126d42fa794d67a90c5b91ad',107 'wiki.eml.zip': '5be541be6115af5914ac2b8118a09232b771123b',108 'wiki.en.zip': '7f83d578a31a8168423c77ea25ad381494a5e920',109 'wiki.eo.zip': 'e7612df98c37cb872f0edc3c3e21dcd2f80a4d69',110 'wiki.es.zip': '1b7668b23db26810ea433173ce0c11281e801f74',111 'wiki.et.zip': 'aa31004e7b8ebf359e166b8ea6b8e6f77fac190f',112 'wiki.eu.zip': '8d7699451cbac4d69750caa8d58b4740cc72e0ca',113 'wiki.ext.zip': '3aeb4d77c48eb503b26ceb2a76a0a7d841124a71',114 'wiki.fa.zip': '08b6e805c8623fba526143d46f4685549c4380a6',115 'wiki.ff.zip': '64f690eda733a6fb4f794e42eb6ff05f09ec1d38',116 'wiki.fiu_vro.zip': '35c3fdcec0f0dc1ce303212967ea59936641daee',117 'wiki.fi.zip': '252299a2a59cc0ac07ba25f9458afc26bbac669f',118 'wiki.fj.zip': '004d1279c27324d02b961341cf0d6ee06dbe8966',119 'wiki.fo.zip': '12f1d6360d4867cdebcc93be87c024a4709d1af5',120 'wiki.frp.zip': '8a0f636b5440a9aab38014efada9edfdf94150d5',121 'wiki.frr.zip': '7c9e7b8109b98aa39b303dd77d837b37e96d4113',122 'wiki.fr.zip': 'd906e68760153d771e5982009b0150e913254b2d',123 'wiki.fur.zip': 'd5d2ae08696ed074a581eac563a60eb85467a792',124 'wiki.fy.zip': '342609d29882fae0a3b402d8ea1478606be0d93b',125 'wiki.gag.zip': 'f2b91f89dd9b9a1301727476f7823b7260b5f129',126 'wiki.gan.zip': 'd3ad3c1151555266e1feb9f98b066ee31ee5f410',127 'wiki.ga.zip': '798b0c26783c7af05d9c4f899ca9fddafeb1e0a1',128 'wiki.gd.zip': '49085fa182a528bdc51f10e99bef33c88c1e3112',129 'wiki.glk.zip': '9e16727ffcc691483b69ecbcd331b1df2efa4bcd',130 'wiki.gl.zip': 'c71c7e6601b2cbdc7930982fbeea636deddd107d',131 'wiki.gn.zip': '493ccb583211217ccd23e0a43f42ba773bd94f78',132 'wiki.gom.zip': '45bbd49750ddb7df5afe01fcfd5dda2958934dfa',133 'wiki.got.zip': '669d018f72827fb965e5ef37e224e21f4682b2e5',134 'wiki.gu.zip': '4afe874f7830f693e9f83508fc3fb444b33aebdf',135 'wiki.gv.zip': '9411197eebc07775949d9bb6e440780a68502a5c',136 'wiki.hak.zip': 'cd1e14bd5d50fa764883b148bda5b821375531e0',137 'wiki.haw.zip': 'cacd4eb4e476bdd842e8014764b8ae380b346ed2',138 'wiki.ha.zip': '14acc50950b451f40fe028fd08d042af44732398',139 'wiki.he.zip': 'a9e2cd13bc2e55d83820c529bac1f518a7198bc0',140 'wiki.hif.zip': 'dcdd488239deb0ede807cff263ddc972009c21f5',141 'wiki.hi.zip': '15899ec17985bc0e1db1df497e1b4a51bba1982b',142 'wiki.ho.zip': 'fde454bb4f3841ea5dde2bbf879138305a4d0b36',143 'wiki.hr.zip': 'f5d33ba967f7c56538fa9f5f0093f6d634e9db44',144 'wiki.hsb.zip': '64dc13c7645d2b65b8ba252bd8dfb1c616e8923a',145 'wiki.ht.zip': 'cf50a5cadcf91aba9ab58d095d65f348e2375d12',146 'wiki.hu.zip': 'b27f293caedf81a2d09204b11f52a7c8d7443643',147 'wiki.hy.zip': '641b8666bc2168998989fae1b20a09d3428766bb',148 'wiki.hz.zip': '1639f9f096de6fac84336a784a391ce73e523d62',149 'wiki.ia.zip': '37640aaf8a25c02883190951337b5a6f0157d781',150 'wiki.id.zip': '56ee0c7a38a6d232706932493eaa37b2a87667ee',151 'wiki.ie.zip': '7c3a5d7f96c801570e2305f45a40d401fcc038b9',152 'wiki.ig.zip': '405ebc2e8a959163c9f2f8dd015a0bcefd440111',153 'wiki.ii.zip': '1ec1c7d95d61eeca2dbbd8e432caf88524aaf28e',154 'wiki.ik.zip': 'e9d088c0d8d0ab420d6d0469c6a0fdb668f1833c',155 'wiki.ilo.zip': 'cbc9754978ce55e86da2eb3db20579f4a1f19947',156 'wiki.io.zip': '9e5ab1fd5c4f1094d111f501129e0eecccec69a0',157 'wiki.is.zip': '0744e63636cf794e0a406c922827628a3dd415b7',158 'wiki.it.zip': '29f4eb6a5d7dcf45b02b4d08a4a70dfae4c41200',159 'wiki.iu.zip': 'fb2e8de825d554257768d363a3a09f711afb001b',160 'wiki.jam.zip': '077cfb6de9d025aee4a5b2ea9ce15ada02f10a4f',161 'wiki.ja.zip': '7940f6c2bc490c04902f0faf0562b92cae7136bf',162 'wiki.jbo.zip': '3d086b6c9a369f197516cd0dc699a94612f45c6a',163 'wiki.jv.zip': '2f68cb3436b27a25ddfa40fab3e2cd44574b437e',164 'wiki.kaa.zip': '9fd5df362b7cb615f2267084d8b3fb8608be2693',165 'wiki.kab.zip': '96abf1440ad21de58d7274d3a16885ef4a2efda4',166 'wiki.ka.zip': '72ddb2382c87184fc05a93e89ed8aa4f54a62a0a',167 'wiki.kbd.zip': '81dfc3c6f8581c2aa15342c84688b4ba59b81cc6',168 'wiki.kg.zip': '4d07cabef6f804fc6432d3f630675ed4cbbdd49e',169 'wiki.ki.zip': '59b5c31df227ff9454ad8b3a1d16b065620dbddf',170 'wiki.kj.zip': '751b80c4a4d82dd217d3d2b3905eb39b349874d7',171 'wiki.kk.zip': '7fb733a2405f421a7c49b756381a52965a8af205',172 'wiki.kl.zip': '05a9d5c9bf12d8845356f88b546418d2e40f79c6',173 'wiki.km.zip': 'da0a67028fa0244a2e7257ae259c2f7a7544dc66',174 'wiki.kn.zip': '6cead946350b31fb2f353085fd00b8ea9c9ecc77',175 'wiki.koi.zip': '0c61f83434404267527eaf583e89b4d8bb3a6a65',176 'wiki.ko.zip': 'c0825282faf1e7af6820bd8b28d06c77760dcbe4',177 'wiki.krc.zip': '0df3c3f0f89521299dab741be3d698b2c94c194e',178 'wiki.kr.zip': '71651f046cef420fb28ca15e35720bb7747c4586',179 'wiki.ksh.zip': '8b9ab88baa49e72e40a5a80bef98f3ea2afbdd07',180 'wiki.ks.zip': '02af37f12753662c9e7bcac3b8786dfd2f298710',181 'wiki.ku.zip': 'ca1d370b327ceca025884bf83139456024a3a978',182 'wiki.kv.zip': '28b3617c5566f3182f14bf11a906456b227840ba',183 'wiki.kw.zip': '075a02e8eaae26897c23898fb4d36f4e41e4d1d0',184 'wiki.ky.zip': '771601a934cd4d0a98e5059f6389d2496e8dcf7c',185 'wiki.lad.zip': '2788ba3f275d72299e877c96cde106bd8590f405',186 'wiki.la.zip': '759f6365874442ab8e04d992b047f53ad74231a6',187 'wiki.lbe.zip': 'c8105f1cf8a3d46ccfacff1d40a581f442b3c4a1',188 'wiki.lb.zip': 'dac5af52364f2c0d3a0c794411465d1254f2fb48',189 'wiki.lez.zip': '17331cb779dee8cb60f2734213af80d57acfcfad',190 'wiki.lg.zip': 'fd4e2d67d1f098474053abc9a1984dfe4a2854b7',191 'wiki.lij.zip': 'c29157f5e4d2b37c01cf6e389f03ddafef6acdb2',192 'wiki.li.zip': '10490e49a12230af2127543da69c427f92c6508f',193 'wiki.lmo.zip': 'cc44163572deddd78af6b006394f623cb21934fc',194 'wiki.ln.zip': 'bf52699c5cbf79bedb2e2856d8a720189b6864f3',195 'wiki.lo.zip': '3fd8a70d8e26071a365f10016875a4a4f15ffcee',196 'wiki.lrc.zip': 'e262b4fcc55cba48d997cd06d006b82a5abe09a9',197 'wiki.ltg.zip': 'df6a83f2fab35f9a2f97fd8d857cb1cfa59f331f',198 'wiki.lt.zip': 'a738a3f29a6a5481082a7a9a41b2040b9cf537e4',199 'wiki.lv.zip': '8e328d99aacaa021fcc51425caebc063e22e6cf4',200 'wiki.mai.zip': 'e909de86c27eced2cb5f02f550da7fc2502b5eda',201 'wiki.map_bms.zip': '192bf6b88f955746abb398893868482730585e3a',202 'wiki.mdf.zip': '3d0d5da3c85bef8ae52f0fd17e314a1960a26d36',203 'wiki.mg.zip': 'fe66055b63ce8771bf43f8dd543bbd967f8ea8b3',204 'wiki.mhr.zip': '33514c98da3bd9602851db96fa3dd8192aac0674',205 'wiki.mh.zip': 'dc77309103c6cfed7ff095b3f9f158e1ae437e71',206 'wiki.min.zip': '8b925eea6df0411ee09baef5801d807cfec8cfa4',207 'wiki.mi.zip': 'd57831e8d7cb2ec260fc9d83d4281f0bacfb29a5',208 'wiki.mk.zip': 'b1fc2d85527e99530a93e3bbc5fa9fcde89910f3',209 'wiki.ml.zip': 'b9d53b8e76a05f5e959afd190da3015b36793297',210 'wiki.mn.zip': '715bf0ee67b48ec872659380fcf63ad006ddcc7e',211 'wiki.mo.zip': 'fb273fe373eb61310051d94ad6911320f573d0ec',212 'wiki.mrj.zip': 'b0d1e43e37e1718c8e05fd81a511095636def361',213 'wiki.mr.zip': '67e942a7742cc957298c8cd0cd0af0531dc936d7',214 'wiki.ms.zip': 'e218f113702b039fc8e80a77b894cd9fa4eff77d',215 'wiki.mt.zip': 'd68d5b636eac07b2e1307186c2c05b9a80e39658',216 'wiki.multi.ar.zip': '31c7b742c63c3367e9bce5c4dca37d5ceb33f1a6',217 'wiki.multi.bg.zip': '8991e8123bce7fd6c8e4510c71ede5715ae36f01',218 'wiki.multi.ca.zip': '0786e071438150485d394a4bf2e976d3a1b313ff',219 'wiki.multi.cs.zip': '7237f291146e69f0fc7002a0e175c7fd003d44e8',220 'wiki.multi.da.zip': '5591c20015191101aee190c02738c99073a8fe76',221 'wiki.multi.de.zip': '986160e51a08f4a93f1573d17352e375cbaedd6d',222 'wiki.multi.el.zip': '570eb12811ce61f6176f263eff3e945be69e7da0',223 'wiki.multi.en.zip': '2c3ef35d8338d4a905e7d10645572ab7a6730d44',224 'wiki.multi.es.zip': 'c1db7c7175665a7230f92ed038b78de780e060e9',225 'wiki.multi.et.zip': '54d0515865c754331b445dd9ba0ae7ed79b770aa',226 'wiki.multi.fi.zip': 'c94abc803a42b89cd75b278114b1f2cf4e2f3ecd',227 'wiki.multi.fr.zip': 'd4904b79eaf8ae386a7011ad84afc9b4238c9928',228 'wiki.multi.he.zip': '370ec2a379eecc2d2e984cde3e0f6d0a027eade7',229 'wiki.multi.hr.zip': 'd3f25ae76b040ffa09e964f6edc55488f6086394',230 'wiki.multi.hu.zip': '4b64bcdf0fc1f01bbd8427bd7bf6b46319308e7a',231 'wiki.multi.id.zip': '3ad5f590d5c847b35a334f1bdb48b9c466f5de68',232 'wiki.multi.it.zip': '18746450e665e96c33f2e2026986f643a27e0945',233 'wiki.multi.mk.zip': '1d899f1449d8729b7dbae226f05151a656694626',234 'wiki.multi.nl.zip': 'ff0a04dbb07c2cdbc61d5a241175e30ed46b48d4',235 'wiki.multi.no.zip': 'd1af729024181e64f58ae37ab233fc53811e2601',236 'wiki.multi.pl.zip': '91c3984c4f3158b1cb1ff11d8cc4f9240631266e',237 'wiki.multi.pt.zip': 'a1782c4fa4337008f82c0e2bf78e4323d145be29',238 'wiki.multi.ro.zip': 'b1a0840d084009ce00c47a3c24c984648dbe8785',239 'wiki.multi.ru.zip': '540607ba4334dab6089de463f974861aac8a35ae',240 'wiki.multi.sk.zip': '2a2bb39e011cf2bf6dcb8cb6c482b8eb9764eea3',241 'wiki.multi.sl.zip': '99442dab442dc196c107868db9174c78e270db1e',242 'wiki.multi.sv.zip': 'b40be83d2d7c27633c712aea62ceec0d409cc03a',243 'wiki.multi.tr.zip': 'e2bffab1616f54d180ba3d8bfe5e94ec9a489184',244 'wiki.multi.uk.zip': 'e97f64d9ba2b58a5e80c9b896b87340aba1e0eb0',245 'wiki.multi.vi.zip': '532fa24d8787a8906fb04a88e74a713b00cb33ec',246 'wiki.mus.zip': '1bb0cad10889b8a3bfa36c36c7da1f2fb2237bb8',247 'wiki.mwl.zip': 'e3d1fd1fa6290521d403e84eba577e552e330844',248 'wiki.myv.zip': '64a6505691441778766b7941b5e7f45a624a64a5',249 'wiki.my.zip': '491ce8dbf174d4abff758db4950f49eda90883d9',250 'wiki.mzn.zip': '76abf410749fd4516ead20ced891b54245fcd4a3',251 'wiki.nah.zip': '0496592cdd70eaf61b257fb5345843d38f425592',252 'wiki.nap.zip': 'f0df66cdbef5734f0afeb806cda631722fb426d8',253 'wiki.na.zip': '2456e4776b5e985cfaedfac244e0b40cff4e613c',254 'wiki.nds_nl.zip': 'ffd10e05b749281634eb7a758102d8d6ff42760e',255 'wiki.nds.zip': '2455e9fa4294828b25b32bdad7307a105f9fbe1d',256 'wiki-news-300d-1M-subword.zip': '697f4c8f37443be3aee7b96abe28fd7ebec95ef3',257 'wiki-news-300d-1M.zip': '567ef9c2e207be25da23e61312e6ba620da30466',258 'wiki.new.zip': 'a781885678cc1079d4be221c414339eb9bee8d19',259 'wiki.ne.zip': '180b068343288cda40d012aaa99d29459d341eb4',260 'wiki.ng.zip': '6db8111ab700f7b0841af87f1f1453341048014e',261 'wiki.nl.zip': '582420f290947cf38503b7f4b8ea9bb21918005e',262 'wiki.nn.zip': '4a0e30376b361ee19800e6d897a865572e330f84',263 'wiki.nov.zip': 'ac98c0300302019ff855698561708abd81730db3',264 'wiki.no.zip': '6893a7912ab3756e31d09ef1f9023c27c0b047f8',265 'wiki.nrm.zip': 'bd27aadf25a165ebbac486437ea6a06b710fdda6',266 'wiki.nso.zip': 'c55dfebb83351c952831db34e779e0a380212f05',267 'wiki.nv.zip': 'cf122e5ee041287917c594a2cb6cd247978f1ec0',268 'wiki.ny.zip': '9086021a60babd7e87afa469dbadb004523f5fd2',269 'wiki.oc.zip': '15075544cf837135127d8688cd06fb8e4c8b7f3d',270 'wiki.olo.zip': '523628bb652e1563b4dd5a94b518addf10699f74',271 'wiki.om.zip': 'a29360ab3930d889c4eb5b385589f84c1ff9f06e',272 'wiki.or.zip': 'a782e649ae5307dece445b0c11b15ffb9ce88297',273 'wiki.os.zip': '0d76ca005afd48b87dea5c9784c4c48bb51d3e3e',274 'wiki.pag.zip': 'b046ef71badc9d7eec161e3aec2ffc3abb7bad20',275 'wiki.pam.zip': 'abed25ef407e05209f2653d571bba5bc7c66e7b3',276 'wiki.pap.zip': '5d099bfc65c85f824634a191ce33e8e42f947ded',277 'wiki.pa.zip': '2066ed0016720b9f8779f55f2cc2de08511025f6',278 'wiki.pcd.zip': '66914c99e5531c0484448b84568971362cdad0f6',279 'wiki.pdc.zip': '6ed181fa1f8782917ae7849490c0a5cb0b0b9b29',280 'wiki.pfl.zip': '8d271226af8509962b15a96c4d6e41d9aabd972c',281 'wiki.pih.zip': '365955dbecb17027435fe487ab92a7a267fa25bd',282 'wiki.pi.zip': 'eeb863545392c92cff0f3e3d9c3f61539d3fa1dd',283 'wiki.pl.zip': '2b0cae8af2637bc24b958e6757149d1b9f8c8fea',284 'wiki.pms.zip': '9eff2e96e1cb9bf02adf816c4feb5aa3cd1a384f',285 'wiki.pnb.zip': '23f77d1d9469f5b2c342984288cb3092d53d8dee',286 'wiki.pnt.zip': '84cc9532d2fd7b322bcba91e01ac36c9a719e23a',287 'wiki.ps.zip': '18c9ffb2a81cbc25299b26e35170a29b7de9309c',288 'wiki.pt.zip': '37752109a44829de5ea10b173d7c0cecc0b1a0d7',289 'wiki.qu.zip': '5582c07eeeaec10d9382b3ab90d2921fc97fa2e0',290 'wiki.rmy.zip': 'a106ab536001e92e7a9708417faee9418f4058d0',291 'wiki.rm.zip': '67a324941f2b895a418fbd89314a18bfda19b1de',292 'wiki.rn.zip': 'ce17294909c046e90bb0131632e1d795d1771816',293 'wiki.roa_rup.zip': 'a9a378e90cd46353283c92cfb7d34dd485a018d2',294 'wiki.roa_tara.zip': '953fe4cf1667cbb9b3b8e11666885bfedf74b411',295 'wiki.ro.zip': '6bbb0f9452398416d9183e00e6cd091a02fb351f',296 'wiki.rue.zip': 'e9f9b8ab63c7722b4b68e8c465b1c69436132553',297 'wiki.ru.zip': 'f8f68aa5792941d7750b545e56f1ff5127e88cc2',298 'wiki.rw.zip': '018b9fb76fca5ce7a3e1f266df33fcc1bbc50493',299 'wiki.sah.zip': 'f6c94dbd3b719b154217388310fab72e5a69f823',300 'wiki.sa.zip': '4dc78b48d651056546d14b659c6598770c6bce77',301 'wiki.scn.zip': '218ba35c042cb3e179988bac9acf51cccf37422b',302 'wiki.sco.zip': 'daa8cedbb223e87d48f720aed9ce63dd0c81c632',303 'wiki.sc.zip': '909cc5160cad60fda34ab89c2b87ae4229402eeb',304 'wiki.sd.zip': '5468ed141bf2f1d9b1f8d7b31fee926b496ea9db',305 'wiki.se.zip': '0eb962f8768d88ffcbde3aac833e134a263c2055',306 'wiki.sg.zip': '651035aa74dc2f515253444f48aa9911094f9d27',307 'wiki.sh.zip': 'cf3057b61bd5bca6f47640801681d451aee210cf',308 'wiki.simple.zip': '367737535e39defb0e713a7ff2374cb932c5a9bc',309 'wiki.si.zip': 'cebb2f4011b0d679fe856c5950076e3c48496ecc',310 'wiki.sk.zip': '6c43758d0c0f52351210c558cc33266a65709068',311 'wiki.sl.zip': 'd0239eefc830e5919bef8d9173a884e9e7371e7a',312 'wiki.sm.zip': '2e3cf33f17b449c8f81cc9ea4c84d542cfd23a14',313 'wiki.sn.zip': '4d3844ee350ee0065e5fe910a3f669ef863a2fc9',314 'wiki.so.zip': '9da45db9b21d1f27c4f73152539c1e4fc9b1c49c',315 'wiki.sq.zip': '0db976ec147df49e648cf8256562371d0ae6f2f0',316 'wiki.srn.zip': '120e229d522cc22008c50e0eb74b23d9f6eca51d',317 'wiki.sr.zip': '63b67391158bdd7a642f7d8412771c22e1041744',318 'wiki.ss.zip': '4368f7931f6730a6e8cb9b5794906f2d827582a8',319 'wiki.stq.zip': 'fb1ba577bf6fb7f7fcdc52bf392e63ed8492465d',320 'wiki.st.zip': 'b7e96392b3880c19e210fd42bc72e3f76c07a4c3',321 'wiki.su.zip': '4c4880cfca1ff954c88e44a32f201218eb2be146',322 'wiki.sv.zip': 'e2b10091585f795dd18289c4a65a1da591a78196',323 'wiki.sw.zip': '726631d8998ba1647d040e6b70f4bad7b8d8c367',324 'wiki.szl.zip': 'a70de974cff95cad0443f5faa6c8412c92998100',325 'wiki.ta.zip': '6bafd0bb523f654038393ba191012527745b940b',326 'wiki.tcy.zip': 'b4bd573eaf9fd87300a25648b38a053161d12c39',327 'wiki.tet.zip': '7e5608958977164e544850a5a169f5d55cd47a20',328 'wiki.te.zip': '948e5a6ec13ac95b595c3f52a6e7b9642a56c530',329 'wiki.tg.zip': '5b46429024d6819f6b511a4924b90c958615d40e',330 'wiki.th.zip': 'b8ee0878cec41b4ab1055a17d0ed669de1ed9afd',331 'wiki.ti.zip': 'd55abb74bb3ff195d2293ee9e77886111ee50e52',332 'wiki.tk.zip': '20263f39a31a1d55343f9dea7aecaa2860aefde8',333 'wiki.tl.zip': '2f2b809017249f8c4f8d5eb62979b58f16e8732b',334 'wiki.tn.zip': '0aa11b07b1ad6437bc1e9b6476d51ddd35dad994',335 'wiki.to.zip': '6b90b32ae258a56e67b42736675236b91163b3ad',336 'wiki.tpi.zip': 'ca9591e621ae667a1521d0bb5275435d45e974cc',337 'wiki.tr.zip': '3b6f86c2a115c7adec1b073b1f5624890e680148',338 'wiki.ts.zip': '8a00b16f2881977ad6f8c8665316c27fcab9b842',339 'wiki.tt.zip': '8d2f559bf1e09180d6dc4b127d61815a27670a20',340 'wiki.tum.zip': '5b3f6f3d8cae4d9534cd1fd3afc2f64ec8342b8d',341 'wiki.tw.zip': '7c189fabfcdb2973178c25d35fd10e46ee7148aa',342 'wiki.tyv.zip': '5e3811a19bbf961a5361ac37ff3502287c9ab022',343 'wiki.ty.zip': 'a7f31f8cabf4282533773aa7e63f294315cc85ea',344 'wiki.udm.zip': '643df5ab0914535e46e6839845d0ab585c81a119',345 'wiki.ug.zip': 'a5388269893ac4c7da28b2284f3536ca0f3c9341',346 'wiki.uk.zip': 'fdc9b0a0ab806e5845e9d89b8887ec9d555a0547',347 'wiki.ur.zip': '75579eb5609ea31d79bc2d1bd81d01f48e01bc7c',348 'wiki.uz.zip': 'aa149200f8c6e3e8bb5aa3c67112675d136900b8',349 'wiki.vec.zip': '58c4c9528154e256fbefeb97b8c1675356079f74',350 'wiki.vep.zip': '966b371afcc383058a5fbc6ee8f822620f03feac',351 'wiki.ve.zip': '6450e3ec2c78980c5a41d71ff159aa27918dda75',352 'wiki.vi.zip': 'bfa287fbb358a66b4f9576585df3e46607e1595c',353 'wiki.vls.zip': '7335bfda43890f42e045b8a5de25d1a8629fe012',354 'wiki.vo.zip': 'c2ca18bea165cb1253c1d88fa9958a25088fc84b',355 'wiki.war.zip': '5cda8fdd64e3acf5488ad361b68a63fb23747559',356 'wiki.wa.zip': '2e538c10a0e9f43ea5875c90a8ce01a07c4695a7',357 'wiki.wo.zip': 'f54c65ab63f98ffec7b3fb5bdd51a814034bd673',358 'wiki.wuu.zip': '68d9ad802836737392d62056231bf1b7a58594c9',359 'wiki.xal.zip': 'fb39fed41ccba2e4e58ab7714a53aae3695dbe04',360 'wiki.xh.zip': 'd37caa4d94e66588879231d0826798d8aa4b0a44',361 'wiki.xmf.zip': '956c43bca0d88e9348099cde43d58898e43d9f27',362 'wiki.yi.zip': '151c1670c48e976e4202272b066d7080a8c83615',363 'wiki.yo.zip': 'fdbd0fc6e35bb04c3aef1fa6f0262ba261b11199',364 'wiki.za.zip': '11f6a5dcb49c4d0571d5ac4fb3d7dda1d378fc06',365 'wiki.zea.zip': '22159a722c5c0390bad9206eb75e6e166efe38e9',366 'wiki.zh_classical.zip': 'c689d61d2254caf1ecec0909249523b09a737717',367 'wiki.zh_min_nan.zip': '0516a413565484d924a4c8b50c690d39344cdb64',368 'wiki.zh_yue.zip': '464f4c1c2039194cbae7502ed3a2eeff4df9e34f',369 'wiki.zh.zip': '2374ec566f6411b9bb570077636695fe9768a5ba',370 'wiki.zu.zip': 'a6d0325dab37cd551e6d7f6c783dd13f4c71db2f'}371FAST_TEXT_FILE_SHA1 = \372 {'crawl-300d-2M.vec': '9b556504d099a6c01f3dd76b88775d02cb2f1946',373 'wiki.aa.vec': '5cce30fc85471572c498f278bbe495184577363e',374 'wiki.ab.vec': '9d89a403a9a866d3da8dd8cfab849f59ee499343',375 'wiki.ace.vec': '85d00074f7a08626f39da6a0c8a5cfa250096ab9',376 'wiki.ady.vec': '9d17d74f0348224cdebf8a831e61af0825f8952d',377 'wiki.af.vec': '999e64bcd8dab8de42cb1feceeca360def35324d',378 'wiki.ak.vec': '6092b8af335c2dc93e8df2bbf1d715f01e637bb4',379 'wiki.als.vec': '96052e96870695cca50857b5fde5f9f42219139a',380 'wiki.am.vec': 'dff7fcdd8f5ba0638ab9e1758a89800766156d72',381 'wiki.ang.vec': 'a7c30e02422d97d23a0701279c5c1c03159130a5',382 'wiki.an.vec': '5b4c2b1de5c04e4e0be83841410ca84c47305d21',383 'wiki.arc.vec': 'fd3ad743103f80cde9cfc048d7ca509e50efb35a',384 'wiki.ar.vec': 'c46e2142f799cc385bd25f0c0a8943ca565505a4',385 'wiki.arz.vec': '5e904087043b91f4945dd708f4230fdf51360132',386 'wiki.ast.vec': '89a90357101953b7c292697fd050c00fe5c38ac5',387 'wiki.as.vec': 'cad5883b5147cbe6cdbf604f65cabdb675a59258',388 'wiki.av.vec': '99976a63ca8c4231f808fd4314f0433db35e290d',389 'wiki.ay.vec': 'be359dad25b2c742d3abfa94c5f5db13f86c730e',390 'wiki.azb.vec': 'e23af0a436b97434813c3cb14ed114cc5b352faa',391 'wiki.az.vec': '9581d55d9056ad398a153c37b502f3a07867d091',392 'wiki.bar.vec': '96130f1f2e5bffdd06c202ad4472e5234020980a',393 'wiki.bat_smg.vec': 'cb3aef58da2011183b39fca64cabf3d9d7a62f4b',394 'wiki.ba.vec': '22147ee16b2d163cc88d09a035264fd0c10dab68',395 'wiki.bcl.vec': 'd4117b5c443438ddfa608b10a5be2c2501817e7e',396 'wiki.be.vec': '6cf81322cd7b046a7f02ec4c4960ad27045383fa',397 'wiki.bg.vec': '7c1cc6d0c52b038e4b7173259b0c009f242cf486',398 'wiki.bh.vec': 'ab2d29017afa015c49566a6d9bf75393c23ac4c0',399 'wiki.bi.vec': '15785220cd6e6c86cc87e7d3f3322a5541a4fe5d',400 'wiki.bjn.vec': '5f134cf288e8042dcd048a3ee76159aab42c7288',401 'wiki.bm.vec': 'f36a19c95e90865f6518d4487e59f363b47bd865',402 'wiki.bn.vec': '6fc3bfd9af455719f55bee0bea31b11afc70cf06',403 'wiki.bo.vec': '2e9358e03dcfa09da23d2e1499d84b10348fd8a9',404 'wiki.bpy.vec': 'c2bb15487c4bdb8fa869772694300ae1fee73896',405 'wiki.br.vec': 'df44e16abd2017e2a1b6c6588ee02779b19907f6',406 'wiki.bs.vec': 'c4943a290819ceae1611dd11179b40aab0df0471',407 'wiki.bug.vec': '942d8f7dadde5faa33aa72862501434f48e29f60',408 'wiki.bxr.vec': 'eaf767690c6b194605ae778719212e3874873d4c',409 'wiki.ca.vec': 'f5971edee11c939f6a7accfd33a9a45caa54141a',410 'wiki.cbk_zam.vec': '6fef47b4559eec402ce371de20dfb018acd6347d',411 'wiki.cdo.vec': '95e8196bf76323dbabab1b8a49ba4d677af3ccea',412 'wiki.ceb.vec': 'b8516a55537b8f80c927d77d95cdf7e4ff849a05',413 'wiki.ce.vec': '1d94b0168a773895b23889f7f07d7cf56c11a360',414 'wiki.cho.vec': 'cec6778f025fa9ae4134046c6c3a6291bd9c63f9',415 'wiki.chr.vec': '8501bf86b41074ed6c8d15b9209ef7ce83122e70',416 'wiki.ch.vec': '46803f3a1734f6a7b0d8cb053bbb86a6915d02e9',417 'wiki.chy.vec': '26c87688551ffe3a0c7a5952e894306651e62131',418 'wiki.ckb.vec': 'adb2fef309f1d93f429442b9c16c1564192c58f3',419 'wiki.co.vec': 'af876a918594e5541207bc12f17bfc4268df7b93',420 'wiki.crh.vec': 'c0d2310a1207fcacc94b25b149420b33bf835015',421 'wiki.cr.vec': '61dd9f044b7dfa56dcf1c3c07c7504c569420528',422 'wiki.csb.vec': '649cb2692f08414987c875dc331022567d367497',423 'wiki.cs.vec': 'f3ec1502aeee6a550d8cf784273fa62f61419a4e',424 'wiki.cu.vec': 'ddadb14ea00ea1dda716ee33732497ec049b526f',425 'wiki.cv.vec': '9cdb0bee5a0fea030def85597dba7108f21b0424',426 'wiki.cy.vec': '32d976a9bfc4dd6e39328c906eead0f597bd9e25',427 'wiki.da.vec': '526947dab1ffbc1465c7a766f2bca4de50676b08',428 'wiki.de.vec': '2ed2696afe55f023b0040b238d9a47e5fedfe48b',429 'wiki.diq.vec': '77f3c370d1d77806fafe368cf788af550ff607dd',430 'wiki.dsb.vec': 'e49a647a441fbf011ac5411dd6005e8725b9a65d',431 'wiki.dv.vec': 'e135ba97c711a021bc3317db2b95db5212c17658',432 'wiki.dz.vec': '24888f0b2cd156360bfb5e9e905240163ba798d8',433 'wiki.ee.vec': 'afd1670655daa7ffba51187a415fdd0b43f1d487',434 'wiki.el.vec': '6f034271390feaa6f9d7d16f933ddef637755979',435 'wiki.eml.vec': 'de6be7a2ffdda226eec730dd54b4c614bd7f5dca',436 'wiki.en.vec': 'c1e418f144ceb332b4328d27addf508731fa87df',437 'wiki.eo.vec': 'b56998fd69f66755b722a9481a9bdaf10f62c9aa',438 'wiki.es.vec': '2f41401aa0925167176bcd7a6770423d891dfef5',439 'wiki.et.vec': '64d56b66c02d5e49b1b66a85854d67d2dd9ebd41',440 'wiki.eu.vec': '5e72f4ef93666971fea5d2180b354e0a0821ba91',441 'wiki.ext.vec': '456c5632b13a0f136cd180ebe2dda67b83f78397',442 'wiki.fa.vec': '09b6cc685c895c66b853af9617787d3ab0891e2c',443 'wiki.ff.vec': '12b09d695f5fb8de4b5da9d36a73eb178b293a04',444 'wiki.fiu_vro.vec': '168a71a2b1c478e6810fa5dce9612d8bf8a273dc',445 'wiki.fi.vec': '91d19baae994d7e556b5b5938be2dc6013f9c706',446 'wiki.fj.vec': '36d36dc14001a109926bfc633594f6a2f7401697',447 'wiki.fo.vec': 'eead8ddc7bb74b12b16784723abf802bb51f844d',448 'wiki.frp.vec': '0eb70a613ccf807c7308c1f62535f0606465029d',449 'wiki.frr.vec': 'cde62af939cb2de35e341cef2c74813802a58ed4',450 'wiki.fr.vec': 'b092229005a65d8683a4112852fe6eb8161a6917',451 'wiki.fur.vec': 'd4a595cffa1abcdcf4229ba15277179ce5d20bc6',452 'wiki.fy.vec': 'd4beef537b7ff142a3986513879ff51a9ec14a7b',453 'wiki.gag.vec': 'c82ec7a5d081f0673661824f4fc34345dee255f0',454 'wiki.gan.vec': '7e53a33b7bd5b0360ea4cb452145616c09445029',455 'wiki.ga.vec': 'caaa5b2167a499893313ac1aa38416a6a0fe9a24',456 'wiki.gd.vec': 'f4b513598a1bf0f0d5b6521ea8ce363e9596cb97',457 'wiki.glk.vec': '20a7759075916e10531f5b3577302353cef565cd',458 'wiki.gl.vec': '8888bb8f3d70b36729b9ae479fe3765e0c083862',459 'wiki.gn.vec': '98594af7897c5a1f35885ddecc77556a7e7ae981',460 'wiki.gom.vec': '5a1193d9e5d49d06354c14e2b7c01bea176e13f1',461 'wiki.got.vec': 'dfa06de83a0e3099027c57b84561d7d990ea8310',462 'wiki.gu.vec': 'f9e13452eb63d92bea44c7c3db8fba9945c7000e',463 'wiki.gv.vec': '993a7ee31bdacc91763dad656aa6c2947b873473',464 'wiki.hak.vec': '9e83512d34c7f81739492bf0abbb25ff1ef88573',465 'wiki.ha.vec': '677a24efeeb1bcb8c0a931407775f18b18e875ae',466 'wiki.haw.vec': '58fea5aa1b37723797d26fb3d050ce6176757240',467 'wiki.he.vec': '55534560247394669e3f5c169136770c93bc2708',468 'wiki.hif.vec': '49697cf784814d3f1a47559724028e0fc0940d36',469 'wiki.hi.vec': '8049bb8604bc049d48bd934e27b0e184c480a413',470 'wiki.ho.vec': '9c75a09e099213aa8cd1f1020b223427537cbdd8',471 'wiki.hr.vec': '0c96f9af092cf8a84b03aec1426cd23921671489',472 'wiki.hsb.vec': '3dc7830544c58535bed308c552d609e13b973502',473 'wiki.ht.vec': '5039dfb58a074ac046813f2dae81159be8c5213f',474 'wiki.hu.vec': 'cd777e9efca3d4bd97c89f01690cfa4840d9c46f',475 'wiki.hy.vec': '21f9259d04cfd22db446a45d3622af225f00cf20',476 'wiki.hz.vec': '2a94b1390d68027748a05169fbc0c11a9a183456',477 'wiki.ia.vec': '2a348dc924638efc20c34785852b0837364aed76',478 'wiki.id.vec': 'c49d5c9bec89114599427f6c12a5bda2e5523dfd',479 'wiki.ie.vec': '01b0d11c0e7397418e73853d220e97bdcf7a8961',480 'wiki.ig.vec': 'd2d1643b4fb1a18a4d002cf2969073f7f201b3b2',481 'wiki.ii.vec': '41c6cd68b3ebe4ece2a06c37b06dca5d07c9fb3a',482 'wiki.ik.vec': 'af31cbec7b839f50fa70553ec63c58f7067d3ea8',483 'wiki.ilo.vec': 'c0e43835a3f4e0033ea5d7c6ff189982b2f26a05',484 'wiki.io.vec': 'af0c480c5872bff31d82e767c1116da2a6be0c00',485 'wiki.is.vec': 'ae0b018f92b3e218f2dacb2045a8f0a0446788a5',486 'wiki.it.vec': 'ac4a985e85ffae48047034e2603d804bf126caa9',487 'wiki.iu.vec': '5d51b2ba215005216ae003f4a6d6ef39fb30ca2e',488 'wiki.jam.vec': '6d51e384c56330097c2531fdbf4e74418909e388',489 'wiki.ja.vec': '7a2b1af1e46d795410692a002e40fa3085135f69',490 'wiki.jbo.vec': 'c90481946aa4b6b304528292612ae620f6549f3e',491 'wiki.jv.vec': '2ff7927d3ff04b8208133497b3778ede00ea463f',492 'wiki.kaa.vec': 'd990d3b9bd511d2d630f923099a6b9110231b2ed',493 'wiki.kab.vec': 'e3b73d41267d8d4cd42f6cc5a0c05dc4e021bf74',494 'wiki.ka.vec': '8b92b73f27f9b77818211e053a33985589de7c62',495 'wiki.kbd.vec': 'f5b8dbe47a7fae702232b5680b070ef6e865539e',496 'wiki.kg.vec': '1550647b6059e6eb649b100e31c53bd0661117b2',497 'wiki.ki.vec': 'c4e373e2ea13f7fa1e95b0733365e4b3fc8b2cc8',498 'wiki.kj.vec': 'c27e563683f9c96ff6f680a6d6bb9e9e2f9960d0',499 'wiki.kk.vec': '6343b2b31bad2e13d03a110b91c38fab4adc01cd',500 'wiki.kl.vec': 'e5def7fb1b56c5956b6e951e912d53ba0ff089f8',501 'wiki.km.vec': '64f7fff1df90b1f7241b232e901f76223a3719e0',502 'wiki.kn.vec': '32763f4f860f0d081f3aabf3e7d17b7858e7d877',503 'wiki.koi.vec': '4001f0617fe0fdd3b22116b304f497b7b16c6e4c',504 'wiki.ko.vec': '042c85a788c2778cca538cf716b8a78f0d7fa823',505 'wiki.krc.vec': '0c6ef043d51e5f337a309804f1db180fa0bb2cb8',506 'wiki.kr.vec': '25d5b4d5911a819c48328c48fb346417d07d4070',507 'wiki.ksh.vec': '4c3bb4f12073532b6fb7cc6c2be5e53319ef5b65',508 'wiki.ks.vec': '5056a87c4ee2d8bf0792436fc6b2b61648014de9',509 'wiki.ku.vec': '4d3a2401527dd9ba6be2b0cd31f6cd3edebadce9',510 'wiki.kv.vec': '164dc44d701b9d606a45f0b0446076adc3858dca',511 'wiki.kw.vec': 'f9eaa35a7e4f077f6de85c7801f74582f91b52c1',512 'wiki.ky.vec': '13b0ae3f23822317a0243bd9182105c631c834b3',513 'wiki.lad.vec': 'c510e520cde97050bf1cbeb36f2b90e6348ceed4',514 'wiki.la.vec': '9ea6286a0581084533db8d6ee96e0b7d15166543',515 'wiki.lbe.vec': '283619d93255571f14fd4545bb0577979171b990',516 'wiki.lb.vec': 'b146f23628c84e64314a35a5b6cc65a33777e22d',517 'wiki.lez.vec': '8e579b984a500ad89fc66767bfd7319766bd669b',518 'wiki.lg.vec': 'b096f5248dfbb343dc4696c97ea253510e1c4ef9',519 'wiki.lij.vec': '4ff5bb405c820e4119f0636efc301da15a08c00a',520 'wiki.li.vec': '0fb9ec4ac93676d8ef651692062bc3d7f6ae0843',521 'wiki.lmo.vec': 'a89414d9ceee4823622258f18936f67faf7e06e7',522 'wiki.ln.vec': '70b6a286b42958e25cb80824e0d8f1aee2de6dde',523 'wiki.lo.vec': '7c83f82b80c49b8eab21f62ecdb3681b8bda40a6',524 'wiki.lrc.vec': 'c1ae4fb79a19d44bfe8f601f0a30fbec841fa612',525 'wiki.ltg.vec': 'ec2f13d1290bd54afcaa74569e66e43e9bfef264',526 'wiki.lt.vec': '58d3ebef24e5e31be1a8318b45c08ebb16ad775a',527 'wiki.lv.vec': 'ef6b549f96e22718f513d47a611d3d6bc001a164',528 'wiki.mai.vec': '7f513ff36e485b19f91f83b30c32dd82e9e497f6',529 'wiki.map_bms.vec': 'e7deab5fdd38fa3331b1bcb4a16432b38c512e21',530 'wiki.mdf.vec': 'b16099ce0283a241339716eac41cfd99fdea7f36',531 'wiki.mg.vec': '0808252740909d6129f672584311263e7b2adadc',532 'wiki.mhr.vec': '39f62e292336cabc364f0d1913540b881b406393',533 'wiki.mh.vec': '7d2d8bff722fe0a5d869d9da11792a406aff3dc3',534 'wiki.min.vec': '3bb0fa596cf27a1d165c55684bebdc8d40cb8ad7',535 'wiki.mi.vec': 'e8acf9c7c2ab840a192c563aa776201a88e4ca89',536 'wiki.mk.vec': '85a3d3f13fa88ffde023d2326c65bdded4983dff',537 'wiki.ml.vec': '2b70fe76e8cf199a18551de782784a21e8db0b66',538 'wiki.mn.vec': '7cef7ecdf9d98484d9b598b25d0e717dba6acfd9',539 'wiki.mo.vec': 'cc54b661aefabdf516b49d24acb51273b3acf210',540 'wiki.mrj.vec': 'aa1c1ecba1ffd6b42c8d9659a8a04ab328ae1650',541 'wiki.mr.vec': '2cd6cf88bfdfb24850d345749ce0cfea8d65829e',542 'wiki.ms.vec': '458e1a079799a54cdc0a7b78c7fa1729d2683a6d',543 'wiki.mt.vec': '81f4c1d84dd4cc4276d59cb903fcc9aba46be981',544 'wiki.multi.ar.vec': 'f1f12cc9d629382af574a3db74fe49c2fd615c8f',545 'wiki.multi.bg.vec': '22470e664e4b35761a33c64433ea2f0c12140673',546 'wiki.multi.ca.vec': 'bc8d98b4d86d740d1985d73d211d887d561bcdd7',547 'wiki.multi.cs.vec': '17358b62e63f96b0479d6a70e9235a0421493884',548 'wiki.multi.da.vec': 'ebc75f428714d26fb1fa31accce49ad3b31e273b',549 'wiki.multi.de.vec': 'b9a63406aedf4446b467b94d12674bfe4723b52d',550 'wiki.multi.el.vec': '03d33db85bf83f35b943ce93b18c02fa98a0bc05',551 'wiki.multi.en.vec': '696719afdbe470ee4a2eb668229486dba1df19cc',552 'wiki.multi.es.vec': '98c9e35564ec57fee5dbc6155890150452f45d3f',553 'wiki.multi.et.vec': 'db10189093387e853f2fd3978770e1cc7bc07820',554 'wiki.multi.fi.vec': '746916885a1c7d4ec3f139a32cf267f9e15f5363',555 'wiki.multi.fr.vec': 'fe1535827b631d934beb02f8d36ba901b2c94a46',556 'wiki.multi.he.vec': '6dd112f018165317da22971a2b6fdb2a15dafa91',557 'wiki.multi.hr.vec': 'ff9f23cf595ec8dd93cd93c6b48049730c34253b',558 'wiki.multi.hu.vec': '6da405c9b048f3cbb990bfb29ef149f0430aa2e7',559 'wiki.multi.id.vec': '34edadab182682198c37ade8538530c545635742',560 'wiki.multi.it.vec': 'c55802bd73d46a6fc86771097670e02a70b5d46d',561 'wiki.multi.mk.vec': 'cec8550503ebca0bdc7ad11f2c15085b7072a990',562 'wiki.multi.nl.vec': 'c3f45a5fe8a8bc213cdf35dce51651b752ca60c4',563 'wiki.multi.no.vec': '105236df530c8fc2ce5b1e2550a2059bbc46fc28',564 'wiki.multi.pl.vec': '676eb5acb22982c0c9a7d6e4c90d26730c6d120e',565 'wiki.multi.pt.vec': '625b0a5384873c79a5dcfff5ee3fde49a3a65013',566 'wiki.multi.ro.vec': '82bd59674509b69f988f9870e3a291836ba43e84',567 'wiki.multi.ru.vec': 'a7d9c5f2ab2abb448a5111d352caa921adabe830',568 'wiki.multi.sk.vec': '98d849ee77f0320472cc5afa002bfde129be7089',569 'wiki.multi.sl.vec': 'fb5cfb8a9c44380d74fb21ddd204e820c4e05c31',570 'wiki.multi.sv.vec': '95d6cc3ba23dffff9be6adb467b617dd57780cb2',571 'wiki.multi.tr.vec': 'ecb0e353eaccba3fcacc6994d93065934ef429e9',572 'wiki.multi.uk.vec': '35f4f5a1ead8bd66bcaf865021fc3aae94456ab6',573 'wiki.multi.vi.vec': 'b1abe06360e1d65a0db65dd41ead7b2f9d651ea0',574 'wiki.mus.vec': 'fa1066f7bd09df4589993ca498c19aeb6cf986fd',575 'wiki.mwl.vec': '3d10a218242b94fcc3981aa3beb012b701827a55',576 'wiki.my.vec': 'e7c7989e32b23ca1a9caf534cc65ecaf9e1b9112',577 'wiki.myv.vec': '7de0927fd3d65677de7f770b3bd57c73b58df85d',578 'wiki.mzn.vec': 'aefad49237808acab99e1ca8eeaaf531666f261d',579 'wiki.nah.vec': 'c52e01cf4479fb7ec91ef39f298e8f97aeb6496e',580 'wiki.nap.vec': '6c9bd8ce1e85ee679b25189fd6f6d36afb119b6c',581 'wiki.na.vec': '8a592eb3dbe5693372714dff495d01cabc3ea215',582 'wiki.nds_nl.vec': '1cd96d12e78e5cd3f65ca2773a17696bda387b9f',583 'wiki.nds.vec': '7bf293149c08226e05bcf0442ac6e601162b9ffd',584 'wiki.ne.vec': '1045d7876f947cd4602d9ca79f7c4323a5d3a52d',585 'wiki-news-300d-1M-subword.vec': '717a3058e0ba5ef3cde52c3df0d4f0f60b0a113a',586 'wiki-news-300d-1M.vec': '11cac9efe6f599e659be182f5766d6fbd5b1cab9',587 'wiki.new.vec': '51f6c0b4ef1aee9fad4ab1cb69a7479db35e39a5',588 'wiki.ng.vec': 'c3016cc07d40bd43bea84b7c600244ff3d2a928e',589 'wiki.nl.vec': 'd796ee27e37b7d1d464e03c265c31ab62b52533e',590 'wiki.nn.vec': '35aeab89ffeca0377accbbd3bf18b81913c75448',591 'wiki.no.vec': 'd52e8019d7cc48569c8c3b514d2b1bd10261b5c0',592 'wiki.nov.vec': '5455c6e8463b1c43dd073e3e177702fb9a1dd834',593 'wiki.nrm.vec': 'b4cb941b126b26fa045c5fc75a490a31a969101c',594 'wiki.nso.vec': 'a906271509c2b343df35d1471509492bbfa883aa',595 'wiki.nv.vec': 'f5a6ea213bfe95c82cb22b53b4965df8b67ffeab',596 'wiki.ny.vec': '3aec3dcaea6c35f8254c407621644f87df37e411',597 'wiki.oc.vec': 'cc1833492899d75571148c2c305591f53d63f0b1',598 'wiki.olo.vec': 'cbadb4cada4dc579d0becdac93dfb479d76bf6c8',599 'wiki.om.vec': '91789a8d9f9284f7e71e4bb8d9a60eae4af4adca',600 'wiki.or.vec': 'a6b120fe536b6c0133b077dca0043c3bc97eef0b',601 'wiki.os.vec': '791b26cc300e9a1f0a08c7b2213a264e41ce30d6',602 'wiki.pag.vec': '03f71faf060c4eb33802275279967349c0337553',603 'wiki.pam.vec': '8fbd31e70d0ca0c61eb1a152efaa8ecb29180967',604 'wiki.pap.vec': '8cd98267cc55a4f9de80212e29651ddf7a9e83fd',605 'wiki.pa.vec': '4939d0db77a5b28d7d5aab0fab4f999d93b2053e',606 'wiki.pcd.vec': 'd2e8e7321b6f1bce94c563cb8ef8af2b45cc3e48',607 'wiki.pdc.vec': '401e24d0fb9b0ae9e06a5c700684361f58727fcf',608 'wiki.pfl.vec': '0ad9b7f3ae13f909f12835107432fee4c4ed3031',609 'wiki.pih.vec': '4ae6ef2a9c6c88e9322eda900e0f58be5592a29b',610 'wiki.pi.vec': 'd388db284357042f4260e1a567cb489b05bb8e0b',611 'wiki.pl.vec': 'd031adb6f83eda0364a861dcbf5ef779b5951c0b',612 'wiki.pms.vec': 'e30bda8d33d61db43243c157b9ac2feeaff316c8',613 'wiki.pnb.vec': '35f38862d3d83012d6db7baa8a4105e3e0a416e7',614 'wiki.pnt.vec': '38134772012d68f247e34daf220d9d4ed3e7f489',615 'wiki.ps.vec': '64f1bec5d5b937289199ceae2e1da6557ce48852',616 'wiki.pt.vec': '7f11ebdb0cbf5929b38319f1e977d2c13bcd741b',617 'wiki.qu.vec': '58de8c8290e8bc8f2a6a677312e28457113437b2',618 'wiki.rm.vec': '5d3144b47a0dd98648a6df0636384ab2a010ad7b',619 'wiki.rmy.vec': '3d36d3485961900c23355a0f7c2ba656a8558c29',620 'wiki.rn.vec': '80b6171b78dd932f59f70dbef074abb906af4eee',621 'wiki.roa_rup.vec': 'e31a44353cd84b976586c8df35a2ab58318120f0',622 'wiki.roa_tara.vec': 'b3fcb01ff0bac53a0ba08c5c0c411f26ee83a95a',623 'wiki.ro.vec': 'c088ea2752d5ec8b42e32410c191a14839ae8a1f',624 'wiki.rue.vec': 'fe539e0ea0bbbfd3ee06bd0c5521a035c7361ec5',625 'wiki.ru.vec': '7514a2c60ee4118abb451ed32a0d61cb52dec384',626 'wiki.rw.vec': 'af2ec410da6519a86ba21004c8b4c7fde768a91c',627 'wiki.sah.vec': '202470467194a1cbdcd571b14ef68371a29b38d9',628 'wiki.sa.vec': '7fed78d1d7674453b9876ee99aeeeba85ea46699',629 'wiki.scn.vec': 'bde043a235551e1643506774c5d9b61ecf2fc424',630 'wiki.sco.vec': '4625a5ad90a57f994be9b3aa4f8f3ecda941a821',631 'wiki.sc.vec': 'dba8dc7754ef04b1ba0cd702d94eea9575cde91c',632 'wiki.sd.vec': '36852d1253496e598fbd9b9009f07f454a6bea5b',633 'wiki.se.vec': 'f46b35ee6b893c2f12dd1b929bbc2b8120cbcd8d',634 'wiki.sg.vec': '90ece136bef7ad6e4e97776a1c7238499544405d',635 'wiki.sh.vec': '016691ecb26ace442731d92b1265e5c6c3d8ca5f',636 'wiki.simple.vec': '55267c50fbdf4e4ae0fbbda5c73830a379d68795',637 'wiki.si.vec': 'd05ed6a0bc1ee56e5d2e5f881d47372095f6eb0c',638 'wiki.sk.vec': '98759aacf7352d49a51390fae02030776510ae13',639 'wiki.sl.vec': 'b26997c0ed1de26a47b11efdc26ac1e7f189fa54',640 'wiki.sm.vec': '88c2c57ca483626b052403418cb4372d72352bc9',641 'wiki.sn.vec': '8dbb1019dcc8f842a8c0f550295ae697f8e1b7e0',642 'wiki.so.vec': '294756b60b03fe57cb08abd8d677d6a717b40bc8',643 'wiki.sq.vec': 'd07ffed553f5eb4756d0a1548a7ba9a51a52f7c6',644 'wiki.srn.vec': 'faee05e550f5b08809a9ae5586ac4b08c9a1c359',645 'wiki.sr.vec': '3cf09f476f55a92fdd2880f7ba336656ab232736',646 'wiki.ss.vec': '488546a3b2f88f549c50ae9f32f1997cc441b039',647 'wiki.stq.vec': '1bf88af29f1d86cac16042a5bea6b1651c96a8c1',648 'wiki.st.vec': '963646055d12873b1c83b0eef8649ecaf473d42e',649 'wiki.su.vec': '25e864495acb6d280bab0e62480f68550c9ceed4',650 'wiki.sv.vec': 'eab83ae36701139696477b91b6e8d292ef175053',651 'wiki.sw.vec': '8e70d207dbbd14e60a48e260a23fbf284a8e9f06',652 'wiki.szl.vec': '0573cf888ec70b459b0596d34814fe60fd69f190',653 'wiki.ta.vec': 'b66b5358527b1f3a6a421ab26464a3c1e75e18af',654 'wiki.tcy.vec': '388b1d89642fcc790b688e9643b3d19e14d66f40',655 'wiki.tet.vec': 'f38fe0e76b9b08ff652689eeee42c4fdadd9a47e',656 'wiki.te.vec': 'e71dcf3cc45da1bcdae5e431324025bd2026d0c8',657 'wiki.tg.vec': '6a5cd5bfe571ca0359b66d21bf6950553213f42d',658 'wiki.th.vec': '1d6e0d525392a1042d017534f6c320c5a0afd345',659 'wiki.ti.vec': 'c769fbc99bbb4138a40231e573685c7948d4a4c4',660 'wiki.tk.vec': '33ae577f77d339ab7a0dff88855b8d5c974d0aef',661 'wiki.tl.vec': 'd508e229ced7201510999e76d583de3ff2339d8b',662 'wiki.tn.vec': '39f45f3fa86645bb25c54150204abcd51cc1048c',663 'wiki.to.vec': '64d512665b55e9ef9a3915e8167347be79310fa0',664 'wiki.tpi.vec': '407b96d235f54f3e0be9dc23a3bab89c6593a621',665 'wiki.tr.vec': '13234aa1bf5f99e81d933482b3b83c3e4bf6c85e',666 'wiki.ts.vec': '00f8229e2f230afd388221c0f823a1de9fc0e443',667 'wiki.tt.vec': '913bb3a11da6f8142b3bbec3ef065162d9350f1d',668 'wiki.tum.vec': 'bfbe43364724af882a520d2edcc2ce049c7357cd',669 'wiki.tw.vec': 'f329b667d70d9f0b753e55e1b1579b5a5191d3bd',670 'wiki.ty.vec': 'b881f60b8c75a71864d9847a17961d368f3058fc',671 'wiki.tyv.vec': 'e8f9a36dc58e4108c553f96e247a877a099ab5ba',672 'wiki.udm.vec': '336a8526f22e177faac69573661dc9c3ce36591f',673 'wiki.ug.vec': '586d2febafaf17c9187c599ffd7b96e559103c34',674 'wiki.uk.vec': '77f7737b9f88eac2b3e130ea8abb8886336fd0c6',675 'wiki.ur.vec': 'cb8132102152a958df72bd3e25f1a72abb4c9c76',676 'wiki.uz.vec': '11c3a76dae12b454f693811e33ae2e60015743e2',677 'wiki.vec.vec': 'ae4b055fba21974e56beecab3a95f9dc24a62fd0',678 'wiki.vep.vec': 'a38a781fde24f4d7b52aa8bc450b9949dd4e1808',679 'wiki.ve.vec': 'b7d2947501de1c30a9f8496d5efae20c051104e1',680 'wiki.vi.vec': 'bc84245b52b2e212e28dc6856c0693ce9845a9c5',681 'wiki.vls.vec': '07e8636908c057b9870ce4b98c7130d460cf882a',682 'wiki.vo.vec': 'c830988b6965bfce2f932b1be193f7d1f755f411',683 'wiki.war.vec': '1f5d443d6f612b59a53820dd6f39fd886a6ad30f',684 'wiki.wa.vec': '18f9ca1a585e1d18c3630029141a2e19d7d34a8e',685 'wiki.wo.vec': '2ad96a7a9e640bc0dbcf316b1f414b92802dcb8e',686 'wiki.wuu.vec': 'e1cbae1d3ad52329d0f36ada764016fbacf07049',687 'wiki.xal.vec': 'b738222d84cb8c8fdb2b30a7219aa5d3bdc2f61c',688 'wiki.xh.vec': 'bf37f741b0b75953281d11df2b4d80100df9e666',689 'wiki.xmf.vec': 'dc1923cfd1a7002d5d60426b60e6756854ab4a14',690 'wiki.yi.vec': '299d61958b7dcc38774768f1489121384726d860',691 'wiki.yo.vec': 'e35c8aff2924ba07936be9d0d94bd298f09702a4',692 'wiki.za.vec': 'e3a0e58bd2e5b1891c71f1f7e37ff71997a20361',693 'wiki.zea.vec': 'ee12db26aab3f2b3b2745a298ef414e7aeb5a058',694 'wiki.zh_classical.vec': '840981c83dd8e5cb02d1cd695e2fe0870941316c',695 'wiki.zh_min_nan.vec': 'f91ccb013e200bb7ed560082ddf4bdd9c2f315bb',696 'wiki.zh.vec': '117ab34faa80e381641fbabf3a24bc8cfba44050',697 'wiki.zh_yue.vec': 'd2ac1ab9eb1a908797644f83f259c90cb3c1a350',...

Full Screen

Full Screen

test_zipimport.py

Source:test_zipimport.py Github

copy

Full Screen

1import sys2import os3import marshal4import imp5import struct6import time7import unittest8from test import support9from test.test_importhooks import ImportHooksBaseTestCase, test_src, test_co10# some tests can be ran even without zlib11try:12 import zlib13except ImportError:14 zlib = None15from zipfile import ZipFile, ZipInfo, ZIP_STORED, ZIP_DEFLATED16import zipimport17import linecache18import doctest19import inspect20import io21from traceback import extract_tb, extract_stack, print_tb22raise_src = 'def do_raise(): raise TypeError\n'23# so we only run testAFakeZlib once if this test is run repeatedly24# which happens when we look for ref leaks25test_imported = False26def make_pyc(co, mtime):27 data = marshal.dumps(co)28 if type(mtime) is type(0.0):29 # Mac mtimes need a bit of special casing30 if mtime < 0x7fffffff:31 mtime = int(mtime)32 else:33 mtime = int(-0x100000000 + int(mtime))34 pyc = imp.get_magic() + struct.pack("<i", int(mtime)) + data35 return pyc36def module_path_to_dotted_name(path):37 return path.replace(os.sep, '.')38NOW = time.time()39test_pyc = make_pyc(test_co, NOW)40TESTMOD = "ziptestmodule"41TESTPACK = "ziptestpackage"42TESTPACK2 = "ziptestpackage2"43TEMP_ZIP = os.path.abspath("junk95142.zip")44pyc_file = imp.cache_from_source(TESTMOD + '.py')45pyc_ext = ('.pyc' if __debug__ else '.pyo')46class UncompressedZipImportTestCase(ImportHooksBaseTestCase):47 compression = ZIP_STORED48 def setUp(self):49 # We're reusing the zip archive path, so we must clear the50 # cached directory info and linecache51 linecache.clearcache()52 zipimport._zip_directory_cache.clear()53 ImportHooksBaseTestCase.setUp(self)54 def doTest(self, expected_ext, files, *modules, **kw):55 z = ZipFile(TEMP_ZIP, "w")56 try:57 for name, (mtime, data) in files.items():58 zinfo = ZipInfo(name, time.localtime(mtime))59 zinfo.compress_type = self.compression60 z.writestr(zinfo, data)61 z.close()62 stuff = kw.get("stuff", None)63 if stuff is not None:64 # Prepend 'stuff' to the start of the zipfile65 with open(TEMP_ZIP, "rb") as f:66 data = f.read()67 with open(TEMP_ZIP, "wb") as f:68 f.write(stuff)69 f.write(data)70 sys.path.insert(0, TEMP_ZIP)71 mod = __import__(".".join(modules), globals(), locals(),72 ["__dummy__"])73 call = kw.get('call')74 if call is not None:75 call(mod)76 if expected_ext:77 file = mod.get_file()78 self.assertEqual(file, os.path.join(TEMP_ZIP,79 *modules) + expected_ext)80 finally:81 z.close()82 os.remove(TEMP_ZIP)83 def testAFakeZlib(self):84 #85 # This could cause a stack overflow before: importing zlib.py86 # from a compressed archive would cause zlib to be imported87 # which would find zlib.py in the archive, which would... etc.88 #89 # This test *must* be executed first: it must be the first one90 # to trigger zipimport to import zlib (zipimport caches the91 # zlib.decompress function object, after which the problem being92 # tested here wouldn't be a problem anymore...93 # (Hence the 'A' in the test method name: to make it the first94 # item in a list sorted by name, like unittest.makeSuite() does.)95 #96 # This test fails on platforms on which the zlib module is97 # statically linked, but the problem it tests for can't98 # occur in that case (builtin modules are always found first),99 # so we'll simply skip it then. Bug #765456.100 #101 if "zlib" in sys.builtin_module_names:102 return103 if "zlib" in sys.modules:104 del sys.modules["zlib"]105 files = {"zlib.py": (NOW, test_src)}106 try:107 self.doTest(".py", files, "zlib")108 except ImportError:109 if self.compression != ZIP_DEFLATED:110 self.fail("expected test to not raise ImportError")111 else:112 if self.compression != ZIP_STORED:113 self.fail("expected test to raise ImportError")114 def testPy(self):115 files = {TESTMOD + ".py": (NOW, test_src)}116 self.doTest(".py", files, TESTMOD)117 def testPyc(self):118 files = {TESTMOD + pyc_ext: (NOW, test_pyc)}119 self.doTest(pyc_ext, files, TESTMOD)120 def testBoth(self):121 files = {TESTMOD + ".py": (NOW, test_src),122 TESTMOD + pyc_ext: (NOW, test_pyc)}123 self.doTest(pyc_ext, files, TESTMOD)124 def testEmptyPy(self):125 files = {TESTMOD + ".py": (NOW, "")}126 self.doTest(None, files, TESTMOD)127 def testBadMagic(self):128 # make pyc magic word invalid, forcing loading from .py129 badmagic_pyc = bytearray(test_pyc)130 badmagic_pyc[0] ^= 0x04 # flip an arbitrary bit131 files = {TESTMOD + ".py": (NOW, test_src),132 TESTMOD + pyc_ext: (NOW, badmagic_pyc)}133 self.doTest(".py", files, TESTMOD)134 def testBadMagic2(self):135 # make pyc magic word invalid, causing an ImportError136 badmagic_pyc = bytearray(test_pyc)137 badmagic_pyc[0] ^= 0x04 # flip an arbitrary bit138 files = {TESTMOD + pyc_ext: (NOW, badmagic_pyc)}139 try:140 self.doTest(".py", files, TESTMOD)141 except ImportError:142 pass143 else:144 self.fail("expected ImportError; import from bad pyc")145 def testBadMTime(self):146 badtime_pyc = bytearray(test_pyc)147 # flip the second bit -- not the first as that one isn't stored in the148 # .py's mtime in the zip archive.149 badtime_pyc[7] ^= 0x02150 files = {TESTMOD + ".py": (NOW, test_src),151 TESTMOD + pyc_ext: (NOW, badtime_pyc)}152 self.doTest(".py", files, TESTMOD)153 def testPackage(self):154 packdir = TESTPACK + os.sep155 files = {packdir + "__init__" + pyc_ext: (NOW, test_pyc),156 packdir + TESTMOD + pyc_ext: (NOW, test_pyc)}157 self.doTest(pyc_ext, files, TESTPACK, TESTMOD)158 def testDeepPackage(self):159 packdir = TESTPACK + os.sep160 packdir2 = packdir + TESTPACK2 + os.sep161 files = {packdir + "__init__" + pyc_ext: (NOW, test_pyc),162 packdir2 + "__init__" + pyc_ext: (NOW, test_pyc),163 packdir2 + TESTMOD + pyc_ext: (NOW, test_pyc)}164 self.doTest(pyc_ext, files, TESTPACK, TESTPACK2, TESTMOD)165 def testZipImporterMethods(self):166 packdir = TESTPACK + os.sep167 packdir2 = packdir + TESTPACK2 + os.sep168 files = {packdir + "__init__" + pyc_ext: (NOW, test_pyc),169 packdir2 + "__init__" + pyc_ext: (NOW, test_pyc),170 packdir2 + TESTMOD + pyc_ext: (NOW, test_pyc)}171 z = ZipFile(TEMP_ZIP, "w")172 try:173 for name, (mtime, data) in files.items():174 zinfo = ZipInfo(name, time.localtime(mtime))175 zinfo.compress_type = self.compression176 z.writestr(zinfo, data)177 z.close()178 zi = zipimport.zipimporter(TEMP_ZIP)179 self.assertEqual(zi.archive, TEMP_ZIP)180 self.assertEqual(zi.is_package(TESTPACK), True)181 mod = zi.load_module(TESTPACK)182 self.assertEqual(zi.get_filename(TESTPACK), mod.__file__)183 self.assertEqual(zi.is_package(packdir + '__init__'), False)184 self.assertEqual(zi.is_package(packdir + TESTPACK2), True)185 self.assertEqual(zi.is_package(packdir2 + TESTMOD), False)186 mod_path = packdir2 + TESTMOD187 mod_name = module_path_to_dotted_name(mod_path)188 __import__(mod_name)189 mod = sys.modules[mod_name]190 self.assertEqual(zi.get_source(TESTPACK), None)191 self.assertEqual(zi.get_source(mod_path), None)192 self.assertEqual(zi.get_filename(mod_path), mod.__file__)193 # To pass in the module name instead of the path, we must use the194 # right importer195 loader = mod.__loader__196 self.assertEqual(loader.get_source(mod_name), None)197 self.assertEqual(loader.get_filename(mod_name), mod.__file__)198 # test prefix and archivepath members199 zi2 = zipimport.zipimporter(TEMP_ZIP + os.sep + TESTPACK)200 self.assertEqual(zi2.archive, TEMP_ZIP)201 self.assertEqual(zi2.prefix, TESTPACK + os.sep)202 finally:203 z.close()204 os.remove(TEMP_ZIP)205 def testZipImporterMethodsInSubDirectory(self):206 packdir = TESTPACK + os.sep207 packdir2 = packdir + TESTPACK2 + os.sep208 files = {packdir2 + "__init__" + pyc_ext: (NOW, test_pyc),209 packdir2 + TESTMOD + pyc_ext: (NOW, test_pyc)}210 z = ZipFile(TEMP_ZIP, "w")211 try:212 for name, (mtime, data) in files.items():213 zinfo = ZipInfo(name, time.localtime(mtime))214 zinfo.compress_type = self.compression215 z.writestr(zinfo, data)216 z.close()217 zi = zipimport.zipimporter(TEMP_ZIP + os.sep + packdir)218 self.assertEqual(zi.archive, TEMP_ZIP)219 self.assertEqual(zi.prefix, packdir)220 self.assertEqual(zi.is_package(TESTPACK2), True)221 mod = zi.load_module(TESTPACK2)222 self.assertEqual(zi.get_filename(TESTPACK2), mod.__file__)223 self.assertEqual(224 zi.is_package(TESTPACK2 + os.sep + '__init__'), False)225 self.assertEqual(226 zi.is_package(TESTPACK2 + os.sep + TESTMOD), False)227 mod_path = TESTPACK2 + os.sep + TESTMOD228 mod_name = module_path_to_dotted_name(mod_path)229 __import__(mod_name)230 mod = sys.modules[mod_name]231 self.assertEqual(zi.get_source(TESTPACK2), None)232 self.assertEqual(zi.get_source(mod_path), None)233 self.assertEqual(zi.get_filename(mod_path), mod.__file__)234 # To pass in the module name instead of the path, we must use the235 # right importer236 loader = mod.__loader__237 self.assertEqual(loader.get_source(mod_name), None)238 self.assertEqual(loader.get_filename(mod_name), mod.__file__)239 finally:240 z.close()241 os.remove(TEMP_ZIP)242 def testGetData(self):243 z = ZipFile(TEMP_ZIP, "w")244 z.compression = self.compression245 try:246 name = "testdata.dat"247 data = bytes(x for x in range(256))248 z.writestr(name, data)249 z.close()250 zi = zipimport.zipimporter(TEMP_ZIP)251 self.assertEqual(data, zi.get_data(name))252 self.assertIn('zipimporter object', repr(zi))253 finally:254 z.close()255 os.remove(TEMP_ZIP)256 def testImporterAttr(self):257 src = """if 1: # indent hack258 def get_file():259 return __file__260 if __loader__.get_data("some.data") != b"some data":261 raise AssertionError("bad data")\n"""262 pyc = make_pyc(compile(src, "<???>", "exec"), NOW)263 files = {TESTMOD + pyc_ext: (NOW, pyc),264 "some.data": (NOW, "some data")}265 self.doTest(pyc_ext, files, TESTMOD)266 def testImport_WithStuff(self):267 # try importing from a zipfile which contains additional268 # stuff at the beginning of the file269 files = {TESTMOD + ".py": (NOW, test_src)}270 self.doTest(".py", files, TESTMOD,271 stuff=b"Some Stuff"*31)272 def assertModuleSource(self, module):273 self.assertEqual(inspect.getsource(module), test_src)274 def testGetSource(self):275 files = {TESTMOD + ".py": (NOW, test_src)}276 self.doTest(".py", files, TESTMOD, call=self.assertModuleSource)277 def testGetCompiledSource(self):278 pyc = make_pyc(compile(test_src, "<???>", "exec"), NOW)279 files = {TESTMOD + ".py": (NOW, test_src),280 TESTMOD + pyc_ext: (NOW, pyc)}281 self.doTest(pyc_ext, files, TESTMOD, call=self.assertModuleSource)282 def runDoctest(self, callback):283 files = {TESTMOD + ".py": (NOW, test_src),284 "xyz.txt": (NOW, ">>> log.append(True)\n")}285 self.doTest(".py", files, TESTMOD, call=callback)286 def doDoctestFile(self, module):287 log = []288 old_master, doctest.master = doctest.master, None289 try:290 doctest.testfile(291 'xyz.txt', package=module, module_relative=True,292 globs=locals()293 )294 finally:295 doctest.master = old_master296 self.assertEqual(log,[True])297 def testDoctestFile(self):298 self.runDoctest(self.doDoctestFile)299 def doDoctestSuite(self, module):300 log = []301 doctest.DocFileTest(302 'xyz.txt', package=module, module_relative=True,303 globs=locals()304 ).run()305 self.assertEqual(log,[True])306 def testDoctestSuite(self):307 self.runDoctest(self.doDoctestSuite)308 def doTraceback(self, module):309 try:310 module.do_raise()311 except:312 tb = sys.exc_info()[2].tb_next313 f,lno,n,line = extract_tb(tb, 1)[0]314 self.assertEqual(line, raise_src.strip())315 f,lno,n,line = extract_stack(tb.tb_frame, 1)[0]316 self.assertEqual(line, raise_src.strip())317 s = io.StringIO()318 print_tb(tb, 1, s)319 self.assertTrue(s.getvalue().endswith(raise_src))320 else:321 raise AssertionError("This ought to be impossible")322 def testTraceback(self):323 files = {TESTMOD + ".py": (NOW, raise_src)}324 self.doTest(None, files, TESTMOD, call=self.doTraceback)325 @unittest.skipIf(support.TESTFN_UNENCODABLE is None,326 "need an unencodable filename")327 def testUnencodable(self):328 filename = support.TESTFN_UNENCODABLE + ".zip"329 z = ZipFile(filename, "w")330 zinfo = ZipInfo(TESTMOD + ".py", time.localtime(NOW))331 zinfo.compress_type = self.compression332 z.writestr(zinfo, test_src)333 z.close()334 try:335 zipimport.zipimporter(filename)336 finally:337 os.remove(filename)338@unittest.skipUnless(zlib, "requires zlib")339class CompressedZipImportTestCase(UncompressedZipImportTestCase):340 compression = ZIP_DEFLATED341class BadFileZipImportTestCase(unittest.TestCase):342 def assertZipFailure(self, filename):343 self.assertRaises(zipimport.ZipImportError,344 zipimport.zipimporter, filename)345 def testNoFile(self):346 self.assertZipFailure('AdfjdkFJKDFJjdklfjs')347 def testEmptyFilename(self):348 self.assertZipFailure('')349 def testBadArgs(self):350 self.assertRaises(TypeError, zipimport.zipimporter, None)351 self.assertRaises(TypeError, zipimport.zipimporter, TESTMOD, kwd=None)352 def testFilenameTooLong(self):353 self.assertZipFailure('A' * 33000)354 def testEmptyFile(self):355 support.unlink(TESTMOD)356 open(TESTMOD, 'w+').close()357 self.assertZipFailure(TESTMOD)358 def testFileUnreadable(self):359 support.unlink(TESTMOD)360 fd = os.open(TESTMOD, os.O_CREAT, 000)361 try:362 os.close(fd)363 self.assertZipFailure(TESTMOD)364 finally:365 # If we leave "the read-only bit" set on Windows, nothing can366 # delete TESTMOD, and later tests suffer bogus failures.367 os.chmod(TESTMOD, 0o666)368 support.unlink(TESTMOD)369 def testNotZipFile(self):370 support.unlink(TESTMOD)371 fp = open(TESTMOD, 'w+')372 fp.write('a' * 22)373 fp.close()374 self.assertZipFailure(TESTMOD)375 # XXX: disabled until this works on Big-endian machines376 def _testBogusZipFile(self):377 support.unlink(TESTMOD)378 fp = open(TESTMOD, 'w+')379 fp.write(struct.pack('=I', 0x06054B50))380 fp.write('a' * 18)381 fp.close()382 z = zipimport.zipimporter(TESTMOD)383 try:384 self.assertRaises(TypeError, z.find_module, None)385 self.assertRaises(TypeError, z.load_module, None)386 self.assertRaises(TypeError, z.is_package, None)387 self.assertRaises(TypeError, z.get_code, None)388 self.assertRaises(TypeError, z.get_data, None)389 self.assertRaises(TypeError, z.get_source, None)390 error = zipimport.ZipImportError391 self.assertEqual(z.find_module('abc'), None)392 self.assertRaises(error, z.load_module, 'abc')393 self.assertRaises(error, z.get_code, 'abc')394 self.assertRaises(IOError, z.get_data, 'abc')395 self.assertRaises(error, z.get_source, 'abc')396 self.assertRaises(error, z.is_package, 'abc')397 finally:398 zipimport._zip_directory_cache.clear()399def cleanup():400 # this is necessary if test is run repeated (like when finding leaks)401 global test_imported402 if test_imported:403 zipimport._zip_directory_cache.clear()404 if hasattr(UncompressedZipImportTestCase, 'testAFakeZlib'):405 delattr(UncompressedZipImportTestCase, 'testAFakeZlib')406 if hasattr(CompressedZipImportTestCase, 'testAFakeZlib'):407 delattr(CompressedZipImportTestCase, 'testAFakeZlib')408 test_imported = True409def test_main():410 cleanup()411 try:412 support.run_unittest(413 UncompressedZipImportTestCase,414 CompressedZipImportTestCase,415 BadFileZipImportTestCase,416 )417 finally:418 support.unlink(TESTMOD)419if __name__ == "__main__":...

Full Screen

Full Screen

test_common.py

Source:test_common.py Github

copy

Full Screen

...55 # Verify the compress type.56 self.assertEqual(info.compress_type, expected_compress_type)57 # Verify the zip contents.58 self.assertEqual(zip_file.read(arcname), contents)59 self.assertIsNone(zip_file.testzip())60 def _test_ZipWrite(self, contents, extra_zipwrite_args=None):61 extra_zipwrite_args = dict(extra_zipwrite_args or {})62 test_file = tempfile.NamedTemporaryFile(delete=False)63 test_file_name = test_file.name64 zip_file = tempfile.NamedTemporaryFile(delete=False)65 zip_file_name = zip_file.name66 # File names within an archive strip the leading slash.67 arcname = extra_zipwrite_args.get("arcname", test_file_name)68 if arcname[0] == "/":69 arcname = arcname[1:]70 zip_file.close()71 zip_file = zipfile.ZipFile(zip_file_name, "w")72 try:73 test_file.write(contents)...

Full Screen

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Python automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful