def copy_file(self, infile, outfile, check=True):
self.ensure_dir(os.path.dirname(outfile))<EOL>logger.info('<STR_LIT>', infile, outfile)<EOL>if not self.dry_run:<EOL><INDENT>msg = None<EOL>if check:<EOL><INDENT>if os.path.islink(outfile):<EOL><INDENT>msg = '<STR_LIT>' % outfile<EOL><DEDENT>elif os.path.exists(outfile) and not os.path.isfile(outfile):<EOL><INDENT>msg = '<STR_LIT>' % outfile<EOL><DEDENT><DEDENT>if msg:<EOL><INDENT>raise ValueError(msg + '<STR_LIT>')<EOL><DEDENT>shutil.copyfile(infile, outfile)<EOL><DEDENT>self.record_as_written(outfile)<EOL>
Copy a file respecting dry-run and force flags.