Example #1
0
    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)
Example #2
0
    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)
Example #3
0
def test_mkdir_existingfile(tmpdir):
    d = tmpdir.join('foo')
    d.write('helloworld')
    with pytest.raises(OSError):
        mkdir(str(d))
Example #4
0
def test_mkdir_existing(tmpdir):
    d = tmpdir.join('foo')
    d.mkdir()
    mkdir(str(d))
    assert d.isdir()
Example #5
0
def test_mkdir(tmpdir):
    d = tmpdir.join('foo')
    mkdir(str(d))
    assert d.isdir()
Example #6
0
def test_mkdir_existingfile(tmpdir):
    d = tmpdir.join('foo')
    d.write('helloworld')
    with pytest.raises(OSError):
        mkdir(str(d))
Example #7
0
def test_mkdir_existing(tmpdir):
    d = tmpdir.join('foo')
    d.mkdir()
    mkdir(str(d))
    assert d.isdir()
Example #8
0
def test_mkdir(tmpdir):
    d = tmpdir.join('foo')
    mkdir(str(d))
    assert d.isdir()