def command_copy(args):
 sources = args.sources
 destpath = args.destpath
 source_files = []
 for file_ in sources:
  if ('*' in file_):
   selected = glob(file_)
   source_files.extend(selected)
  elif os.path.isfile(file_):
   source_files.append(file_)
 if (destpath.endswith('/') or os.path.isdir(destpath) or (len(sources) > 1)):
  destdir = destpath
 else:
  assert (len(source_files) == 1)
  destdir = os.path.dirname(destpath)
 if (not os.path.isdir(destdir)):
  sys.stdout.write(('copy: Create dir %s\n' % destdir))
  os.makedirs(destdir)
 for source in source_files:
  destname = os.path.join(destdir, os.path.basename(source))
  sys.stdout.write(('copy: %s => %s\n' % (source, destname)))
  shutil.copy(source, destname)
 return 0

def command_copy ( args ) : sources = args . sources destpath = args . destpath source_files = [ ] for file_ in sources : if ( '*' in file_ ) : selected = glob ( file_ ) source_files . extend ( selected ) elif os . path . isfile ( file_ ) : source_files . append ( file_ ) if ( destpath . endswith ( '/' ) or os . path . isdir ( destpath ) or ( len ( sources ) > 1 ) ) : destdir = destpath else : assert ( len ( source_files ) == 1 ) destdir = os . path . dirname ( destpath ) if ( not os . path . isdir ( destdir ) ) : sys . stdout . write ( ( 'copy: Create dir %s\n' % destdir ) ) os . makedirs ( destdir ) for source in source_files : destname = os . path . join ( destdir , os . path . basename ( source ) ) sys . stdout . write ( ( 'copy: %s => %s\n' % ( source , destname ) ) ) shutil . copy ( source , destname ) return 0
copy one or more source-files(s) to a destpath .