Flutter Engine
The Flutter Engine
Functions
copy Namespace Reference

Functions

def main ()
 

Function Documentation

◆ main()

def copy.main ( )

Definition at line 14 of file copy.py.

14def main():
15 if len(sys.argv) != 3:
16 print('usage: copy.py source dest', file=sys.stderr)
17 return 1
18 source = sys.argv[1]
19 dest = sys.argv[2]
20
21 if os.path.isdir(source):
22 print(f'{source} is a directory, tool "copy" does not support directory copies')
23 return 1
24
25 if os.path.exists(dest):
26 if os.path.isdir(dest):
27
28 def _on_error(fn, path, dummy_excinfo):
29 # The operation failed, possibly because the file is set to
30 # read-only. If that's why, make it writable and try the op
31 # again.
32 if not os.access(path, os.W_OK):
33 os.chmod(path, stat.S_IWRITE)
34 fn(path)
35
36 shutil.rmtree(dest, onerror=_on_error)
37 else:
38 if not os.access(dest, os.W_OK):
39 # Attempt to make the file writable before deleting it.
40 os.chmod(dest, stat.S_IWRITE)
41 os.unlink(dest)
42
43 shutil.copy2(source, dest)
44
45
def main()
Definition: copy.py:14
def print(*args, **kwargs)
Definition: run_tests.py:49