本文整理汇总了Python中trac.util.compat.set函数的典型用法代码示例。如果您正苦于以下问题:Python set函数的具体用法?Python set怎么用?Python set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _update_pages
def _update_pages(self):
all_pages = WikiSystem(self.env).get_pages()
self.pages = set([p for p in all_pages if len(p) >= self.minimum_length])
exclude = set([p.strip() for p in (self.exclude or '') if p.strip()])
self.pages.difference_update(exclude)
explicitly_wikified = set([p.strip() for p in (self.explicitly_wikify or '') if p.strip()])
self.pages.update(explicitly_wikified)
开发者ID:lkraav,项目名称:trachacks,代码行数:7,代码来源:autowikify.py
示例2: sort
def sort(self):
"""Do an in-place topological sort of this prototype."""
from api import TracForgeAdminSystem
steps = TracForgeAdminSystem(self.env).get_project_setup_participants()
all_provides = set()
for action, args in self:
all_provides |= set(steps[action].get('provides', ()))
effective_depends = {}
for action, args in self:
# All real deps are always used
effective_depends.setdefault(action, []).extend(steps[action].get('depends', ()))
for tag in steps[action].get('optional_depends', ()):
# Any optional dep that is provided by something else is used
if tag in all_provides:
effective_depends[action].append(tag)
old = set([action for action, args in self])
new = []
tags = set()
for i in xrange(len(self)):
for action in old:
self.env.log.debug('TracForge: %s %s %s %s %s', i, action, old, new, tags)
if all([tag in tags for tag in effective_depends[action]]):
new.append(action)
tags |= set(steps[action].get('provides', []))
old.remove(action)
break
if not old:
break
if old:
raise ValueError('Cant solve')
action_map = dict(self)
self[:] = [(action, action_map[action]) for action in new]
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:35,代码来源:model.py
示例3: __init__
def __init__(self, env, tkt, db=None, ticket_cache=None):
'''Initialize ticket links
Use `ticket_cache` (if is not None) to store fetched tickets.
'''
self.env = env
if not isinstance(tkt, Ticket):
if ticket_cache is not None:
tid = int(tkt)
if tid not in ticket_cache:
ticket_cache[tid] = Ticket(self.env, tid)
tkt = ticket_cache[tid]
else:
tkt = Ticket(self.env, tkt)
self.tkt = tkt
db = db or self.env.get_db_cnx()
cursor = db.cursor()
cursor.execute('SELECT dest FROM mastertickets WHERE source=%s ORDER BY dest', (self.tkt.id,))
self.blocking = set([int(num) for num, in cursor])
self._old_blocking = copy.copy(self.blocking)
cursor.execute('SELECT source FROM mastertickets WHERE dest=%s ORDER BY source', (self.tkt.id,))
self.blocked_by = set([int(num) for num, in cursor])
self._old_blocked_by = copy.copy(self.blocked_by)
开发者ID:lexqt,项目名称:EduTracMasterTickets,代码行数:25,代码来源:model.py
示例4: get_user_permissions
def get_user_permissions(self, username):
"""Retrieve the permissions for the given user and return them in a
dictionary.
The permissions are stored in the database as (username, action)
records. There's simple support for groups by using lowercase names for
the action column: such a record represents a group and not an actual
permission, and declares that the user is part of that group.
"""
subjects = set([username])
for provider in self.group_providers:
subjects.update(provider.get_permission_groups(username))
actions = set([])
db = self.env.get_db_cnx()
cursor = db.cursor()
cursor.execute("SELECT username,action FROM permission")
rows = cursor.fetchall()
while True:
num_users = len(subjects)
num_actions = len(actions)
for user, action in rows:
if user in subjects:
if action.isupper() and action not in actions:
actions.add(action)
if not action.isupper() and action not in subjects:
# action is actually the name of the permission group
# here
subjects.add(action)
if num_users == len(subjects) and num_actions == len(actions):
break
return list(actions)
开发者ID:gdgkyoto,项目名称:kyoto-gtug,代码行数:32,代码来源:perm.py
示例5: ticket_deleted
def ticket_deleted(self, tkt):
db = self.env.get_db_cnx()
links = TicketLinks(self.env, tkt, db)
links.blocking = set()
links.blocked_by = set()
links.save('trac', 'Ticket #%s deleted' % tkt.id, when=None, db=db)
db.commit()
开发者ID:jblomo,项目名称:trac-mastertickets,代码行数:9,代码来源:api.py
示例6: ticket_changed
def ticket_changed(self, tkt, comment, author, old_values):
db = self.env.get_db_cnx()
links = TicketLinks(self.env, tkt, db)
links.blocking = set(self.NUMBERS_RE.findall(tkt['blocking'] or ''))
links.blocked_by = set(self.NUMBERS_RE.findall(tkt['blockedby'] or ''))
links.save(author, comment, tkt.time_changed, db)
db.commit()
开发者ID:dagvl,项目名称:masterticketsplugin,代码行数:9,代码来源:api.py
示例7: testSprintTicketStatsChartUsesAliases
def testSprintTicketStatsChartUsesAliases(self):
self.env.compmgr.enabled[SprintTicketStatsChartGenerator] = True
self.teh.create_ticket(Type.USER_STORY, {Key.SPRINT: self.sprint.name})
get_widget = ChartGenerator(self.env).get_chartwidget
widget = get_widget(ChartType.SPRINT_TICKET_STATS, sprint_name=self.sprint.name)
chart_labels = set([item[1] for item in widget.data["labels"]])
self.assert_equals(set(["User Story", "Task"]), chart_labels)
开发者ID:nagyist,项目名称:agilo,代码行数:9,代码来源:chart_test.py
示例8: post_process_request
def post_process_request(self, req, template, data, content_type):
if req.path_info.startswith('/ticket/'):
# In case of an invalid ticket, the data is invalid
if not data:
return template, data, content_type
tkt = data['ticket']
links = TicketLinks(self.env, tkt)
for i in links.blocked_by:
if Ticket(self.env, i)['status'] != 'closed':
add_script(req, 'mastertickets/disable_resolve.js')
break
# Add link to depgraph if needed
if links:
add_ctxtnav(req, 'Depgraph', req.href.depgraph(tkt.id))
for change in data.get('changes', {}):
if not change.has_key('fields'):
continue
for field, field_data in change['fields'].iteritems():
if field in self.fields:
if field_data['new'].strip():
new = set([int(n) for n in field_data['new'].split(',')])
else:
new = set()
if field_data['old'].strip():
old = set([int(n) for n in field_data['old'].split(',')])
else:
old = set()
add = new - old
sub = old - new
elms = tag()
if add:
elms.append(
tag.em(u', '.join([unicode(n) for n in sorted(add)]))
)
elms.append(u' added')
if add and sub:
elms.append(u'; ')
if sub:
elms.append(
tag.em(u', '.join([unicode(n) for n in sorted(sub)]))
)
elms.append(u' removed')
field_data['rendered'] = elms
#add a link to generate a dependency graph for all the tickets in the milestone
if req.path_info.startswith('/milestone/'):
if not data:
return template, data, content_type
milestone=data['milestone']
add_ctxtnav(req, 'Depgraph', req.href.depgraph('milestone', milestone.name))
return template, data, content_type
开发者ID:pierrejean-coudert,项目名称:trac-mastertickets,代码行数:56,代码来源:web_ui.py
示例9: _field_names_for_backlog_types
def _field_names_for_backlog_types(self):
field_names = set()
ticket_config = AgiloConfig(self.env).ticket_configuration
for type_name in self.ticket_types:
# don't trust the type_name in self.ticket_types, backlog admin page
# does not do validation on that
if type_name not in ticket_config.fieldnames_per_type:
continue
fields_for_this_type = ticket_config.fieldnames_per_type[type_name]
field_names.update(set(fields_for_this_type))
return field_names
开发者ID:djangsters,项目名称:agilo,代码行数:11,代码来源:backlog_config.py
示例10: post_process_request
def post_process_request(self, req, template, origData, content_type):
if req.path_info.startswith('/newticket'):
mode = 'new'
elif req.path_info.startswith('/ticket/'):
mode = 'view'
else:
return template, origData, content_type
fieldData = {}
fieldData['condfields'] = {}
all_fields = []
standard_fields = set()
for f in TicketSystem(self.env).get_ticket_fields():
all_fields.append(f['name'])
if not f.get('custom'):
standard_fields.add(f['name'])
if 'owner' in all_fields:
curr_idx = all_fields.index('owner')
if 'cc' in all_fields:
insert_idx = all_fields.index('cc')
else:
insert_idx = len(all_fields)
if curr_idx < insert_idx:
all_fields.insert(insert_idx, all_fields[curr_idx])
del all_fields[curr_idx]
for t in self.types:
fieldData['condfields'][t] = self.get_fields(t, all_fields, standard_fields)
# fields = set(getattr(self, t+'_fields'))
# if self.include_std:
# fields.update(standard_fields)
# fields.update(self.forced_fields)
# fieldData['condfields'][t] = dict([
# (f, f in fields) for f in all_fields
# ])
self.log.debug(all_fields)
self.log.info(standard_fields)
fieldData['mode'] = mode
fieldData['all_fields'] = list(all_fields)
fieldData['ok_view_fields'] = sorted(set(all_fields) - self.forced_fields,
key=lambda x: all_fields.index(x))
fieldData['ok_new_fields'] = sorted((set(all_fields) - self.forced_fields) - set(['owner']),
key=lambda x: all_fields.index(x))
add_script_data(req, fieldData)
add_script(req, '/condfields.js')
return template, origData, content_type
开发者ID:creswick,项目名称:trac-condfields,代码行数:50,代码来源:web_ui.py
示例11: process_request
def process_request(self, req):
data = {}
ticket_types = {}
field_types = {}
mode = req.path_info[12:-3]
if mode != 'new' and mode != 'view':
raise TracError('Invalid condfields view')
all_fields = []
standard_fields = set()
for f in TicketSystem(self.env).get_ticket_fields():
all_fields.append(f['name'])
field_types[f['name']] = f['type']
if not f.get('custom'):
standard_fields.add(f['name'])
if 'owner' in all_fields:
curr_idx = all_fields.index('owner')
if 'cc' in all_fields:
insert_idx = all_fields.index('cc')
else:
insert_idx = len(all_fields)
if curr_idx < insert_idx:
all_fields.insert(insert_idx, all_fields[curr_idx])
del all_fields[curr_idx]
for t in self.types:
if not self.show_default:
hiddenfields = set(getattr(self, t+'_fields'))
fields = set(all_fields)
fields.difference_update(hiddenfields)
else:
fields = set(getattr(self, t+'_fields'))
if self.include_std:
fields.update(standard_fields)
fields.update(set(self.forced_fields))
ticket_types[t] = dict([
(f, f in fields) for f in all_fields
])
self.log.debug(all_fields)
self.log.info(standard_fields)
data['mode'] = mode
data['types'] = json.dumps(ticket_types)
data['field_types'] = json.dumps(field_types)
data['required_fields'] = json.dumps(list(self.forced_fields))
return 'condfields.js', {'condfields': data}, 'text/plain'
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:50,代码来源:web_ui.py
示例12: _get_metric_groups
def _get_metric_groups(self, available_metrics):
# Some metrics are well known and we show them together in one chart.
# We have the RT_USP ratio separate because of two reasons:
# - it has not much to do with the other charts
# - the numbers are much lower so we would need to add a second scale
# which is not yet implemented in the team metrics chart.
chart_groups = [(Key.ESTIMATED_VELOCITY, Key.VELOCITY),
(Key.CAPACITY, Key.COMMITMENT),
(Key.RT_USP_RATIO, )]
grouped_metrics = []
[grouped_metrics.extend(i) for i in chart_groups]
other_metrics = set(available_metrics).difference(set(grouped_metrics))
other_metrics = [(i,) for i in other_metrics]
return chart_groups + other_metrics
开发者ID:djangsters,项目名称:agilo,代码行数:14,代码来源:web_ui.py
示例13: post_process_request
def post_process_request(self, req, template, data, content_type):
if req.path_info.startswith('/ticket/'):
tkt = data['ticket']
links = TicketLinks(self.env, tkt)
for i in links.blocked_by:
if Ticket(self.env, i)['status'] != 'closed':
add_script(req, 'mastertickets/disable_resolve.js')
break
data['mastertickets'] = {
'field_values': {
'blocking': linkify_ids(self.env, req, links.blocking),
'blockedby': linkify_ids(self.env, req, links.blocked_by),
},
}
# Add link to depgraph if needed
if links:
add_ctxtnav(req, 'Depgraph', req.href.depgraph(tkt.id))
for change in data.get('changes', []):
for field, field_data in change['fields'].iteritems():
if field in self.fields:
if field_data['new'].strip():
new = set([int(n) for n in field_data['new'].split(',')])
else:
new = set()
if field_data['old'].strip():
old = set([int(n) for n in field_data['old'].split(',')])
else:
old = set()
add = new - old
sub = old - new
elms = tag()
if add:
elms.append(
tag.em(u', '.join([unicode(n) for n in sorted(add)]))
)
elms.append(u' added')
if add and sub:
elms.append(u'; ')
if sub:
elms.append(
tag.em(u', '.join([unicode(n) for n in sorted(sub)]))
)
elms.append(u' removed')
field_data['rendered'] = elms
return template, data, content_type
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:50,代码来源:web_ui.py
示例14: ticket_changed
def ticket_changed(self, tkt, comment, author, old_values):
db = self.env.get_db_cnx()
links = TicketLinks(self.env, tkt, db)
old_relations = {'blocking': set([]), 'blockedby': set([])}
if "blocking" in old_values:
old_relations['blocking'] = extract_ticket_ids(old_values['blocking'])
if "blockedby" in old_values:
old_relations['blockedby'] = extract_ticket_ids(old_values['blockedby'])
links.save(old_relations, author, comment, tkt.time_changed, db)
db.commit()
开发者ID:mmariani,项目名称:TracTicketRelations,代码行数:15,代码来源:api.py
示例15: ticket_deleted
def ticket_deleted(self, tkt):
with self.env.db_transaction as db:
links = CrashDumpTicketLinks(self.env, tkt, db)
links.crashes = set()
links.save('trac', 'Ticket #%s deleted'%tkt.id, when=None, db=db)
db.commit()
开发者ID:aroth-arsoft,项目名称:trac-crashdump,代码行数:7,代码来源:api.py
示例16: get_months_authors_categories
def get_months_authors_categories(self, from_dt=None, to_dt=None,
user=None, perm=None):
""" Returns a structure of post metadata:
([ ((year1, month1), count), ((year1, month2), count) ], # newest first
[ (author1, count), (author2, count) ], # alphabetical
[ (category1, count), (category2, count) ], # alphabetical
total) # num of posts
* Use 'from_dt' and 'to_dt' (datetime objects) to restrict search to
posts with a publish_time within the intervals (None means ignore).
* If user and perm is provided, the list is also filtered for permissions.
* Note also that it only fetches from most recent version. """
blog_posts = get_blog_posts(self.env, from_dt=from_dt, to_dt=to_dt)
a_dict = {}
c_dict = {}
m_dict = {}
total = 0
for post in blog_posts:
if user and perm:
# Check permissions
bp = BlogPost(self.env, post[0], post[1])
if not 'BLOG_VIEW' in perm(bp.resource):
continue # Skip this post
post_time = post[2]
m_dict[(post_time.year, post_time.month)] = m_dict.get(
(post_time.year, post_time.month), 0) + 1
author = post[3]
a_dict[author] = a_dict.get(author, 0) + 1
categories = post[6] # a list
for category in set(categories):
c_dict[category] = c_dict.get(category, 0) + 1
total += 1
return ([(m, m_dict.get(m, 0)) for m in sorted(m_dict.keys(), reverse=True)],
[(a, a_dict.get(a, 0)) for a in sorted(a_dict.keys())],
[(c, c_dict.get(c, 0)) for c in sorted(c_dict.keys())],
total)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:35,代码来源:core.py
示例17: get_all_status
def get_all_status(self):
"""Returns a sorted list of all the states all of the action
controllers know about."""
valid_states = set()
for controller in self.action_controllers:
valid_states.update(controller.get_all_status())
return sorted(valid_states)
开发者ID:twisted-infra,项目名称:twisted-trac-source,代码行数:7,代码来源:api.py
示例18: _all_configured_ticket_fields
def _all_configured_ticket_fields(self):
field_names = set()
ticket_config = AgiloConfig(self.env).ticket_configuration
for field_names_for_type in ticket_config.fieldnames_per_type.values():
for field_name in field_names_for_type:
field_names.add(field_name)
return list(field_names)
开发者ID:djangsters,项目名称:agilo,代码行数:7,代码来源:backlog_config.py
示例19: get_tagged_resources
def get_tagged_resources(self, req, tags):
if not self.check_permission(req.perm, "view"):
return
db = self.env.get_db_cnx()
cursor = db.cursor()
args = [self.realm]
sql = "SELECT DISTINCT name FROM tags WHERE tagspace=%s"
if tags:
sql += " AND tags.tag IN (%s)" % ", ".join(["%s" for t in tags])
args += tags
sql += " ORDER by name"
cursor.execute(sql, args)
resources = {}
for (name,) in cursor:
resource = Resource(self.realm, name)
if self.check_permission(req.perm(resource), "view"):
resources[resource.id] = resource
if not resources:
return
args = [self.realm] + list(resources)
# XXX Is this going to be excruciatingly slow?
sql = "SELECT DISTINCT name, tag FROM tags WHERE tagspace=%%s AND " "name IN (%s) ORDER BY name" % ", ".join(
["%s" for _ in resources]
)
cursor.execute(sql, args)
for name, tags in groupby(cursor, lambda row: row[0]):
resource = resources[name]
yield resource, set([tag[1] for tag in tags])
开发者ID:okamototk,项目名称:kanonconductor,代码行数:32,代码来源:api.py
示例20: validate_blog_post
def validate_blog_post(self, req, postname, version, fields):
if 'blog-preview' in req.args:
return []
blog_res = Resource('blog', postname, version)
if req.perm(blog_res).has_permission('BLOG_ADMIN'):
return []
if version > 1:
bp = BlogPost(self.env, postname, version)
last_post_fields = bp._fetch_fields(version=version-1)
else:
last_post_fields = {}
field_names = set(fields).union(last_post_fields)
changes = []
for field in field_names:
old = to_unicode(last_post_fields.get(field, ''))
new = to_unicode(fields.get(field, ''))
if new and old != new:
changes.append((old, new))
author = fields.get('author', '')
if arity(FilterSystem.test) == 4:
# 0.11 compatible method signature
FilterSystem(self.env).test(req, author, changes)
else:
# 0.12+ compatible that adds an 'ip' argument
FilterSystem(self.env).test(req, author, changes, req.remote_addr)
return []
开发者ID:kzhamaji,项目名称:TracFullBlogPlugin,代码行数:29,代码来源:spamfilter.py
注:本文中的trac.util.compat.set函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论