当前位置: 首页>>代码示例>>Python>>正文


Python AttachFile.error_msg方法代码示例

本文整理汇总了Python中MoinMoin.action.AttachFile.error_msg方法的典型用法代码示例。如果您正苦于以下问题:Python AttachFile.error_msg方法的具体用法?Python AttachFile.error_msg怎么用?Python AttachFile.error_msg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MoinMoin.action.AttachFile的用法示例。


在下文中一共展示了AttachFile.error_msg方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _do_diff

# 需要导入模块: from MoinMoin.action import AttachFile [as 别名]
# 或者: from MoinMoin.action.AttachFile import error_msg [as 别名]
def _do_diff(pagename, request):
    # return attachment list
    _ = request.getText

    form = values_to_form(request.values)

    att1 = form.get('att1', [''])[0]
    att2 = form.get('att2', [''])[0]
    sort = form.get('sort', ['normal'])[0]

    if (not (att1 and att2) or not 
        (AttachFile.exists(request, pagename, att1) and 
         AttachFile.exists(request, pagename, att2))):
        AttachFile.error_msg(pagename, request, 
                             _('Could not diff, attachments not selected or nonexisting'))
        return

    form['target'] = [att1]
    request.values = CombinedMultiDict([MultiDict(form)])
    pagename, filename, fpath = AttachFile._access_file(pagename, request)

    att1data = open(fpath, 'r').read()

    form['target'] = [att2]
    request.values = CombinedMultiDict([MultiDict(form)])
    pagename, filename, fpath = AttachFile._access_file(pagename, request)
    att2data = open(fpath, 'r').read()

    if sort == 'sort':
        att1data = '\n'.join(sorted(att1data.split('\n')))
        att2data = '\n'.join(sorted(att2data.split('\n')))
    elif sort == 'uniq':
        att1data = '\n'.join(sorted(set(att1data.split('\n'))))
        att2data = '\n'.join(sorted(set(att2data.split('\n'))))
    elif sort == 'cnt':
        att1tmp = list()
        for line in sorted(set(att1data.split('\n'))):
            if not line:
                continue
            att1tmp.append("%s %s" % (att1data.count(line), line))
        att2tmp = list()
        for line in sorted(set(att2data.split('\n'))):
            if not line:
                continue
            att2tmp.append("%s %s" % (att2data.count(line), line))
        att1data = '\n'.join(att1tmp)
        att2data = '\n'.join(att2tmp)

    # Use user interface language for this generated page
    request.setContentLanguage(request.lang)
    request.theme.send_title(_('Diff of %s and %s') % (att1, att2), 
                             pagename=pagename)
    request.write('<div id="content">\n') # start content div

    if request.user.show_fancy_diff:
        from MoinMoin.util import diff_html
        request.write(request.formatter.rawHTML(diff_html.diff(request, 
                                                               att1data, 
                                                               att2data)))
    else:
        from MoinMoin.util import diff_text
        lines = diff_text.diff(att1data.split("\n"), att2data.split("\n"))

        request.write(request.formatter.preformatted(1))
        for line in lines:
                if line[0] == "@":
                    request.write(request.formatter.rule(1))
                request.write(request.formatter.text(line + '\n'))
        request.write(request.formatter.preformatted(0))

    AttachFile.send_uploadform(pagename, request)
    request.write('</div>\n') # end content div
    request.theme.send_footer(pagename)
    request.theme.send_closing_html()
开发者ID:graphingwiki,项目名称:graphingwiki,代码行数:76,代码来源:AttachFile.py


注:本文中的MoinMoin.action.AttachFile.error_msg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。