@cherrypy.expose
    def save(self, working_name, *paths, **args):
        rel_path = '/'.join(paths)
        full_path = os.path.join(self.settings.source, rel_path)
        document = _extract_document({}, working_name)
        if not document.template_name:
            raise cherrypy.HTTPRedirect('/timeout')

        overwrite = args.pop(OVERWRITE_PARAM_NAME, False)
        placeholders_change = False
        placeholders_messages = []

        if os.path.exists(full_path) and not os.path.isdir(full_path):
            handler = _set_logging_handler()
            content = self.final_renderer.content_to_save(
                rel_path, document.template_name, document.styles, **document.args)
            locale, name = _get_email_locale_n_name(rel_path)
            placeholders_change = not place_holders.validate_email_content(locale, name, content, self.settings.source)
            placeholders_messages = list(handler.error_msgs())

        if overwrite and not os.path.exists(full_path):
            # Create and save
            try:
                output = self.final_renderer.save(rel_path, document.template_name, document.styles, **document.args)
                if output:
                    output = str(output, 'utf-8')
                    return self.final_renderer.question(
                        title='Saved & postprocessed email: {}'.format(rel_path),
                        description=html_escape(output),
                        actions=[
                            ['View', '/email/{}'.format(rel_path), 2000],
                        ]
                    )

            except subprocess.CalledProcessError as err:
                output = str(err.output, 'utf-8') if err.output else 'Error #{}'.format(err.returncode)
                return self.final_renderer.error(
                    title='Postprocessing failed for email: {}'.format(rel_path),
                    description=html_escape(output),
                    actions=[
                        ['View', '/email/{}'.format(rel_path)],
                    ]
                )

            # No postprocessing performed/requested
            raise cherrypy.HTTPRedirect('/email/{}'.format(rel_path))
        elif os.path.isdir(full_path):
            # Show directory or allow user to create new file
            html = self.edit_renderer.directory(
                'Select save name/directory: ' + rel_path,
                self.settings.source, rel_path,
                (lambda path: '/save/{0}/{1}'.format(working_name, path)),
                old_filename=os.path.basename(document.email_name) if document.email_name else '',
                actions=[
                    ['Save', '/saveas/{0}/{1}'.format(working_name, rel_path)],
                    ['Return to Edit', '/edit/{}'.format(working_name)],
                ]
            )
            return html
        else:
            # File already exists or placeholders change: overwrite?
            question_str = 'Are you sure you want to overwrite the existing email <code>{}</code>?'.format(rel_path)
            if placeholders_change:
                question_str = 'Are you sure you want to overwrite the existing email <code>{0}</code>?\
                                <blockquote><b>WARNING</b><br/>{1}\
                                </blockquote>'.format(rel_path, '<br/>'.join(placeholders_messages))

            # File already exists: overwrite?
            return self.edit_renderer.question(
                'Overwriting ' + rel_path,
                question_str,
                [
                    ['No, save as a new file',
                     '/save/{0}/{1}'.format(
                         working_name, os.path.dirname(rel_path)
                     )],
                    ['Yes, how dare you question me!',
                     '/save/{0}/{1}?{2}=1'.format(
                         working_name, rel_path, OVERWRITE_PARAM_NAME
                     )],
                ]
            )
dataset/ETHPy150Open KeepSafe/ks-email-parser/email_parser/gui/gui.py/Server.save/operator `or` -> `and`