rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
and not constraint[0][0] in '!~^$':
and not constraint[0][0] in ('!', '~', '^', '$'):
def get_columns(self): if self.cols: return self.cols
36331da02fc9b314c1a7351ab2da64f6c8fdca9b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/36331da02fc9b314c1a7351ab2da64f6c8fdca9b/Query.py
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 mode == '$' and value: return "IFNULL(%s,'') %sLIKE '%%%s'" % ( name, neg and 'NOT ' or '', value) elif mode == '': return "IFNULL(%s,'')%s='%s'" % (name, neg and '!' or '', value)
36331da02fc9b314c1a7351ab2da64f6c8fdca9b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/36331da02fc9b314c1a7351ab2da64f6c8fdca9b/Query.py
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 mode == '$' and value: return "IFNULL(%s,'') %sLIKE '%%%s'" % ( name, neg and 'NOT ' or '', value) elif mode == '': return "IFNULL(%s,'')%s='%s'" % (name, neg and '!' or '', value)
36331da02fc9b314c1a7351ab2da64f6c8fdca9b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/36331da02fc9b314c1a7351ab2da64f6c8fdca9b/Query.py
if val[:1] in "~^$":
if val[:1] in ('~', '^', '$'):
def display(self): self.req.hdf.setValue('title', 'Custom Query') query = self.query
36331da02fc9b314c1a7351ab2da64f6c8fdca9b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/36331da02fc9b314c1a7351ab2da64f6c8fdca9b/Query.py
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'))
8fe5af3eb3c7cbdcbae2f83f6e49308e72d0f8ef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/8fe5af3eb3c7cbdcbae2f83f6e49308e72d0f8ef/core.py
'preview': ' '}
'preview': ''}
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_file_size': max_preview_size, 'preview': ' '} else: return {'preview': self.render(req, mimetype, content, filename, detail, annotations)}
c56f91fd281c45fbb93fecc6eb4f0f0c0de8c68c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/c56f91fd281c45fbb93fecc6eb4f0f0c0de8c68c/api.py
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 isinstance(value, str): if escape: self.hdf.setValue(prefix, markup.escape(value)) else: self.hdf.setValue(prefix, value) elif isinstance(value, unicode): if escape: self.hdf.setValue(prefix, markup.escape(value).encode('utf-8')) else: self.hdf.setValue(prefix, value.encode('utf-8')) elif isinstance(value, dict): for k in value.keys(): add_value('%s.%s' % (prefix, k), value[k]) else: if hasattr(value, '__iter__') or \ isinstance(value, (list, tuple)): for idx, item in enumerate(value): add_value('%s.%d' % (prefix, idx), item) else: self.hdf.setValue(prefix, str(value))
0d61b3c895b74b88982a5911af0fc4d194d32699 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/0d61b3c895b74b88982a5911af0fc4d194d32699/clearsilver.py
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])
b0b4fdf1fedd97e19a01238709cc41ff875315e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/b0b4fdf1fedd97e19a01238709cc41ff875315e5/attachment.py
'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"
ce87e6d19d4f8f40d7b864ece2a4de626604501e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/ce87e6d19d4f8f40d7b864ece2a4de626604501e/setup.py
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.log.info("Syncing with repository (%s to %s)" % (youngest_stored, self.repos.youngest_rev)) cursor = self.db.cursor() if youngest_stored: current_rev = self.repos.next_rev(youngest_stored) else: current_rev = self.repos.oldest_rev while current_rev: changeset = self.repos.get_changeset(current_rev) cursor.execute("INSERT INTO revision (rev,time,author,message) " "VALUES (%s,%s,%s,%s)", (current_rev, changeset.date, changeset.author, changeset.message)) for path,kind,action,base_path,base_rev in changeset.get_changes(): self.log.debug("Caching node change in [%s]: %s" % (current_rev, (path, kind, action, base_path, base_rev))) kind = kindmap[kind] action = actionmap[action] cursor.execute("INSERT INTO node_change (rev,path,kind," "change,base_path,base_rev) " "VALUES (%s,%s,%s,%s,%s,%s)", (current_rev, path, kind, action, base_path, base_rev)) current_rev = self.repos.next_rev(current_rev) self.db.commit()
7641a2c84ff6f0f1fd03c5cf238e6e2f29a67bcd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/7641a2c84ff6f0f1fd03c5cf238e6e2f29a67bcd/cache.py
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_factory('test'), get_attachments_dir=lambda: attachments_dir, get_db_cnx=lambda: self.db) self.perm = Mock(assert_permission=lambda x: None, has_permission=lambda x: True)
099069b3a902ad6e5626a7de48cc355cffdbb848 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/099069b3a902ad6e5626a7de48cc355cffdbb848/attachment.py
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_factory('test'), get_attachments_dir=lambda: attachments_dir, get_db_cnx=lambda: self.db) self.perm = Mock(assert_permission=lambda x: None, has_permission=lambda x: True)
099069b3a902ad6e5626a7de48cc355cffdbb848 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/099069b3a902ad6e5626a7de48cc355cffdbb848/attachment.py
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/attachments/wiki/SomePage/bar.jpg', attachment.path)
099069b3a902ad6e5626a7de48cc355cffdbb848 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/099069b3a902ad6e5626a7de48cc355cffdbb848/attachment.py
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/attachments/wiki/SomePage/bar.jpg', attachment.path)
099069b3a902ad6e5626a7de48cc355cffdbb848 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/099069b3a902ad6e5626a7de48cc355cffdbb848/attachment.py
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('/tmp/trac-tempenv/attachments/wiki/%DCberSicht/Teh%20bar.jpg', attachment.path)
099069b3a902ad6e5626a7de48cc355cffdbb848 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/099069b3a902ad6e5626a7de48cc355cffdbb848/attachment.py
self.assertEqual('/tmp/trac-tempenv/attachments/wiki/%DCberSicht/Teh%20bar.jpg',
self.assertEqual(os.path.join(self.attachments_dir, 'wiki', '%DCberSicht', 'Teh%20bar.jpg'),
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('/tmp/trac-tempenv/attachments/wiki/%DCberSicht/Teh%20bar.jpg', attachment.path)
099069b3a902ad6e5626a7de48cc355cffdbb848 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/099069b3a902ad6e5626a7de48cc355cffdbb848/attachment.py
poolable = have_pysqlite and sqlite_version >= 30301
poolable = have_pysqlite and os.name == 'nt' and sqlite_version >= 30301
def to_sql(cls, table): return _to_sql(table)
7f64c451e6657945d130e677d6df5df376785f48 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/7f64c451e6657945d130e677d6df5df376785f48/sqlite_backend.py
return PooledConnection(self, cnx, tid)
def get_cnx(self, timeout=None): start = time.time() self._available.acquire() try: tid = threading._get_ident() if tid in self._active: num, cnx = self._active.get(tid) if num == 0: # was pushed back (see _cleanup) if try_rollback(cnx): self._active[tid][0] = num + 1 return PooledConnection(self, cnx, tid) else: del self._active[tid] while True: if self._dormant: cnx = self._dormant.pop() if try_rollback(cnx): break else: self._cursize -= 1 elif self._maxsize and self._cursize < self._maxsize: cnx = self._connector.get_connection(**self._kwargs) self._cursize += 1 break else: if timeout: if (time.time() - start) >= timeout: raise TimeoutError('Unable to get database ' 'connection within %d seconds' % timeout) self._available.wait(timeout) else: # Warning: without timeout, Trac *might* hang self._available.wait() self._active[tid] = [1, cnx] return PooledConnection(self, cnx, tid) finally: self._available.release()
170f74c4cde8b5ba88c0e16e7ebfb415819ac0a0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/170f74c4cde8b5ba88c0e16e7ebfb415819ac0a0/pool.py
def send_response(self, code): raise RuntimeError, 'Virtual method not implemented' def send_header(self, name, value): raise RuntimeError, 'Virtual method not implemented' def end_headers(self): raise RuntimeError, 'Virtual method not implemented'
def init_request(self): import neo_cgi import neo_cs import neo_util import Cookie self.hdf = neo_util.HDF() self.incookie = Cookie.SimpleCookie() self.outcookie = Cookie.SimpleCookie()
8450371c7958ff365662ad39fe6ba78e8bddc7c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/8450371c7958ff365662ad39fe6ba78e8bddc7c8/core.py
if port == 80:
if os.getenv('HTTP_X_FORWARDED_HOST'): self.base_url = 'http://%s%s/' % (os.getenv('HTTP_X_FORWARDED_HOST'), self.cgi_location) elif port == 80:
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.command = os.getenv('REQUEST_METHOD') host = os.getenv('SERVER_NAME') try: port = int(os.getenv('SERVER_PORT')) except TypeError: port = 80 if port == 80: self.base_url = 'http://%s%s' % (host, self.cgi_location) elif port == 443: self.base_url = 'https://%s%s' % (host, self.cgi_location) else: self.base_url = 'http://%s:%d%s' % (host, port, self.cgi_location) if os.getenv('HTTP_COOKIE'): self.incookie.load(os.getenv('HTTP_COOKIE')) if os.getenv('HTTP_HOST'): self.hdf.setValue('HTTP.Host', os.getenv('HTTP_HOST'))
8450371c7958ff365662ad39fe6ba78e8bddc7c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/8450371c7958ff365662ad39fe6ba78e8bddc7c8/core.py
self.fileno = 0 def close_file(self, file_baton, pool):
self.prev_path = None self.fileno = -1 self.prefix = None def _check_next(self, old_path, new_path, pool): if self.prev_path == (old_path or new_path): return
def __init__(self, old_root, new_root, rev, req, args, env): BaseDiffEditor.__init__(self, old_root, new_root, rev, req, args, env) self.fileno = 0
5d4c14a9ae16d7086c0ba29b263aafad5e909c0b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/5d4c14a9ae16d7086c0ba29b263aafad5e909c0b/Changeset.py
def change_file_prop(self, file_baton, name, value, pool): if not file_baton: return (old_path, new_path, pool) = file_baton prefix = 'changeset.changes.%d.props.%s' % (self.fileno, name)
self.prev_path = old_path or new_path self.prefix = 'changeset.changes.%d' % (self.fileno)
def close_file(self, file_baton, pool): self.fileno += 1
5d4c14a9ae16d7086c0ba29b263aafad5e909c0b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/5d4c14a9ae16d7086c0ba29b263aafad5e909c0b/Changeset.py
old_value = svn.fs.node_prop(self.old_root, old_path, name, pool) self.req.hdf.setValue(prefix + '.old', old_value) if value: self.req.hdf.setValue(prefix + '.new', value) def change_dir_prop(self, dir_baton, name, value, pool):
old_rev = svn.fs.node_created_rev(self.old_root, old_path, pool) self.req.hdf.setValue('%s.rev.old' % self.prefix, str(old_rev)) self.req.hdf.setValue('%s.browser_href.old' % self.prefix, self.env.href.browser(old_path, old_rev)) if new_path: new_rev = svn.fs.node_created_rev(self.new_root, new_path, pool) self.req.hdf.setValue('%s.rev.new' % self.prefix, str(new_rev)) self.req.hdf.setValue('%s.browser_href.new' % self.prefix, self.env.href.browser(new_path, new_rev)) def add_directory(self, path, parent_baton, copyfrom_path, copyfrom_revision, dir_pool): self._check_next(None, path, dir_pool) def delete_entry(self, path, revision, parent_baton, pool): self._check_next(path, None, pool) def change_dir_prop(self, dir_baton, name, value, dir_pool):
def change_file_prop(self, file_baton, name, value, pool): if not file_baton: return
5d4c14a9ae16d7086c0ba29b263aafad5e909c0b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/5d4c14a9ae16d7086c0ba29b263aafad5e909c0b/Changeset.py
def change_dir_prop(self, dir_baton, name, value, pool): if not dir_baton: return
5d4c14a9ae16d7086c0ba29b263aafad5e909c0b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/5d4c14a9ae16d7086c0ba29b263aafad5e909c0b/Changeset.py
prefix = 'changeset.changes.%d.props.%s' % (self.fileno, name)
self._check_next(old_path, new_path, dir_pool) prefix = '%s.props.%s' % (self.prefix, name)
def change_dir_prop(self, dir_baton, name, value, pool): if not dir_baton: return
5d4c14a9ae16d7086c0ba29b263aafad5e909c0b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/5d4c14a9ae16d7086c0ba29b263aafad5e909c0b/Changeset.py
old_value = svn.fs.node_prop(self.old_root, old_path, name, pool)
old_value = svn.fs.node_prop(self.old_root, old_path, name, dir_pool)
def change_dir_prop(self, dir_baton, name, value, pool): if not dir_baton: return
5d4c14a9ae16d7086c0ba29b263aafad5e909c0b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/5d4c14a9ae16d7086c0ba29b263aafad5e909c0b/Changeset.py
old_rev = svn.fs.node_created_rev(self.old_root, old_path, pool) new_rev = svn.fs.node_created_rev(self.new_root, new_path, pool) prefix = 'changeset.changes.%d' % (self.fileno) self.req.hdf.setValue('%s.rev.old' % prefix, str(old_rev)) self.req.hdf.setValue('%s.rev.new' % prefix, str(new_rev)) self.req.hdf.setValue('%s.browser_href.old' % prefix, self.env.href.file(old_path, old_rev)) self.req.hdf.setValue('%s.browser_href.new' % prefix, self.env.href.file(new_path, new_rev))
self._check_next(old_path, new_path, pool)
def apply_textdelta(self, file_baton, base_checksum): if not file_baton: return (old_path, new_path, pool) = file_baton old_rev = svn.fs.node_created_rev(self.old_root, old_path, pool) new_rev = svn.fs.node_created_rev(self.new_root, new_path, pool)
5d4c14a9ae16d7086c0ba29b263aafad5e909c0b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/5d4c14a9ae16d7086c0ba29b263aafad5e909c0b/Changeset.py
mime_type = svn.fs.node_prop (self.new_root, new_path, svn.util.SVN_PROP_MIME_TYPE, pool)
mime_type = svn.fs.node_prop(self.new_root, new_path, svn.util.SVN_PROP_MIME_TYPE, pool)
def apply_textdelta(self, file_baton, base_checksum): if not file_baton: return (old_path, new_path, pool) = file_baton old_rev = svn.fs.node_created_rev(self.old_root, old_path, pool) new_rev = svn.fs.node_created_rev(self.new_root, new_path, pool)
5d4c14a9ae16d7086c0ba29b263aafad5e909c0b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/5d4c14a9ae16d7086c0ba29b263aafad5e909c0b/Changeset.py
builder = Diff.HDFBuilder(self.req.hdf, '%s.diff' % prefix, tabwidth)
builder = Diff.HDFBuilder(self.req.hdf, '%s.diff' % self.prefix, tabwidth)
def apply_textdelta(self, file_baton, base_checksum): if not file_baton: return (old_path, new_path, pool) = file_baton old_rev = svn.fs.node_created_rev(self.old_root, old_path, pool) new_rev = svn.fs.node_created_rev(self.new_root, new_path, pool)
5d4c14a9ae16d7086c0ba29b263aafad5e909c0b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/5d4c14a9ae16d7086c0ba29b263aafad5e909c0b/Changeset.py
format = ('%%%is: %%-%is | ' % (width[1], width[1]),
format = ('%%%is: %%-%is | ' % (width[0], width[1]),
def format_props(self): tkt = self.ticket fields = [f for f in tkt.fields if f['type'] != 'textarea' and f['name'] != 'summary'] t = self.modtime or tkt.time_changed width = [0, 0, 0, 0] for i, f in enum([f['name'] for f in fields]): if not f in tkt.values.keys(): continue fval = tkt[f] if fval.find('\n') > -1: continue idx = 2 * (i % 2) if len(f) > width[idx]: width[idx] = len(f) if len(fval) > width[idx + 1]: width[idx + 1] = len(fval) format = ('%%%is: %%-%is | ' % (width[1], width[1]), ' %%%is: %%-%is%s' % (width[2], width[3], CRLF)) i = 1 l = (width[0] + width[1] + 5) sep = l*'-' + '+' + (self.COLS-l)*'-' txt = sep + CRLF big = [] for i, f in enum([f['name'] for f in fields]): if not tkt.values.has_key(f): continue fval = tkt[f] if '\n' in str(fval): big.append((f.capitalize(), fval)) else: txt += format[i % 2] % (f.capitalize(), fval) if not i % 2: txt += '\n' if big: txt += sep for k,v in big: txt += '\n%s:\n%s\n\n' % (k,v) txt += sep return txt
f438c3aa773fbc8d04ab50d68352961a8c349104 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/f438c3aa773fbc8d04ab50d68352961a8c349104/Notify.py
self.hdf.setValue('HTTP.Host', os.getenv('HTTP_HOST'))
self.hdf.setValue('HTTP.Host', os.getenv('HTTP_HOST').split(':')[0])
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.command = os.getenv('REQUEST_METHOD') host = os.getenv('SERVER_NAME') proto_port = '' port = int(os.environ.get('SERVER_PORT', 80)) if port == 443: proto = 'https' else: proto = 'http' if port != 80: proto_port = ':%d' % port
c9cfa9ed5eb02648c2ddb11f49ec52bd388eabec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/c9cfa9ed5eb02648c2ddb11f49ec52bd388eabec/core.py
if column in ['id', 'ticket', '
if column in ('ticket', 'id', '_id', '
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'} for action in [k for k,v in actions.items() if req.perm.has_permission(v)]: req.hdf['report.can_' + action] = True req.hdf['report.href'] = self.env.href.report(id)
2a745aa87936e1e869b815421da626d392098904 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/2a745aa87936e1e869b815421da626d392098904/report.py
if col[0] in ('ticket', 'id')]
if col[0] in ('ticket', 'id', '_id')]
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'} for action in [k for k,v in actions.items() if req.perm.has_permission(v)]: req.hdf['report.can_' + action] = True req.hdf['report.href'] = self.env.href.report(id)
2a745aa87936e1e869b815421da626d392098904 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/2a745aa87936e1e869b815421da626d392098904/report.py
elif column in ['time', 'date','changetime', 'created', 'modified']:
elif column in ('time', 'date','changetime', 'created', 'modified'):
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'} for action in [k for k,v in actions.items() if req.perm.has_permission(v)]: req.hdf['report.can_' + action] = True req.hdf['report.href'] = self.env.href.report(id)
2a745aa87936e1e869b815421da626d392098904 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/2a745aa87936e1e869b815421da626d392098904/report.py
"""Render an XHTML preview of the given `content` (a raw str object)
"""Render an XHTML preview of the given `content`. `content` is the same as an `IHTMLPreviewRenderer.render`'s `content` argument.
def render(self, req, mimetype, content, filename=None, url=None, annotations=None): """Render an XHTML preview of the given `content` (a raw str object)
e93909bc074150b9e0cf24fb9f8ab9c269c3c5a2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/e93909bc074150b9e0cf24fb9f8ab9c269c3c5a2/api.py
full_mimetype = mimetype or self.get_mimetype(filename, content)
full_mimetype = mimetype if not full_mimetype: if hasattr(content, 'read'): content = content.read(mimeview.get_max_preview_size()) full_mimetype = self.get_mimetype(filename, content)
def render(self, req, mimetype, content, filename=None, url=None, annotations=None): """Render an XHTML preview of the given `content` (a raw str object)
e93909bc074150b9e0cf24fb9f8ab9c269c3c5a2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/e93909bc074150b9e0cf24fb9f8ab9c269c3c5a2/api.py
def render(self, req, mimetype, content, filename=None, url=None, annotations=None): """Render an XHTML preview of the given `content` (a raw str object)
e93909bc074150b9e0cf24fb9f8ab9c269c3c5a2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/e93909bc074150b9e0cf24fb9f8ab9c269c3c5a2/api.py
content = expanded_content result = renderer.render(req, full_mimetype, content,
rendered_content = expanded_content result = renderer.render(req, full_mimetype, rendered_content,
def render(self, req, mimetype, content, filename=None, url=None, annotations=None): """Render an XHTML preview of the given `content` (a raw str object)
e93909bc074150b9e0cf24fb9f8ab9c269c3c5a2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/e93909bc074150b9e0cf24fb9f8ab9c269c3c5a2/api.py
assert tid == threading._get_ident()
def shutdown(self, tid=None): assert tid == threading._get_ident() if tid: try: self._lock.acquire() self._cache.pop(tid, None) finally: self._lock.release()
a184eecbfdd364ed069bbd6a45324396897ca595 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/a184eecbfdd364ed069bbd6a45324396897ca595/api.py
SHREF_TARGET_MIDDLE = r"(?:\|(?=[^| ])|&(?!lt;)|[^|& ])" SHREF_TARGET_LAST_CHAR = r"[^|'~_\.,& \)]"
SHREF_TARGET_MIDDLE = r"(?:\|(?=[^|\s])|&(?!lt;)|[^|&\s])" SHREF_TARGET_LAST_CHAR = r"[^|'~_\.,&\s\)\]:?!]"
def process(self, req, text, inline=False): if self.error: return system_message('Error: Failed to load processor <code>%s</code>' % self.name, self.error) text = self.processor(req, text) if inline: code_block_start = re.compile('^<div class="code-block">') code_block_end = re.compile('</div>$') text, nr = code_block_start.subn('<span class="code-block">', text, 1 ) if nr: text, nr = code_block_end.subn('</span>', text, 1 ) return text else: return text
424ba53b5861faf25714a83d3fcc3b54c11aab59 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/424ba53b5861faf25714a83d3fcc3b54c11aab59/formatter.py
changeset = Mock(Changeset, 1, 'Import', 'joe', 42000, get_changes=lambda: iter(changes))
changesets = [Mock(Changeset, 0, '', '', 41000, get_changes=lambda: []), Mock(Changeset, 1, 'Import', 'joe', 42000, get_changes=lambda: iter(changes))]
def test_initial_sync(self): changes = [('trunk', Node.DIRECTORY, Changeset.ADD, None, None), ('trunk/README', Node.FILE, Changeset.ADD, None, None)] changeset = Mock(Changeset, 1, 'Import', 'joe', 42000, get_changes=lambda: iter(changes)) repos = Mock(Repository, None, self.log, get_changeset=lambda x: changeset, get_oldest_rev=lambda: 1, get_youngest_rev=lambda: 1, next_rev=lambda x: x == '0' and '1' or None) cache = CachedRepository(self.db, repos, None, self.log) cache.sync()
a81203a7fc8eb7c779fef3fbf03a8b56fbbc04a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/a81203a7fc8eb7c779fef3fbf03a8b56fbbc04a6/cache.py
get_changeset=lambda x: changeset, get_oldest_rev=lambda: 1,
get_changeset=lambda x: changesets[int(x)], get_oldest_rev=lambda: 0,
def test_initial_sync(self): changes = [('trunk', Node.DIRECTORY, Changeset.ADD, None, None), ('trunk/README', Node.FILE, Changeset.ADD, None, None)] changeset = Mock(Changeset, 1, 'Import', 'joe', 42000, get_changes=lambda: iter(changes)) repos = Mock(Repository, None, self.log, get_changeset=lambda x: changeset, get_oldest_rev=lambda: 1, get_youngest_rev=lambda: 1, next_rev=lambda x: x == '0' and '1' or None) cache = CachedRepository(self.db, repos, None, self.log) cache.sync()
a81203a7fc8eb7c779fef3fbf03a8b56fbbc04a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/a81203a7fc8eb7c779fef3fbf03a8b56fbbc04a6/cache.py
next_rev=lambda x: x == '0' and '1' or None)
next_rev=lambda x: int(x) == 0 and '1' or None)
def test_initial_sync(self): changes = [('trunk', Node.DIRECTORY, Changeset.ADD, None, None), ('trunk/README', Node.FILE, Changeset.ADD, None, None)] changeset = Mock(Changeset, 1, 'Import', 'joe', 42000, get_changes=lambda: iter(changes)) repos = Mock(Repository, None, self.log, get_changeset=lambda x: changeset, get_oldest_rev=lambda: 1, get_youngest_rev=lambda: 1, next_rev=lambda x: x == '0' and '1' or None) cache = CachedRepository(self.db, repos, None, self.log) cache.sync()
a81203a7fc8eb7c779fef3fbf03a8b56fbbc04a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/a81203a7fc8eb7c779fef3fbf03a8b56fbbc04a6/cache.py
field['optional'] = '' in field['options']
if '' in field['options']: field['optional'] = True field['options'].remove('')
def get_custom_fields(self): fields = [] config = self.config['ticket-custom'] for name in [option for option, value in config.options() if '.' not in option]: field = { 'name': name, 'type': config.get(name), 'order': config.getint(name + '.order', 0), 'label': config.get(name + '.label') or name.capitalize(), 'value': config.get(name + '.value', '') } if field['type'] == 'select' or field['type'] == 'radio': field['options'] = config.getlist(name + '.options', sep='|') field['optional'] = '' in field['options'] elif field['type'] == 'textarea': field['width'] = config.getint(name + '.cols') field['height'] = config.getint(name + '.rows') fields.append(field)
c24b175863d14a154305882378751cd05a0b0c61 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/c24b175863d14a154305882378751cd05a0b0c61/api.py
req.path_info = path_info
req.path_info = to_utf8(path_info)
def dispatch_request(path_info, req, env): """Main entry point for the Trac web interface.""" # Re-parse the configuration file if it changed since the last the time it # was parsed env.config.parse_if_needed() base_url = env.config.get('trac', 'base_url') if not base_url: base_url = absolute_url(req) req.base_url = base_url req.path_info = path_info env.href = Href(req.cgi_location) env.abs_href = Href(req.base_url) db = env.get_db_cnx() try: try: dispatcher = RequestDispatcher(env) dispatcher.dispatch(req) except RequestDone: pass finally: db.close()
4811fe8a5989c5e878c1d260ebbdfe50862ebf74 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/4811fe8a5989c5e878c1d260ebbdfe50862ebf74/main.py
content = content.read(mimeview.get_max_preview_size())
content = content.read(self.get_max_preview_size())
def render(self, req, mimetype, content, filename=None, url=None, annotations=None): """Render an XHTML preview of the given `content`.
4128ff9a9115a3970f3d0eb15dbd9792ce426945 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/4128ff9a9115a3970f3d0eb15dbd9792ce426945/api.py
(cons_locale, cons_charset) = locale.getdefaultlocale()
cons_charset = locale.getpreferredencoding()
def print_listing(self, headers, data, sep=' ', decor=True): (cons_locale, cons_charset) = locale.getdefaultlocale() ldata = list(data) if decor: ldata.insert(0, headers) print colw = [] ncols = len(ldata[0]) # assumes all rows are of equal length for cnum in xrange(0, ncols): mw = 0 for cell in [unicode(d[cnum]) or '' for d in ldata]: if len(cell) > mw: mw = len(cell) colw.append(mw) for rnum in xrange(len(ldata)): for cnum in xrange(ncols): if decor and rnum == 0: sp = ('%%%ds' % len(sep)) % ' ' # No separator in header else: sp = sep if cnum + 1 == ncols: sp = '' # No separator after last column pdata = ((u'%%-%ds%s' % (colw[cnum], sp)) % (ldata[rnum][cnum] or '')) if cons_charset and isinstance(pdata, unicode): pdata = pdata.encode(cons_charset) print pdata, print if rnum == 0 and decor: print ''.join(['-' for x in xrange(0, (1 + len(sep)) * cnum + sum(colw))]) print
7ab135dbd60529ad1a53ff5a3f13bfd5a9f7dca2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/7ab135dbd60529ad1a53ff5a3f13bfd5a9f7dca2/admin.py
__default_templates_dir__ = '%(templates)s' __default_htdocs_dir__ = '%(htdocs)s' __default_wiki_dir__ = '%(wiki)s'
__default_templates_dir__ = '%(templates)r' __default_htdocs_dir__ = '%(htdocs)r' __default_wiki_dir__ = '%(wiki)r'
def siteconfig(self): templates_dir = os.path.join(self.prefix, 'share','trac','templates') htdocs_dir = os.path.join(self.prefix, 'share','trac','htdocs') wiki_dir = os.path.join(self.prefix, 'share','trac','wiki-default') f = open(_p('trac/siteconfig.py'),'w') f.write("""
f9f058a8c0cfdc1b7632c175c77e0096f3c52f1f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/f9f058a8c0cfdc1b7632c175c77e0096f3c52f1f/setup.py
fields = [f for f in tkt.fields if f['type'] != 'textarea' and f['name'] not in ('summary', 'cc')]
fields = [f for f in tkt.fields if f['name'] not in ('summary', 'cc')]
def format_props(self): tkt = self.ticket fields = [f for f in tkt.fields if f['type'] != 'textarea' and f['name'] not in ('summary', 'cc')] t = self.modtime or tkt.time_changed width = [0, 0, 0, 0] for i, f in enum([f['name'] for f in fields]): if not tkt.values.has_key(f): continue fval = tkt[f] if fval.find('\n') > -1: continue idx = 2 * (i % 2) if len(f) > width[idx]: width[idx] = len(f) if len(fval) > width[idx + 1]: width[idx + 1] = len(fval) format = ('%%%is: %%-%is | ' % (width[0], width[1]), ' %%%is: %%-%is%s' % (width[2], width[3], CRLF)) l = (width[0] + width[1] + 5) sep = l * '-' + '+' + (self.COLS - l) * '-' txt = sep + CRLF big = [f for f in tkt.fields if f['type'] == 'textarea' and f['name'] != 'description'] i = 0 for f in [f['name'] for f in fields]: if not tkt.values.has_key(f): continue fval = tkt[f] if '\n' in str(fval): big.append((f.capitalize(), CRLF.join(fval.splitlines()))) else: txt += format[i % 2] % (f.capitalize(), fval) i += 1 if not i % 2: txt += CRLF if big: txt += sep for name, value in big: txt += CRLF.join(['', name + ':', value, '', '']) txt += sep return txt
f1ab6093ddcbd5043fbfaafca5b5e06bde87313b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/f1ab6093ddcbd5043fbfaafca5b5e06bde87313b/Notify.py
for i, f in enum([f['name'] for f in fields]):
i = 0 for f in [f['name'] for f in fields if f['type'] != 'textarea']:
def format_props(self): tkt = self.ticket fields = [f for f in tkt.fields if f['type'] != 'textarea' and f['name'] not in ('summary', 'cc')] t = self.modtime or tkt.time_changed width = [0, 0, 0, 0] for i, f in enum([f['name'] for f in fields]): if not tkt.values.has_key(f): continue fval = tkt[f] if fval.find('\n') > -1: continue idx = 2 * (i % 2) if len(f) > width[idx]: width[idx] = len(f) if len(fval) > width[idx + 1]: width[idx + 1] = len(fval) format = ('%%%is: %%-%is | ' % (width[0], width[1]), ' %%%is: %%-%is%s' % (width[2], width[3], CRLF)) l = (width[0] + width[1] + 5) sep = l * '-' + '+' + (self.COLS - l) * '-' txt = sep + CRLF big = [f for f in tkt.fields if f['type'] == 'textarea' and f['name'] != 'description'] i = 0 for f in [f['name'] for f in fields]: if not tkt.values.has_key(f): continue fval = tkt[f] if '\n' in str(fval): big.append((f.capitalize(), CRLF.join(fval.splitlines()))) else: txt += format[i % 2] % (f.capitalize(), fval) i += 1 if not i % 2: txt += CRLF if big: txt += sep for name, value in big: txt += CRLF.join(['', name + ':', value, '', '']) txt += sep return txt
f1ab6093ddcbd5043fbfaafca5b5e06bde87313b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/f1ab6093ddcbd5043fbfaafca5b5e06bde87313b/Notify.py
if fval.find('\n') > -1:
if fval.find('\n') != -1:
def format_props(self): tkt = self.ticket fields = [f for f in tkt.fields if f['type'] != 'textarea' and f['name'] not in ('summary', 'cc')] t = self.modtime or tkt.time_changed width = [0, 0, 0, 0] for i, f in enum([f['name'] for f in fields]): if not tkt.values.has_key(f): continue fval = tkt[f] if fval.find('\n') > -1: continue idx = 2 * (i % 2) if len(f) > width[idx]: width[idx] = len(f) if len(fval) > width[idx + 1]: width[idx + 1] = len(fval) format = ('%%%is: %%-%is | ' % (width[0], width[1]), ' %%%is: %%-%is%s' % (width[2], width[3], CRLF)) l = (width[0] + width[1] + 5) sep = l * '-' + '+' + (self.COLS - l) * '-' txt = sep + CRLF big = [f for f in tkt.fields if f['type'] == 'textarea' and f['name'] != 'description'] i = 0 for f in [f['name'] for f in fields]: if not tkt.values.has_key(f): continue fval = tkt[f] if '\n' in str(fval): big.append((f.capitalize(), CRLF.join(fval.splitlines()))) else: txt += format[i % 2] % (f.capitalize(), fval) i += 1 if not i % 2: txt += CRLF if big: txt += sep for name, value in big: txt += CRLF.join(['', name + ':', value, '', '']) txt += sep return txt
f1ab6093ddcbd5043fbfaafca5b5e06bde87313b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/f1ab6093ddcbd5043fbfaafca5b5e06bde87313b/Notify.py
big = [f for f in tkt.fields if f['type'] == 'textarea' and f['name'] != 'description']
big = []
def format_props(self): tkt = self.ticket fields = [f for f in tkt.fields if f['type'] != 'textarea' and f['name'] not in ('summary', 'cc')] t = self.modtime or tkt.time_changed width = [0, 0, 0, 0] for i, f in enum([f['name'] for f in fields]): if not tkt.values.has_key(f): continue fval = tkt[f] if fval.find('\n') > -1: continue idx = 2 * (i % 2) if len(f) > width[idx]: width[idx] = len(f) if len(fval) > width[idx + 1]: width[idx + 1] = len(fval) format = ('%%%is: %%-%is | ' % (width[0], width[1]), ' %%%is: %%-%is%s' % (width[2], width[3], CRLF)) l = (width[0] + width[1] + 5) sep = l * '-' + '+' + (self.COLS - l) * '-' txt = sep + CRLF big = [f for f in tkt.fields if f['type'] == 'textarea' and f['name'] != 'description'] i = 0 for f in [f['name'] for f in fields]: if not tkt.values.has_key(f): continue fval = tkt[f] if '\n' in str(fval): big.append((f.capitalize(), CRLF.join(fval.splitlines()))) else: txt += format[i % 2] % (f.capitalize(), fval) i += 1 if not i % 2: txt += CRLF if big: txt += sep for name, value in big: txt += CRLF.join(['', name + ':', value, '', '']) txt += sep return txt
f1ab6093ddcbd5043fbfaafca5b5e06bde87313b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/f1ab6093ddcbd5043fbfaafca5b5e06bde87313b/Notify.py
for f in [f['name'] for f in fields]: if not tkt.values.has_key(f):
for f in fields: fname = f['name'] if not tkt.values.has_key(fname):
def format_props(self): tkt = self.ticket fields = [f for f in tkt.fields if f['type'] != 'textarea' and f['name'] not in ('summary', 'cc')] t = self.modtime or tkt.time_changed width = [0, 0, 0, 0] for i, f in enum([f['name'] for f in fields]): if not tkt.values.has_key(f): continue fval = tkt[f] if fval.find('\n') > -1: continue idx = 2 * (i % 2) if len(f) > width[idx]: width[idx] = len(f) if len(fval) > width[idx + 1]: width[idx + 1] = len(fval) format = ('%%%is: %%-%is | ' % (width[0], width[1]), ' %%%is: %%-%is%s' % (width[2], width[3], CRLF)) l = (width[0] + width[1] + 5) sep = l * '-' + '+' + (self.COLS - l) * '-' txt = sep + CRLF big = [f for f in tkt.fields if f['type'] == 'textarea' and f['name'] != 'description'] i = 0 for f in [f['name'] for f in fields]: if not tkt.values.has_key(f): continue fval = tkt[f] if '\n' in str(fval): big.append((f.capitalize(), CRLF.join(fval.splitlines()))) else: txt += format[i % 2] % (f.capitalize(), fval) i += 1 if not i % 2: txt += CRLF if big: txt += sep for name, value in big: txt += CRLF.join(['', name + ':', value, '', '']) txt += sep return txt
f1ab6093ddcbd5043fbfaafca5b5e06bde87313b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/f1ab6093ddcbd5043fbfaafca5b5e06bde87313b/Notify.py
fval = tkt[f] if '\n' in str(fval): big.append((f.capitalize(), CRLF.join(fval.splitlines())))
fval = tkt[fname] if f['type'] == 'textarea' or '\n' in str(fval): big.append((fname.capitalize(), CRLF.join(fval.splitlines())))
def format_props(self): tkt = self.ticket fields = [f for f in tkt.fields if f['type'] != 'textarea' and f['name'] not in ('summary', 'cc')] t = self.modtime or tkt.time_changed width = [0, 0, 0, 0] for i, f in enum([f['name'] for f in fields]): if not tkt.values.has_key(f): continue fval = tkt[f] if fval.find('\n') > -1: continue idx = 2 * (i % 2) if len(f) > width[idx]: width[idx] = len(f) if len(fval) > width[idx + 1]: width[idx + 1] = len(fval) format = ('%%%is: %%-%is | ' % (width[0], width[1]), ' %%%is: %%-%is%s' % (width[2], width[3], CRLF)) l = (width[0] + width[1] + 5) sep = l * '-' + '+' + (self.COLS - l) * '-' txt = sep + CRLF big = [f for f in tkt.fields if f['type'] == 'textarea' and f['name'] != 'description'] i = 0 for f in [f['name'] for f in fields]: if not tkt.values.has_key(f): continue fval = tkt[f] if '\n' in str(fval): big.append((f.capitalize(), CRLF.join(fval.splitlines()))) else: txt += format[i % 2] % (f.capitalize(), fval) i += 1 if not i % 2: txt += CRLF if big: txt += sep for name, value in big: txt += CRLF.join(['', name + ':', value, '', '']) txt += sep return txt
f1ab6093ddcbd5043fbfaafca5b5e06bde87313b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/f1ab6093ddcbd5043fbfaafca5b5e06bde87313b/Notify.py
txt += format[i % 2] % (f.capitalize(), fval)
txt += format[i % 2] % (fname.capitalize(), fval)
def format_props(self): tkt = self.ticket fields = [f for f in tkt.fields if f['type'] != 'textarea' and f['name'] not in ('summary', 'cc')] t = self.modtime or tkt.time_changed width = [0, 0, 0, 0] for i, f in enum([f['name'] for f in fields]): if not tkt.values.has_key(f): continue fval = tkt[f] if fval.find('\n') > -1: continue idx = 2 * (i % 2) if len(f) > width[idx]: width[idx] = len(f) if len(fval) > width[idx + 1]: width[idx + 1] = len(fval) format = ('%%%is: %%-%is | ' % (width[0], width[1]), ' %%%is: %%-%is%s' % (width[2], width[3], CRLF)) l = (width[0] + width[1] + 5) sep = l * '-' + '+' + (self.COLS - l) * '-' txt = sep + CRLF big = [f for f in tkt.fields if f['type'] == 'textarea' and f['name'] != 'description'] i = 0 for f in [f['name'] for f in fields]: if not tkt.values.has_key(f): continue fval = tkt[f] if '\n' in str(fval): big.append((f.capitalize(), CRLF.join(fval.splitlines()))) else: txt += format[i % 2] % (f.capitalize(), fval) i += 1 if not i % 2: txt += CRLF if big: txt += sep for name, value in big: txt += CRLF.join(['', name + ':', value, '', '']) txt += sep return txt
f1ab6093ddcbd5043fbfaafca5b5e06bde87313b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/f1ab6093ddcbd5043fbfaafca5b5e06bde87313b/Notify.py
if not i % 2:
if i % 2:
def format_props(self): tkt = self.ticket fields = [f for f in tkt.fields if f['type'] != 'textarea' and f['name'] not in ('summary', 'cc')] t = self.modtime or tkt.time_changed width = [0, 0, 0, 0] for i, f in enum([f['name'] for f in fields]): if not tkt.values.has_key(f): continue fval = tkt[f] if fval.find('\n') > -1: continue idx = 2 * (i % 2) if len(f) > width[idx]: width[idx] = len(f) if len(fval) > width[idx + 1]: width[idx + 1] = len(fval) format = ('%%%is: %%-%is | ' % (width[0], width[1]), ' %%%is: %%-%is%s' % (width[2], width[3], CRLF)) l = (width[0] + width[1] + 5) sep = l * '-' + '+' + (self.COLS - l) * '-' txt = sep + CRLF big = [f for f in tkt.fields if f['type'] == 'textarea' and f['name'] != 'description'] i = 0 for f in [f['name'] for f in fields]: if not tkt.values.has_key(f): continue fval = tkt[f] if '\n' in str(fval): big.append((f.capitalize(), CRLF.join(fval.splitlines()))) else: txt += format[i % 2] % (f.capitalize(), fval) i += 1 if not i % 2: txt += CRLF if big: txt += sep for name, value in big: txt += CRLF.join(['', name + ':', value, '', '']) txt += sep return txt
f1ab6093ddcbd5043fbfaafca5b5e06bde87313b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/f1ab6093ddcbd5043fbfaafca5b5e06bde87313b/Notify.py
def init_request(self): core.Request.init_request(self) options = self.req.get_options()
8c8d659f72c1bd488b713bfdca633d8975787ff9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/8c8d659f72c1bd488b713bfdca633d8975787ff9/ModPythonHandler.py
FieldStorage class with an added get function.
FieldStorage class with a get function that provides an empty string as the default value for the 'default' parameter, mimicking the CGI interface.
def end_headers(self): pass
8c8d659f72c1bd488b713bfdca633d8975787ff9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/8c8d659f72c1bd488b713bfdca633d8975787ff9/ModPythonHandler.py
req.write('<li><a href="%s">%s</a></li>' % (href_join(mpr.idx_location, project), project))
req.write('<li><a href="%s">%s</a></li>' % (href_join(mpr.idx_location, project), 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>' % (href_join(mpr.idx_location, project), project)) req.write('</ul></body><html>')
8c8d659f72c1bd488b713bfdca633d8975787ff9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/8c8d659f72c1bd488b713bfdca633d8975787ff9/ModPythonHandler.py
command, line = line[0], line[1:]
command = ' ' if line: command, line = line[0], line[1:]
def htmlify(match): div, mod = divmod(len(match.group(0)), 2) return div * '&nbsp; ' + mod * '&nbsp;'
a9cdb0882821a973ad2a87907ca3248b2ef57151 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/a9cdb0882821a973ad2a87907ca3248b2ef57151/patch.py
url, annotations)}
url, annotations), 'raw_href': url}
def preview_to_hdf(self, req, content, length, mimetype, filename, url=None, annotations=None): """Prepares a rendered preview of the given `content`.
e0ab87618defe595284685c17b4ecdb21167e14d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/e0ab87618defe595284685c17b4ecdb21167e14d/api.py
return 'timeline_rss.cs', 'text/xml'
return 'timeline_rss.cs', 'application/rss+xml'
def process_request(self, req): req.perm.assert_permission(perm.TIMELINE_VIEW)
65c0c9f409ad3c49a84972bc6189271d6bce969f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/65c0c9f409ad3c49a84972bc6189271d6bce969f/Timeline.py
args = filter(None, args)
def get_constraint_sql(name, value, mode, neg): if name not in custom_fields: name = 't.' + name else: name = name + '.value' value = value[len(mode) + neg:]
4d5d97624532165424b518ae58d8e3a31844193f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/4d5d97624532165424b518ae58d8e3a31844193f/query.py
cinfo['browser_href.new'] = self.env.href.browser(new_path, rev)
cinfo['browser_href.new'] = self.env.href.browser(new_path, rev=rev)
def get_change_info(self, rev): cursor = self.db.cursor () cursor.execute("SELECT name, change FROM node_change " "WHERE rev=%s", (rev,)) info = [] while 1: row = cursor.fetchone() if not row: break change = row['change'] name = row['name'] if change in 'CRdm': # 'C'opy, 'R'eplace or 'd'elete on a branch # the name column contains the encoded ''path_info'' # (see _save_change method in sync.py). m = re.match('(.*) // (-?\d+), (.*)', name) if change == 'd': new_path = None else: new_path = m.group(1) old_rev = int(m.group(2)) if old_rev < 0: old_rev = None old_path = m.group(3) elif change == 'D': # 'D'elete new_path = None old_path = name old_rev = None elif change == 'A': # 'A'dd new_path = name old_path = old_rev = None else: # 'M'odify new_path = old_path = name old_rev = None if old_path and not old_rev: # 'D' and 'M' history = svn.fs.node_history(self.old_root, old_path, self.pool) history = svn.fs.history_prev(history, 0, self.pool) # what an API... old_rev = svn.fs.history_location(history, self.pool)[1] # Note: 'node_created_rev' doesn't work reliably key = (new_path or old_path) info.append((key, change, new_path, old_path, old_rev))
5304b982a6c96671fea398b5c0665537d7d0f9ec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/5304b982a6c96671fea398b5c0665537d7d0f9ec/Changeset.py
cinfo['browser_href.old'] = self.env.href.browser(old_path, old_rev)
cinfo['browser_href.old'] = self.env.href.browser(old_path, rev=old_rev)
def get_change_info(self, rev): cursor = self.db.cursor () cursor.execute("SELECT name, change FROM node_change " "WHERE rev=%s", (rev,)) info = [] while 1: row = cursor.fetchone() if not row: break change = row['change'] name = row['name'] if change in 'CRdm': # 'C'opy, 'R'eplace or 'd'elete on a branch # the name column contains the encoded ''path_info'' # (see _save_change method in sync.py). m = re.match('(.*) // (-?\d+), (.*)', name) if change == 'd': new_path = None else: new_path = m.group(1) old_rev = int(m.group(2)) if old_rev < 0: old_rev = None old_path = m.group(3) elif change == 'D': # 'D'elete new_path = None old_path = name old_rev = None elif change == 'A': # 'A'dd new_path = name old_path = old_rev = None else: # 'M'odify new_path = old_path = name old_rev = None if old_path and not old_rev: # 'D' and 'M' history = svn.fs.node_history(self.old_root, old_path, self.pool) history = svn.fs.history_prev(history, 0, self.pool) # what an API... old_rev = svn.fs.history_location(history, self.pool)[1] # Note: 'node_created_rev' doesn't work reliably key = (new_path or old_path) info.append((key, change, new_path, old_path, old_rev))
5304b982a6c96671fea398b5c0665537d7d0f9ec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/5304b982a6c96671fea398b5c0665537d7d0f9ec/Changeset.py
self.add_link('alternate', '?format=diff', 'Unified Diff',
self.add_link(req, 'alternate', '?format=diff', 'Unified Diff',
def render(self, req): self.perm.assert_permission (perm.CHANGESET_VIEW)
5304b982a6c96671fea398b5c0665537d7d0f9ec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/5304b982a6c96671fea398b5c0665537d7d0f9ec/Changeset.py
self.add_link('alternate', '?format=zip', 'Zip Archive',
self.add_link(req, 'alternate', '?format=zip', 'Zip Archive',
def render(self, req): self.perm.assert_permission (perm.CHANGESET_VIEW)
5304b982a6c96671fea398b5c0665537d7d0f9ec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/5304b982a6c96671fea398b5c0665537d7d0f9ec/Changeset.py
self.add_link('first', self.env.href.changeset(1), 'Changeset 1') self.add_link('prev', self.env.href.changeset(self.rev - 1),
self.add_link(req, 'first', self.env.href.changeset(1), 'Changeset 1') self.add_link(req, 'prev', self.env.href.changeset(self.rev - 1),
def render(self, req): self.perm.assert_permission (perm.CHANGESET_VIEW)
5304b982a6c96671fea398b5c0665537d7d0f9ec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/5304b982a6c96671fea398b5c0665537d7d0f9ec/Changeset.py
self.add_link('next', self.env.href.changeset(self.rev + 1),
self.add_link(req, 'next', self.env.href.changeset(self.rev + 1),
def render(self, req): self.perm.assert_permission (perm.CHANGESET_VIEW)
5304b982a6c96671fea398b5c0665537d7d0f9ec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/5304b982a6c96671fea398b5c0665537d7d0f9ec/Changeset.py
self.add_link('last', self.env.href.changeset(youngest_rev),
self.add_link(req, 'last', self.env.href.changeset(youngest_rev),
def render(self, req): self.perm.assert_permission (perm.CHANGESET_VIEW)
5304b982a6c96671fea398b5c0665537d7d0f9ec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/5304b982a6c96671fea398b5c0665537d7d0f9ec/Changeset.py
mimetype = mimetypes.guess_type(path)[0] or \ 'application/octet-stream'
mimetype = get_mimetype(path) or 'application/octet-stream'
def send_file(self, path, mimetype=None): """Send a local file to the browser. This method includes the "Last-Modified", "Content-Type" and "Content-Length" headers in the response, corresponding to the file attributes. It also checks the last modification time of the local file against the "If-Modified-Since" provided by the user agent, and sends a "304 Not Modified" response if it matches. """ if not os.path.isfile(path): raise HTTPNotFound("File %s not found" % path)
3e4f52d418a606c023b2582e2999dd888f8e6e8e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/3e4f52d418a606c023b2582e2999dd888f8e6e8e/api.py
if not authenticated and self.last_visit: if time.time() - self.last_visit > UPDATE_INTERVAL: self.bake_cookie()
if not authenticated and refresh_cookie: self.bake_cookie()
def get_session(self, sid, authenticated=False): db = self.env.get_db_cnx() cursor = db.cursor() self.sid = sid cursor.execute("SELECT last_visit FROM session " "WHERE sid=%s AND authenticated=%s", (sid, int(authenticated))) row = cursor.fetchone() if not row: return self._new = False self.last_visit = int(row[0]) cursor.execute("SELECT name,value FROM session_attribute " "WHERE sid=%s and authenticated=%s", (sid, int(authenticated))) for name, value in cursor: self[name] = value self._old.update(self)
c4750c15b54885f44055d6ce3431f4d9775dc380 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/c4750c15b54885f44055d6ce3431f4d9775dc380/session.py
'title': util.row[0],
'title': row[0],
def _render_confirm_delete(self, req, db, id): req.perm.assert_permission('REPORT_DELETE')
5a0824890fb594416ef096e4f37d0234096076ef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/5a0824890fb594416ef096e4f37d0234096076ef/report.py
time.strftime("%a, %d %b %Y %H:%M:%S GMT", self.last_modified)) req.send_header('Pragma', 'no-cache') req.send_header('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT') req.send_header('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0') req.send_header('Cache-Control', 'post-check=0, pre-check=0')
time.strftime("%a, %d %b %Y %H:%M:%S GMT", self.last_modified))
def display_raw(self, req): req.send_response(200) req.send_header('Content-Type', self.mime_type) req.send_header('Content-Length', str(self.length)) req.send_header('Last-Modified', time.strftime("%a, %d %b %Y %H:%M:%S GMT", self.last_modified)) req.send_header('Pragma', 'no-cache') req.send_header('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT') req.send_header('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0') req.send_header('Cache-Control', 'post-check=0, pre-check=0') req.end_headers() i = 0 while 1: data = self.read_func(self.CHUNK_SIZE) if not data: break req.write(data) i += self.CHUNK_SIZE
74120833ed550d69a6a65e69042631dfac99a114 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/74120833ed550d69a6a65e69042631dfac99a114/File.py
args[x] = _args[x].value
argv = _args[x] if type(argv) == list: argv = argv[0] args[x] = argv.value
def real_main(): import sync import Href import perm import auth from util import dict_get_with_default, redirect path_info = os.getenv('PATH_INFO') remote_addr = os.getenv('REMOTE_ADDR') remote_user = os.getenv('REMOTE_USER') http_cookie = os.getenv('HTTP_COOKIE') http_referer = os.getenv('HTTP_REFERER') cgi_location = os.getenv('SCRIPT_NAME') database = open_database() config = database.load_config() Href.initialize(cgi_location) # Authenticate the user cookie = Cookie.SimpleCookie(http_cookie) if cookie.has_key('trac_auth'): auth_cookie = cookie['trac_auth'].value else: auth_cookie = None authenticator = auth.Authenticator(database, auth_cookie, remote_addr) if path_info == '/logout': authenticator.logout() redirect (http_referer or Href.href.wiki()) elif remote_user and authenticator.authname == 'anonymous': auth_cookie = authenticator.login(remote_user, remote_addr) # send the cookie to the browser as a http header cookie = Cookie.SimpleCookie() cookie['trac_auth'] = auth_cookie cookie['trac_auth']['path'] = cgi_location print cookie.output() if path_info == '/login': redirect (http_referer or Href.href.wiki()) # Parse arguments args = parse_args(path_info) _args = cgi.FieldStorage() for x in _args.keys(): args[x] = _args[x].value # Load the selected module mode = dict_get_with_default(args, 'mode', 'wiki') module_name, constructor_name, need_svn = modules[mode] module = __import__(module_name, globals(), locals(), []) constructor = getattr(module, constructor_name) module = constructor(config, args) module._name = mode module.db = database module.authname = authenticator.authname module.remote_addr = remote_addr module.cgi_location = cgi_location module.perm = perm.PermissionCache(database, authenticator.authname) module.perm.add_to_hdf(module.cgi.hdf) # Only open the subversion repository for the modules that really # need it. This saves us some precious time. if need_svn: from svn import util, repos, core core.apr_initialize() pool = core.svn_pool_create(None) repos_dir = config['general']['repository_dir'] # Remove any trailing slash or else subversion might abort if not os.path.split(repos_dir)[1]: repos_dir = os.path.split(repos_dir)[0] rep = repos.svn_repos_open(repos_dir, pool) fs_ptr = repos.svn_repos_fs(rep) module.repos = rep module.fs_ptr = fs_ptr sync.sync(database, rep, fs_ptr, pool) else: pool = None # Let the wiki module build a dictionary of all page names import Wiki Wiki.populate_page_dict(database) module.pool = pool module.run() if pool: core.svn_pool_destroy(pool) core.apr_terminate()
df6867cff3173ed1f4d48d334ee012b5904b9637 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/df6867cff3173ed1f4d48d334ee012b5904b9637/trac.py
'session for user %s' % (sid, req.authname))
'session for user %s' % (sid, self.req.authname))
def promote_session(self, sid): """ Promotes an anonymous session to an authenticated session, if there is no preexisting session data for that user name. """ assert self.req.authname != 'anonymous', \ 'Cannot promote session of anonymous user'
c37148ae73c202fd29b7ddf1dde3519d387817c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/c37148ae73c202fd29b7ddf1dde3519d387817c9/session.py
if self.hasTickets(): raise Exception("Will not modify database with existing tickets!")
self.assertNoTickets()
def setSeverityList(self, s): """Remove all severities, set them to `s`""" if self.hasTickets(): raise Exception("Will not modify database with existing tickets!") c = self.db().cursor() c.execute("""DELETE FROM enum WHERE type='severity'""") for value, i in s: print "inserting severity ", value, " ", i c.execute("""INSERT INTO enum (type, name, value) VALUES (%s, %s, %s)""", "severity", value.encode('utf-8'), i) self.db().commit()
278262b3815812ba5a808f31a44ab5da9fcaadf9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/278262b3815812ba5a808f31a44ab5da9fcaadf9/bugzilla2trac.py
if self.hasTickets(): raise Exception("Will not modify database with existing tickets!")
self.assertNoTickets()
def setPriorityList(self, s): """Remove all priorities, set them to `s`""" if self.hasTickets(): raise Exception("Will not modify database with existing tickets!") c = self.db().cursor() c.execute("""DELETE FROM enum WHERE type='priority'""") for value, i in s: print "inserting priority ", value, " ", i c.execute("""INSERT INTO enum (type, name, value) VALUES (%s, %s, %s)""", "priority", value.encode('utf-8'), i) self.db().commit()
278262b3815812ba5a808f31a44ab5da9fcaadf9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/278262b3815812ba5a808f31a44ab5da9fcaadf9/bugzilla2trac.py
if self.hasTickets(): raise Exception("Will not modify database with existing tickets!")
self.assertNoTickets()
def setComponentList(self, l, key): """Remove all components, set them to `l`""" if self.hasTickets(): raise Exception("Will not modify database with existing tickets!") c = self.db().cursor() c.execute("""DELETE FROM component""") for comp in l: print "inserting component ", comp[key] c.execute("""INSERT INTO component (name) VALUES (%s)""", comp[key].encode('utf-8')) self.db().commit()
278262b3815812ba5a808f31a44ab5da9fcaadf9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/278262b3815812ba5a808f31a44ab5da9fcaadf9/bugzilla2trac.py
if self.hasTickets(): raise Exception("Will not modify database with existing tickets!")
self.assertNoTickets()
def setVersionList(self, v, key): """Remove all versions, set them to `v`""" if self.hasTickets(): raise Exception("Will not modify database with existing tickets!") c = self.db().cursor() c.execute("""DELETE FROM version""") for vers in v: print "inserting version ", vers[key] c.execute("""INSERT INTO version (name) VALUES (%s)""", vers[key].encode('utf-8')) self.db().commit()
278262b3815812ba5a808f31a44ab5da9fcaadf9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/278262b3815812ba5a808f31a44ab5da9fcaadf9/bugzilla2trac.py
if self.hasTickets(): raise Exception("Will not modify database with existing tickets!")
self.assertNoTickets()
def setMilestoneList(self, m, key): """Remove all milestones, set them to `m`""" if self.hasTickets(): raise Exception("Will not modify database with existing tickets!") c = self.db().cursor() c.execute("""DELETE FROM milestone""") for ms in m: print "inserting milestone ", ms[key] c.execute("""INSERT INTO milestone (name) VALUES (%s)""", ms[key].encode('utf-8')) self.db().commit()
278262b3815812ba5a808f31a44ab5da9fcaadf9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/278262b3815812ba5a808f31a44ab5da9fcaadf9/bugzilla2trac.py
def addTicket(self, time, changetime, component,
def addTicket(self, id, time, changetime, component,
def addTicket(self, time, changetime, component, severity, priority, owner, reporter, cc, version, milestone, status, resolution, summary, description, keywords): c = self.db().cursor()
278262b3815812ba5a808f31a44ab5da9fcaadf9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/278262b3815812ba5a808f31a44ab5da9fcaadf9/bugzilla2trac.py
c.execute("""INSERT INTO ticket (time, changetime, component,
desc = description.encode('utf-8') if PREFORMAT_COMMENTS: desc = '{{{\n%s\n}}}' % desc print "inserting ticket %s -- %s" % (id, summary) c.execute("""INSERT INTO ticket (id, time, changetime, component,
def addTicket(self, time, changetime, component, severity, priority, owner, reporter, cc, version, milestone, status, resolution, summary, description, keywords): c = self.db().cursor()
278262b3815812ba5a808f31a44ab5da9fcaadf9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/278262b3815812ba5a808f31a44ab5da9fcaadf9/bugzilla2trac.py
VALUES (%s, %s, %s,
VALUES (%s, %s, %s, %s,
def addTicket(self, time, changetime, component, severity, priority, owner, reporter, cc, version, milestone, status, resolution, summary, description, keywords): c = self.db().cursor()
278262b3815812ba5a808f31a44ab5da9fcaadf9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/278262b3815812ba5a808f31a44ab5da9fcaadf9/bugzilla2trac.py
time.strftime('%s'), changetime.strftime('%s'), component.encode('utf-8'),
id, time.strftime('%s'), changetime.strftime('%s'), component.encode('utf-8'),
def addTicket(self, time, changetime, component, severity, priority, owner, reporter, cc, version, milestone, status, resolution, summary, description, keywords): c = self.db().cursor()
278262b3815812ba5a808f31a44ab5da9fcaadf9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/278262b3815812ba5a808f31a44ab5da9fcaadf9/bugzilla2trac.py
summary.encode('utf-8'), '{{{\n%s\n}}}' % (description.encode('utf-8'), ), keywords)
summary.encode('utf-8'), desc, keywords)
def addTicket(self, time, changetime, component, severity, priority, owner, reporter, cc, version, milestone, status, resolution, summary, description, keywords): c = self.db().cursor()
278262b3815812ba5a808f31a44ab5da9fcaadf9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/278262b3815812ba5a808f31a44ab5da9fcaadf9/bugzilla2trac.py
ticket, time.strftime('%s'), author, 'comment', '', '{{{\n%s\n}}}' % (value.encode('utf-8'), ))
ticket, time.strftime('%s'), author, 'comment', '', comment)
def addTicketComment(self, ticket, time, author, value): c = self.db().cursor() c.execute("""INSERT INTO ticket_change (ticket, time, author, field, oldvalue, newvalue) VALUES (%s, %s, %s, %s, %s, %s)""", ticket, time.strftime('%s'), author, 'comment', '', '{{{\n%s\n}}}' % (value.encode('utf-8'), )) self.db().commit()
278262b3815812ba5a808f31a44ab5da9fcaadf9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/278262b3815812ba5a808f31a44ab5da9fcaadf9/bugzilla2trac.py
class TheBugzillaConverter: def __init__(self, _db, _host, _user, _password, _env, _force): try: print "Bugzilla MySQL('%s':'%s':'%s':'%s'): connecting..." % (_db, _host, _user, _password) self.mysql_con = MySQLdb.connect(host=_host, user=_user, passwd=_password, db=_db, compress=1, cursorclass=MySQLdb.cursors.DictCursor) self.mysql_cur = self.mysql_con.cursor() print "Trac SQLite('%s'): connecting..." % (_env) trac = TracDatabase(_env) if _force == 1: print "cleaning all tickets..." c = trac.db().cursor() c.execute("""DELETE FROM ticket_change""") trac.db().commit() c.execute("""DELETE FROM ticket""") trac.db().commit() severities = (('blocker', '1'), ('critical', '2'), ('major', '3'), ('normal', '4'), ('minor', '5'), ('trivial', '6'), ('enhancement', '7')) trac.setSeverityList(severities) self.mysql_cur.execute("SELECT value FROM components") components = self.mysql_cur.fetchall() trac.setComponentList(components, 'value') priorities = (('P1', '1'), ('P2', '2'), ('P3', '3'), ('P4', '4'), ('P5', '5')) trac.setPriorityList(priorities) self.mysql_cur.execute("SELECT value FROM versions") versions = self.mysql_cur.fetchall() trac.setVersionList(versions, 'value') self.mysql_cur.execute("SELECT value FROM milestones") milestones = self.mysql_cur.fetchall() if milestones[0] == '---': trac.setMilestoneList(milestones, 'value') else: trac.setMilestoneList([], '') self.mysql_cur.execute("SELECT * FROM bugs ORDER BY bug_id") bugs = self.mysql_cur.fetchall() ticket = {} for bug in bugs: ticket['time'] = bug['creation_ts'] ticket['changetime'] = bug['delta_ts'] ticket['component'] = bug['component'] ticket['severity'] = bug['bug_severity'] ticket['priority'] = bug['priority'] self.mysql_cur.execute("SELECT * FROM profiles WHERE userid = " + str(bug['assigned_to'])) owner = self.mysql_cur.fetchall() if len(owner) == 0: ticket['owner'] = '' else: ticket['owner'] = owner[0]['login_name'] self.mysql_cur.execute("SELECT * FROM profiles WHERE userid = " + str(bug['reporter'])) reporter = self.mysql_cur.fetchall() if len(reporter) == 0: ticket['reporter'] = '' else: ticket['reporter'] = reporter[0]['login_name'] self.mysql_cur.execute("SELECT * FROM cc WHERE bug_id = " + str(bug['bug_id'])) cc_list = self.mysql_cur.fetchall() cc_str = '' last = 1 for cc in cc_list: self.mysql_cur.execute("SELECT * FROM profiles WHERE userid = " + str(cc['who'])) cc_profile = self.mysql_cur.fetchall() cc_str = cc_str + cc_profile[0]['login_name'] if len(cc_list) != last: cc_str = cc_str + ', ' last = last + 1 ticket['cc'] = cc_str ticket['version'] = bug['version'] if bug['target_milestone'] == '---': ticket['milestone'] = '' else: ticket['milestone'] = bug['target_milestone'] ticket['status'] = bug['bug_status'].lower() ticket['resolution'] = bug['resolution'].lower() if ticket['status'] == 'open': if owner != '': ticket['status'] = 'assigned' else: ticket['status'] = 'new' elif ticket['status'] == 'review ready': if ticket['owner'] != '': ticket['status'] = 'assigned' else: ticket['status'] = 'new' ticket['resolution'] = 'fixed' elif ticket['status'] == 'review completed': ticket['status'] = 'closed' ticket['resolution'] = 'fixed' elif ticket['status'] == 'review rejected': if ticket['owner'] != '': ticket['status'] = 'assigned' else: ticket['status'] = 'new' ticket['summary'] = bug['short_desc'] self.mysql_cur.execute("SELECT * FROM longdescs WHERE bug_id = " + str(bug['bug_id'])) longdescs = self.mysql_cur.fetchall() if len(longdescs) == 0: ticket['description'] = '' else: ticket['description'] = longdescs[0]['thetext'] ticket['keywords'] = bug['keywords'] i = trac.addTicket(time=ticket['time'], changetime=ticket['changetime'], component=ticket['component'], severity=ticket['severity'], priority=ticket['priority'], owner=ticket['owner'], reporter=ticket['reporter'], cc=ticket['cc'], version=ticket['version'], milestone=ticket['milestone'], status=ticket['status'], resolution=ticket['resolution'], summary=ticket['summary'], description=ticket['description'], keywords=ticket['keywords']) iter = 0 for desc in longdescs: if iter == 0: iter = iter + 1 continue self.mysql_cur.execute("SELECT * FROM profiles WHERE userid = " + str(desc['who'])) who = self.mysql_cur.fetchall() if len(who) == 0: who_name = '' else: who_name = who[0]['login_name'] trac.addTicketComment(ticket=i, time=desc['bug_when'], author=who_name, value=desc['thetext']) iter = iter + 1 self.mysql_cur.execute("SELECT * FROM bugs_activity WHERE bug_id = " + str(bug['bug_id'])) bugs_activity = self.mysql_cur.fetchall() for activity in bugs_activity: self.mysql_cur.execute("SELECT * FROM profiles WHERE userid = " + str(activity['who'])) who = self.mysql_cur.fetchall() if len(who) == 0: who_name = '' else: who_name = who[0]['login_name'] self.mysql_cur.execute("SELECT * FROM fielddefs WHERE fieldid = " + str(activity['fieldid'])) field = self.mysql_cur.fetchall() if len(field) == 0: field_name = '' else: field_name = field[0]['name'].lower() removed = activity['removed'].lower() added = activity['added'].lower() 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 activity['removed'] == 'review ready': removed = 'assigned' elif activity['removed'] == 'review completed': removed = 'closed' elif activity['removed'] == 'review rejected': removed = 'assigned' if activity['added'] == 'review ready': added = 'assigned' elif activity['added'] == 'review completed': added = 'closed' elif activity['added'] == 'review rejected': added = 'assigned' elif field_name.lower() == 'short_desc': field_name = 'summary' try: trac.addTicketChange(ticket=i, time=activity['bug_when'], author=who_name, field=field_name, oldvalue=removed, newvalue=added) except Exception, e: print "bug activity " + str(activity['fieldid']) + " skipped for reason: ", e print "inserted ticket ", str(i), " bug_id ", str(bug['bug_id']) print "Success!" except Exception, e: print 'Error:', e
def addAttachment(self, id, attachment, description, author): print 'inserting attachment for ticket %s -- %s' % (id, description) self.env.create_attachment(self.db(), 'ticket', str(id), attachment, description, author, 'unknown') def getLoginName(self, cursor, userid): if userid not in self.loginNameCache: cursor.execute("SELECT * FROM profiles WHERE userid = %s" % userid) loginName = cursor.fetchall() if loginName: loginName = loginName[0]['login_name'] else: print 'warning: unknown bugzilla userid %d, recording as anonymous' % userid loginName = 'anonymous' self.loginNameCache[userid] = loginName return self.loginNameCache[userid] def getFieldName(self, cursor, fieldid): if fieldid not in self.fieldNameCache: cursor.execute("SELECT * FROM fielddefs WHERE fieldid = %s" % fieldid) fieldName = cursor.fetchall() if fieldName: fieldName = fieldName[0]['name'].lower() else: print 'warning: unknown bugzilla fieldid %d, recording as unknown' % userid fieldName = 'unknown' self.fieldNameCache[fieldid] = fieldName return self.fieldNameCache[fieldid] def productFilter(fieldName, products): first = True result = '' for product in products: if not first: result += " or " first = False result += "%s = '%s'" % (fieldName, product) return result def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' print "Bugzilla MySQL('%s':'%s':'%s':'%s'): connecting..." % (_db, _host, _user, _password) mysql_con = MySQLdb.connect(host=_host, user=_user, passwd=_password, db=_db, compress=1, cursorclass=MySQLdb.cursors.DictCursor) mysql_cur = mysql_con.cursor() print "Trac SQLite('%s'): connecting..." % (_env) trac = TracDatabase(_env) if _force == 1: print "cleaning all tickets..." c = trac.db().cursor() c.execute("""DELETE FROM ticket_change""") trac.db().commit() c.execute("""DELETE FROM ticket""") trac.db().commit() c.execute("""DELETE FROM attachment""") os.system('rm -rf %s' % trac.env.get_attachments_dir()) os.mkdir(trac.env.get_attachments_dir()) trac.db().commit() print print "1. import severities..." severities = (('blocker', '1'), ('critical', '2'), ('major', '3'), ('normal', '4'), ('minor', '5'), ('trivial', '6'), ('enhancement', '7')) trac.setSeverityList(severities) print print "2. import components..." sql = "SELECT DISTINCTROW value FROM components" if PRODUCTS: sql += " WHERE %s" % productFilter('program', PRODUCTS) mysql_cur.execute(sql) components = mysql_cur.fetchall() trac.setComponentList(components, 'value') print print "3. import priorities..." priorities = (('P1', '1'), ('P2', '2'), ('P3', '3'), ('P4', '4'), ('P5', '5')) trac.setPriorityList(priorities) print print "4. import versions..." sql = "SELECT DISTINCTROW value FROM versions" if PRODUCTS: sql += " WHERE %s" % productFilter('program', PRODUCTS) mysql_cur.execute(sql) versions = mysql_cur.fetchall() trac.setVersionList(versions, 'value') print print "5. import milestones..." mysql_cur.execute("SELECT value FROM milestones") milestones = mysql_cur.fetchall() 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" mysql_cur.execute(sql) bugs = mysql_cur.fetchall() print print "7. import bugs and bug activity..." for bug in bugs: bugid = bug['bug_id'] ticket = {} keywords = [] ticket['id'] = bugid ticket['time'] = bug['creation_ts'] ticket['changetime'] = bug['delta_ts'] ticket['component'] = bug['component'] ticket['severity'] = bug['bug_severity'] ticket['priority'] = bug['priority'] ticket['owner'] = trac.getLoginName(mysql_cur, bug['assigned_to']) ticket['reporter'] = trac.getLoginName(mysql_cur, bug['reporter']) mysql_cur.execute("SELECT * FROM cc WHERE bug_id = %s" % bugid) cc_records = mysql_cur.fetchall() cc_list = [] for cc in cc_records: cc_list.append(trac.getLoginName(mysql_cur, cc['who'])) ticket['cc'] = string.join(cc_list, ', ') ticket['version'] = bug['version'] if bug['target_milestone'] == '---': ticket['milestone'] = '' else: ticket['milestone'] = bug['target_milestone'] bug_status = bug['bug_status'].lower() ticket['status'] = statusXlator[bug_status] ticket['resolution'] = bug['resolution'].lower() if bug_status == 'open': if owner != '': ticket['status'] = 'assigned' else: ticket['status'] = 'new' ticket['summary'] = bug['short_desc'] keywords = string.split(bug['keywords'], ' ') mysql_cur.execute("SELECT * FROM longdescs WHERE bug_id = %s" % bugid) longdescs = list(mysql_cur.fetchall()) if len(longdescs) == 0: ticket['description'] = '' else: ticket['description'] = longdescs[0]['thetext'] del longdescs[0] for desc in longdescs: ignore = False for comment in IGNORE_COMMENTS: if re.match(comment, desc['thetext']): ignore = True if ignore: continue trac.addTicketComment(ticket=bugid, time=desc['bug_when'], author=trac.getLoginName(mysql_cur, desc['who']), value=desc['thetext']) mysql_cur.execute("SELECT * FROM bugs_activity WHERE bug_id = %s ORDER BY bug_when" % bugid) bugs_activity = mysql_cur.fetchall() resolution = '' for activity in bugs_activity: field_name = trac.getFieldName(mysql_cur, activity['fieldid']).lower() removed = activity[activityFields['removed']] added = activity[activityFields['added']] if field_name == 'resolution' or field_name == 'bug_status': removed = removed.lower() added = added.lower() if field_name == 'resolution': resolution = added.lower() keywordChange = False oldKeywords = string.join(keywords, " ") 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 removed in STATUS_KEYWORDS: kw = STATUS_KEYWORDS[removed] if kw in keywords: keywords.remove(kw) else: oldKeywords = string.join(keywords + [ kw ], " ") keywordChange = True if added in STATUS_KEYWORDS: kw = STATUS_KEYWORDS[added] keywords.append(kw) keywordChange = True added = statusXlator[added] removed = statusXlator[removed] 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[added] keywords.append(kw) keywordChange = True if keywordChange: newKeywords = string.join(keywords, " ") trac.addTicketChange(ticket=bugid, time=activity['bug_when'], author=trac.getLoginName(mysql_cur, activity['who']), field='keywords', oldvalue=oldKeywords, newvalue=newKeywords) if field_name in IGNORED_ACTIVITY_FIELDS: continue if added == removed: continue trac.addTicketChange(ticket=bugid, time=activity['bug_when'], author=trac.getLoginName(mysql_cur, activity['who']), field=field_name, oldvalue=removed, newvalue=added) if not ticket['resolution'] and ticket['status'] == 'closed': ticket['resolution'] = resolution if bug['bug_status'] in STATUS_KEYWORDS: kw = STATUS_KEYWORDS[bug['bug_status']] if kw not in keywords: keywords.append(kw) if bug['product'] in PRODUCT_KEYWORDS: kw = PRODUCT_KEYWORDS[bug['product']] if kw not in keywords: keywords.append(kw) mysql_cur.execute("SELECT * FROM attachments WHERE bug_id = %s" % bugid) attachments = mysql_cur.fetchall() for a in attachments: author = trac.getLoginName(mysql_cur, a['submitter_id']) tracAttachment = Attachment(a['filename'], a['thedata']) trac.addAttachment(bugid, tracAttachment, a['description'], author) ticket['keywords'] = string.join(keywords) ticketid = trac.addTicket(**ticket) print "Success!"
def addTicketChange(self, ticket, time, author, field, oldvalue, newvalue): c = self.db().cursor() c.execute("""INSERT INTO ticket_change (ticket, time, author, field, oldvalue, newvalue) VALUES (%s, %s, %s, %s, %s, %s)""", ticket, time.strftime('%s'), author, field, oldvalue.encode('utf-8'), newvalue.encode('utf-8')) self.db().commit()
278262b3815812ba5a808f31a44ab5da9fcaadf9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/278262b3815812ba5a808f31a44ab5da9fcaadf9/bugzilla2trac.py
print """\ Usage: bugzilla2trac.py --db <MySQL dbname> - Bugzilla's database [-h | --host <MySQL hostname>] - Bugzilla's DNS host name [-u | --user <MySQL username>] - effective Bugzilla's database user [-p | --passwd <MySQL password>] - Bugzilla's user password --tracenv /path/to/trac/env - full path to Trac db environment [-f | --force] - force to clean up Trac db [--help | help] - this help info""" sys.exit(0) if __name__ == "__main__": db = '' host = 'localhost' user = '' password = '' env = '' force = 0 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): db = sys.argv[iter+1] iter = iter + 1 elif sys.argv[iter] in ['-h', '--host'] and iter+1 < len(sys.argv): host = sys.argv[iter+1] iter = iter + 1 elif sys.argv[iter] in ['-u', '--user'] and iter+1 < len(sys.argv): user = sys.argv[iter+1] iter = iter + 1 elif sys.argv[iter] in ['-p', '--passwd'] and iter+1 < len(sys.argv): passwd = sys.argv[iter+1] iter = iter + 1 elif sys.argv[iter] in ['--tracenv'] and iter+1 < len(sys.argv): env = sys.argv[iter+1] iter = iter + 1 elif sys.argv[iter] in ['-f', '--force']: force = 1 else: print "Error: unknown parameter: " + sys.argv[iter] sys.exit(0) iter = iter + 1 else: usage() TheBugzillaConverter(db, host, user, password, env, force)
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 <MySQL hostname> - Bugzilla's DNS host name" print " -u | --user <MySQL username> - effective Bugzilla's database user" print " -p | --passwd <MySQL password> - Bugzilla's user password" print " -c | --clean - remove current Trac tickets before importing" print " --help | help - this help info" print print "Additional configuration options can be defined directly in the script." print sys.exit(0) 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[iter] in ['-h', '--host'] and iter+1 < len(sys.argv): BZ_HOST = sys.argv[iter+1] iter = iter + 1 elif sys.argv[iter] in ['-u', '--user'] and iter+1 < len(sys.argv): BZ_USER = sys.argv[iter+1] iter = iter + 1 elif sys.argv[iter] in ['-p', '--passwd'] and iter+1 < len(sys.argv): BZ_PASSWORD = sys.argv[iter+1] iter = iter + 1 elif sys.argv[iter] in ['--tracenv'] and iter+1 < len(sys.argv): TRAC_ENV = sys.argv[iter+1] iter = iter + 1 elif sys.argv[iter] in ['-c', '--clean']: TRAC_CLEAN = 1 else: print "Error: unknown parameter: " + sys.argv[iter] sys.exit(0) iter = iter + 1 else: usage() convert(BZ_DB, BZ_HOST, BZ_USER, BZ_PASSWORD, TRAC_ENV, TRAC_CLEAN) if __name__ == '__main__': main()
def usage(): print """\
278262b3815812ba5a808f31a44ab5da9fcaadf9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/278262b3815812ba5a808f31a44ab5da9fcaadf9/bugzilla2trac.py
self.assertEqual(16, self.repos.normalize_rev('latest')) self.assertEqual(16, self.repos.normalize_rev('head')) self.assertEqual(16, self.repos.normalize_rev('')) self.assertEqual(16, self.repos.normalize_rev(None))
self.assertEqual(17, self.repos.normalize_rev('latest')) self.assertEqual(17, self.repos.normalize_rev('head')) self.assertEqual(17, self.repos.normalize_rev('')) self.assertEqual(17, self.repos.normalize_rev(None))
def test_repos_normalize_rev(self): self.assertEqual(16, self.repos.normalize_rev('latest')) self.assertEqual(16, self.repos.normalize_rev('head')) self.assertEqual(16, self.repos.normalize_rev('')) self.assertEqual(16, self.repos.normalize_rev(None)) self.assertEqual(11, self.repos.normalize_rev('11')) self.assertEqual(11, self.repos.normalize_rev(11))
19ecd012506375489920938d2a952ccb2c5b3ac4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/19ecd012506375489920938d2a952ccb2c5b3ac4/svn_fs.py
self.assertEqual(16, self.repos.youngest_rev)
self.assertEqual(17, self.repos.youngest_rev)
def test_rev_navigation(self): self.assertEqual(1, self.repos.oldest_rev) self.assertEqual(None, self.repos.previous_rev(0)) self.assertEqual(None, self.repos.previous_rev(1)) self.assertEqual(16, self.repos.youngest_rev) self.assertEqual(6, self.repos.next_rev(5)) self.assertEqual(7, self.repos.next_rev(6)) # ... self.assertEqual(None, self.repos.next_rev(16))
19ecd012506375489920938d2a952ccb2c5b3ac4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/19ecd012506375489920938d2a952ccb2c5b3ac4/svn_fs.py
self.assertEqual(None, self.repos.next_rev(16))
self.assertEqual(None, self.repos.next_rev(17))
def test_rev_navigation(self): self.assertEqual(1, self.repos.oldest_rev) self.assertEqual(None, self.repos.previous_rev(0)) self.assertEqual(None, self.repos.previous_rev(1)) self.assertEqual(16, self.repos.youngest_rev) self.assertEqual(6, self.repos.next_rev(5)) self.assertEqual(7, self.repos.next_rev(6)) # ... self.assertEqual(None, self.repos.next_rev(16))
19ecd012506375489920938d2a952ccb2c5b3ac4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/19ecd012506375489920938d2a952ccb2c5b3ac4/svn_fs.py
self.assertEqual(14, node.rev) self.assertEqual(1133340423L, node.last_modified)
self.assertEqual(17, node.rev) self.assertEqual(1143808225L, node.last_modified)
def test_get_node(self): node = self.repos.get_node('/trunk') self.assertEqual('trunk', node.name) self.assertEqual('/trunk', node.path) self.assertEqual(Node.DIRECTORY, node.kind) self.assertEqual(14, node.rev) self.assertEqual(1133340423L, node.last_modified) node = self.repos.get_node('/trunk/README.txt') self.assertEqual('README.txt', node.name) self.assertEqual('/trunk/README.txt', node.path) self.assertEqual(Node.FILE, node.kind) self.assertEqual(3, node.rev) self.assertEqual(1112361898, node.last_modified)
19ecd012506375489920938d2a952ccb2c5b3ac4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/19ecd012506375489920938d2a952ccb2c5b3ac4/svn_fs.py
self.assertEqual(14, self.repos.normalize_rev('latest')) self.assertEqual(14, self.repos.normalize_rev('head')) self.assertEqual(14, self.repos.normalize_rev('')) self.assertEqual(14, self.repos.normalize_rev(None))
self.assertEqual(17, self.repos.normalize_rev('latest')) self.assertEqual(17, self.repos.normalize_rev('head')) self.assertEqual(17, self.repos.normalize_rev('')) self.assertEqual(17, self.repos.normalize_rev(None))
def test_repos_normalize_rev(self): self.assertEqual(14, self.repos.normalize_rev('latest')) self.assertEqual(14, self.repos.normalize_rev('head')) self.assertEqual(14, self.repos.normalize_rev('')) self.assertEqual(14, self.repos.normalize_rev(None)) self.assertEqual(5, self.repos.normalize_rev('5')) self.assertEqual(5, self.repos.normalize_rev(5))
19ecd012506375489920938d2a952ccb2c5b3ac4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/19ecd012506375489920938d2a952ccb2c5b3ac4/svn_fs.py
self.assertEqual(14, self.repos.youngest_rev)
self.assertEqual(17, self.repos.youngest_rev)
def test_rev_navigation(self): self.assertEqual(1, self.repos.oldest_rev) self.assertEqual(None, self.repos.previous_rev(0)) self.assertEqual(1, self.repos.previous_rev(2)) self.assertEqual(14, self.repos.youngest_rev) self.assertEqual(2, self.repos.next_rev(1)) self.assertEqual(3, self.repos.next_rev(2)) # ... self.assertEqual(None, self.repos.next_rev(14))
19ecd012506375489920938d2a952ccb2c5b3ac4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/19ecd012506375489920938d2a952ccb2c5b3ac4/svn_fs.py
self.assertEqual(None, self.repos.next_rev(14))
self.assertEqual(None, self.repos.next_rev(17))
def test_rev_navigation(self): self.assertEqual(1, self.repos.oldest_rev) self.assertEqual(None, self.repos.previous_rev(0)) self.assertEqual(1, self.repos.previous_rev(2)) self.assertEqual(14, self.repos.youngest_rev) self.assertEqual(2, self.repos.next_rev(1)) self.assertEqual(3, self.repos.next_rev(2)) # ... self.assertEqual(None, self.repos.next_rev(14))
19ecd012506375489920938d2a952ccb2c5b3ac4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/19ecd012506375489920938d2a952ccb2c5b3ac4/svn_fs.py
root = svn.fs.revision_root(self.fs_ptr, rev, self.pool)
def render(self): FileCommon.render(self) rev = self.args.get('rev', None) self.path = self.args.get('path', '/') if not rev: rev = svn.fs.youngest_rev(self.fs_ptr, self.pool) else: rev = int(rev) self.req.hdf.setValue('file.rev', str(rev)) self.req.hdf.setValue('file.path', self.path) self.req.hdf.setValue('file.rawurl', self.env.href.file(self.path, rev, 'raw')) self.req.hdf.setValue('file.texturl', self.env.href.file(self.path, rev, 'text')) self.req.hdf.setValue('file.logurl', self.env.href.log(self.path)) root = svn.fs.revision_root(self.fs_ptr, rev, self.pool) # Try to do an educated guess about the mime-type self.mime_type = svn.fs.node_prop (root, self.path, svn.util.SVN_PROP_MIME_TYPE, self.pool) if not self.mime_type: self.mime_type = self.env.mimeview.get_mimetype(filename=self.path) or 'text/plain'
ec26cc32f0e56175c64489c2a3059a74dba4cbf6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/ec26cc32f0e56175c64489c2a3059a74dba4cbf6/File.py
def create_report(self, title, sql):
def create_report(self, title, description, sql):
def create_report(self, title, sql): self.perm.assert_permission(perm.REPORT_CREATE)
0027c4b6b513d5e30705c4bc999e43367a18616e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/0027c4b6b513d5e30705c4bc999e43367a18616e/Report.py
cursor.execute('INSERT INTO report (id, title, sql)' 'VALUES (NULL, %s, %s)', title, sql)
cursor.execute('INSERT INTO report (id, title, sql, description)' 'VALUES (NULL, %s, %s, %s)', title, sql, description)
def create_report(self, title, sql): self.perm.assert_permission(perm.REPORT_CREATE)
0027c4b6b513d5e30705c4bc999e43367a18616e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/0027c4b6b513d5e30705c4bc999e43367a18616e/Report.py
title = self.args['title'] sql = self.args['sql'] description = self.args['description']
title = self.args.get('title', '') sql = self.args.get('sql', '') description = self.args.get('description', '')
def commit_changes(self, id): """ saves report changes to the database """ self.perm.assert_permission(perm.REPORT_MODIFY)
0027c4b6b513d5e30705c4bc999e43367a18616e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/0027c4b6b513d5e30705c4bc999e43367a18616e/Report.py