Example #1
0
 def test_nonascii_paths(self):
     self.requireFeature(UnicodeFilenameFeature)
     tt = self.get_empty_tt()
     tt.new_file(u'\u1234file', tt.root, [b'contents'], b'new-file')
     tt.new_file('other', tt.root, [b'contents'], b'other-file')
     tarfile = self.transform_to_tar(tt)
     tarfile.seek(0)
     tree = self.make_branch_and_tree('bar')
     import_tar(tree, tarfile)
     self.assertPathExists(u'bar/\u1234file')
Example #2
0
def get_tarfile_size(tarfile):
    """
    Determine the size of a file inside the tarball.
    If the object has a size attribute, use that. Otherwise seek to the end
    and report that.
    """
    if hasattr(tarfile, 'size'):
        return tarfile.size
    size = tarfile.seek(0, 2)
    tarfile.seek(0, 0)
    return size
Example #3
0
def _get_tarfile_size(tarfile):
    """
  Determine the size of a file inside the tarball.
  If the object has a size attribute, use that. Otherwise seek to the end
  and report that.
  """
    try:
        return tarfile.size
    except AttributeError:
        pass

    size = tarfile.seek(0, 2)
    tarfile.seek(0, 0)
    return size
Example #4
0
def get_tarfile_size(tarfile):
    if hasattr(tarfile, 'size'):
        return tarfile.size
    size = tarfile.seek(0, 2)
    tarfile.seek(0, 0)
    return size