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


Python formatter.format_to_oneliner函数代码示例

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


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

示例1: format

 def format(self):
     if not self.changesets:
         message = _("No changesets for #%s" % self.tkt_id)
         yield tag.span(format_to_oneliner(self.env, self.context, message, 
                                           shorten=False),
                        class_='ticketchangesets hint')
         return
     n = len(self.changesets)
     ix = 0 # current index for adding separation markers between repos
     for (reponame, changesets) in self.changesets:
         if n > 1:
             if self.hint == 'ticket':
                 if reponame and reponame != '(default)':
                     yield tag.h3(reponame, class_='change')
                 else:
                     yield tag.h3(_("Default Repository"), class_='change')
             elif ix > 0:
                 yield ', '
         revs = changesets.wiki_revs(reponame, self.compact)
         log = changesets.wiki_log(reponame)
         message = revs + ' (' + log + ')'
         yield tag.span(format_to_oneliner(self.env, self.context, message,
                                           shorten=False),
                        class_='ticketchangesets')
         ix += 1
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:25,代码来源:web_ui.py

示例2: expand_macro

 def expand_macro(self, formatter, name, args):
     args = tuple(args.split(','))
     if len(args) == 2 :
       return tag.span(format_to_oneliner(self.env, formatter.context, args[1]),
                       style='background-color: %s' % args[0])
     else:
       return tag.span(format_to_oneliner(self.env, formatter.context, args[2]),
                       style='background-color: %s; color: %s' % args[0:2])
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:8,代码来源:Color.py

示例3: render_inline_content

    def render_inline_content(self, _env, _context, _content,mode):
        #Sceneheaders must start with INT, EXT, or EST
        sceneheader_re = re.compile('\n(INT|EXT|[^a-zA-Z0-9]EST)([\.\-\s]+?)(.+?)([A-Za-z0-9\)\s\.])\n')
        #Transitions
        transitions_re = re.compile('\n([^<>\na-z]*?:|FADE TO BLACK\.|FADE OUT\.|CUT TO BLACK\.)[\s]??\n')
        #action blocks
        actions_re = re.compile('\n{2}(([^a-z\n\:]+?[\.\?\,\s\!]*?)\n{2}){1,2}')
        #character cues    
        characters_re = re.compile('\n{1}(\w+[\.-]*[\s]*\w+?[^\!\)\?\.\s])\n{1}')
#        characters_re = re.compile('\n([^<>a-z\s][^a-z:\!\?]*?[^a-z\(\!\?:,][\s]??)\n{1}')
        #parentheticals
        parentheticals_re = re.compile('(\([^<>]*?\)[\s]??)\n')
        #dialog
        dialog_re = re.compile('(<p class="character">.*<\/p>|<p class="parenthetical">.*<\/p>)\n{0,1}(.+?)\n')
        #default
        default_re = re.compile('([^<>]*?)\n')
        #clean up
        cleanup_re = re.compile('<p class="action">[\n\s]*?<\/p>')
        #styling
#        bold_re = re.compile('(\*{2}|\[b\])(.*?)(\*{2}|\[\/b\])')
#        italic_re = re.compile('(\*{1}|\[i\])(.*?)(\*{1}|\[\/i\])')
#        underline_re = re.compile('(_|\[u\])(.*?)(_|\[\/u\])')
        
        theoutput = tag.div(class_="scrippet"+mode)        
#        self.log.debug("BEFORE SCENE: %s" % _content)
        _content = sceneheader_re.sub(r'<p class="sceneheader">\1\2\3\4</p>' + "\n",_content)
#        self.log.debug("BEFORE TRANSITIONS: %s" % _content)
        _content = transitions_re.sub(r'<p class="transition">\1</p>' + "\n",_content)
#        self.log.debug("BEFORE ACTIONS: %s" % _content)
        _content = actions_re.sub("\n" + r'<p class="action">\2</p>' + "\n",_content)
#        self.log.debug("BEFORE CHARACTERS: %s" % _content)
#        self.log.debug(_content);
        _content = characters_re.sub(r'<p class="character">\1</p>',_content)
#        self.log.debug(characters_re.sub(r'<p class="character">\1</p>',_content));
        _content = parentheticals_re.sub(r'<p class="parenthetical">\1</p>',_content); #format_to_oneliner(_env, _context, _content))
        _content = dialog_re.sub(r'\1' + "\n" + r'<p class="dialogue">\2</p>' + "\n",_content); #format_to_oneliner(_env, _context, _content))
        _content = default_re.sub(r'<p class="action">\1</p>' + "\n",_content)
        _content = cleanup_re.sub("",_content)
#        _content = bold_re.sub(r'<b>\2</b>',_content)
#        _content = italic_re.sub(r'<i>\2</i>',_content)
#        _content = underline_re.sub(r'<u>\2</u>',_content)
        para_re = re.compile(r'<p class="(?P<_class>.*?)">(?P<_body>.*?)</p>')
        for line in _content.splitlines():
#            self.log.debug("LINE: %s" % line)
            m = para_re.search(line)
            if m != None:
#                self.log.debug("BODY: %s" % m.group('_body'))
#                self.log.debug("CLASS: %s" % m.group('_class'))
                if "FADE IN" in m.group('_body') and m.group('_class') == "transition":
                    theoutput.append(tag.p(format_to_oneliner(_env, _context,m.group('_body')),class_="action"+mode))
                else:
                    theoutput.append(tag.p(format_to_oneliner(_env, _context,m.group('_body')),class_=m.group('_class')+mode))
        return theoutput
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:53,代码来源:macro.py

示例4: get_timeline_events

    def get_timeline_events(self, req, start, stop, filters):
        self.log.debug("start: %s, stop: %s, filters: %s" % (start, stop,
          filters))

        if ('discussion' in filters) and 'DISCUSSION_VIEW' in req.perm:
            # Create request context.
            context = Context.from_request(req)
            context.realm = 'discussion-core'

            # Get database access.
            db = self.env.get_db_cnx()
            context.cursor = db.cursor()

            # Get API component.
            api = self.env[DiscussionApi]

            # Add CSS styles and scripts.
            add_stylesheet(context.req, 'discussion/css/discussion.css')

            # Get forum events.
            for forum in api.get_changed_forums(context, start, stop):
                # Return event.
                title = 'New forum %s created' % (forum['name'],)
                description = tag(format_to_oneliner(self.env, context,
                  forum['subject']), ' - ', format_to_oneliner(self.env,
                  context, forum['description']))
                ids = ('forum', forum['id'])
                yield ('discussion unsolved', to_datetime(forum['time'], utc),
                  forum['author'], (title, description, ids))

            # Get topic events.
            for topic in api.get_changed_topics(context, start, stop):
                title = 'New topic on %s created' % (topic['forum_name'],)
                description = format_to_oneliner(self.env, context,
                  topic['subject'])
                ids = ('topic', topic['id'])
                yield ('discussion solved' if 'solved' in topic['status']
                  else 'discussion unsolved', to_datetime(topic['time'], utc),
                  topic['author'], (title, description, ids))

            # Get message events.
            for message in api.get_changed_messages(context, start, stop):
                title = 'New reply on %s created' % (message['forum_name'],)
                description = format_to_oneliner(self.env, context,
                  message['topic_subject'])
                ids = (('topic',message['topic']),'message', message['id'])
                yield ('discussion unsolved', to_datetime(message['time'], utc),
                  message['author'], (title, description, ids))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:48,代码来源:timeline.py

示例5: get_macro_descr

 def get_macro_descr():
     for macro_provider in formatter.wiki.macro_providers:
         names = list(macro_provider.get_macros() or [])
         if name_filter and not any(name.startswith(name_filter)
                                    for name in names):
             continue
         try:
             name_descriptions = [
                 (name, macro_provider.get_macro_description(name))
                 for name in names]
         except Exception, e:
             yield system_message(
                 _("Error: Can't get description for macro %(name)s",
                   name=names[0]), e), names
         else:
             for descr, pairs in groupby(name_descriptions,
                                         key=lambda p: p[1]):
                 if descr:
                     if isinstance(descr, (tuple, list)):
                         descr = dgettext(descr[0],
                                          to_unicode(descr[1])) \
                                 if descr[1] else ''
                     else:
                         descr = to_unicode(descr) or ''
                     if content == '*':
                         descr = format_to_oneliner(
                             self.env, formatter.context, descr,
                             shorten=True)
                     else:
                         descr = format_to_html(
                             self.env, formatter.context, descr)
                 yield descr, [name for name, descr in pairs]
开发者ID:exocad,项目名称:exotrac,代码行数:32,代码来源:macros.py

示例6: expand_macro

    def expand_macro(self, formatter, name, args):
        from trac.config import Option
        section_filter = key_filter = ''
        args, kw = parse_args(args)
        if args:
            section_filter = args.pop(0).strip()
        if args:
            key_filter = args.pop(0).strip()

        registry = Option.get_registry(self.compmgr)
        sections = {}
        for (section, key), option in registry.iteritems():
            if section.startswith(section_filter):
                sections.setdefault(section, {})[key] = option

        return tag.div(class_='tracini')(
            (tag.h3(tag.code('[%s]' % section), id='%s-section' % section),
             tag.table(class_='wiki')(
                 tag.tbody(tag.tr(tag.td(tag.tt(option.name)),
                                  tag.td(format_to_oneliner(
                                      self.env, formatter.context,
                                      to_unicode(option.__doc__))))
                           for option in sorted(sections[section].itervalues(),
                                                key=lambda o: o.name)
                           if option.name.startswith(key_filter))))
            for section in sorted(sections))
开发者ID:wiraqutra,项目名称:photrackjp,代码行数:26,代码来源:macros.py

示例7: expand_macro

 def expand_macro(self, formatter, name, content):
     
     if not content:
         return ''
     
     args, kwargs = parse_args(content)        
     if len(args) > 1:
         return system_message("Number of args can't be greater than 1")
     
     if args[0] == 'author':
         page = WikiPage(self.env, formatter.context.resource, 1)
         text = page.author 
     elif args[0] == 'version':
         page = WikiPage(self.env, formatter.context.resource)
         text = str(page.version)
     elif args[0] == 'changed_by':
         page = WikiPage(self.env, formatter.context.resource)
         text = page.author
     elif args[0] == 'comment':
         page = WikiPage(self.env, formatter.context.resource)
         text = page.comment
     elif args[0] == 'changed_ts':
         page = WikiPage(self.env, formatter.context.resource)
         text = format_datetime(page.time)
     else:
         return system_message("Unkwown argument %s" % args[0])
     
     return format_to_oneliner(self.env, formatter.context, text)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:28,代码来源:macro.py

示例8: _do_ticket

 def _do_ticket(self, req, template, data, content_type):
     if 'ticket' in data and 'linked_tickets' in data:
         ticket = data['ticket']
         context = Context.from_request(req, ticket.resource)
         
         # Add name:#n links to link fields of Ticket instance when
         # flowing from storage to browser
         if req.method == 'GET':
             RemoteLinksProvider(self.env).augment_ticket(ticket)
         
         # Rerender link fields
         for field in data['fields']:
             if field['type'] == 'link':
                 name = field['name']
                 field['rendered'] = format_to_oneliner(self.env, context,
                                                        ticket[name])
         
         # Add RemoteTicket objects for linked issues table, and pass list
         # of rejects that could not be retrieved
         linked_tickets, linked_rejects = self._remote_tickets(ticket,
                                                               context)
         data['linked_tickets'].extend(linked_tickets)
         data['linked_rejects'].extend(linked_rejects)
     
     # Provide list of remote sites if newlinked form options are present
     if 'newlinked_options' in data:
         remote_sites = RemoteTicketSystem(self.env).get_remote_tracs()
         data['remote_sites'] = remote_sites
     
     return (template, data, content_type)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:30,代码来源:web_ui.py

示例9: _info_formatter

 def _info_formatter(self, formatter, match, fullmatch):
     infotype = fullmatch.group('infotype').lower()
     body = format_to_oneliner(formatter.env, formatter.context,
                 fullmatch.group('notes'), False)
     return tag.div(tag.blockquote(tag.b(infotype.capitalize() + ': ')
         + body,class_=infotype.upper()),
         class_=infotype.upper())
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:7,代码来源:plugin.py

示例10: _get_changed_forums

 def _get_changed_forums(self, context, start, stop):
     columns = ('id', 'name', 'author', 'subject', 'description', 'time')
     sql_values = {'start' : to_timestamp(start),
       'stop' : to_timestamp(stop)}
     sql = ("SELECT f.id, f.name, f.author, f.subject, f.description, f.time "
            "FROM forum f "
            "WHERE f.time BETWEEN %(start)s AND %(stop)s" % (sql_values))
     self.log.debug(sql)
     context.cursor.execute(sql)
     for row in context.cursor:
         row = dict(zip(columns, row))
         row['time'] = to_datetime(row['time'], utc)
         row['subject'] = format_to_oneliner(self.env, context,
           row['subject'])
         row['description'] = format_to_oneliner(self.env, context,
           row['description'])
         yield row
开发者ID:okamototk,项目名称:kanonconductor,代码行数:17,代码来源:timeline.py

示例11: render_timeline_event

	def render_timeline_event(self, context, field, event):
		builder_name, num, end, branch, rev, results, text = event[3]
		if field == 'url':
			return None
		elif field == 'title':
			return tag('Build ', tag.a('#%s'%num, href=context.href.buildbot('builder/%s/%s'%(builder_name, num))),
				' of ', builder_name, ' ', results == 'success' and tag.span('passed', style="color: #080") or tag.span('failed', style="color: #f00"))
		elif field == 'description':
			return format_to_oneliner(self.env, context, 'Built from %s'%(rev and 'r%s sources'%rev or 'local changes (see TryBuildUsage)'))
开发者ID:1stvamp,项目名称:buildbot,代码行数:9,代码来源:web_ui.py

示例12: _replaces_formatter

 def _replaces_formatter(self, formatter, ns, match):
     replaces = match.group('replaces')
     
     if replaces not in self.replace:
         return match.group(0)
     title = self.replace[replaces]
     
     context = Context.from_request(formatter.req, formatter.resource)
     
     return Markup('<span>%s</span>' % (format_to_oneliner(self.env,context,title)))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:10,代码来源:wiki.py

示例13: expand_macro

 def expand_macro(self, formatter, name, content, args):
     self.log.debug("SpoilerMacro: expand_macro")
     add_stylesheet(formatter.req, 'spoiler/css/spoiler.css')
     add_javascript(formatter.req, 'spoiler/js/spoiler.js')
     if '\n' in content:
         output = tag.div(class_="spoiler")(format_to_html(self.env, formatter.context,content))
     else:
         output = tag.span(class_="spoiler")(format_to_oneliner(self.env, formatter.context,content))
     self.log.debug("SpoilerMacro: expand_macro output")
     return output
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:10,代码来源:macro.py

示例14: expand_macro

    def expand_macro(self, formatter, name, args):
        from trac.config import ConfigSection, Option
        section_filter = key_filter = ''
        args, kw = parse_args(args)
        if args:
            section_filter = args.pop(0).strip()
        if args:
            key_filter = args.pop(0).strip()

        def getdoc(option_or_section):
            doc = to_unicode(option_or_section.__doc__)
            if doc:
                doc = dgettext(option_or_section.doc_domain, doc)
            return doc

        registry = ConfigSection.get_registry(self.compmgr)
        sections = dict((name, getdoc(section))
                        for name, section in registry.iteritems()
                        if name.startswith(section_filter))

        registry = Option.get_registry(self.compmgr)
        options = {}
        for (section, key), option in registry.iteritems():
            if section.startswith(section_filter):
                options.setdefault(section, {})[key] = option
                sections.setdefault(section, '')

        def default_cell(option):
            default = option.default
            if default is True:
                default = 'true'
            elif default is False:
                default = 'false'
            elif default == 0:
                default = '0.0' if isinstance(default, float) else '0'
            elif default:
                default = ', '.join(to_unicode(val) for val in default) \
                          if isinstance(default, (list, tuple)) \
                          else to_unicode(default)
            else:
                return tag.td(_("(no default)"), class_='nodefault')
            return tag.td(tag.code(default), class_='default')

        return tag.div(class_='tracini')(
            (tag.h3(tag.code('[%s]' % section), id='%s-section' % section),
             format_to_html(self.env, formatter.context, section_doc),
             tag.table(class_='wiki')(tag.tbody(
                 tag.tr(tag.td(tag.tt(option.name)),
                        tag.td(format_to_oneliner(
                            self.env, formatter.context, getdoc(option))),
                        default_cell(option))
                 for option in sorted(options.get(section, {}).itervalues(),
                                      key=lambda o: o.name)
                 if option.name.startswith(key_filter))))
            for section, section_doc in sorted(sections.iteritems()))
开发者ID:thimalk,项目名称:bloodhound,代码行数:55,代码来源:macros.py

示例15: render_timeline_event

    def render_timeline_event(self, context, field, event):
        # Decompose event data.
        id, name, description, size = event[3]

        # Return apropriate content.
        if field == 'url':
           return context.req.href.downloads(id)
        elif field == 'title':
           return tag('New download ', tag.em(name), ' created')
        elif field == 'description':
           return tag('(%s) ' % (pretty_size(size),), format_to_oneliner(
             self.env, context, description))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:12,代码来源:timeline.py


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