@log_calls<EOL><INDENT>def dsync_files(self, source, target):<DEDENT>
src_s3_url = S3URL.is_valid(source)<EOL>dst_s3_url = S3URL.is_valid(target)<EOL>source_list = self.relative_dir_walk(source)<EOL>if len(source_list) == <NUM_LIT:0> or '<STR_LIT:.>' in source_list:<EOL><INDENT>raise Failure('<STR_LIT>')<EOL><DEDENT>sync_list = [(os.path.join(source, f), os.path.join(target, f)) for f in source_list]<EOL>pool = ThreadPool(ThreadUtil, self.opt)<EOL>if src_s3_url and not dst_s3_url:<EOL><INDENT>for src, dest in sync_list:<EOL><INDENT>pool.download(src, dest)<EOL><DEDENT><DEDENT>elif not src_s3_url and dst_s3_url:<EOL><INDENT>for src, dest in sync_list:<EOL><INDENT>pool.upload(src, dest)<EOL><DEDENT><DEDENT>elif src_s3_url and dst_s3_url:<EOL><INDENT>for src, dest in sync_list:<EOL><INDENT>pool.copy(src, dest)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise InvalidArgument('<STR_LIT>')<EOL><DEDENT>pool.join()<EOL>if self.opt.delete_removed:<EOL><INDENT>target_list = self.relative_dir_walk(target)<EOL>remove_list = [os.path.join(target, f) for f in (set(target_list) - set(source_list))]<EOL>if S3URL.is_valid(target):<EOL><INDENT>pool = ThreadPool(ThreadUtil, self.opt)<EOL>pool.batch_delete(remove_list)<EOL>pool.join()<EOL><DEDENT>else:<EOL><INDENT>for f in remove_list:<EOL><INDENT>try:<EOL><INDENT>os.unlink(f)<EOL>message('<STR_LIT>', f)<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT><DEDENT>
Sync directory to directory.