def edit_doc(self, doc_entry_or_title, editor, file_ext,
                 folder_entry_or_path=None):
        import subprocess
        import tempfile

        try:
            doc_title = safe_decode(doc_entry_or_title.title.text)
            new_doc = False
        except AttributeError:
            doc_title = doc_entry_or_title
            new_doc = True

        temp_dir = tempfile.mkdtemp()
        # If we're creating a new document and not given a folder entry
        if new_doc and isinstance(folder_entry_or_path, basestring):
            folder_path = os.path.normpath(folder_entry_or_path)
            # Some systems allow more than one path separator
            if os.altsep:
                folder_path.replace(os.altsep, os.sep)
            base_folder = folder_path.split(os.sep)[0]
            # Define the base path such that upload_docs will create a folder
            # named base_folder
            base_path = os.path.join(temp_dir, base_folder)
            total_basename = os.path.join(temp_dir, folder_path)
            os.makedirs(total_basename)
            path = os.path.join(total_basename,
                                self.to_safe_filename(doc_title) + '.' + file_ext)
        else:
            path = os.path.join(temp_dir,
                                self.to_safe_filename(doc_title) + '.' + file_ext)
            base_path = path

        if not new_doc:
            self.Export(doc_entry_or_title.content.src, path)
            file_hash = _md5_hash_file(path)
        else:
            file_hash = None

        command_args = shlex.split(safe_encode(editor)) + [path]
        subprocess.call(command_args)
        impatient_editors = self.config.lazy_get(SECTION_HEADER,
                                                 'impatient_editors',
                                                 default='')
        if impatient_editors:
            impatient_editors = impatient_editors.split(',')
            if command_args[0] in impatient_editors:
                LOG.info('I noticed you are using an application that will not wait for '
                         'you to finish editing your file.')
                LOG.info('Hit enter in this shell when you finished editing and saved '
                         'your work.')
                raw_input('')
        if file_hash and file_hash == _md5_hash_file(path):
            LOG.info('No modifications to file, not uploading.')
            return None
        elif not os.path.exists(path):
            LOG.info('No file written, not uploading.')
            return None

        if new_doc:
            if isinstance(folder_entry_or_path, basestring):
                # Let code in upload_docs handle the creation of new folder(s)
                self.upload_docs([base_path], doc_title)
            else:
                # folder_entry_or_path is None or a GDataEntry.
                doc_entry = self.upload_single_doc(path,
                                                   folder_entry=folder_entry_or_path)
        else:
            try:
                doc_entry = self._modify_entry(
                    doc_entry_or_title, path, file_ext)
            except self.request_error, err:
                LOG.error(err)
                new_path = safe_move(path, '.')
                LOG.info(safe_encode('Moved edited document to ' +
                                     safe_decode(new_path)))
                return None

        try:
            # Good faith effort to keep the temp directory clean.
            shutil.rmtree(temp_dir)
        except OSError:
            # Only seen errors on Windows, but catch the more general OSError.
            pass
        return doc_entry
Calls runfunc with different args and kwargs each time.
dataset/ETHPy150Open vinitkumar/googlecl/src/googlecl/docs/base.py/DocsBaseCL.edit_doc--crossover with--dataset/ETHPy150Open SmokinCaterpillar/pypet/pypet/environment.py/Environment.run_map