'Copy file `name` from `source_dir` to `dest_dir`.
Return 1 if the file exists in either `source_dir` or `dest_dir`.'

def copy_file(self, name, source_dir, dest_dir):

    source = os.path.join(source_dir, name)
    dest = os.path.join(dest_dir, name)
    if self.theme_files_copied.has_key(dest):
        return 1
    else:
        self.theme_files_copied[dest] = 1
    if os.path.isfile(source):
        if self.files_to_skip_pattern.search(source):
            return None
        settings = self.document.settings
        if (os.path.exists(dest) and (not settings.overwrite_theme_files)):
            settings.record_dependencies.add(dest)
        else:
            src_file = open(source, 'rb')
            src_data = src_file.read()
            src_file.close()
            dest_file = open(dest, 'wb')
            dest_dir = dest_dir.replace(os.sep, '/')
            dest_file.write(src_data.replace('ui/default', dest_dir[dest_dir.rfind('ui/'):]))
            dest_file.close()
            settings.record_dependencies.add(source)
        return 1
    if os.path.isfile(dest):
        return 1
