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

Python locale._函数代码示例

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

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



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

示例1: run

	def run(self):

		env = self.state.document.settings.env

		targetid = "question-%d" % env.new_serialno('question')
		targetnode = nodes.target('', '', ids=[targetid])
 

		ad = Question('\n'.join(self.content))
		ad += nodes.title(_('Question'), _('Question'))
		#ad += nodes.class(_('Question'), _('Question'))
		self.state.nested_parse(self.content, self.content_offset, ad)
		ad.attributes["classes"] =  ["question"]
		#ad.options["class"] = "question"

		#ad = Question()
		#ad.name = self.name 
		#ad.content_offset = self.content_offset 
		#ad.options = self.options 
		#ad.content = self.content 
		#ad.block_text = self.block_text
		#ad.state = self.state
		#ad.state_machine = self.state_machine

		#ad = make_admonition(Question, self.name, [_('Question')], self.options,
		#					self.content, self.lineno, self.content_offset,
		#					self.block_text, self.state, self.state_machine)

		return [targetnode,ad]
开发者ID:richnou,项目名称:odfi-doc,代码行数:29,代码来源:questions.py


示例2: build

    def build(self, force_all=False, filenames=None):
        # type: (bool, List[unicode]) -> None
        try:
            if force_all:
                self.builder.compile_all_catalogs()
                self.builder.build_all()
            elif filenames:
                self.builder.compile_specific_catalogs(filenames)
                self.builder.build_specific(filenames)
            else:
                self.builder.compile_update_catalogs()
                self.builder.build_update()

            status = (self.statuscode == 0 and
                      _('succeeded') or _('finished with problems'))
            if self._warncount:
                logger.info(bold(_('build %s, %s warning%s.') %
                                 (status, self._warncount,
                                  self._warncount != 1 and 's' or '')))
            else:
                logger.info(bold(_('build %s.') % status))
        except Exception as err:
            # delete the saved env to force a fresh build next time
            envfile = path.join(self.doctreedir, ENV_PICKLE_FILENAME)
            if path.isfile(envfile):
                os.unlink(envfile)
            self.emit('build-finished', err)
            raise
        else:
            self.emit('build-finished', None)
        self.builder.cleanup()
开发者ID:nwf,项目名称:sphinx,代码行数:31,代码来源:application.py


示例3: setup

def setup(app):
    from sphinx.domains.python import PyField
    from sphinx.util.docfields import Field

    app.add_object_type(
        'confval',
        'confval',
        objname='configuration value',
        indextemplate='pair: %s; configuration value',
        doc_field_types=[
            PyField(
                'type',
                label=_('Type'),
                has_arg=False,
                names=('type',),
                bodyrolename='class'
            ),
            Field(
                'default',
                label=_('Default'),
                has_arg=False,
                names=('default',),
            ),
        ]
    )
开发者ID:snide,项目名称:sphinx_rtd_theme,代码行数:25,代码来源:conf.py


示例4: __init__

    def __init__(self, name, theme_path, factory):
        # type: (unicode, unicode, HTMLThemeFactory) -> None
        self.name = name
        self.base = None
        self.rootdir = None

        if path.isdir(theme_path):
            # already a directory, do nothing
            self.rootdir = None
            self.themedir = theme_path
        else:
            # extract the theme to a temp directory
            self.rootdir = tempfile.mkdtemp('sxt')
            self.themedir = path.join(self.rootdir, name)
            extract_zip(theme_path, self.themedir)

        self.config = configparser.RawConfigParser()
        self.config.read(path.join(self.themedir, THEMECONF))  # type: ignore

        try:
            inherit = self.config.get('theme', 'inherit')
        except configparser.NoSectionError:
            raise ThemeError(_('theme %r doesn\'t have "theme" setting') % name)
        except configparser.NoOptionError:
            raise ThemeError(_('theme %r doesn\'t have "inherit" setting') % name)

        if inherit != 'none':
            try:
                self.base = factory.create(inherit)
            except ThemeError:
                raise ThemeError(_('no theme named %r found, inherited by %r') %
                                 (inherit, name))
开发者ID:atodorov,项目名称:sphinx,代码行数:32,代码来源:theming.py


示例5: get_index_text

 def get_index_text(self, objectname, name):
     # type: (unicode, unicode) -> unicode
     if self.objtype == 'directive':
         return _('%s (directive)') % name
     elif self.objtype == 'role':
         return _('%s (role)') % name
     return ''
开发者ID:JelteF,项目名称:sphinx,代码行数:7,代码来源:rst.py


示例6: man_visit_graphviz

def man_visit_graphviz(self, node):
    # type: (nodes.NodeVisitor, graphviz) -> None
    if 'alt' in node.attributes:
        self.body.append(_('[graph: %s]') % node['alt'])
    else:
        self.body.append(_('[graph]'))
    raise nodes.SkipNode
开发者ID:AWhetter,项目名称:sphinx,代码行数:7,代码来源:graphviz.py


示例7: depart_caption

        def depart_caption(self, node):
            self.body.append('</span>')

            # append permalink if available
            if isinstance(node.parent, nodes.container) \
            and node.parent.get('literal_block'):
                self.add_permalink_ref(
                    node.parent, _('Permalink to this code')
                )
            elif isinstance(node.parent, nodes.figure):
                image_nodes = node.parent.traverse(nodes.image)
                target_node = image_nodes and image_nodes[0] or node.parent
                self.add_permalink_ref(
                    target_node, _('Permalink to this image')
                )
            elif node.parent.get('toctree'):
                self.add_permalink_ref(
                    node.parent.parent, _('Permalink to this toctree')
                )

            if isinstance(node.parent, nodes.container) \
            and node.parent.get('literal_block'):
                self.body.append('</div>\n')
            else:
                SmartyPantsHTMLTranslator.__bases__[0].__bases__[0] \
                    .depart_caption(self, node)
开发者ID:i386x,项目名称:doit,代码行数:26,代码来源:conf.py


示例8: process_usecase_nodes

def process_usecase_nodes(app, doctree, fromdocname):
    if not app.config.usecases_include_usecases:
        for node in doctree.traverse(usecase):
            node.parent.remove(node)

    # Replace all usecaselist nodes with a list of the collected usecases.
    # Argument each usecase with a backlink to the original location.
    env = app.builder.env

    if not hasattr(env, "usecase_all_usecases"):
        return

    for node in doctree.traverse(usecaselist):
        if not app.config.usecases_include_usecases:
            node.replace_self([])
            continue

        content = []

        for usecase_info in env.usecase_all_usecases:
            para = nodes.paragraph()
            # Create a reference

            if app.config.usecases_simple_usecaseslist:
                para += nodes.strong("UseCase: ", "UseCase: ")
                # description = (
                #    _('%s ') %
                #    (usecase_info['usecase-name']))
                # para += nodes.Text(description, description)
                newnode = nodes.reference("", "")
                innernode = nodes.emphasis(_(usecase_info["usecase-name"]), _(usecase_info["usecase-name"]))
                newnode["refdocname"] = usecase_info["docname"]
                newnode["refuri"] = app.builder.get_relative_uri(fromdocname, usecase_info["docname"])
                newnode["refuri"] += "#" + usecase_info["target"]["refid"]
                newnode.append(innernode)
                para += newnode
                content.append(para)

            else:
                filename = env.doc2path(usecase_info["docname"], base=None)
                description = _("(The original entry is located in %s, line %d and can be found ") % (
                    filename,
                    usecase_info["lineno"],
                )
                para += nodes.Text(description, description)
                newnode = nodes.reference("", "")
                innernode = nodes.emphasis(_("here"), _("here"))
                newnode["refdocname"] = usecase_info["docname"]
                newnode["refuri"] = app.builder.get_relative_uri(fromdocname, usecase_info["docname"])
                # newnode['refuri'] += '#' + usecase_info['target']['refid']
                newnode.append(innernode)

                para += newnode
                para += nodes.Text(".)", ".)")

                # Insert into the usecaselist
                content.append(usecase_info["usecase"])
                content.append(para)

        node.replace_self(content)
开发者ID:kreuzberger,项目名称:sphinx-extensions-ooa,代码行数:60,代码来源:usecases.py


示例9: get_index_text

 def get_index_text(self, name):
     if self.objtype == 'option':
         return _('%s (option)') % name
     elif self.objtype == 'variable':
         return _('%s (variable)') % name
     else:
         return ''
开发者ID:VonRosenchild,项目名称:build-test,代码行数:7,代码来源:psdom.py


示例10: man_visit_graphviz

def man_visit_graphviz(self, node):
    warn_for_deprecated_option(self, node)
    if 'alt' in node.attributes:
        self.body.append(_('[graph: %s]') % node['alt'])
    else:
        self.body.append(_('[graph]'))
    raise nodes.SkipNode
开发者ID:miyakogi,项目名称:sphinx,代码行数:7,代码来源:graphviz.py


示例11: generic_visit_altair_plot

def generic_visit_altair_plot(self, node):
    # TODO: generate PNGs and insert them here
    if 'alt' in node.attributes:
        self.body.append(_('[ graph: %s ]') % node['alt'])
    else:
        self.body.append(_('[ graph ]'))
    raise nodes.SkipNode
开发者ID:DaveGavin,项目名称:altair,代码行数:7,代码来源:altairplot.py


示例12: assemble_doctree

 def assemble_doctree(self, indexfile):
     docnames = set([indexfile])
     self.info(darkgreen(indexfile) + " ", nonl=1)
     tree = self.env.get_doctree(indexfile)
     tree['docname'] = indexfile
     # extract toctree nodes from the tree and put them in a fresh document
     new_tree = docutils.utils.new_document('<rinoh output>')
     for node in tree.traverse(addnodes.toctree):
         new_tree += node
     largetree = inline_all_toctrees(self, docnames, indexfile, new_tree,
                                     darkgreen)
     largetree['docname'] = indexfile
     self.info()
     self.info("resolving references...")
     self.env.resolve_references(largetree, indexfile, self)
     # resolve :ref:s to distant tex files -- we can't add a cross-reference,
     # but append the document name
     for pendingnode in largetree.traverse(addnodes.pending_xref):
         docname = pendingnode['refdocname']
         sectname = pendingnode['refsectname']
         newnodes = [nodes.emphasis(sectname, sectname)]
         for subdir, title in self.titles:
             if docname.startswith(subdir):
                 newnodes.append(nodes.Text(_(' (in '), _(' (in ')))
                 newnodes.append(nodes.emphasis(title, title))
                 newnodes.append(nodes.Text(')', ')'))
                 break
         else:
             pass
         pendingnode.replace_self(newnodes)
     return largetree
开发者ID:ascribe,项目名称:rinohtype,代码行数:31,代码来源:__init__.py


示例13: depart_title

def depart_title(self, node):

    # XXX Because we want to inject our link into the title, this is
    # largely copy-pasta'd from sphinx.html.writers.HtmlTranslator.

    close_tag = self.context[-1]

    if (self.permalink_text and self.builder.add_permalinks and
        node.parent.hasattr('ids') and node.parent['ids']):
        aname = node.parent['ids'][0]

        if close_tag.startswith('</a></h'):
            self.body.append('</a>')

        self.body.append(u'<a class="headerlink" href="#%s" ' % aname +
                         u'title="%s">%s</a>' % (
                         _('Permalink to this headline'),
                         self.permalink_text))

        self.body.append(u'<a class="headerlink" href="%s#%s" ' % (
                                html.slide_path(self.builder), aname,) +
                         u'title="%s">%s' % (
                         _('Slides'),
                         self.builder.app.config.slide_html_slide_link_symbol))

        if not close_tag.startswith('</a></h'):
            self.body.append('</a>')

    BaseTranslator.depart_title(self, node)
开发者ID:AndreaCrotti,项目名称:hieroglyph,代码行数:29,代码来源:writer.py


示例14: process_see_nodes

def process_see_nodes(app, doctree, fromdocname):
    for node in doctree.traverse(see):
        content = []
        para = nodes.paragraph()
        para += nodes.Text("See also:", "See also:")
        for name in node.refs:
            join_str = " "
            if name != node.refs[0]:
                join_str  = ", "
            link_txt = join_str + name;

            if name not in app.env.domaindata['bro']['idtypes']:
                # Just create the text and issue warning
                app.env.warn(fromdocname,
                             'unknown target for ".. bro:see:: %s"' % (name))
                para += nodes.Text(link_txt, link_txt)
            else:
                # Create a reference
                typ = app.env.domaindata['bro']['idtypes'][name]
                todocname = app.env.domaindata['bro']['objects'][(typ, name)]

                newnode = nodes.reference('', '')
                innernode = nodes.literal(_(name), _(name))
                newnode['refdocname'] = todocname
                newnode['refuri'] = app.builder.get_relative_uri(
                    fromdocname, todocname)
                newnode['refuri'] += '#' + typ + '-' + name
                newnode.append(innernode)
                para += nodes.Text(join_str, join_str)
                para += newnode

        content.append(para)
        node.replace_self(content)
开发者ID:fabaff,项目名称:bro,代码行数:33,代码来源:bro.py


示例15: convert_overrides

 def convert_overrides(self, name, value):
     # type: (unicode, Any) -> Any
     if not isinstance(value, string_types):
         return value
     else:
         defvalue = self.values[name][0]
         if isinstance(defvalue, dict):
             raise ValueError(_('cannot override dictionary config setting %r, '
                                'ignoring (use %r to set individual elements)') %
                              (name, name + '.key=value'))
         elif isinstance(defvalue, list):
             return value.split(',')
         elif isinstance(defvalue, integer_types):
             try:
                 return int(value)
             except ValueError:
                 raise ValueError(_('invalid number %r for config value %r, ignoring') %
                                  (value, name))
         elif hasattr(defvalue, '__call__'):
             return value
         elif defvalue is not None and not isinstance(defvalue, string_types):
             raise ValueError(_('cannot override config setting %r with unsupported '
                                'type, ignoring') % name)
         else:
             return value
开发者ID:atodorov,项目名称:sphinx,代码行数:25,代码来源:config.py


示例16: get_index_text

 def get_index_text(self, objectname, name_obj):
     name = name_obj[0].split('->')[-1]
     if objectname or name_obj[1]:
         objectname = name_obj[0].split('->')[0]
         return _('%s() (%s member)') % (name, objectname)
     else:
         return _('%s() (method)') % name
开发者ID:Lemma1,项目名称:MINAMI,代码行数:7,代码来源:lassodomain.py


示例17: text_visit_graphviz

def text_visit_graphviz(self, node):
    warn_for_deprecated_option(self, node)
    if 'alt' in node.attributes:
        self.add_text(_('[graph: %s]') % node['alt'])
    else:
        self.add_text(_('[graph]'))
    raise nodes.SkipNode
开发者ID:miyakogi,项目名称:sphinx,代码行数:7,代码来源:graphviz.py


示例18: get_index_text

 def get_index_text(self, modname, name_cls):
     if self.objtype == 'function':
         if not modname:
             return _('%s() (global function)') % name_cls[0]
         return _('%s() (module function in %s)') % (name_cls[0], modname)
     else:
         return ''
开发者ID:torcolvin,项目名称:sphinx-contrib,代码行数:7,代码来源:rubydomain.py


示例19: convert

    def convert(self, _from, _to):
        # type: (unicode, unicode) -> bool
        """Converts the image to expected one."""
        try:
            args = ([self.config.image_converter] +
                    self.config.image_converter_args +
                    [_from, _to])
            logger.debug('Invoking %r ...', args)
            p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
        except OSError as err:
            if err.errno != ENOENT:  # No such file or directory
                raise
            logger.warning(_('convert command %r cannot be run.'
                             'check the image_converter setting'),
                           self.config.image_converter)
            return False

        try:
            stdout, stderr = p.communicate()
        except (OSError, IOError) as err:
            if err.errno not in (EPIPE, EINVAL):
                raise
            stdout, stderr = p.stdout.read(), p.stderr.read()
            p.wait()
        if p.returncode != 0:
            raise ExtensionError(_('convert exited with error:\n'
                                   '[stderr]\n%s\n[stdout]\n%s') %
                                 (stderr, stdout))

        return True
开发者ID:atodorov,项目名称:sphinx,代码行数:30,代码来源:imgconverter.py


示例20: run

    def run(self):
        pkgname = self.arguments[0].strip()
        env = self.state.document.settings.env
        env.ref_context['qbs:package'] = pkgname

        if 'noindex' in self.options:
            return []

        sdkname = self.options.get('sdk', env.ref_context.get('qbs:sdk', None))

        if sdkname:
            pkgname = sdkname + '.' + pkgname

        env.domaindata['qbs']['packages'][pkgname] = (env.docname, self.options.get('synopsis', ''))
        env.domaindata['qbs']['objects'][pkgname] = (env.docname, 'package')

        # target
        targetname = 'package-' + pkgname
        targetnode = nodes.target('', '', ids=[targetname], ismod=True)
        self.state.document.note_explicit_target(targetnode)

        # index
        if sdkname:
            itext = _('%s (Qbs Package in %s)') % (pkgname[len(sdkname) + 1:], sdkname)
        else:
            itext = _('%s (Qbs Package') % (pkgname[len(sdkname) + 1:])
        inode = addnodes.index(entries=[('single', itext, targetname, '', None)])

        return [targetnode, inode]
开发者ID:StoiridhProject,项目名称:StoiridhTools,代码行数:29,代码来源:qbs.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python locale.__函数代码示例发布时间:2022-05-27
下一篇:
Python jinja2glue.BuiltinTemplateLoader类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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