• Home
  • Raw
  • Download

Lines Matching refs:fobj

94         with self.tar.extractfile(tarinfo) as fobj:
95 data = fobj.read()
107 with self.tar.extractfile(tarinfo) as fobj:
108 fobj2 = io.TextIOWrapper(fobj)
131 with open(os.path.join(TEMPDIR, "ustar/regtype"), "rb") as fobj:
132 data = fobj.read()
135 fobj = self.tar.extractfile(tarinfo)
137 text = fobj.read()
138 fobj.seek(0)
139 self.assertEqual(0, fobj.tell(),
141 fobj.seek(2048, 0)
142 self.assertEqual(2048, fobj.tell(),
144 fobj.seek(-1024, 1)
145 self.assertEqual(1024, fobj.tell(),
147 fobj.seek(1024, 1)
148 self.assertEqual(2048, fobj.tell(),
150 s = fobj.read(10)
153 fobj.seek(0, 2)
154 self.assertEqual(tarinfo.size, fobj.tell(),
156 self.assertEqual(fobj.read(), b"",
158 fobj.seek(-tarinfo.size, 2)
159 self.assertEqual(0, fobj.tell(),
161 fobj.seek(512)
162 s1 = fobj.readlines()
163 fobj.seek(512)
164 s2 = fobj.readlines()
167 fobj.seek(0)
168 self.assertEqual(len(fobj.readline()), fobj.tell(),
170 fobj.seek(512)
171 self.assertEqual(len(fobj.readline()) + 512, fobj.tell(),
173 fobj.seek(0)
174 line = fobj.readline()
175 self.assertEqual(fobj.read(), data[len(line):],
177 fobj.close()
180 with self.tar.extractfile("ustar/regtype") as fobj:
181 fobj = io.TextIOWrapper(fobj)
182 data = fobj.read().encode("iso8859-1")
185 fobj.seek(100)
359 with self.open(tmpname, "w") as fobj:
360 fobj.write(char * 1024)
363 fobj.write(tarinfo.tobuf())
364 fobj.write(data)
381 with open(tmpname, "r+b") as fobj:
382 fobj.truncate(size)
404 with open(self.tarname, "rb") as fobj:
405 self.assertIsInstance(fobj.name, str)
406 with tarfile.open(fileobj=fobj, mode=self.mode) as tar:
408 self.assertEqual(tar.name, os.path.abspath(fobj.name))
411 with open(self.tarname, "rb") as fobj:
412 data = fobj.read()
413 fobj = io.BytesIO(data)
414 self.assertRaises(AttributeError, getattr, fobj, "name")
415 tar = tarfile.open(fileobj=fobj, mode=self.mode)
419 with open(self.tarname, "rb") as fobj:
420 data = fobj.read()
421 fobj = io.BytesIO(data)
422 fobj.name = ""
423 with tarfile.open(fileobj=fobj, mode=self.mode) as tar:
430 with open(fd, 'rb') as fobj:
431 self.assertIsInstance(fobj.name, int)
432 with tarfile.open(fileobj=fobj, mode=self.mode) as tar:
438 with open(tarname, 'rb') as fobj:
439 self.assertIsInstance(fobj.name, bytes)
440 with tarfile.open(fileobj=fobj, mode=self.mode) as tar:
442 self.assertEqual(tar.name, os.path.abspath(fobj.name))
485 with self.open(self.tarname) as fobj:
486 fobj.seek(offset)
489 tar = tar.open(self.tarname, mode="r:", fileobj=fobj)
502 with open(tarname, "rb") as fobj:
504 fileobj=fobj, mode=self.mode)
627 with open(empty, "wb") as fobj:
628 fobj.write(b"")
674 with self.tar.extractfile(tarinfo) as fobj:
677 buf = fobj.read(512)
686 with self.tar.extractfile(tarinfo) as fobj:
687 data = fobj.read()
784 with open(tarname, "rb") as fobj:
785 data = fobj.read()
788 with bz2.BZ2File(tmpname, "wb", compresslevel=1) as fobj:
789 fobj.write(data)
920 fobj = io.BytesIO(self.tar.fileobj.read(3 * 512))
922 tarfile.open(name="foo.tar", fileobj=fobj)
929 with open(tarname, "rb") as fobj:
930 fobj.seek(offset)
931 tarinfo = tarfile.TarInfo.frombuf(fobj.read(512),
951 with open(filename, "rb") as fobj:
952 data = fobj.read()
983 with open(name, "wb") as fobj:
985 fobj.seek(4096)
986 fobj.write(b'x' * 4096)
987 fobj.truncate()
1044 fobj = io.BytesIO()
1045 tar = tarfile.open(fileobj=fobj, mode=self.mode)
1048 self.assertFalse(fobj.closed, "external fileobjs must never closed")
1050 data = fobj.getvalue()
1053 self.assertFalse(fobj.closed)
1054 self.assertEqual(data, fobj.getvalue())
1066 with self.open(tmpname, "rb") as fobj:
1067 self.assertEqual(len(fobj.read()), tarfile.RECORDSIZE * 2)
1099 with open(path, "wb") as fobj:
1100 fobj.write(b"aaa")
1117 with open(path, "wb") as fobj:
1118 fobj.write(b"aaa")
1164 with open(path, "wb") as fobj:
1165 fobj.write(b"aaa")
1177 with open(target, "wb") as fobj:
1178 fobj.write(b"aaa")
1404 with open(tmpname, "rb") as fobj:
1405 data = fobj.read()
1409 with self.open(tmpname) as fobj:
1410 data = fobj.read()
1534 with open(cls.file_path, "wb") as fobj:
1535 fobj.write(b"aaa")
1641 with open(self.foo, "wb") as fobj:
1642 fobj.write(b"foo")
1999 fobj = io.BytesIO(b"\0" * 1024)
2000 self._add_testfile(fobj)
2001 fobj.seek(0)
2002 self._test(fileobj=fobj)
2006 with open(self.tarname, "rb") as fobj:
2007 data = fobj.read()
2008 fobj = io.BytesIO(data)
2009 self._add_testfile(fobj)
2010 fobj.seek(0)
2011 self._test(names=["foo", "bar"], fileobj=fobj)
2021 with open(self.tarname, "wb") as fobj:
2022 fobj.write(data)
2432 with open(tmpname, "wb") as fobj:
2434 with tarfile.open(fileobj=fobj, mode="w") as tar:
2438 self.assertFalse(fobj.closed, "external file object was closed")
2531 fobj = io.BytesIO(b"content")
2535 items = [(filename_1, 99, 98, tarfile.REGTYPE, fobj),
2537 (filename_2, 88, 87, tarfile.REGTYPE, fobj),
2645 with open(tarname, "rb") as fobj:
2646 data = fobj.read()