MCPcopy
hub / github.com/pyinstaller/pyinstaller / archive

Method archive

bootloader/waflib/Scripting.py:279–312  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

277 self.archive()
278
279 def archive(self):
280 import tarfile
281 arch_name = self.get_arch_name()
282 try:
283 self.base_path
284 except AttributeError:
285 self.base_path = self.path
286 node = self.base_path.make_node(arch_name)
287 try:
288 node.delete()
289 except OSError:
290 pass
291 files = self.get_files()
292 if self.algo.startswith('tar.'):
293 tar = tarfile.open(node.abspath(), 'w:' + self.algo.replace('tar.', ''))
294 for x in files:
295 self.add_tar_file(x, tar)
296 tar.close()
297 elif self.algo == 'zip':
298 import zipfile
299 zip = zipfile.ZipFile(node.abspath(), 'w', compression=zipfile.ZIP_DEFLATED)
300 for x in files:
301 archive_name = self.get_base_name() + '/' + x.path_from(self.base_path)
302 zip.write(x.abspath(), archive_name, zipfile.ZIP_DEFLATED)
303 zip.close()
304 else:
305 self.fatal('Valid algo types are tar.bz2, tar.gz, tar.xz or zip')
306 try:
307 from hashlib import sha256
308 except ImportError:
309 digest = ''
310 else:
311 digest = ' (sha256=%r)' % sha256(node.read(flags='rb')).hexdigest()
312 Logs.info('New archive created: %s%s', self.arch_name, digest)
313
314 def get_tar_path(self, node):
315 return node.abspath()

Callers 2

executeMethod · 0.95
executeMethod · 0.80

Calls 12

get_arch_nameMethod · 0.95
get_filesMethod · 0.95
add_tar_fileMethod · 0.95
get_base_nameMethod · 0.95
make_nodeMethod · 0.80
deleteMethod · 0.80
abspathMethod · 0.80
path_fromMethod · 0.80
fatalMethod · 0.80
readMethod · 0.80
infoMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected