本文整理汇总了Python中trac.util.shorten_line函数的典型用法代码示例。如果您正苦于以下问题:Python shorten_line函数的具体用法?Python shorten_line怎么用?Python shorten_line使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shorten_line函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_search_results
def get_search_results(self, req, terms, filters):
if not 'discussion' in filters:
return
# Create context.
context = Context.from_request(req)
context.realm = 'discussion-core'
# Get database access.
db = self.env.get_db_cnx()
cursor = db.cursor()
# Search in topics.
query, args = search_to_sql(db, ['author', 'subject', 'body'], terms)
columns = ('id', 'forum', 'time', 'subject', 'body', 'author')
sql = ("SELECT id, forum, time, subject, body, author "
"FROM topic "
" WHERE %s" % (query,))
self.log.debug(sql)
cursor.execute(sql, args)
for row in cursor:
row = dict(zip(columns, row))
row['time'] = to_datetime(row['time'], utc)
yield (req.href.discussion('topic', row['id']) + '#-1',
"Topic #%d: %s" % (row['id'], shorten_line(row['subject'])),
row['time'], row['author'], shorten_result(row['body'], [query]))
# Search in messages
query, args = search_to_sql(db, ['m.author', 'm.body',
't.subject'], terms)
columns = ('id', 'forum', 'topic', 'time', 'author', 'body', 'subject')
sql = ("SELECT m.id, m.forum, m.topic, m.time, m.author, m.body, "
"t.subject "
"FROM message m "
"LEFT JOIN "
"(SELECT subject, id "
"FROM topic) t "
"ON t.id = m.topic "
"WHERE %s" % (query))
self.log.debug(sql)
cursor.execute(sql, args)
for row in cursor:
row = dict(zip(columns, row))
row['time'] = to_datetime(row['time'], utc)
yield (req.href.discussion('message', row['id']) + '#%s' % (
row['id']), "Message #%d: %s" % (row['id'], shorten_line(
row['subject'])), row['time'], row['author'], shorten_result(
row['body'], [query]))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:48,代码来源:search.py
示例2: _format_sha_link
def _format_sha_link(self, formatter, sha, label):
# FIXME: this function needs serious rethinking...
reponame = ''
context = formatter.context
while context:
if context.resource.realm in ('source', 'changeset'):
reponame = context.resource.parent.id
break
context = context.parent
try:
repos = self.env.get_repository(reponame)
if not repos:
raise Exception("Repository '%s' not found" % reponame)
sha = repos.normalize_rev(sha) # in case it was abbreviated
changeset = repos.get_changeset(sha)
return tag.a(label, class_='changeset',
title=shorten_line(changeset.message),
href=formatter.href.changeset(sha, repos.reponame))
except Exception, e:
return tag.a(label, class_='missing changeset',
title=to_unicode(e), rel='nofollow')
开发者ID:thimalk,项目名称:bloodhound,代码行数:26,代码来源:git_fs.py
示例3: get_search_results
def get_search_results(self, req, query, filters):
if not "discussion" in filters:
return
# Create database context
db = self.env.get_db_cnx()
cursor = db.cursor()
# Search in topics.
columns = ("id", "forum", "time", "subject", "body", "author")
sql = "SELECT id, forum, time, subject, body, author FROM topic" " WHERE subject || body LIKE '%%%s%%'" % (
query
)
self.log.debug(sql)
cursor.execute(sql)
for row in cursor:
row = dict(zip(columns, row))
yield (
self.env.href.discussion(row["forum"], row["id"]) + "#-1",
"topic: %d: %s" % (row["id"], util.shorten_line(row["subject"])),
row["time"],
row["author"],
shorten_result(row["body"], query.split()),
)
# Search in messages
columns = ("id", "forum", "topic", "time", "author", "body", "subject")
sql = (
"SELECT id, forum, topic, time, author, body, (SELECT"
" subject FROM topic t WHERE t.id = message.topic) FROM message"
" WHERE body LIKE '%%%s%%'" % (query)
)
self.log.debug(sql)
cursor.execute(sql)
for row in cursor:
row = dict(zip(columns, row))
yield (
self.env.href.discussion(row["forum"], row["topic"], row["id"]) + "#%s" % (row["id"]),
"message: %d: %s" % (row["id"], util.shorten_line(row["subject"])),
row["time"],
row["author"],
shorten_result(row["body"], query.split()),
)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:43,代码来源:search.py
示例4: _format_link
def _format_link(self, formatter, ns, target, label):
cursor = formatter.db.cursor()
cursor.execute("SELECT subject,id FROM mailarc WHERE messageid = %s" , (target,))
row = cursor.fetchone()
if row:
subject = util.escape(util.shorten_line(row[0]))
return '<a href="%s" title="%s">%s</a>' \
% (formatter.href.mailarchive(row[1]), subject, label)
else:
return label
开发者ID:okamototk,项目名称:kanonconductor,代码行数:10,代码来源:wikisyntax.py
示例5: _format_sha_link
def _format_sha_link(self, formatter, original_sha, label):
for repository in RepositoryManager(self.env).get_real_repositories():
try:
sha = repository.normalize_rev(original_sha) # in case it was abbreviated
changeset = repository.get_changeset(sha)
return tag.a(label, class_='changeset',
title=shorten_line(changeset.message),
href=formatter.href.changeset(sha, repository.reponame))
except Exception, e:
pass
开发者ID:klas-genestack,项目名称:github-trac,代码行数:10,代码来源:github.py
示例6: _format_sha_link
def _format_sha_link(self, formatter, ns, sha, label, fullmatch=None):
try:
changeset = self.env.get_repository().get_changeset(sha)
return tag.a(label, class_="changeset",
title=shorten_line(changeset.message),
href=formatter.href.changeset(sha))
except TracError, e:
return tag.a(label, class_="missing changeset",
href=formatter.href.changeset(sha),
title=unicode(e), rel="nofollow")
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:10,代码来源:git_fs.py
示例7: _format_link
def _format_link(self, formatter, ns, rev, label):
cursor = formatter.db.cursor()
cursor.execute('SELECT message FROM revision WHERE rev=%s', (rev,))
row = cursor.fetchone()
if row:
return '<a class="changeset" title="%s" href="%s">%s</a>' \
% (util.escape(util.shorten_line(row[0])),
formatter.href.changeset(rev), label)
else:
return '<a class="missing changeset" href="%s" rel="nofollow">%s</a>' \
% (formatter.href.changeset(rev), label)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:11,代码来源:setchangeset.py
示例8: _entry_to_hdf
def _entry_to_hdf(req, entry):
return {
'id': entry.id,
'time': format_datetime(entry.time),
'timedelta': pretty_timedelta(entry.time),
'path': entry.path,
'url': req.abs_href(entry.path),
'path_clipped': shorten_line(entry.path, 25),
'href': req.href(entry.path),
'admin_href': req.href.admin('spamfilter', 'monitor', entry.id),
'author': entry.author,
'author_clipped': shorten_line(entry.author, 25),
'ipnr': entry.ipnr,
'authenticated': entry.authenticated,
'headers': entry.headers,
'content': shorten_line(entry.content),
'full_content': entry.content,
'rejected': entry.rejected,
'karma': entry.karma, 'reasons': entry.reasons
}
开发者ID:lamby,项目名称:pkg-trac-spamfilter,代码行数:20,代码来源:admin.py
示例9: rev_link
def rev_link(rev, label=None):
try:
reponame = context.resource.parent.id
repos = self.env.get_repository(reponame)
return tag.a(label, class_="changeset",
title=shorten_line(label),
href=context.href.browser(repos.reponame) + '?rev=%s' % rev)
except Exception, e:
return tag.a(sha, class_="missing tag",
title=to_unicode(e), rel="nofollow")
开发者ID:wadahiro,项目名称:trac-git-plugin,代码行数:12,代码来源:git_fs.py
示例10: _format_link
def _format_link(self, formatter, ns, target, label):
cursor = formatter.db.cursor()
cursor.execute("SELECT summary,status FROM ticket WHERE id=%s",
(target,))
row = cursor.fetchone()
if row:
summary = util.escape(util.shorten_line(row[0]))
return '<a class="%s ticket" href="%s" title="%s (%s)">%s</a>' \
% (row[1], formatter.href.ticket(target), summary, row[1],
label)
else:
return '<a class="missing ticket" href="%s" rel="nofollow">%s</a>' \
% (formatter.href.ticket(target), label)
开发者ID:lkraav,项目名称:trachacks,代码行数:13,代码来源:api.py
示例11: get_search_results
def get_search_results(self, req, query, filters):
if not 'changeset' in filters:
return
authzperm = SubversionAuthorizer(self.env, req.authname)
db = self.env.get_db_cnx()
sql, args = query_to_sql(db, query, 'message||author')
cursor = db.cursor()
cursor.execute("SELECT rev,time,author,message "
"FROM revision WHERE " + sql, args)
for rev, date, author, log in cursor:
if not authzperm.has_permission_for_changeset(rev):
continue
yield (self.env.href.changeset(rev),
'[%s]: %s' % (rev, util.shorten_line(log)),
date, author, shorten_result(log, query.split()))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:15,代码来源:setchangeset.py
示例12: get_search_results
def get_search_results(self, req, keywords, filters):
if not 'discussion' in filters:
return
# Create database context
db = self.env.get_db_cnx()
cursor = db.cursor()
# Search in topics.
query = ' '.join(keywords)
columns = ('id', 'forum', 'time', 'subject', 'body', 'author')
sql = "SELECT id, forum, time, subject, body, author FROM topic" \
" WHERE subject || body LIKE '%%%s%%'" % (query)
self.log.debug(sql)
cursor.execute(sql)
for row in cursor:
row = dict(zip(columns, row))
yield (req.href.discussion(row['forum'], row['id']) + '#-1',
"topic: %d: %s" % (row['id'], util.shorten_line(row['subject'])),
row['time'], row['author'], shorten_result(row['body'],
[query]))
# Search in messages
columns = ('id', 'forum', 'topic', 'time', 'author', 'body', 'subject')
sql = "SELECT m.id, m.forum, m.topic, m.time, m.author, m.body," \
" t.subject FROM message m LEFT JOIN (SELECT subject, id FROM" \
" topic) t ON t.id = m.topic WHERE body LIKE '%%%s%%'" \
% (query)
self.log.debug(sql)
cursor.execute(sql)
for row in cursor:
row = dict(zip(columns, row))
yield (req.href.discussion(row['forum'], row['topic'], row['id'])
+ '#%s' % (row['id']), "message: %d: %s" % (row['id'],
util.shorten_line(row['subject'])), row['time'], row['author'],
shorten_result(row['body'], [query]))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:36,代码来源:search.py
示例13: sha_link
def sha_link(sha, label=None):
# sha is assumed to be a non-abbreviated 40-chars sha id
try:
reponame = context.resource.parent.id
repos = self.env.get_repository(reponame)
cset = repos.get_changeset(sha)
if label is None:
label = repos.display_rev(sha)
return tag.a(label, class_='changeset',
title=shorten_line(cset.message),
href=context.href.changeset(sha, repos.reponame))
except Exception, e:
return tag.a(sha, class_='missing changeset',
title=to_unicode(e), rel='nofollow')
开发者ID:thimalk,项目名称:bloodhound,代码行数:16,代码来源:git_fs.py
示例14: _pydoc_formatter
def _pydoc_formatter(self, formatter, ns, object, label):
object = urllib.unquote(object)
label = urllib.unquote(label)
if not object or object == 'index':
return '<a class="wiki" href="%s">%s</a>' % \
(formatter.href.pydoc(), label)
else:
try:
_, target = PyDoc(self.env).load_object(object)
doc = pydoc.getdoc(target)
if doc: doc = doc.strip().splitlines()[0]
return '<a class="wiki" title="%s" href="%s">%s</a>' % \
(shorten_line(doc), formatter.href.pydoc(object), label)
except ImportError:
return '<a class="missing wiki" href="%s">%s?</a>' % \
(formatter.href.pydoc(object), label)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:16,代码来源:tracpydoc.py
示例15: _format_sha_link
def _format_sha_link(self, context, sha, label):
reponame = ''
while context:
if context.resource.realm in ('source', 'changeset'):
reponame = context.resource.parent.id
break
context = context.parent
repos = self.env.get_repository(reponame)
if repos:
try:
changeset = repos.get_changeset(sha)
return tag.a(label, class_="changeset",
title=shorten_line(changeset.message),
href=context.href.changeset(sha, reponame))
except NoSuchChangeset, e:
errmsg = to_unicode(e)
开发者ID:cboos,项目名称:trac-git-plugin,代码行数:16,代码来源:git_fs.py
示例16: get_search_results
def get_search_results(self, req, query, filters):
if not 'ticket' in filters:
return
db = self.env.get_db_cnx()
sql, args = query_to_sql(db, query, 'b.newvalue')
sql2, args2 = query_to_sql(db, query, 'summary||keywords||description||reporter||cc')
cursor = db.cursor()
cursor.execute("SELECT DISTINCT a.summary,a.description,a.reporter, "
"a.keywords,a.id,a.time FROM ticket a "
"LEFT JOIN ticket_change b ON a.id = b.ticket "
"WHERE (b.field='comment' AND %s ) OR %s" % (sql, sql2),
args + args2)
for summary,desc,author,keywords,tid,date in cursor:
yield (self.env.href.ticket(tid),
'#%d: %s' % (tid, util.shorten_line(summary)),
date, author,
shorten_result(desc, query.split()))
开发者ID:lkraav,项目名称:trachacks,代码行数:17,代码来源:api.py
示例17: get_timeline_events
def get_timeline_events(self, req, start, stop, filters):
if 'changeset' in filters:
format = req.args.get('format')
show_files = int(self.config.get('timeline',
'changeset_show_files'))
db = self.env.get_db_cnx()
repos = self.env.get_repository()
authzperm = SubversionAuthorizer(self.env, req.authname)
rev = repos.youngest_rev
while rev:
if not authzperm.has_permission_for_changeset(rev):
rev = repos.previous_rev(rev)
continue
chgset = repos.get_changeset(rev)
if chgset.date < start:
return
if chgset.date < stop:
message = chgset.message or '--'
if format == 'rss':
title = util.Markup('Changeset <em>[%s]</em>: %s',
chgset.rev,
util.shorten_line(message))
href = self.env.abs_href.changeset(chgset.rev)
message = wiki_to_html(message, self.env, req, db,
absurls=True)
else:
title = util.Markup('Changeset <em>[%s]</em> by %s',
chgset.rev, chgset.author)
href = self.env.href.changeset(chgset.rev)
message = wiki_to_oneliner(message, self.env, db,
shorten=True)
if show_files:
files = []
for chg in chgset.get_changes():
if show_files > 0 and len(files) >= show_files:
files.append('...')
break
files.append('<span class="%s">%s</span>'
% (chg[2], util.escape(chg[0])))
message = '<span class="changes">' + ', '.join(files) +\
'</span>: ' + message
yield 'changeset', href, title, chgset.date, chgset.author,\
util.Markup(message)
rev = repos.previous_rev(rev)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:45,代码来源:setchangeset.py
示例18: _format_sha_link
def _format_sha_link(self, formatter, ns, sha, label, context=None):
reponame = ""
if context is None:
context = formatter.context
if formatter is None:
formatter = context # hack
while context:
if context.resource.realm in ("source", "changeset"):
reponame = context.resource.parent.id
break
context = context.parent
repos = self.env.get_repository(reponame)
if repos:
try:
changeset = repos.get_changeset(sha)
return tag.a(
label,
class_="changeset",
title=shorten_line(changeset.message),
href=formatter.href.changeset(sha, reponame),
)
except Exception, e:
errmsg = to_unicode(e)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:23,代码来源:git_fs.py
示例19: _render_overview
def _render_overview(self, req):
data = {'title': 'Build Status'}
show_all = False
if req.args.get('show') == 'all':
show_all = True
data['show_all'] = show_all
repos = self.env.get_repository(authname=req.authname)
assert repos, 'No "(default)" Repository: Add a repository or alias ' \
'named "(default)" to Trac.'
configs = []
for config in BuildConfig.select(self.env, include_inactive=show_all):
rev = config.max_rev or repos.youngest_rev
try:
if not _has_permission(req.perm, repos, config.path, rev=rev):
continue
except NoSuchNode:
add_warning(req, "Configuration '%s' points to non-existing "
"path '/%s' at revision '%s'. Configuration skipped." \
% (config.name, config.path, rev))
continue
description = config.description
if description:
description = wiki_to_html(description, self.env, req)
platforms_data = []
for platform in TargetPlatform.select(self.env, config=config.name):
pd = { 'name': platform.name,
'id': platform.id,
'builds_pending': len(list(Build.select(self.env,
config=config.name, status=Build.PENDING,
platform=platform.id))),
'builds_inprogress': len(list(Build.select(self.env,
config=config.name, status=Build.IN_PROGRESS,
platform=platform.id)))
}
platforms_data.append(pd)
config_data = {
'name': config.name, 'label': config.label or config.name,
'active': config.active, 'path': config.path,
'description': description,
'builds_pending' : len(list(Build.select(self.env,
config=config.name,
status=Build.PENDING))),
'builds_inprogress' : len(list(Build.select(self.env,
config=config.name,
status=Build.IN_PROGRESS))),
'href': req.href.build(config.name),
'builds': [],
'platforms': platforms_data
}
configs.append(config_data)
if not config.active:
continue
prev_rev = None
for platform, rev, build in collect_changes(repos, config):
if rev != prev_rev:
if prev_rev is None:
chgset = repos.get_changeset(rev)
config_data['youngest_rev'] = {
'id': rev, 'href': req.href.changeset(rev),
'display_rev': repos.normalize_rev(rev),
'author': chgset.author or 'anonymous',
'date': format_datetime(chgset.date),
'message': wiki_to_oneliner(
shorten_line(chgset.message), self.env, req=req)
}
else:
break
prev_rev = rev
if build:
build_data = _get_build_data(self.env, req, build)
build_data['platform'] = platform.name
config_data['builds'].append(build_data)
else:
config_data['builds'].append({
'platform': platform.name, 'status': 'pending'
})
data['configs'] = sorted(configs, key=lambda x:x['label'].lower())
data['page_mode'] = 'overview'
in_progress_builds = Build.select(self.env, status=Build.IN_PROGRESS)
pending_builds = Build.select(self.env, status=Build.PENDING)
data['builds_pending'] = len(list(pending_builds))
data['builds_inprogress'] = len(list(in_progress_builds))
add_link(req, 'views', req.href.build(view='inprogress'),
'In Progress Builds')
add_ctxtnav(req, 'In Progress Builds',
req.href.build(view='inprogress'))
return data
开发者ID:kroman0,项目名称:bitten,代码行数:97,代码来源:web_ui.py
示例20: get_timeline_events
def get_timeline_events(self, req, start, stop, filters):
if 'ticket' in filters:
format = req.args.get('format')
sql = []
# New tickets
sql.append("SELECT time,id,'','new',type,summary,reporter,summary"
" FROM ticket WHERE time>=%s AND time<=%s")
# Reopened tickets
sql.append("SELECT t1.time,t1.ticket,'','reopened',t.type,"
" t2.newvalue,t1.author,t.summary "
" FROM ticket_change t1"
" LEFT OUTER JOIN ticket_change t2 ON (t1.time=t2.time"
" AND t1.ticket=t2.ticket AND t2.field='comment')"
" LEFT JOIN ticket t on t.id = t1.ticket "
" WHERE t1.field='status' AND t1.newvalue='reopened'"
" AND t1.time>=%s AND t1.time<=%s")
# Closed tickets
sql.append("SELECT t1.time,t1.ticket,t2.newvalue,'closed',t.type,"
" t3.newvalue,t1.author,t.summary"
" FROM ticket_change t1"
" INNER JOIN ticket_change t2 ON t1.ticket=t2.ticket"
" AND t1.time=t2.time"
" LEFT OUTER JOIN ticket_change t3 ON t1.time=t3.time"
" AND t1.ticket=t3.ticket AND t3.field='comment'"
" LEFT JOIN ticket t on t.id = t1.ticket "
" WHERE t1.field='status' AND t1.newvalue='closed'"
" AND t2.field='resolution'"
" AND t1.time>=%s AND t1.time<=%s")
db = self.env.get_db_cnx()
cursor = db.cursor()
cursor.execute(" UNION ALL ".join(sql), (start, stop, start, stop,
start, stop))
kinds = {'new': 'newticket', 'reopened': 'newticket',
'closed': 'closedticket'}
verbs = {'new': 'created', 'reopened': 'reopened',
'closed': 'closed'}
for t, id, resolution, status, type, message, author, summary \
in cursor:
title = util.Markup('Ticket <em title="%s">#%s</em> (%s) %s by '
'%s', summary, id, type, verbs[status],
author)
if format == 'rss':
href = self.env.abs_href.ticket(id)
if status != 'new':
message = wiki_to_html(message or '--', self.env, req,
db)
else:
message = util.escape(message)
else:
href = self.env.href.ticket(id)
if status != 'new':
message = util.Markup(': ').join(filter(None, [
resolution,
wiki_to_oneliner(message, self.env, db,
shorten=True)
]))
else:
message = util.escape(util.shorten_line(message))
yield kinds[status], href, title, t, author, message
开发者ID:lkraav,项目名称:trachacks,代码行数:63,代码来源:web_ui.py
注:本文中的trac.util.shorten_line函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论