@@ -191,21 +191,24 @@ def get_about_locations(location):
191191 if is_about_file (loc ):
192192 yield loc
193193
194+ def norm (p ):
195+ """
196+ Normalize the path
197+ """
198+ if p .startswith (UNC_PREFIX ) or p .startswith (to_posix (UNC_PREFIX )):
199+ p = p .strip (UNC_PREFIX ).strip (to_posix (UNC_PREFIX ))
200+ p = to_posix (p )
201+ p = p .strip (posixpath .sep )
202+ p = posixpath .normpath (p )
203+ return p
204+
194205
195206def get_relative_path (base_loc , full_loc ):
196207 """
197208 Return a posix path for a given full location relative to a base location.
198209 The first segment of the different between full_loc and base_loc will become
199210 the first segment of the returned path.
200211 """
201- def norm (p ):
202- if p .startswith (UNC_PREFIX ) or p .startswith (to_posix (UNC_PREFIX )):
203- p = p .strip (UNC_PREFIX ).strip (to_posix (UNC_PREFIX ))
204- p = to_posix (p )
205- p = p .strip (posixpath .sep )
206- p = posixpath .normpath (p )
207- return p
208-
209212 base = norm (base_loc )
210213 path = norm (full_loc )
211214
@@ -476,8 +479,10 @@ def copy_file(from_path, to_path):
476479 return
477480
478481 if on_windows :
479- from_path = add_unc (from_path )
480- to_path = add_unc (to_path )
482+ if not from_path .startswith (UNC_PREFIXES ):
483+ from_path = add_unc (from_path )
484+ if not to_path .startswith (UNC_PREFIXES ):
485+ to_path = add_unc (to_path )
481486
482487 # Strip the white spaces
483488 from_path = from_path .strip ()
@@ -491,9 +496,14 @@ def copy_file(from_path, to_path):
491496 os .makedirs (to_path )
492497 try :
493498 if os .path .isdir (from_path ):
494- print ("#############################" )
495- from distutils .dir_util import copy_tree
496- copy_tree (from_path , to_path )
499+ # Copy the whole directory structure
500+ folder_name = os .path .basename (from_path )
501+ to_path = os .path .join (to_path , folder_name )
502+ # Since we need to copy everything along with the directory structure,
503+ # making sure the directory does not exist will not hurt.
504+ shutil .rmtree (to_path )
505+ # Copy the directory recursively along with its structure
506+ shutil .copytree (from_path , to_path )
497507 else :
498508 shutil .copy2 (from_path , to_path )
499509 except Exception as e :
0 commit comments