本文整理汇总了Python中Nouvelle.tag函数的典型用法代码示例。如果您正苦于以下问题:Python tag函数的具体用法?Python tag怎么用?Python tag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tag函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: render_intervals
def render_intervals(self, context):
return [[
tag('a', _name=anchor, id=anchor)[
tag('h2')[ name ],
],
tag('div', _class='sensorInterval')[ ' ', self.renderInterval(length, context) ],
] for name, length, anchor in self.intervals]
开发者ID:mvanderkolff,项目名称:navi-misc,代码行数:7,代码来源:web.py
示例2: renderEntry
def renderEntry(self, entry):
return [
tag('hr'),
tag('a', href="feeds.py/entry?id=%s" % entry.guid)[ entry.title ],
tag('br'),
tag('i')[ entry.feed.name ], " (", formatDate(entry.date), ") ",
]
开发者ID:mvanderkolff,项目名称:navi-misc,代码行数:7,代码来源:mobile-feed-aggregator.py
示例3: unknownElement
def unknownElement(self, element):
# Format the element name and attributes
elementName = tag("span", _class="xml-element-name")[element.nodeName]
elementContent = [elementName]
for attr in element.attributes.values():
elementContent.extend(
[
" ",
tag("span", _class="xml-attribute-name")[attr.name],
'="',
tag("span", _class="xml-attribute-value")[attr.value],
'"',
]
)
# Now the contents...
if element.hasChildNodes():
completeElement = [
"<",
elementContent,
">",
tag("blockquote", _class="xml-element-content")[[self.parse(e) for e in element.childNodes],],
"</",
elementName,
">",
]
else:
completeElement = ["<", elementContent, "/>"]
return tag("div", _class="xml-element")[completeElement]
开发者ID:Kays,项目名称:cia-vc,代码行数:30,代码来源:MessageViewer.py
示例4: _render_rows
def _render_rows(self, metadata, context, result):
url, description, photo_results, owner_results = metadata
rows = []
if url:
rows.append(tag("a", href=url)[url])
if photo_results and photo_results[0][0]:
path, width, height = photo_results[0]
rows.append(Template.Photo("/images/db/" + path, width=width, height=height))
if description:
rows.append(description)
# XXX: This is kind of a hack, but it should improve usability
# between the old and new sites. Show 'edit' links if
# this is something users can edit (projects or authors)
# and if it isn't claimed exclusively already.
if (
not owner_results
and len(self.target.pathSegments) >= 2
and self.target.pathSegments[0] in ("project", "author")
):
rows.append(
tag(
"a",
href="/account/%ss/add/%s/" % (self.target.pathSegments[0], "/".join(self.target.pathSegments[1:])),
)["Edit..."]
)
result.callback(rows)
开发者ID:Kays,项目名称:cia-vc,代码行数:29,代码来源:Metadata.py
示例5: formatLine
def formatLine(self, line):
"""Format one line from the IRC log, returning a (timestamp, nick, content) tuple"""
timestamp, message = line.split(" ", 1)
timestamp = self.formatTimestamp(int(timestamp[1:]))
nick = ()
# Strip colors
message = re.sub("(\x03..|\x0F|\x02)", "", message)
if message[0] == '<':
# Normal conversation
sender, content = message[1:].split("> ", 1)
nick = [" <", self.formatNick(sender), "> "]
elif message[0] == '-':
# A system message of some sort
content = tag('span', _class="serverMessage")[ message[1:].split("- ", 1)[1] ]
elif message[0] == '[':
# A CTCP message
sender, ctcp = message[1:].split("] ", 1)
msgType, content = ctcp.split(" ", 1)
if msgType == "ACTION":
content = [self.formatNick(sender), " ", content]
else:
content = ["CTCP ", msgType, " ", content]
else:
content = message
return [tag('td', _class="timestamp")[ timestamp ],
tag('td', _class="nick")[ nick ],
tag('td', _class="content")[ content ]]
开发者ID:mvanderkolff,项目名称:navi-misc,代码行数:33,代码来源:irc_format.py
示例6: SubscriptionLink
def SubscriptionLink(url, content, icon="/images/rss.png", iconSize=(36,14)):
"""An anchor tag that can be used to link to RSS feeds.
"""
return tag('a', href = url)[
tag('img', src=icon, _class="left-icon", alt="RSS",
width=iconSize[0], height=iconSize[1]),
content,
]
开发者ID:Justasic,项目名称:cia-vc,代码行数:8,代码来源:Template.py
示例7: renderMetadataItem
def renderMetadataItem(self, name, value, mimeType, context):
"""Render a single metadata item. If the content is short and in
a text format, we include it directly. Otherwise, just link to it.
XXX: These links don't really make sense any more, since the metadata
format changed.
"""
valueTag = tag('value', _type=mimeType)[ str(value) ]
return tag('item', _name=name)[ valueTag ]
开发者ID:Kays,项目名称:cia-vc,代码行数:8,代码来源:Feed.py
示例8: _render_photo
def _render_photo(self, query_results, context, result):
if query_results and query_results[0][0]:
result.callback(tag('image')[
tag('url')[ '/images/db/' + query_results[0][0] ],
tag('title')[ place('title') ],
tag('link')[ place('link') ],
])
else:
result.callback([])
开发者ID:Kays,项目名称:cia-vc,代码行数:9,代码来源:Feed.py
示例9: render_content
def render_content(self, context):
e = self.entries[context['args']['id']]
return [
tag('b')[ place('title') ],
tag('br'),
tag('i')[ e.feed.name ], " (", formatDate(e.date), ") ",
tag('hr'),
tag('p')[ e.content ],
]
开发者ID:mvanderkolff,项目名称:navi-misc,代码行数:9,代码来源:mobile-feed-aggregator.py
示例10: renderTemperature
def renderTemperature(latest, _class='temperatures'):
degC = latest.get('average')
if degC is None:
return "No data"
degF = units.degCtoF(degC)
return tag('div', _class=_class)[
tag('span', _class='mainTemperature')[ "%.01f" % degF, xml("°"), "F" ],
tag('span', _class='temperatureSeparator')[ " / " ],
tag('span', _class='altTemperature')[ "%.01f" % degC, xml("°"), "C" ],
]
开发者ID:mvanderkolff,项目名称:navi-misc,代码行数:10,代码来源:web.py
示例11: format
def format(self, f):
"""Read an IRC log from the given file-like object, returning
the corresponding formatted Nouvelle tree.
"""
return tag('table')[[
tag('tr')[
self.formatLine(line),
]
for line in f.xreadlines()
]]
开发者ID:mvanderkolff,项目名称:navi-misc,代码行数:10,代码来源:irc_format.py
示例12: renderBargraph
def renderBargraph(alpha, numBars=16):
alpha = max(0, min(1, alpha))
filledBars = int(alpha * numBars + 0.5)
bars = []
for i in xrange(numBars):
if i < filledBars:
bars.append(tag('span', _class="filledBar")[ " " ])
else:
bars.append(tag('span', _class="emptyBar")[ " " ])
return tag('span', _class="bargraph")[ bars ]
开发者ID:mvanderkolff,项目名称:navi-misc,代码行数:10,代码来源:web.py
示例13: MessageHeaders
def MessageHeaders(d):
"""A factory for displaying message headers from a dictionary-like object.
If order is important (it probably is) use twisted.python.util.OrderedDict.
"""
return tag('table', _class="messageHeaders")[[
tag('tr')[
tag('td', _class='name')[ name, ":" ],
tag('td', _class='value')[ value ],
]
for name, value in d.iteritems()
]]
开发者ID:Justasic,项目名称:cia-vc,代码行数:11,代码来源:Template.py
示例14: SectionGrid
def SectionGrid(*rows):
"""Create a grid of sections, for layouts showing a lot of small boxes
in a regular pattern.
"""
return tag('table', _class="sectionGrid")[[
tag('tr', _class="sectionGrid")[[
tag('td', _class="sectionGrid")[
cell
] for cell in row
]] for row in rows
]]
开发者ID:Justasic,项目名称:cia-vc,代码行数:11,代码来源:Template.py
示例15: render_tabs
def render_tabs(self, context):
"""The page's tabs show all named components"""
tabs = []
for component in context['request'].site.components:
if component.name:
tabs.append(tag('li')[
xml('» '),
tag('a', href=component.url)[ component.name ],
])
return tag('ul', _class='heading')[ tabs ]
开发者ID:Justasic,项目名称:cia-vc,代码行数:11,代码来源:Template.py
示例16: render_navigation
def render_navigation(self, context):
if self.showDetails(context):
detailSwitch = tag('a', _class='navigation', href="?details=0")["Hide details"]
else:
detailSwitch = tag('a', _class='navigation', href="?details=1")["Show details"]
return tag('div', _class='navigation')[
tag('a', _class='navigation', href='../../')[ "All Sensors..." ],
[tag('a', _class='navigation', href="#%s" % anchor or 'top')[ name ]
for name, length, anchor in self.intervals],
detailSwitch,
]
开发者ID:mvanderkolff,项目名称:navi-misc,代码行数:12,代码来源:web.py
示例17: render_description
def render_description(self, context):
details = []
if self.source.sensor_type:
details.append("%s sensor" % self.source.sensor_type)
if self.source.micro_type:
details.append("%s microcontroller" % self.source.micro_type)
return tag('div', _class='description')[
self.source.description,
tag('p')[ ", ".join(details) ],
]
开发者ID:mvanderkolff,项目名称:navi-misc,代码行数:12,代码来源:web.py
示例18: _render
def _render(self, rows, result):
"""The backend for render(), called once our rows list is known"""
if rows:
result.callback(subcontext(owner=self)[
tag('span', _class="section")[ place("title") ],
tag('div', _class="section")[
tag('div', _class="sectionTop")[" "],
[tag('div', _class="row")[r] for r in rows],
],
])
else:
result.callback([])
开发者ID:Justasic,项目名称:cia-vc,代码行数:12,代码来源:Template.py
示例19: render_sources
def render_sources(self, context):
return tag('table')[
tag('tr')[
tag('th')[ "Name" ],
tag('th')[ "Current Temperature" ],
tag('th')[ "Last 24 Hours" ],
tag('th')[ "Last Updated" ],
tag('th')[ "Battery" ],
],
tag('tr')[ tag('td')[" "] ],
[self.renderSource(source, context) for source in self.db.iterSources()],
]
开发者ID:mvanderkolff,项目名称:navi-misc,代码行数:12,代码来源:web.py
示例20: component_headers
def component_headers(self, element, args):
"""Format all relevant commit metadata in an email-style header box"""
message = args.message
commit = XML.dig(message.xml, "message", "body", "commit")
source = XML.dig(message.xml, "message", "source")
author = XML.dig(commit, "author")
version = XML.dig(commit, "version")
revision = XML.dig(commit, "revision")
diffLines = XML.dig(commit, "diffLines")
url = XML.dig(commit, "url")
log = XML.dig(commit, "log")
project = XML.dig(source, "project")
module = XML.dig(source, "module")
branch = XML.dig(source, "branch")
headers = OrderedDict()
if author:
headers['Author'] = XML.shallowText(author)
if project:
headers['Project'] = XML.shallowText(project)
if module:
headers['Module'] = XML.shallowText(module)
if branch:
headers['Branch'] = XML.shallowText(branch)
if version:
headers['Version'] = XML.shallowText(version)
if revision:
headers['Revision'] = XML.shallowText(revision)
if diffLines:
headers['Changed Lines'] = XML.shallowText(diffLines)
if url:
headers['URL'] = tag('a', href=XML.shallowText(url))[ Util.extractSummary(url) ]
return [Template.MessageHeaders(headers)]
开发者ID:Justasic,项目名称:cia-vc,代码行数:35,代码来源:Commit.py
注:本文中的Nouvelle.tag函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论