rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
if milestones[0] == '---': trac.setMilestoneList(milestones, 'value') else: trac.setMilestoneList([], '') print print '6. retrieving bugs...' sql = "SELECT * FROM bugs " if PRODUCTS: sql += " WHERE %s" % productFilter('product', PRODUCTS) sql += " ORDER BY bug_id"
trac.setMilestoneList(milestones, 'value') print "\n6. Retrieving bugs..." sql = """SELECT DISTINCT b.*, c.name AS component, p.name AS product FROM bugs AS b, components AS c, products AS p """ sql += " WHERE (" + makeWhereClause('p.name', PRODUCTS) sql += ") AND b.product_id = p.id" sql += " AND b.component_id = c.i...
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
print print "7. import bugs and bug activity..."
print "\n7. Import bugs and bug activity..."
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
ticket['component'] = bug['component']
if COMPONENTS_FROM_PRODUCTS: ticket['component'] = bug['product'] else: ticket['component'] = bug['component']
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
ticket['priority'] = bug['priority']
ticket['priority'] = bug['priority'].lower()
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
mysql_cur.execute("SELECT * FROM cc WHERE bug_id = %s" % bugid)
mysql_cur.execute("SELECT * FROM cc WHERE bug_id = %s", bugid)
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
if bug['target_milestone'] == '---': ticket['milestone'] = '' else: ticket['milestone'] = bug['target_milestone']
target_milestone = bug['target_milestone'] if target_milestone in IGNORE_MILESTONES: target_milestone = '' ticket['milestone'] = target_milestone
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
keywords = string.split(bug['keywords'], ' ')
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
value=desc['thetext']) mysql_cur.execute("SELECT * FROM bugs_activity WHERE bug_id = %s ORDER BY bug_when" % bugid)
value = desc['thetext']) mysql_cur.execute("""SELECT * FROM bugs_activity WHERE bug_id = %s ORDER BY bug_when""" % bugid)
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
if field_name == 'resolution' or field_name == 'bug_status':
if field_name == "resolution" or field_name == "bug_status":
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
if field_name == 'resolution':
if field_name == "resolution":
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
keywordChange = False oldKeywords = string.join(keywords, " ")
add_keywords = [] remove_keywords = []
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
if field_name == 'bug_severity': field_name = 'severity' elif field_name == 'assigned_to': field_name = 'owner' elif field_name == 'bug_status': field_name = 'status'
if field_name == "bug_severity": field_name = "severity" elif field_name == "assigned_to": field_name = "owner" elif field_name == "bug_status": field_name = "status"
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
kw = STATUS_KEYWORDS[removed] if kw in keywords: keywords.remove(kw) else: oldKeywords = string.join(keywords + [ kw ], " ") keywordChange = True
remove_keywords.append(STATUS_KEYWORDS[removed])
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
kw = STATUS_KEYWORDS[added] keywords.append(kw) keywordChange = True
add_keywords.append(STATUS_KEYWORDS[added])
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
elif field_name == 'short_desc': field_name = 'summary' elif field_name == 'product': if removed in PRODUCT_KEYWORDS: kw = PRODUCT_KEYWORDS[removed] if kw in keywords: keywords.remove(kw) else: oldKeywords = string.join(keywords + [ kw ], " ") keywordChange = True if added in PRODUCT_KEYWORDS: kw = PRODUCT_KEYWORDS[add...
elif field_name == "short_desc": field_name = "summary" elif field_name == "product" and COMPONENTS_FROM_PRODUCTS: field_name = "component" elif ((field_name == "product" and not COMPONENTS_FROM_PRODUCTS) or (field_name == "component" and COMPONENTS_FROM_PRODUCTS)): if MAP_ALL_KEYWORDS or removed in KEYWORDS_MAPPING: k...
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
if keywordChange: newKeywords = string.join(keywords, " ") ticketChangeKw = ticketChange ticketChangeKw['field'] = 'keywords' ticketChangeKw['oldvalue'] = oldKeywords ticketChangeKw['newvalue'] = newKeywords ticketChanges.append(ticketChangeKw)
if add_keywords or remove_keywords: old_keywords = keywords + [kw for kw in remove_keywords if kw not in keywords] keywords = [kw for kw in keywords if kw not in remove_keywords] keywords += [kw for kw in add_keywords if kw not in keywords] if old_keywords != keywords: ticketChangeKw = ticketChange.copy() ticketChan...
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
if (field_name == 'summary'
if (field_name == "summary"
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
if not ticket['resolution'] and ticket['status'] == 'closed':
if not ticket['resolution'] and ticket['status'] == "closed":
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
if bug['bug_status'] in STATUS_KEYWORDS: kw = STATUS_KEYWORDS[bug['bug_status']]
bug_status = bug['bug_status'] if bug_status in STATUS_KEYWORDS: kw = STATUS_KEYWORDS[bug_status]
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
if bug['product'] in PRODUCT_KEYWORDS: kw = PRODUCT_KEYWORDS[bug['product']] if kw not in keywords:
product = bug['product'] if product in KEYWORDS_MAPPING and not COMPONENTS_FROM_PRODUCTS: kw = KEYWORDS_MAPPING.get(product, product) if kw and kw not in keywords:
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
tracAttachment = Attachment(a['filename'], a['thedata']) trac.addAttachment(bugid, tracAttachment, a['description'], author) ticket['keywords'] = string.join(keywords) ticketid = trac.addTicket(**ticket) print "Success!"
print "\n8. Importing users and passwords..." if BZ_VERSION >= 2180: mysql_cur.execute("SELECT login_name, cryptpassword FROM profiles") users = mysql_cur.fetchall() htpasswd = file("htpasswd", 'w') for user in users: if LOGIN_MAP.has_key(user['login_name']): login = LOGIN_MAP[user['login_name']] else: login = user['lo...
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
print "bugzilla2trac - Imports a bug database from Bugzilla into Trac." print print "Usage: bugzilla2trac.py [options]" print print "Available Options:" print " --db <MySQL dbname> - Bugzilla's database" print " --tracenv /path/to/trac/env - full path to Trac db environment" print " -h | --host <My...
print """bugzilla2trac - Imports a bug database from Bugzilla into Trac. Usage: bugzilla2trac.py [options] Available Options: --db <MySQL dbname> - Bugzilla's database name --tracenv /path/to/trac/env - Full path to Trac db environment -h | --host <MySQL hostname> - Bugzilla's DNS host name -u |...
def usage(): print "bugzilla2trac - Imports a bug database from Bugzilla into Trac." print print "Usage: bugzilla2trac.py [options]" print print "Available Options:" print " --db <MySQL dbname> - Bugzilla's database" print " --tracenv /path/to/trac/env - full path to Trac db environment" print " -h...
if sys.argv[1] in ['--help','help'] or len(sys.argv) < 4: usage() iter = 1 while iter < len(sys.argv): if sys.argv[iter] in ['--db'] and iter+1 < len(sys.argv): BZ_DB = sys.argv[iter+1] iter = iter + 1 elif sys.argv[iter] in ['-h', '--host'] and iter+1 < len(sys.argv): BZ_HOST = sys.argv[iter+1] iter = iter + 1 elif sy...
if sys.argv[1] in ['--help','help'] or len(sys.argv) < 4: usage() iter = 1 while iter < len(sys.argv): if sys.argv[iter] in ['--db'] and iter+1 < len(sys.argv): BZ_DB = sys.argv[iter+1] iter = iter + 1 elif sys.argv[iter] in ['-h', '--host'] and iter+1 < len(sys.argv): BZ_HOST = sys.argv[iter+1] iter = iter + 1 elif sy...
def main(): global BZ_DB, BZ_HOST, BZ_USER, BZ_PASSWORD, TRAC_ENV, TRAC_CLEAN if len (sys.argv) > 1: if sys.argv[1] in ['--help','help'] or len(sys.argv) < 4: usage() iter = 1 while iter < len(sys.argv): if sys.argv[iter] in ['--db'] and iter+1 < len(sys.argv): BZ_DB = sys.argv[iter+1] iter = iter + 1 elif sys.argv[ite...
def __init__(self, application, auths):
def __init__(self, application, auths, single_env_name=None):
def __init__(self, application, auths): self.application = application self.auths = auths
if len(path_parts) > 1 and path_parts[1] == 'login': env_name = path_parts[0]
if len(path_parts) > self.part and path_parts[self.part] == 'login': env_name = self.single_env_name or path_parts[0]
def __call__(self, environ, start_response): path_info = environ.get('PATH_INFO', '') path_parts = filter(None, path_info.split('/')) if len(path_parts) > 1 and path_parts[1] == 'login': env_name = path_parts[0] if env_name: auth = self.auths.get(env_name, self.auths.get('*')) if auth: remote_user = auth.do_auth(enviro...
def __init__(self, application, env_parent_dir, env_paths):
def __init__(self, application, env_parent_dir, env_paths, single_env):
def __init__(self, application, env_parent_dir, env_paths): self.application = application self.environ = {} self.environ['trac.env_path'] = None if env_parent_dir: self.environ['trac.env_parent_dir'] = env_parent_dir else: self.environ['trac.env_paths'] = env_paths
options.env_parent_dir, args)
options.env_parent_dir, args, options.single_env)
def _validate_callback(option, opt_str, value, parser, valid_values): if value not in valid_values: raise OptionValueError('%s must be one of: %s, not %s' % (opt_str, '|'.join(valid_values), value)) setattr(parser.values, option.dest, value)
wsgi_app = AuthenticationMiddleware(wsgi_app, auths)
if options.single_env: project_name = os.path.basename(os.path.normpath(args[0])) wsgi_app = AuthenticationMiddleware(wsgi_app, auths, project_name) else: wsgi_app = AuthenticationMiddleware(wsgi_app, auths)
def _validate_callback(option, opt_str, value, parser, valid_values): if value not in valid_values: raise OptionValueError('%s must be one of: %s, not %s' % (opt_str, '|'.join(valid_values), value)) setattr(parser.values, option.dest, value)
cols.remove(col)
if col in cols: cols.remove(col)
def get_columns(self): if self.cols: return self.cols
odata = ''.join(np.out.splitlines()[1:-1])
odata = ''.join(np.out.splitlines()[1:-2])
def render(self, req, mimetype, content, filename=None, rev=None): cmdline = self.config.get('mimeviewer', 'php_path') # -n to ignore php.ini so we're using default colors cmdline += ' -sn' self.env.log.debug("PHP command line: %s" % cmdline) content = content_to_unicode(self.env, content, mimetype) content = content....
if not old_path or not new_path:
if not self.prefix or not (old_path and new_path):
def apply_textdelta(self, file_baton, base_checksum): old_path, new_path, pool = file_baton if not old_path or not new_path: return old_root = self._old_root(new_path, pool) if not old_root: return
resp = chosen_handler.process_request(req) if resp: chrome = Chrome(self.env) if len(resp) == 2: chrome.populate_hdf(req) template, content_type = \ self._post_process_request(req, *resp) req.display(template, content_type or 'text/html') else: template, data, content_type = resp output = chrome.render_template(req, te...
self._post_process_request(req) except Exception, e: self.log.exception(e) raise err[0], err[1], err[2] except PermissionError, e: raise HTTPForbidden(to_unicode(e)) except TracError, e: raise HTTPInternalError(e.message)
def dispatch(self, req): """Find a registered handler that matches the request and let it process it. In addition, this method initializes the HDF data set and adds the web site chrome. """ self.env.href = req.href # FIXME: remove later in 0.11 self.env.abs_href = Href(self.env.base_url)
req.args['path'] = match.group(2)
req.args['path'] = match.group(2).replace(':', '/')
def match_request(self, req): match = re.match(r'^/attachment/(ticket|wiki)(?:/(.*))?$', req.path_info) if match: req.args['type'] = match.group(1) req.args['path'] = match.group(2) return 1
VALUES('header_logo', 'width', '500'); INSERT INTO config (section, name, value) VALUES('header_logo', 'height', '70');
VALUES('header_logo', 'width', '199'); INSERT INTO config (section, name, value) VALUES('header_logo', 'height', '38');
def insert_default_values (cursor): cursor.execute ("""
req.hdf = HDFWrapper(loadpaths=[default_dir('templates'), tmpl_path])
req.hdf = HDFWrapper(loadpaths=[tmpl_path, default_dir('templates')])
def send_project_index(req, options, env_paths=None): from trac.web.clearsilver import HDFWrapper if 'TRAC_ENV_INDEX_TEMPLATE' in options: tmpl_path, template = os.path.split(options['TRAC_ENV_INDEX_TEMPLATE']) from trac.config import default_dir req.hdf = HDFWrapper(loadpaths=[default_dir('templates'), tmpl_path]) ...
order = getattr(self, category + '_order') def navcmp(x, y): if x[0] not in order: return int(y[0] in order) if y[0] not in order: return -int(x[0] in order) return cmp(order.index(x[0]), order.index(y[0])) items.sort(navcmp)
category_order = category + '_order' if hasattr(self, category_order): order = getattr(self, category_order) def navcmp(x, y): if x[0] not in order: return int(y[0] in order) if y[0] not in order: return -int(x[0] in order) return cmp(order.index(x[0]), order.index(y[0])) items.sort(navcmp)
def populate_hdf(self, req, handler): """Add chrome-related data to the HDF."""
this_summary = summary if (time,id,author) != previous_update:
if (time,id,author,summary) != previous_update:
def get_timeline_events(self, req, start, stop, filters): if 'ticket_details' in filters: db = self.env.get_db_cnx() cursor = db.cursor() cursor.execute("SELECT tc.time,tc.ticket,tc.field, " " tc.oldvalue,tc.newvalue,tc.author,t.summary " "FROM ticket_change tc" " LEFT JOIN ticket t ON t.id = tc.ticket " "AND t...
updates.append((previous_update,field_changes,comment, this_summary))
updates.append((previous_update,field_changes,comment))
def get_timeline_events(self, req, start, stop, filters): if 'ticket_details' in filters: db = self.env.get_db_cnx() cursor = db.cursor() cursor.execute("SELECT tc.time,tc.ticket,tc.field, " " tc.oldvalue,tc.newvalue,tc.author,t.summary " "FROM ticket_change tc" " LEFT JOIN ticket t ON t.id = tc.ticket " "AND t...
previous_update = (time,id,author)
previous_update = (time,id,author,summary)
def get_timeline_events(self, req, start, stop, filters): if 'ticket_details' in filters: db = self.env.get_db_cnx() cursor = db.cursor() cursor.execute("SELECT tc.time,tc.ticket,tc.field, " " tc.oldvalue,tc.newvalue,tc.author,t.summary " "FROM ticket_change tc" " LEFT JOIN ticket t ON t.id = tc.ticket " "AND t...
for (t,id,author),field_changes,comment,summary in updates:
for (t,id,author,summary),field_changes,comment in updates:
def get_timeline_events(self, req, start, stop, filters): if 'ticket_details' in filters: db = self.env.get_db_cnx() cursor = db.cursor() cursor.execute("SELECT tc.time,tc.ticket,tc.field, " " tc.oldvalue,tc.newvalue,tc.author,t.summary " "FROM ticket_change tc" " LEFT JOIN ticket t ON t.id = tc.ticket " "AND t...
self.setup_log()
if sys.platform == "win32": import msvcrt msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) self.setup_log()
def __init__(self, path, create=0): self.path = path if create: self.create() self.verify() self.load_config() self.setup_log()
self.in_list_item = 0
self.in_list_item = False
def format(self, text, out, escape_newlines=False): self.out = out self._open_tags = [] self._list_stack = []
if len(result) and not self.in_list_item and not self.in_table:
if len(result) and not self.in_list_item and not self.in_def_list \ and not self.in_table:
def format(self, text, out, escape_newlines=False): self.out = out self._open_tags = [] self._list_stack = []
open(infile, 'w').write(input) infile.close()
tmp = open(infile, 'w') tmp.write(input) tmp.close()
def __init__(self, command, input=None, capturestderr=None): outfile = tempfile.mktemp() command = '( %s ) > %s' % (command, outfile) if input: infile = tempfile.mktemp() open(infile, 'w').write(input) infile.close() command = command + ' <' + infile if capturestderr: errfile = tempfile.mktemp() command = command + ' 2...
likes = [r"%s %s %%s ESCAPE '_'" % (i, db.like()) for i in columns]
likes = [r"%s %s %%s ESCAPE '/'" % (i, db.like()) for i in columns]
def search_to_sql(db, columns, terms): """ Convert a search query into a SQL condition string and corresponding parameters. The result is returned as a (string, params) tuple. """ if len(columns) < 1 or len(terms) < 1: raise TracError('Empty search attempt, this should really not happen.') likes = [r"%s %s %%s ESCAPE ...
escape_re = re.compile(r'([_%])')
escape_re = re.compile(r'([/_%])')
def search_to_sql(db, columns, terms): """ Convert a search query into a SQL condition string and corresponding parameters. The result is returned as a (string, params) tuple. """ if len(columns) < 1 or len(terms) < 1: raise TracError('Empty search attempt, this should really not happen.') likes = [r"%s %s %%s ESCAPE ...
t = escape_re.sub(r'_\1', t)
t = escape_re.sub(r'/\1', t)
def search_to_sql(db, columns, terms): """ Convert a search query into a SQL condition string and corresponding parameters. The result is returned as a (string, params) tuple. """ if len(columns) < 1 or len(terms) < 1: raise TracError('Empty search attempt, this should really not happen.') likes = [r"%s %s %%s ESCAPE ...
max_preview_size = self.max_preview_size() if len(content) >= max_preview_size: return {'max_file_size_reached': True, 'max_file_size': max_preview_size, 'preview': ''} else: return {'preview': self.render(req, mimetype, content, filename, detail, annotations)}
return {'preview': self.render(req, mimetype, content, filename, detail, annotations)}
def preview_to_hdf(self, req, mimetype, charset, content, filename, detail=None, annotations=None): if not is_binary(content): content = to_utf8(content, charset or self.preview_charset(content)) max_preview_size = self.max_preview_size() if len(content) >= max_preview_size: return {'max_file_size_reached': True, 'max_...
idx = 0
changes = []
def insert_ticket_data(self, req, id, ticket, reporter_id): """Insert ticket data into the hdf""" evals = util.mydict(zip(ticket.keys(), map(lambda x: util.escape(x), ticket.values()))) util.add_to_hdf(evals, req.hdf, 'ticket')
req.hdf.setValue('ticket.changes.%d.date' % idx, time.strftime('%c', time.localtime(date))) req.hdf.setValue('ticket.changes.%d.time' % idx, str(date)) req.hdf.setValue('ticket.changes.%d.author' % idx, util.escape(author)) req.hdf.setValue('ticket.changes.%d.field' % idx, field) req.hdf.setValue('ticket.changes.%d.old...
if date != curr_date or author != curr_author: changes.append({ 'date': time.strftime('%c', time.localtime(date)), 'author': util.escape(author), 'fields': {} }) curr_date = date curr_author = author
def insert_ticket_data(self, req, id, ticket, reporter_id): """Insert ticket data into the hdf""" evals = util.mydict(zip(ticket.keys(), map(lambda x: util.escape(x), ticket.values()))) util.add_to_hdf(evals, req.hdf, 'ticket')
req.hdf.setValue('ticket.changes.%d.new' % idx, wiki_to_html(new, req.hdf, self.env, self.db))
changes[-1]['comment'] = wiki_to_html(new, req.hdf, self.env, self.db) elif field == 'description': changes[-1]['fields'][field] = {}
def insert_ticket_data(self, req, id, ticket, reporter_id): """Insert ticket data into the hdf""" evals = util.mydict(zip(ticket.keys(), map(lambda x: util.escape(x), ticket.values()))) util.add_to_hdf(evals, req.hdf, 'ticket')
req.hdf.setValue('ticket.changes.%d.new' % idx, util.escape(new)) idx = idx + 1
changes[-1]['fields'][field] = {'old': old, 'new': new} util.add_to_hdf(changes, req.hdf, 'ticket.changes')
def insert_ticket_data(self, req, id, ticket, reporter_id): """Insert ticket data into the hdf""" evals = util.mydict(zip(ticket.keys(), map(lambda x: util.escape(x), ticket.values()))) util.add_to_hdf(evals, req.hdf, 'ticket')
'report': {'id': id, 'title': title, 'description': wiki_to_html(description, self.env, req, db, absurls=(format == 'rss')), 'can': perms, 'args': args}}
'report': {'id': id, 'title': title, 'description': description, 'can': perms, 'args': args}}
def _render_view(self, req, db, id): """ uses a user specified sql query to extract some information from the database and presents it as a html table. """ actions = {'create': 'REPORT_CREATE', 'delete': 'REPORT_DELETE', 'modify': 'REPORT_MODIFY'} perms = {} for action in [k for k,v in actions.items() if v in req.perm]...
if col == 'description': cell['parsed'] = wiki_to_html(value, self.env, req, db, absurls=(format == 'rss')) elif col == 'reporter':
if col == 'reporter':
def sortkey(row): val = row[idx] if isinstance(val, basestring): val = val.lower() return val
if '.' in key: prefix, attribute = key.split('.', 1)
idx = key.rfind('.') if idx > 0: prefix, attribute = key[:idx], key[idx+1:]
def render_macro(self, req, name, content): intertracs = {} for key, value in self.config.options('intertrac'): if '.' in key: prefix, attribute = key.split('.', 1) intertrac = intertracs.setdefault(prefix, {}) intertrac[attribute] = value else: intertracs[key] = value # alias
message = wiki_to_html(description or '--', self.env, db, absurls=True)
message = wiki_to_html(description or '--', self.env, req, db, absurls=True)
def get_timeline_events(self, req, start, stop, filters): if 'milestone' in filters: format = req.args.get('format') db = self.env.get_db_cnx() cursor = db.cursor() cursor.execute("SELECT completed,name,description FROM milestone " "WHERE completed>=%s AND completed<=%s", (start, stop,)) for completed,name,description ...
if not fs.has_key(name):
if value and not fs.has_key(name):
def set_if_missing(fs, name, value): if not fs.has_key(name): fs.list.append(cgi.MiniFieldStorage(name, value))
cursor.execute("UPDATE ticket_custom SET value=%s", (self[name],))
cursor.execute("UPDATE ticket_custom SET value=%s " "WHERE ticket=%s AND name=%s", (self[name], id, fname))
def save_changes(self, db, author, comment, when = 0): """Store ticket changes in the database. The ticket must already exist in the database.""" assert self.has_key('id') cursor = db.cursor() if not when: when = int(time.time()) id = self['id']
self.req.check_modified(self.last_modified)
self.req.check_modified(stat[8])
def render(self): FileCommon.render(self) self.view_form = 0 self.attachment_type = self.args.get('type', None) self.attachment_id = self.args.get('id', None) self.filename = self.args.get('filename', None) if self.filename: self.filename = os.path.basename(self.filename)
tabwidth = self.config['diff'].getint('tab_width', self.config['mimeviewer'].getint('tab_width'))
tabwidth = self.config['diff'].getint('tab_width') or \ self.config['mimeviewer'].getint('tab_width', 8)
def _content_changes(old_node, new_node): """Returns the list of differences.
text = unicode(text)
if not isinstance(text, basestring): text = unicode(text) elif not isinstance(text, unicode): text = text.decode('utf-8')
def escape(cls, text, quotes=True): """Create a Markup instance from a string and escape special characters it may contain (<, >, & and "). If the `quotes` parameter is set to `False`, the " character is left as is. Escaping quotes is generally only required for strings that are to be used in attribute values. """ if ...
heading = match[depth+1:-depth-1-len(anchor)] heading = wiki_to_oneliner(heading, self.env, self.db, shorten,
heading_text = match[depth+1:-depth-1-len(anchor)] heading = wiki_to_oneliner(heading_text, self.env, self.db, False,
def _parse_heading(self, match, fullmatch, shorten): match = match.strip()
log_mode = req.args.get('log_mode', 'stop_on_copy') full_messages = req.args.get('full_messages', '') limit = int(req.args.get('limit') or self.config.get('log', 'limit', '100')) repos = self.env.get_repository(req.authname) normpath = repos.normalize_path(path) rev = str(repos.normalize_rev(rev))
verbose = req.args.get('verbose') limit = int(req.args.get('limit') or 100)
def process_request(self, req): req.perm.assert_permission(perm.LOG_VIEW)
req.hdf['log.path'] = path req.hdf['log.rev'] = rev req.hdf['log.limit'] = limit req.hdf['log.mode'] = log_mode req.hdf['log.full_messages'] = full_messages if stop_rev: req.hdf['log.stop_rev'] = stop_rev req.hdf['log.browser_href'] = self.env.href.browser(path, rev=rev) req.hdf['log.log_href'] = self.env.href.log(path...
req.hdf['log'] = { 'path': path, 'rev': rev, 'mode': mode, 'verbose': verbose, 'stop_rev': stop_rev, 'browser_href': self.env.href.browser(path, rev=rev), 'log_href': self.env.href.log(path, rev=rev) }
def process_request(self, req): req.perm.assert_permission(perm.LOG_VIEW)
if log_mode != 'path_history':
if mode != 'path_history':
def process_request(self, req): req.perm.assert_permission(perm.LOG_VIEW)
except util.TracError:
except TracError:
def process_request(self, req): req.perm.assert_permission(perm.LOG_VIEW)
log_mode = 'path_history'
mode = 'path_history'
def process_request(self, req): req.perm.assert_permission(perm.LOG_VIEW)
if log_mode == 'path_history':
if mode == 'path_history':
def process_request(self, req): req.perm.assert_permission(perm.LOG_VIEW)
if not (log_mode == 'path_history' and old_chg == Changeset.EDIT):
if not (mode == 'path_history' and old_chg == Changeset.EDIT):
def history(limit): for h in repos.get_path_history(path, rev, limit): yield h
and not (log_mode == 'path_history' and old_path == normpath):
and not (mode == 'path_history' and old_path == normpath):
def history(limit): for h in repos.get_path_history(path, rev, limit): yield h
if log_mode == 'stop_on_copy':
if mode == 'stop_on_copy':
def history(limit): for h in repos.get_path_history(path, rev, limit): yield h
raise util.TracError("The file or directory '%s' doesn't exist " "at revision %s or at any previous revision." % (path, rev), 'Nonexistent path')
raise TracError("The file or directory '%s' doesn't exist " "at revision %s or at any previous revision." % (path, rev), 'Nonexistent path')
def history(limit): for h in repos.get_path_history(path, rev, limit): yield h
params = { 'rev': rev, 'log_mode': log_mode, 'limit': limit, }
params = {'rev': rev, 'mode': mode, 'limit': limit}
def make_log_href(path, **args): params = { 'rev': rev, 'log_mode': log_mode, 'limit': limit, } params.update(args) if full_messages: params['full_messages'] = full_messages return self.env.href.log(path, **params)
if full_messages: params['full_messages'] = full_messages
if verbose: params['verbose'] = verbose
def make_log_href(path, **args): params = { 'rev': rev, 'log_mode': log_mode, 'limit': limit, } params.update(args) if full_messages: params['full_messages'] = full_messages return self.env.href.log(path, **params)
full_messages, req, format)
verbose, req, format)
def make_log_href(path, **args): params = { 'rev': rev, 'log_mode': log_mode, 'limit': limit, } params.update(args) if full_messages: params['full_messages'] = full_messages return self.env.href.log(path, **params)
return 'log_changelog.cs', 'application/rss+xml'
return 'log_changelog.cs', 'text/plain'
def make_log_href(path, **args): params = { 'rev': rev, 'log_mode': log_mode, 'limit': limit, } params.update(args) if full_messages: params['full_messages'] = full_messages return self.env.href.log(path, **params)
if os.path.dirname(egg_path) == os.path.realpath(plugins_dir):
if paths_equal(os.path.dirname(egg_path), os.path.realpath(plugins_dir)):
def enable_modules(egg_path, modules): """Automatically enable any components provided by plugins loaded from the environment plugins directory.""" if os.path.dirname(egg_path) == os.path.realpath(plugins_dir): for module in modules: env.config.setdefault('components', module + '.*', 'enabled')
def add_options(field, constraints, prefix, options):
def add_options(field, constraints, prefix, cursor, sql): options = []
def add_options(field, constraints, prefix, options): check = constraints.has_key(field) for option in options: if check and (option['name'] in constraints[field]): option['selected'] = 1 util.add_to_hdf(options, self.req.hdf, prefix + field) if check: del constraints[field]
for option in options: if check and (option['name'] in constraints[field]):
cursor.execute(sql) while 1: row = cursor.fetchone() if not row: break option = {'name': row[0]} if check and (row[0] in constraints[field]):
def add_options(field, constraints, prefix, options): check = constraints.has_key(field) for option in options: if check and (option['name'] in constraints[field]): option['selected'] = 1 util.add_to_hdf(options, self.req.hdf, prefix + field) if check: del constraints[field]
def add_db_options(field, constraints, prefix, cursor, sql): cursor.execute(sql) options = [] while 1: row = cursor.fetchone() if not row: break if row[0]: options.append({'name': row[0]}) add_options(field, constraints, prefix, options) add_options('status', constraints, 'query.options.', [{'name': 'new'}, {'name': '...
def add_db_options(field, constraints, prefix, cursor, sql): cursor.execute(sql) options = [] while 1: row = cursor.fetchone() if not row: break if row[0]: options.append({'name': row[0]}) add_options(field, constraints, prefix, options)
add_db_options('component', constraints, 'query.options.', cursor, 'SELECT name FROM component ORDER BY name', ) add_db_options('milestone', constraints, 'query.options.', cursor, 'SELECT name FROM milestone ORDER BY name') add_db_options('version', constraints, 'query.options.', cursor, 'SELECT name FROM version ORDER...
add_options('status', constraints, 'query.options.', cursor, "SELECT name FROM enum WHERE type='status'") add_options('resolution', constraints, 'query.options.', cursor, "SELECT name FROM enum WHERE type='resolution'") add_options('component', constraints, 'query.options.', cursor, "SELECT name FROM component ORDER BY...
def add_db_options(field, constraints, prefix, cursor, sql): cursor.execute(sql) options = [] while 1: row = cursor.fetchone() if not row: break if row[0]: options.append({'name': row[0]}) add_options(field, constraints, prefix, options)
"FROM ticket OUTER JOIN ticket_custom ON id = ticket"
"FROM ticket LEFT OUTER JOIN ticket_custom ON id = ticket"
def _render_results(self, constraints, order, desc): self.req.hdf.setValue('title', 'Custom Query') self.req.hdf.setValue('query.edit_href', self.env.href.query(constraints, order, desc, action='edit'))
self.base_url = 'http://%s:%d%s' % (host, port, cgi_location)
self.base_url = 'http://%s:%d%s' % (host, port, self.cgi_location)
def init_request(self): core.Request.init_request(self) options = self.req.get_options()
req.write('<li><a href="%s">%s</a></li>' % (mpr.idx_location + '/' + project,
req.write('<li><a href="%s">%s</a></li>' % (href_join(mpr.idx_location, project),
def send_project_index(req, mpr, dir): req.content_type = 'text/html' req.write('<html><head><title>Available Projects</title></head>') req.write('<body><h1>Available Projects</h1><ul>') for project in os.listdir(dir): req.write('<li><a href="%s">%s</a></li>' % (mpr.idx_location + '/' + project, project)) req.write('</...
return {'order': order, 'desc': desc and 1 or 0,
return {'order': order, 'desc': desc and 1 or None,
def browse_order(a): return a['is_dir'] and dir_order or 0, file_order(a)
if not order in Ticket.std_fields:
if order != 'id' and not order in Ticket.std_fields:
def _render_results(self, constraints, order, desc): self.req.hdf.setValue('title', 'Custom Query') self.req.hdf.setValue('query.edit_href', self.env.href.query(constraints, order, desc, action='edit'))
and not constraint[0][0] in '!~^$':
and not constraint[0][0] in ('!', '~', '^', '$'):
def get_columns(self): if self.cols: return self.cols
if len(v[0]) and v[0][neg] in "~^$":
if len(v[0]) and v[0][neg] in ('~', '^', '$'):
def get_constraint_sql(name, value, mode, neg): value = sql_escape(value[len(mode and '!' or '' + mode):]) if mode == '~' and value: return "IFNULL(%s,'') %sLIKE '%%%s%%'" % ( name, neg and 'NOT ' or '', value) elif mode == '^' and value: return "IFNULL(%s,'') %sLIKE '%s%%'" % ( name, neg and 'NOT ' or '', value) elif ...
sql.append("\nWHERE " + " AND ".join(filter(None, clauses)))
sql.append("\nWHERE " + " AND ".join(clauses))
def get_constraint_sql(name, value, mode, neg): value = sql_escape(value[len(mode and '!' or '' + mode):]) if mode == '~' and value: return "IFNULL(%s,'') %sLIKE '%%%s%%'" % ( name, neg and 'NOT ' or '', value) elif mode == '^' and value: return "IFNULL(%s,'') %sLIKE '%s%%'" % ( name, neg and 'NOT ' or '', value) elif ...
if val[:1] in "~^$":
if val[:1] in ('~', '^', '$'):
def display(self): self.req.hdf.setValue('title', 'Custom Query') query = self.query
self.cookie.load(os.getenv('HTTP_COOKIE'))
if os.getenv('HTTP_COOKIE'): self.cookie.load(os.getenv('HTTP_COOKIE'))
def init_request(self): Request.init_request(self) self.cgi_location = os.getenv('SCRIPT_NAME') self.remote_addr = os.getenv('REMOTE_ADDR') self.remote_user = os.getenv('REMOTE_USER') self.cookie.load(os.getenv('HTTP_COOKIE'))
self.hdf.setValue(prefix, markup.escape(value))
self.hdf.setValue(prefix, markup.escape(value).encode('utf-8'))
def add_value(prefix, value): if value is None: return elif value in (True, False): self.hdf.setValue(prefix, str(int(value))) elif isinstance(value, markup.Markup): self.hdf.setValue(prefix, value.encode('utf-8')) elif isinstance(value, markup.Fragment): self.hdf.setValue(prefix, unicode(value).encode('utf-8')) elif i...
req.perm.reqiure(perm_map[attachment.parent_type])
req.perm.require(perm_map[attachment.parent_type])
def _do_save(self, req, attachment): perm_map = {'ticket': 'TICKET_APPEND', 'wiki': 'WIKI_MODIFY'} req.perm.reqiure(perm_map[attachment.parent_type])
'install_scripts': my_install_scripts})
'install_scripts': my_install_scripts, 'install_data': my_install_data})
def initialize_options(self): bdist_wininst.initialize_options(self) self.title = "Trac %s" % VERSION self.bitmap = "setup_wininst.bmp"
while current_rev:
while current_rev is not None:
def sync(self): self.log.debug("Checking whether sync with repository is needed") youngest_stored = self.repos.get_youngest_rev_in_cache(self.db) if youngest_stored != str(self.repos.youngest_rev): kindmap = dict(zip(_kindmap.values(), _kindmap.keys())) actionmap = dict(zip(_actionmap.values(), _actionmap.keys())) self...
attachments_dir = os.path.join(self.env_path, 'attachments')
self.attachments_dir = os.path.join(self.env_path, 'attachments')
def setUp(self): self.env_path = os.path.join(tempfile.gettempdir(), 'trac-tempenv') os.mkdir(self.env_path) self.db = InMemoryDatabase() attachments_dir = os.path.join(self.env_path, 'attachments') config = Configuration(None) config.setdefault('attachment', 'max_size', 512) self.env = Mock(config=config, log=logger_f...
get_attachments_dir=lambda: attachments_dir,
get_attachments_dir=lambda: self.attachments_dir,
def setUp(self): self.env_path = os.path.join(tempfile.gettempdir(), 'trac-tempenv') os.mkdir(self.env_path) self.db = InMemoryDatabase() attachments_dir = os.path.join(self.env_path, 'attachments') config = Configuration(None) config.setdefault('attachment', 'max_size', 512) self.env = Mock(config=config, log=logger_f...
self.assertEqual('/tmp/trac-tempenv/attachments/ticket/42/foo.txt',
self.assertEqual(os.path.join(self.attachments_dir, 'ticket', '42', 'foo.txt'),
def test_get_path(self): attachment = Attachment(self.env, 'ticket', 42) attachment.filename = 'foo.txt' self.assertEqual('/tmp/trac-tempenv/attachments/ticket/42/foo.txt', attachment.path) attachment = Attachment(self.env, 'wiki', 'SomePage') attachment.filename = 'bar.jpg' self.assertEqual('/tmp/trac-tempenv/attachme...
self.assertEqual('/tmp/trac-tempenv/attachments/wiki/SomePage/bar.jpg',
self.assertEqual(os.path.join(self.attachments_dir, 'wiki', 'SomePage', 'bar.jpg'),
def test_get_path(self): attachment = Attachment(self.env, 'ticket', 42) attachment.filename = 'foo.txt' self.assertEqual('/tmp/trac-tempenv/attachments/ticket/42/foo.txt', attachment.path) attachment = Attachment(self.env, 'wiki', 'SomePage') attachment.filename = 'bar.jpg' self.assertEqual('/tmp/trac-tempenv/attachme...
self.assertEqual('/tmp/trac-tempenv/attachments/ticket/42/Teh%20foo.txt',
self.assertEqual(os.path.join(self.attachments_dir, 'ticket', '42', 'Teh%20foo.txt'),
def test_get_path_encoded(self): attachment = Attachment(self.env, 'ticket', 42) attachment.filename = 'Teh foo.txt' self.assertEqual('/tmp/trac-tempenv/attachments/ticket/42/Teh%20foo.txt', attachment.path) attachment = Attachment(self.env, 'wiki', '\xdcberSicht') attachment.filename = 'Teh bar.jpg' self.assertEqual('...