本文整理汇总了Python中twisted.web.template.tags.a函数的典型用法代码示例。如果您正苦于以下问题:Python a函数的具体用法?Python a怎么用?Python a使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了a函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: links
def links(self, request, tag):
ds = self.root.edits(self.ob)
therange = range(len(ds))
rev = therange[self.rev]
ul = tags.ul()
for i in therange:
li = tags.li()
if i:
u = URLPath.fromRequest(request)
u = u.sibling('diff')
u.query = urllib.urlencode({
'ob': self.ob.fullName(),
'revA': i-1,
'revB': i,
})
li(tags.a(href=str(u))("(diff)"))
else:
li("(diff)")
li(" - ")
if i == len(ds) - 1:
label = "Latest"
else:
label = str(i)
if i == rev:
li(label)
else:
u = URLPath.fromRequest(request)
u.query = urllib.urlencode({
'rev': str(i),
'ob': self.ob.fullName(),
})
li(tags.a(href=str(u))(label))
li(' - ' + ds[i].user + '/' + ds[i].time)
ul(li)
return tag(ul)
示例2: render_POST
def render_POST(self, request):
uri = request.args.get('uri', [])
if not uri or not tahoeRegex.match(uri[0]):
return self.render_GET(request)
ext = request.args.get('ext', [])
b64uri = base64.urlsafe_b64encode(uri[0])
extension = ''
if ext and ext[0]:
extension = '.' + ext[0].lstrip('.')
if uri[0] not in self.shortdb:
while True:
short = crockford.b32encode(os.urandom(9)).lower()
if short not in self.shortdb:
break
self.shortdb[short] = uri[0]
self.shortdb[uri[0]] = short
self.shortdb.sync()
else:
short = self.shortdb[uri[0]]
if request.args.get('api', []):
return '/' + short + extension
body = tags.p(
tags.a('long url', href=b64uri + extension), '; ',
tags.a('medium url', href='/' + uri[0] + extension), '; ',
tags.a('short url', href=short + extension))
return renderElement(request, body)
示例3: getAuthedLink
def getAuthedLink(self, account):
return tags.span(
tags.a(
tags.span(
account.getDisplayName(), class_="persona-link-text"),
href="/members/account", class_="account-link"),
" | ",
tags.a(
tags.span("Sign out", class_="persona-link-text"),
href="#logout", id="persona-logout-link"),
id="member-links")
示例4: builder_row
def builder_row(self, bn, req, branches, num_builds):
status = self.getStatus(req)
builder = status.getBuilder(bn)
state = builder.getState()[0]
if state == 'building':
state = 'idle'
row = tags.tr()
builderLink = path_to_builder(req, builder)
row(tags.td(class_="box %s" % (state,))
(tags.a(href=builderLink)(bn)))
builds = sorted([
build for build in builder.getCurrentBuilds()
if set(map_branches(branches)) & builder._getBuildBranches(build)
], key=lambda build: build.getNumber(), reverse=True)
builds.extend(builder.generateFinishedBuilds(
map_branches(branches), num_builds=num_builds))
if builds:
for b in builds:
url = path_to_build(req, b)
try:
label = b.getProperty("got_revision")
except KeyError:
label = None
# Label should never be "None", but sometimes
# buildbot has disgusting bugs.
if not label or label == "None" or len(str(label)) > 20:
label = "#%d" % b.getNumber()
if b.isFinished():
text = b.getText()
else:
when = b.getETA()
if when:
text = [
"%s" % (formatInterval(when),),
"%s" % (time.strftime(
"%H:%M:%S",
time.localtime(time.time() + when)),)
]
else:
text = []
row(tags.td(
align="center",
bgcolor=_backgroundColors[b.getResults()],
class_=("LastBuild box ", build_get_class(b)))([
(element, tags.br)
for element
in [tags.a(href=url)(label)] + text]))
else:
row(tags.td(class_="LastBuild box")("no build"))
return row
示例5: footer_right
def footer_right(self, request, tag):
"""
'(c) 2014-2016 ',
tags.a('Open Hive', href='http://open-hive.org/'), ' and ',
tags.a('Hiveeyes', href='https://hiveeyes.org/docs/system/'), '. ',
"""
return tag(tags.p(
'Powered by ',
tags.a('Kotori', href='https://getkotori.org/'), ', ',
tags.a('InfluxDB', href='https://github.com/influxdata/influxdb'), ', ',
tags.a('dygraphs', href='http://dygraphs.com/'), ' and ',
tags.a('DataTables', href='https://datatables.net/'), '.'
))
示例6: generateTabsAndContent
def generateTabsAndContent(results):
"""
results is a dictionary whose keys are normalized ASCII chars and
whose values are the original (possible unicode) chars that map to
the ASCII ones.
"""
tabs = []
contents = []
for asciiLetter in sorted(results.keys()):
if not asciiLetter:
continue
for letter in sorted(results[asciiLetter]):
tab = tags.li(
tags.a(
letter.upper(),
href="#l%s" % letter,
**{"data-toggle": "tab"})
)
tabs.append(tab)
content = tags.div(
tags.p("holding content"),
class_="tab-pane",
id="l%s" % letter)
contents.append(content)
return tags.div(
tags.ul(tabs, class_="nav nav-tabs"),
tags.div(contents, class_="tab-content"),
class_="tabbable tabs-left")
示例7: getSignInLink
def getSignInLink(self):
return tags.span(
tags.a(
tags.span("Persona Sign-in", class_="persona-link-text"),
href="#login", id="persona-login-link",
class_="persona-button dark"),
id="persona-login")
示例8: formatPrincipals
def formatPrincipals(principals):
"""
Format a list of principals into some twisted.web.template DOM objects.
"""
def recordKey(principal):
try:
record = principal.record
except AttributeError:
try:
record = principal.parent.record
except:
return None
return (record.recordType, record.shortNames[0])
def describe(principal):
if hasattr(principal, "record"):
return " - %s" % (principal.record.fullName,)
else:
return ""
return formatList(
tags.a(href=principal.principalURL())(
str(principal), describe(principal)
)
for principal in sorted(principals, key=recordKey)
)
示例9: getCopyright
def getCopyright(self):
year = meta.startingYear
thisYear = datetime.now().year
mailTo = "mailto:%s" % config.salesEmail
if thisYear > year:
year = "%s - %s" % (year, thisYear)
return ("© %s " % year, tags.a(meta.author, href=mailTo))
示例10: _showDirectory
def _showDirectory(self, request, dirinfo):
children = dirinfo[1]['children']
body = tags.ul(*[
tags.li(tags.a(name + ('/' if info[0] == 'dirnode' else ''),
href='/' + info[1]['ro_uri']))
for name, info in children.iteritems()
])
renderElement(request, body)
示例11: hist
def hist(self, data, request):
u = URLPath.fromRequest(request)
u = u.sibling('diff')
u.query = urllib.urlencode({
'ob': data.obj.fullName(),
'rev': data.rev,
})
return tags.a(href=str(u))("(hist)")
示例12: stanForOb
def stanForOb(self, ob, summary=False):
current_docstring = self.currentDocstringForObject(ob)
if summary:
return epydoc2stan.doc2stan(
ob.doctarget, summary=True,
docstring=current_docstring)[0]
r = [tags.div(epydoc2stan.doc2stan(ob.doctarget,
docstring=current_docstring)[0]),
tags.a(href="edit?ob="+ob.fullName())("Edit"),
" "]
if ob.doctarget in self.editsbyob:
r.append(tags.a(href="history?ob="+ob.fullName())(
"View docstring history (",
str(len(self.editsbyob[ob.doctarget])),
" versions)"))
else:
r.append(tags.span(class_='undocumented')("No edits yet."))
return r
示例13: lineno
def lineno(self, request, tag):
if not self.has_lineno_col:
return ()
if hasattr(self.child, 'linenumber'):
line = str(self.child.linenumber)
if self.child.sourceHref:
line = tags.a(href=self.child.sourceHref)(line)
return tag.clear()(line)
else:
return ()
示例14: getDropdown
def getDropdown(self, title, url, cssClass):
elements = []
if title == "About":
links = urls.aboutDropDown
for text, url, type in links:
if type == const.DIVIDER:
element = tags.li(class_="divider")
elif type == const.HEADER:
element = tags.li(text, class_="nav-header")
else:
element = tags.li(tags.a(text, href=url))
elements.append(element)
return tags.li(
tags.a(
title, tags.b(class_="caret"),
href="#", class_="dropdown-toggle",
**{"data-toggle": "dropdown"}),
tags.ul(elements, class_="dropdown-menu"),
class_=cssClass)
示例15: from_dashboard
def from_dashboard(cls, dashboard):
url = '/%s' % (dashboard.config['name'])
if 'share_id' in dashboard.config:
shared_url = '/shared/%s' % dashboard.config['share_id']
shared_url_tag = tags.a(shared_url, href=shared_url)
else:
shared_url_tag = ''
return cls(dashboard.config['title'], url, shared_url_tag)