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

Python translation._函数代码示例

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

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



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

示例1: rename

    def rename(self, new_name):
        """Rename wiki page in-place, keeping the history intact.
        Renaming a page this way will eventually leave dangling references
        to the old page - which litterally doesn't exist anymore.
        """
        assert self.exists, "Cannot rename non-existent page"

        if not validate_page_name(new_name):
            raise TracError(_("Invalid Wiki page name '%(name)s'",
                              name=new_name))
        old_name = self.name
        
        with self.env.db_transaction as db:
            new_page = WikiPage(self.env, new_name)
            if new_page.exists:
                raise TracError(_("Can't rename to existing %(name)s page.",
                                  name=new_name))

            db("UPDATE wiki SET name=%s WHERE name=%s", (new_name, old_name))
            # Invalidate page name cache
            del WikiSystem(self.env).pages
            # Reparent attachments
            from trac.attachment import Attachment
            Attachment.reparent_all(self.env, 'wiki', old_name, 'wiki',
                                    new_name)

        self.name = new_name
        self.env.log.info('Renamed page %s to %s', old_name, new_name)
        
        for listener in WikiSystem(self.env).change_listeners:
            if hasattr(listener, 'wiki_page_renamed'):
                listener.wiki_page_renamed(self, old_name)
开发者ID:trac-ja,项目名称:trac-ja,代码行数:32,代码来源:model.py


示例2: render_usermanager_admin_panel

    def render_usermanager_admin_panel(self, req, panel, user, path_info):
        user_actions = self._get_user_permissions(user)
        all_user_actions = PermissionSystem(self.env).get_user_permissions(user.username)
        actions = PermissionSystem(self.env).get_actions()+list(set([group for group, permissions in PermissionSystem(self.env).get_all_permissions()]))
        data = dict(actions=actions, 
                    all_user_actions=all_user_actions, 
                    user_actions=user_actions,
                    permsys = PermissionSystem(self.env), 
                    messages=[], errors=[])
 
        if req.method=="POST":
            updated_user_permissions = req.args.getlist('um_permission')
            
            for action in actions:
                if action in updated_user_permissions:
                    if not all_user_actions.has_key(action):
                        try: 
                            PermissionSystem(self.env).grant_permission(user.username, action)
                            data['messages'].append(_("Granted permission [%s] for user [%s].")%(action, user.username))
                        except Exception, e:
                            data['errors'].append(e)
                else:
                    if user_actions.has_key(action):
                        try:
                            PermissionSystem(self.env).revoke_permission(user.username, action)
                            data['messages'].append(_("Revoked permission [%s] for user [%s].")%(action, user.username))
                        except Exception, e:
                            data['errors'].append(e)
开发者ID:okamototk,项目名称:kanonconductor,代码行数:28,代码来源:admin_um.py


示例3: _do_list

 def _do_list(self):
     print_table([(m.name, m.due and
                     format_date(m.due, console_date_format),
                   m.completed and
                     format_datetime(m.completed, console_datetime_format))
                  for m in model.Milestone.select(self.env)],
                 [_("Name"), _("Due"), _("Completed")])
开发者ID:Stackato-Apps,项目名称:bloodhound,代码行数:7,代码来源:admin.py


示例4: __init__

 def __init__(self, path, rev, msg=None):
     if msg is None:
         msg = _("No node %(path)s at revision %(rev)s", path=path, rev=rev)
     else:
         msg = _("%(msg)s: No node %(path)s at revision %(rev)s",
                 msg=msg, path=path, rev=rev)
     ResourceNotFound.__init__(self, msg, _('No such node'))
开发者ID:dafrito,项目名称:trac-mirror,代码行数:7,代码来源:api.py


示例5: check_header

 def check_header(self, header):
     """Check the headers for mandatory fields"""
     if not ((Key.ID in header) or ("ticket" in header)):
         return _("Header must contain '%s' or '%s'") % (Key.ID, "ticket")
     if not (Key.SUMMARY in header):
         return _("Header must contain '%s'") % Key.SUMMARY
     return None
开发者ID:nagyist,项目名称:agilo,代码行数:7,代码来源:delete_performer.py


示例6: _sync

 def _sync(self, reponame, rev, clean):
     rm = RepositoryManager(self.env)
     if reponame == '*':
         if rev is not None:
             raise TracError(_('Cannot synchronize a single revision '
                               'on multiple repositories'))
         repositories = rm.get_real_repositories()
     else:
         if is_default(reponame):
             reponame = ''
         repos = rm.get_repository(reponame)
         if repos is None:
             raise TracError(_("Repository '%(repo)s' not found",
                               repo=reponame or '(default)'))
         if rev is not None:
             repos.sync_changeset(rev)
             printout(_('%(rev)s resynced on %(reponame)s.', rev=rev,
                        reponame=repos.reponame or '(default)'))
             return
         repositories = [repos]
     
     db = self.env.get_db_cnx()
     for repos in sorted(repositories, key=lambda r: r.reponame):
         printout(_('Resyncing repository history for %(reponame)s... ',
                    reponame=repos.reponame or '(default)'))
         repos.sync(self._sync_feedback, clean=clean)
         cursor = db.cursor()
         cursor.execute("SELECT count(rev) FROM revision WHERE repos=%s",
                        (repos.id,))
         for cnt, in cursor:
             printout(ngettext('%(num)s revision cached.',
                               '%(num)s revisions cached.', num=cnt))
     printout(_('Done.'))
开发者ID:zjj,项目名称:trac_hack,代码行数:33,代码来源:admin.py


示例7: modify_repository

 def modify_repository(self, reponame, changes):
     """Modify attributes of a repository."""
     if is_default(reponame):
         reponame = ''
     new_reponame = changes.get('name', reponame)
     if is_default(new_reponame):
         new_reponame = ''
     rm = RepositoryManager(self.env)
     with self.env.db_transaction as db:
         id = rm.get_repository_id(reponame)
         if reponame != new_reponame:
             if db("""SELECT id FROM repository WHERE name='name' AND
                      value=%s""", (new_reponame,)):
                 raise TracError(_('The repository "%(name)s" already '
                                   'exists.',
                                   name=new_reponame or '(default)'))
         for (k, v) in changes.iteritems():
             if k not in self.repository_attrs:
                 continue
             if k in ('alias', 'name') and is_default(v):
                 v = ''
             if k == 'dir' and not os.path.isabs(v):
                 raise TracError(_("The repository directory must be "
                                   "absolute"))
             db("UPDATE repository SET value=%s WHERE id=%s AND name=%s",
                (v, id, k))
             if not db(
                     "SELECT value FROM repository WHERE id=%s AND name=%s",
                     (id, k)):
                 db("""INSERT INTO repository (id, name, value)
                       VALUES (%s, %s, %s)
                       """, (id, k, v))
     rm.reload_repositories()
开发者ID:dafrito,项目名称:trac-mirror,代码行数:33,代码来源:api.py


示例8: get_navigation_items

 def get_navigation_items(self, req):
     # The 'Admin' navigation item is only visible if at least one
     # admin panel is available
     panels, providers = self._get_panels(req)
     if panels:
         yield ('mainnav', 'monitoring', tag.a(_('Monitoring'), 
                href=req.href.monitoring(), title=_('Monitoring')))
开发者ID:kopernikus,项目名称:systrac,代码行数:7,代码来源:api.py


示例9: pre_process_request

 def pre_process_request(self, req, handler):
     if req.path_info.startswith('/admin/ticket/components/'):
         if req.method == "POST" and 'renamechildren' in req.args:
             if req.args.get('renamechildren') != 'on':
                 return handler # Let trac handle this update
             # First process the parent component. 
             parentcomponentname = req.path_info[25:]
             parentcomponent = model.Component(self.env, parentcomponentname)
             parentcomponent.name = req.args.get('name')
             parentcomponent.owner = req.args.get('owner')
             parentcomponent.description = req.args.get('description')
             try:
                 parentcomponent.update()
             except self.env.db_exc.IntegrityError:
                 raise TracError(_('The component "%(name)s" already '
                                   'exists.', name=parentcomponentname))
                 
             # Now update the child components
             childcomponents = self._get_component_children(parentcomponentname)
             for component in childcomponents:
                 component.name = component.name.replace(parentcomponentname, req.args.get('name'), 1)
                 component.update()
             add_notice(req, _('Your changes have been saved.'))
             req.redirect(req.href.admin('ticket', 'components'))
             
     return handler
开发者ID:exocad,项目名称:exotrac,代码行数:26,代码来源:web_ui.py


示例10: _do_delete

    def _do_delete(self, req, milestone):
        req.perm(milestone.resource).require('MILESTONE_DELETE')

        retarget_to = req.args.get('target') or None
        # Don't translate ticket comment (comment:40:ticket:5658)
        retargeted_tickets = \
            milestone.move_tickets(retarget_to, req.authname,
                "Ticket retargeted after milestone deleted")
        milestone.delete(author=req.authname)
        add_notice(req, _('The milestone "%(name)s" has been deleted.',
                          name=milestone.name))
        if retargeted_tickets:
            add_notice(req, _('The tickets associated with milestone '
                              '"%(name)s" have been retargeted to milestone '
                              '"%(retarget)s".', name=milestone.name,
                              retarget=retarget_to))
            new_values = {'milestone': retarget_to}
            comment = _("Tickets retargeted after milestone deleted")
            tn = BatchTicketNotifyEmail(self.env)
            try:
                tn.notify(retargeted_tickets, new_values, comment, None,
                          req.authname)
            except Exception, e:
                self.log.error("Failure sending notification on ticket batch "
                               "change: %s", exception_to_unicode(e))
                add_warning(req, tag_("The changes have been saved, but an "
                                      "error occurred while sending "
                                      "notifications: %(message)s",
                                      message=to_unicode(e)))
开发者ID:exocad,项目名称:exotrac,代码行数:29,代码来源:roadmap.py


示例11: _render_editor

    def _render_editor(self, req, id, copy):
        if id != -1:
            req.perm.require("REPORT_MODIFY")
            for title, description, query in self.env.db_query(
                "SELECT title, description, query FROM report WHERE id=%s", (id,)
            ):
                break
            else:
                raise TracError(_("Report {%(num)s} does not exist.", num=id), _("Invalid Report Number"))
        else:
            req.perm.require("REPORT_CREATE")
            title = description = query = ""

        # an explicitly given 'query' parameter will override the saved query
        query = req.args.get("query", query)

        if copy:
            title += " (copy)"

        if copy or id == -1:
            data = {"title": _("Create New Report"), "action": "new", "error": None}
        else:
            data = {
                "title": _("Edit Report {%(num)d} %(title)s", num=id, title=title),
                "action": "edit",
                "error": req.args.get("error"),
            }

        data["report"] = {"id": id, "title": title, "sql": query, "description": description}
        return data
开发者ID:dafrito,项目名称:trac-mirror,代码行数:30,代码来源:report.py


示例12: _render_editor

    def _render_editor(self, req, id, copy):
        if id != -1:
            req.perm.require('REPORT_MODIFY')
            for title, description, query in self.env.db_query(
                    "SELECT title, description, query FROM report WHERE id=%s",
                    (id,)):
                break
            else:
                raise TracError(_("Report {%(num)s} does not exist.", num=id),
                                _("Invalid Report Number"))
        else:
            req.perm.require('REPORT_CREATE')
            title = description = query = ''

        # an explicitly given 'query' parameter will override the saved query
        query = req.args.get('query', query)

        if copy:
            title += ' (copy)'

        if copy or id == -1:
            data = {'title': _('Create New Report'),
                    'action': 'new',
                    'error': None}
        else:
            data = {'title': _('Edit Report {%(num)d} %(title)s', num=id,
                               title=title),
                    'action': 'edit',
                    'error': req.args.get('error')}

        data['report'] = {'id': id, 'title': title,
                          'sql': query, 'description': description}
        return data
开发者ID:nextview,项目名称:medicticket,代码行数:33,代码来源:report.py


示例13: _launch

 def _launch(self, encoded_input, *args):
     """Launch a process (cmd), and returns exitcode, stdout + stderr"""
     # Note: subprocess.Popen doesn't support unicode options arguments
     # (http://bugs.python.org/issue1759845) so we have to encode them.
     # Anyway, dot expects utf-8 or the encoding specified with -Gcharset.
     encoded_cmd = []
     for arg in args:
         if isinstance(arg, unicode):
             arg = arg.encode(self.encoding, 'replace')
         encoded_cmd.append(arg)
     p = subprocess.Popen(encoded_cmd, stdin=subprocess.PIPE,
                          stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     if encoded_input:
         p.stdin.write(encoded_input)
     p.stdin.close()
     out = p.stdout.read()
     err = p.stderr.read()
     failure = p.wait() != 0
     if failure or err or out:
         return (failure, tag.p(tag.br(), _("The command:"), 
                      tag.pre(repr(' '.join(encoded_cmd))), 
                      (_("succeeded but emitted the following output:"),
                       _("failed with the following output:"))[failure],
                      out and tag.pre(repr(out)), 
                      err and tag.pre(repr(err))))
     else:
         return (False, None)
开发者ID:aroth-arsoft,项目名称:trac-graphviz,代码行数:27,代码来源:graphviz.py


示例14: process_request

    def process_request(self, req):
        presel = req.args.get('preselected')
        if presel and (presel + '/').startswith(req.href.browser() + '/'):
            req.redirect(presel)

        path = req.args.get('path', '/')
        rev = req.args.get('rev', '')
        if rev.lower() in ('', 'head'):
            rev = None
        format = req.args.get('format')
        order = req.args.get('order', 'name').lower()
        desc = 'desc' in req.args
        xhr = req.get_header('X-Requested-With') == 'XMLHttpRequest'

        rm = RepositoryManager(self.env)
        all_repositories = rm.get_all_repositories()
        reponame, repos, path = rm.get_repository_by_path(path)

        # Repository index
        show_index = not reponame and path == '/'
        if show_index:
            if repos and (as_bool(all_repositories[''].get('hidden'))
                          or not repos.is_viewable(req.perm)):
                repos = None

        if not repos and reponame:
            raise ResourceNotFound(_("Repository '%(repo)s' not found",
                                     repo=reponame))

        if reponame and reponame != repos.reponame: # Redirect alias
            qs = req.query_string
            req.redirect(req.href.browser(repos.reponame or None, path)
                         + ('?' + qs if qs else ''))
        reponame = repos.reponame if repos else None

        # Find node for the requested path/rev
        context = web_context(req)
        node = None
        changeset = None
        display_rev = lambda rev: rev
        if repos:
            try:
                if rev:
                    rev = repos.normalize_rev(rev)
                # If `rev` is `None`, we'll try to reuse `None` consistently,
                # as a special shortcut to the latest revision.
                rev_or_latest = rev or repos.youngest_rev
                node = get_existing_node(req, repos, path, rev_or_latest)
            except NoSuchChangeset, e:
                raise ResourceNotFound(e, _('Invalid changeset number'))
            if node:
                try:
                    # use changeset instance to retrieve branches and tags
                    changeset = repos.get_changeset(node.rev)
                except NoSuchChangeset:
                    pass

            context = context.child(repos.resource.child('source', path,
                                                   version=rev_or_latest))
            display_rev = repos.display_rev
开发者ID:exocad,项目名称:exotrac,代码行数:60,代码来源:browser.py


示例15: get_navigation_items

 def get_navigation_items(self, req):
     if 'WIKI_VIEW' in req.perm('wiki'):
         yield ('mainnav', 'wiki',
                tag.a(_('Wiki'), href=req.href.wiki(), accesskey=1))
         yield ('metanav', 'help',
                tag.a(_('Help/Guide'), href=req.href.wiki('TracGuide'),
                      accesskey=6))
开发者ID:Stackato-Apps,项目名称:bloodhound,代码行数:7,代码来源:web_ui.py


示例16: get_backlog_list

 def get_backlog_list(self, sql, db=None):
     if not db:
         db = self.env.get_db_cnx()
     cursor = db.cursor()
     cursor.execute(sql)
     closed_backlogs = list()
     running_backlogs = list()
     t = datetime.datetime.now()
     now = time.mktime(t.timetuple())
     
     for row in cursor.fetchall():
         _name, _start, _end = row
         if now > _end:
             #handler milestone
             if _end == 0:
                 running_backlogs.append(_name)
             closed_backlogs.append(_name)
         elif now >= _start and now <= _end:
             running_backlogs.append(_name)
         else:
             pass
         
     cursor.close()
             
     backlog_list = [
         {'label': _('Running (by Start Date)'),
          'options': running_backlogs},
         {'label': _('Closed (by End Date)'),
          'options': closed_backlogs},
     ]
     return backlog_list
开发者ID:lkraav,项目名称:trachacks,代码行数:31,代码来源:ticketreport.py


示例17: notify

    def notify(self, resid, subject, author=None):
        self.subject = subject
        config = self.config['notification']
        if not config.getbool('smtp_enabled'):
            return
        from_email, from_name = '', ''
        if author and config.getbool('smtp_from_author'):
            from_email = self.get_smtp_address(author)
            if from_email:
                from_name = self.name_map.get(author, '')
                if not from_name:
                    mo = self.longaddr_re.search(author)
                    if mo:
                        from_name = mo.group(1)
        if not from_email:
            from_email = config.get('smtp_from')
            from_name = config.get('smtp_from_name') or self.env.project_name
        self.replyto_email = config.get('smtp_replyto')
        self.from_email = from_email or self.replyto_email
        self.from_name = from_name
        if not self.from_email and not self.replyto_email:
            message = tag(
                tag.p(_('Unable to send email due to identity crisis.')),
                # convert explicitly to `Fragment` to avoid breaking message
                # when passing `LazyProxy` object to `Fragment`
                tag.p(to_fragment(tag_(
                    "Neither %(from_)s nor %(reply_to)s are specified in the "
                    "configuration.",
                    from_=tag.strong("[notification] smtp_from"),
                    reply_to=tag.strong("[notification] smtp_replyto")))))
            raise TracError(message, _("SMTP Notification Error"))

        Notify.notify(self, resid)
开发者ID:spsoft-RockWang,项目名称:project-_trac,代码行数:33,代码来源:compat.py


示例18: _prepare_results

    def _prepare_results(self, result_docs, hits):
        ui_docs = [self._process_doc(doc) for doc in result_docs]

        results = Paginator(
            ui_docs,
            self.page - 1,
            self.pagelen,
            hits)

        self._prepare_shown_pages(results)
        results.current_page = {'href': None,
                                'class': 'current',
                                'string': str(results.page + 1),
                                'title': None}

        parameters = self.parameters
        if results.has_next_page:
            next_href = parameters.create_href(page=parameters.page + 1)
            add_link(self.req, 'next', next_href, _('Next Page'))

        if results.has_previous_page:
            prev_href = parameters.create_href(page=parameters.page - 1)
            add_link(self.req, 'prev', prev_href, _('Previous Page'))

        self.data[self.DATA_RESULTS] = results
        prevnext_nav(self.req, _('Previous'), _('Next'))
开发者ID:Stackato-Apps,项目名称:bloodhound,代码行数:26,代码来源:web_ui.py


示例19: _select_login_action

    def _select_login_action(self, req, remote_user):
        """
        Select login action based on user status.

        - If user is expired, error msg is shown
        - If user is active, user will be logged in
        - If user is inactive, legal process is started
        - Otherwise user has no way of logging in (is banned or disabled)

        """
        user_store = get_userstore()
        user = user_store.getUser(remote_user)
        if not user:
            # This may happen if authentication method is case-insensitive
            add_notice(req, _("Incorrect username or password - please try again"))
            return self._show_login(req)

        # Check if expired
        if user.expires and user.expires <= datetime.utcnow():
            author = user_store.get_user_author(user)
            if author:
                add_warning(req, _('Account expired. Contact {0} for extension'.format(author.getDisplayName())))
            else:
                add_warning(req, _('Account expired. Contact service support for extension'))
            return self._show_login(req)

        # User is authentic but can not log in before knowing he is not banned or disabled or activation required
        if user.status == user.STATUS_INACTIVE and self.env.config.getbool('multiproject', 'login_requires_agreed_terms'):
            return self._request_legal_approval(req, remote_user)

        if user.status in (user.STATUS_ACTIVE, user.STATUS_INACTIVE):
            return self._login_success(req, remote_user)

        add_warning(req, _("User status is '%s'. Can not log in." % user_store.USER_STATUS_LABELS[user.status]))
        return self._show_login(req)
开发者ID:alvabai,项目名称:trac-multiproject,代码行数:35,代码来源:login.py


示例20: _do_import

 def _do_import(self, filename=None):
     permsys = PermissionSystem(self.env)
     try:
         with file_or_std(filename, 'rb') as f:
             encoding = stream_encoding(f)
             linesep = os.linesep if filename else '\n'
             reader = csv.reader(f, lineterminator=linesep)
             for row in reader:
                 if len(row) < 2:
                     raise AdminCommandError(
                         _("Invalid row %(line)d. Expected <user>, "
                           "<action>, [action], [...]",
                           line=reader.line_num))
                 user = to_unicode(row[0], encoding)
                 actions = [to_unicode(action, encoding)
                            for action in row[1:]]
                 if user.isupper():
                     raise AdminCommandError(
                         _("Invalid user %(user)s on line %(line)d: All "
                           "upper-cased tokens are reserved for permission "
                           "names.", user=user, line=reader.line_num))
                 old_actions = self.get_user_perms(user)
                 for action in set(actions) - set(old_actions):
                     permsys.grant_permission(user, action)
     except csv.Error as e:
         raise AdminCommandError(
             _("Cannot import from %(filename)s line %(line)d: %(error)s ",
               filename=path_to_unicode(filename or 'stdin'),
               line=reader.line_num, error=e))
     except IOError as e:
         raise AdminCommandError(
             _("Cannot import from %(filename)s: %(error)s",
               filename=path_to_unicode(filename or 'stdin'),
               error=e.strerror))
开发者ID:pkdevbox,项目名称:trac,代码行数:34,代码来源:perm.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python translation.domain_functions函数代码示例发布时间:2022-05-27
下一篇:
Python text.wrap函数代码示例发布时间: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