Flutter Engine
The Flutter Engine
Functions | Variables
zip Namespace Reference

Functions

def add_symlink (zip_file, source, target)
 
def main (args)
 

Variables

 parser = argparse.ArgumentParser(description='This script creates zip files.')
 
 dest
 
 action
 
 help
 
 nargs
 

Function Documentation

◆ add_symlink()

def zip.add_symlink (   zip_file,
  source,
  target 
)
Adds a symlink to a zip file.

Args:
  zip_file: The ZipFile obj where the symlink will be added.
  source: The full path to the symlink.
  target: The target path for the symlink within the zip file.

Definition at line 34 of file zip.py.

34def add_symlink(zip_file, source, target):
35 """Adds a symlink to a zip file.
36
37 Args:
38 zip_file: The ZipFile obj where the symlink will be added.
39 source: The full path to the symlink.
40 target: The target path for the symlink within the zip file.
41 """
42 zip_info = zipfile.ZipInfo(target)
43 zip_info.create_system = 3 # Unix like system
44 unix_st_mode = (
45 stat.S_IFLNK | stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP
46 | stat.S_IWGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IWOTH | stat.S_IXOTH
47 )
48 zip_info.external_attr = unix_st_mode << 16
49 zip_file.writestr(zip_info, os.readlink(source))
50
51
def add_symlink(zip_file, source, target)
Definition: zip.py:34

◆ main()

def zip.main (   args)

Definition at line 52 of file zip.py.

52def main(args):
53 zip_file = zipfile.ZipFile(args.output, 'w', zipfile.ZIP_DEFLATED)
54 if args.source_file:
55 with open(args.source_file) as source_file:
56 file_dict_list = json.load(source_file)
57 for file_dict in file_dict_list:
58 if os.path.islink(file_dict['source']):
59 add_symlink(zip_file, file_dict['source'], file_dict['destination'])
60 continue
61 if os.path.isdir(file_dict['source']):
62 _zip_dir(file_dict['source'], zip_file, file_dict['destination'])
63 else:
64 zip_file.write(file_dict['source'], file_dict['destination'])
65 else:
66 for path, archive_name in args.input_pairs:
67 if os.path.islink(path):
68 add_symlink(zip_file, path, archive_name)
69 continue
70 if os.path.isdir(path):
71 _zip_dir(path, zip_file, archive_name)
72 else:
73 zip_file.write(path, archive_name)
74 zip_file.close()
75
76
def main(args)
Definition: zip.py:52

Variable Documentation

◆ action

zip.action

Definition at line 79 of file zip.py.

◆ dest

zip.dest

Definition at line 79 of file zip.py.

◆ help

zip.help

Definition at line 79 of file zip.py.

◆ nargs

zip.nargs

Definition at line 83 of file zip.py.

◆ parser

zip.parser = argparse.ArgumentParser(description='This script creates zip files.')

Definition at line 78 of file zip.py.