Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
copy_path Namespace Reference

Functions

 EnsureParentExists (path)
 
 SameStat (s1, s2)
 
 SameFile (f1, f2)
 
 CopyPath (src, dst)
 
 main ()
 

Detailed Description

 Copies paths, creates if they do not exist.

Function Documentation

◆ CopyPath()

copy_path.CopyPath (   src,
  dst 
)

Definition at line 38 of file copy_path.py.

38def CopyPath(src, dst):
39 try:
40 EnsureParentExists(dst)
41 shutil.copytree(src, dst)
42 except OSError as exc:
43 if exc.errno == errno.ENOTDIR:
44 if not SameFile(src, dst):
45 shutil.copyfile(src, dst)
46 else:
47 raise
48
49

◆ EnsureParentExists()

copy_path.EnsureParentExists (   path)

Definition at line 20 of file copy_path.py.

20def EnsureParentExists(path):
21 dir_name, _ = os.path.split(path)
22 if not os.path.exists(dir_name):
23 os.makedirs(dir_name)
24
25

◆ main()

copy_path.main ( )

Definition at line 50 of file copy_path.py.

50def main():
51 parser = argparse.ArgumentParser()
52
53 parser.add_argument('--file-list', dest='file_list', action='store', required=True)
54
55 args = parser.parse_args()
56
57 files = open(args.file_list, 'r')
58 files_to_copy = files.read().split()
59 num_files = len(files_to_copy) // 2
60
61 for i in range(num_files):
62 CopyPath(files_to_copy[i], files_to_copy[num_files + i])
63
64 return 0
65
66
Definition main.py:1

◆ SameFile()

copy_path.SameFile (   f1,
  f2 
)

Definition at line 30 of file copy_path.py.

30def SameFile(f1, f2):
31 if not os.path.exists(f2):
32 return False
33 s1 = os.stat(f1)
34 s2 = os.stat(f2)
35 return SameStat(s1, s2)
36
37

◆ SameStat()

copy_path.SameStat (   s1,
  s2 
)

Definition at line 26 of file copy_path.py.

26def SameStat(s1, s2):
27 return s1.st_ino == s2.st_ino and s1.st_dev == s2.st_dev
28
29