MCPcopy Create free account
hub / github.com/RenderKit/oidn / extract_package

Function extract_package

scripts/common.py:26–45  ·  view source on GitHub ↗
(filename, output_dir)

Source from the content-addressed store, hash-verified

24 return filename
25
26def extract_package(filename, output_dir):
27 print('Extracting package:', filename)
28 # Detect the package format and open the package
29 if re.search(r'(\.tar(\..+)?|tgz)$', filename):
30 package = tarfile.open(filename)
31 members = package.getnames()
32 elif filename.endswith('.zip'):
33 package = ZipFile(filename)
34 members = package.namelist()
35 else:
36 raise Exception('unsupported package format')
37 # Avoid nesting two top-level directories with the same name
38 if os.path.commonpath(members) == os.path.basename(output_dir):
39 output_dir = os.path.dirname(output_dir)
40 # Create the output directory if it doesn't exist
41 if not os.path.isdir(output_dir):
42 os.makedirs(output_dir)
43 # Extract the package
44 package.extractall(output_dir)
45 package.close()
46
47def create_package(filename, input_dir):
48 print('Creating package:', filename)

Callers 1

build.pyFile · 0.85

Calls 4

printFunction · 0.85
ExceptionFunction · 0.85
openMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected