def extract(self, destdir, decompress='auto'): """Extract the entire MAR file into a directory. Args: destdir (str): A local directory on disk into which the contents of this MAR file will be extracted. Required parent directories will be created as necessary. decompress (obj, optional): Controls whether files are decompressed when extracted. Must be one of 'auto' or None. Defaults to 'auto'. """ for e in self.mardata.index.entries: name = e.name entry_path = safejoin(destdir, name) entry_dir = os.path.dirname(entry_path) mkdir(entry_dir) with open(entry_path, 'wb') as f: write_to_file(self.extract_entry(e, decompress), f)
def extract(self, destdir, decompress='auto'): """Extract the entire MAR file into a directory. Args: destdir (str): A local directory on disk into which the contents of this MAR file will be extracted. Required parent directories will be created as necessary. decompress (obj, optional): Controls whether files are decompressed when extracted. Must be one of 'auto' or None. Defaults to 'auto'. """ for e in self.mardata.index.entries: name = e.name entry_path = safejoin(destdir, name) entry_dir = os.path.dirname(entry_path) mkdir(entry_dir) with open(entry_path, 'wb') as f: write_to_file(self.extract_entry(e, decompress), f) os.chmod(entry_path, e.flags)
def test_mkdir_existingfile(tmpdir): d = tmpdir.join('foo') d.write('helloworld') with pytest.raises(OSError): mkdir(str(d))
def test_mkdir_existing(tmpdir): d = tmpdir.join('foo') d.mkdir() mkdir(str(d)) assert d.isdir()
def test_mkdir(tmpdir): d = tmpdir.join('foo') mkdir(str(d)) assert d.isdir()