• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python wikiutil.importPlugin函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中MoinMoin.wikiutil.importPlugin函数的典型用法代码示例。如果您正苦于以下问题:Python importPlugin函数的具体用法?Python importPlugin怎么用?Python importPlugin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: contentfilter

 def contentfilter(self, filename):
     """ Get a filter for content of filename and return unicode content. """
     import mimetypes
     from MoinMoin import wikiutil
     request = self.request
     mimetype, encoding = mimetypes.guess_type(filename)
     if mimetype is None:
         mimetype = 'application/octet-stream'
     def mt2mn(mt): # mimetype to modulename
         return mt.replace("/", "_").replace("-","_").replace(".", "_")
     try:
         _filter = mt2mn(mimetype)
         execute = wikiutil.importPlugin(request.cfg, 'filter', _filter)
     except wikiutil.PluginMissingError:
         try:
             _filter = mt2mn(mimetype.split("/", 1)[0])
             execute = wikiutil.importPlugin(request.cfg, 'filter', _filter)
         except wikiutil.PluginMissingError:
             try:
                 _filter = mt2mn('application/octet-stream')
                 execute = wikiutil.importPlugin(request.cfg, 'filter', _filter)
             except wikiutil.PluginMissingError:
                 raise ImportError("Cannot load filter %s" % binaryfilter)
     try:
         data = execute(self, filename)
         request.log("Filter %s returned %d characters for file %s" % (_filter, len(data), filename))
     except (OSError, IOError), err:
         data = ''
         request.log("Filter %s threw error '%s' for file %s" % (_filter, str(err), filename))
开发者ID:imosts,项目名称:flume,代码行数:29,代码来源:lupy.py


示例2: setProcessor

 def setProcessor(self, name):
     """ Set processer to either processor or parser named 'name' """
     cfg = self.request.cfg
     try:
         self.processor = wikiutil.importPlugin(cfg, "processor", name, "process")
         self.processor_is_parser = 0
     except wikiutil.PluginMissingError:
         try:
             self.processor = wikiutil.importPlugin(cfg, "parser", name, "Parser")
             self.processor_is_parser = 1
         except wikiutil.PluginMissingError:
             self.processor = None
开发者ID:Glottotopia,项目名称:aagd,代码行数:12,代码来源:text_moin158_wiki.py


示例3: execute

    def execute(self, macro_name, args):
        """ Get and execute a macro

        Try to get a plugin macro, or a builtin macro or a language
        macro, or just raise ImportError.
        """
        self.name = macro_name
        try:
            str(macro_name)
        except UnicodeEncodeError:
            _ = self._
            return self.formatter.text(_("<<%(macro_name)s: invalid macro name>>") % {"macro_name": macro_name})
        try:
            call = wikiutil.importPlugin(self.cfg, "macro", macro_name, function="macro_%s" % macro_name)
            execute = lambda _self, _args: wikiutil.invoke_extension_function(_self.request, call, _args, [_self])
        except wikiutil.PluginAttributeError:
            # fall back to old execute() method, no longer recommended
            execute = wikiutil.importPlugin(self.cfg, "macro", macro_name)
        except wikiutil.PluginMissingError:
            try:
                call = getattr(self, "macro_%s" % macro_name)
                execute = lambda _self, _args: wikiutil.invoke_extension_function(_self.request, call, _args, [])
            except AttributeError:
                if macro_name in i18n.wikiLanguages():
                    execute = self.__class__._m_lang
                else:
                    raise ImportError("Cannot load macro %s" % macro_name)
        try:
            return execute(self, args)
        except Exception, err:
            # we do not want that a faulty macro aborts rendering of the page
            # and makes the wiki UI unusable (by emitting a Server Error),
            # thus, in case of exceptions, we just log the problem and return
            # some standard text.
            try:
                page_spec = " (page: '%s')" % self.formatter.page.page_name
            except:
                page_spec = ""
            logging.exception("Macro %s%s raised an exception:" % (self.name, page_spec))
            _ = self.request.getText
            return self.formatter.text(
                _("<<%(macro_name)s: execution failed [%(error_msg)s] (see also the log)>>")
                % {
                    "macro_name": self.name,
                    "error_msg": err.args[0],  # note: str(err) or unicode(err) does not work for py2.4/5/6
                }
            )
            import traceback

            logging.info("Stack:\n" + traceback.format_stack())
开发者ID:microcosmx,项目名称:experiments,代码行数:50,代码来源:__init__.py


示例4: get_dependencies

 def get_dependencies(self, macro_name):
     if macro_name in self.Dependencies:
         return self.Dependencies[macro_name]
     try:
         return wikiutil.importPlugin(self.request.cfg, "macro", macro_name, "Dependencies")
     except wikiutil.PluginError:
         return self.defaultDependency
开发者ID:microcosmx,项目名称:experiments,代码行数:7,代码来源:__init__.py


示例5: _handle_submission

def _handle_submission(request):
    """ Handle GET and POST requests of preferences forms.

    Return error msg_class, msg tuple or None, None.
    """
    _ = request.getText
    sub = request.form.get('handler', [None])[0]

    if sub in request.cfg.userprefs_disabled:
        return None, None

    try:
        cls = wikiutil.importPlugin(request.cfg, 'userprefs', sub, 'Settings')
    except wikiutil.PluginMissingError:
        # we never show this plugin to click on so no need to
        # give a message here
        return None, None

    obj = cls(request)
    if not obj.allowed():
        return None, None
    res = obj.handle_form()
    if isinstance(res, tuple):
        return res
    # backward compatibility for userprefs plugins,
    # they just get 'dialog'-style messages.
    return None, res
开发者ID:steveyen,项目名称:moingo,代码行数:27,代码来源:userprefs.py


示例6: execute

def execute(pagename, request):
    macro_action = wikiutil.importPlugin(request.cfg, "macro", pagename, "action_" + pagename)
    
    result = macro_action(request)
    
    request.write(result)
    request.close()
开发者ID:felixonmars,项目名称:process,代码行数:7,代码来源:process.py


示例7: execute

def execute(pagename, request):
    # Strip non-ascii chars in header
    pagename_header = '%s.csv' % (pagename)
    pagename_header = pagename_header.encode('ascii', 'ignore')
    
    request.content_type = 'text/csv; charset=UTF-8'
    request.headers['Content-Disposition'] = \
        'attachment; filename="%s"' % pagename_header
    GetMeta = wikiutil.importPlugin(request.cfg, 'xmlrpc', 'GetMeta', 'do_action')

    form = values_to_form(request.values)

    try:
        args = form['args'][0]
    except (KeyError, IndexError):
        args = u''

    table = GetMeta(request, args, keysonly=False)
    table = getmeta_to_table(table)
    if 0:
        print '--', table, '--'
        print 'args', args
        print 'pagename', pagename

    writer = csv.writer(request, delimiter=';')

    for row in table:
        writer.writerow(map(encode_page, row))
开发者ID:graphingwiki,项目名称:graphingwiki,代码行数:28,代码来源:metaCSV.py


示例8: execute

def execute(pagename, request):
    enter_page(request, pagename, "Group Editor")
    macro = wikiutil.importPlugin(request.cfg, "macro", "GroupEditor", "do_macro")
    request.write(macro(request))
    page = Page(request, pagename)
    request.write(page.link_to(request, text=request.getText("back")))
    exit_page(request, pagename)
开发者ID:graphingwiki,项目名称:graphingwiki,代码行数:7,代码来源:GroupEditor.py


示例9: send_page_content

    def send_page_content(self, request, notparser, body, format_args='',
                          do_cache=0, **kw):
        self.parser = importPlugin(request.cfg, "parser",
                                   'link_collect', "Parser")

        kw['format_args'] = format_args
        kw['do_cache'] = 0
        apply(Page.send_page_content, (self, request, self.parser, body), kw)
开发者ID:graphingwiki,项目名称:graphingwiki,代码行数:8,代码来源:savegraphdata.py


示例10: createParser

 def createParser(self, format, text):
     if format == "wiki":
         format = "text_moin_wiki"
     try:
         Parser = wikiutil.importPlugin(self.request.cfg, "parser", format, "Parser")
     except wikiutil.PluginMissingError:
         from MoinMoin.parser.text import Parser
     parser = Parser(text, self.request)
     return parser
开发者ID:microcosmx,项目名称:experiments,代码行数:9,代码来源:SlideShow.py


示例11: format

    def format(self, formatter):
        if len(self.args) <= 0:
            from MoinMoin.wikiutil import importPlugin
            sqlparser = importPlugin(self.request.cfg, 'parser', 'sql', 'Parser')
            sqlparser(self.query, self.request).format(formatter)
        else:
            try:
                self.validate()
                self.__run_n_format(formatter)
            except Exception as inst:
                from MoinMoin.wikiutil import importPlugin
                sqlparser = importPlugin(self.request.cfg, 'parser', 'sql', 'Parser')
                sqlparser(self.query, self.request).format(formatter)

                self.request.write(u'<pre>%s</pre>' % str(inst))

                import traceback, sys
                traceback.print_exc(file=sys.stdout)
开发者ID:happytk,项目名称:moin,代码行数:18,代码来源:sqlrun.py


示例12: get_dependencies

 def get_dependencies(self, macro_name):
     if self.Dependencies.has_key(macro_name):
         return self.Dependencies[macro_name]
     result = wikiutil.importPlugin(self.request.cfg, 'macro', macro_name,
                                    'Dependencies')
     if result != None:
         return result
     else:
         return ["time"]
开发者ID:moinwiki,项目名称:moin-legacy,代码行数:9,代码来源:wikimacro.py


示例13: processor

 def processor(self, processor_name, lines, is_parser=0):
     """ processor_name MUST be valid!
         writes out the result instead of returning it!
     """
     if not is_parser:
         processor = wikiutil.importPlugin(self.request.cfg, "processor",
                                           processor_name, "process")
         processor(self.request, self, lines)
     else:
         parser = wikiutil.importPlugin(self.request.cfg, "parser",
                                        processor_name, "Parser")
         args = self._get_bang_args(lines[0])
         if args is not None:
             lines = lines[1:]
         p = parser('\n'.join(lines), self.request, format_args=args)
         p.format(self)
         del p
     return ''
开发者ID:imosts,项目名称:flume,代码行数:18,代码来源:base.py


示例14: testSyntaxReferenceDomXml

 def testSyntaxReferenceDomXml(self):
     f_name = 'dom_xml'
     try:
         formatter = wikiutil.importPlugin(self.request.cfg, "formatter", f_name, "Formatter")
     except wikiutil.PluginAttributeError:
         pass
     else:
         print "Formatting using %r" % formatter
         self.formatPage("SyntaxReference", formatter)
         print "Done."
开发者ID:steveyen,项目名称:moingo,代码行数:10,代码来源:test_formatter.py


示例15: getHandler

def getHandler(request, action, identifier="execute"):
    # check for excluded actions
    if action in request.cfg.excluded_actions:
        return None

    handler = wikiutil.importPlugin(request.cfg, "action", action, identifier)
    if handler is None:
        handler = globals().get('do_' + action)
        
    return handler
开发者ID:mikejamesthompson,项目名称:orgsites,代码行数:10,代码来源:wikiaction.py


示例16: attachment_drawing

 def attachment_drawing(self, url, text, **kw):
     # Todo get it to start the drawing editor on a click
     try:
         drawing_action = AttachFile.get_action(self.request, url, do='modify')
         assert drawing_action is not None
         attachment_drawing = wikiutil.importPlugin(self.request.cfg, 'action',
                                           drawing_action, 'gedit_drawing')
         return attachment_drawing(self, url, text, **kw)
     except (wikiutil.PluginMissingError, wikiutil.PluginAttributeError, AssertionError):
         return url
开发者ID:IvanLogvinov,项目名称:soar,代码行数:10,代码来源:text_gedit.py


示例17: macro

 def macro(self, macro_obj, name, args, markup=None):
     try:
         # plugins that are defined in the macro class itself
         # can't generate headings this way, but that's fine
         gen_headings = wikiutil.importPlugin(self.request.cfg, 'macro',
                                              name, 'generates_headings')
         return FormatterBase.macro(self, macro_obj, name, args, markup)
     except (wikiutil.PluginMissingError, wikiutil.PluginAttributeError):
         pass
     return ''
开发者ID:130s,项目名称:roswiki,代码行数:10,代码来源:TOC.py


示例18: importPlugin

def importPlugin(cfg, kind, name, function="execute"):
    """ Import plugin supporting both new and old error handling

    To port old plugins to new moin releases, copy this into your plugin
    and use it instead of wikiutil.importPlugin. Your code would run on
    both 1.3 and later.
    """
    if hasattr(wikiutil, 'PluginMissingError'):
        # New error handling: missing plugins ignored, other errors in
        # plugin code will be raised.
        try:
            Plugin = wikiutil.importPlugin(cfg, kind, name, function)
        except wikiutil.PluginMissingError:
            Plugin = None
    else:
        # Old error handling: most errors in plugin code will be hidden.
        Plugin = wikiutil.importPlugin(cfg, kind, name, function)

    return Plugin
开发者ID:130s,项目名称:roswiki,代码行数:19,代码来源:section.py


示例19: createFormatter

    def createFormatter(self, format):
        try:
            Formatter = wikiutil.importPlugin(self.request.cfg, "formatter", format, "Formatter")
        except wikiutil.PluginMissingError:
            from MoinMoin.formatter.text_plain import Formatter

        formatter = Formatter(self.request)
        self.request.formatter = formatter
        formatter.page = self.page
        return formatter
开发者ID:microcosmx,项目名称:experiments,代码行数:10,代码来源:SlideShow.py


示例20: testSyntaxReferenceDocBook

 def testSyntaxReferenceDocBook(self):
     py.test.skip("docbook is broken")
     f_name = 'text_docbook'
     try:
         formatter = wikiutil.importPlugin(self.request.cfg, "formatter", f_name, "Formatter")
     except wikiutil.PluginAttributeError:
         pass
     else:
         print "Formatting using %r" % formatter
         self.formatPage("HelpOnMoinWikiSyntax", formatter)
         print "Done."
开发者ID:Glottotopia,项目名称:aagd,代码行数:11,代码来源:test_formatter.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python wikiutil.isPicture函数代码示例发布时间:2022-05-24
下一篇:
Python wikiutil.getFrontPage函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap