rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
def to_integral(self, rounding = None, context=None):
def to_integral(self, rounding=None, context=None):
def to_integral(self, rounding = None, context=None): """Rounds to the nearest integer, without raising inexact, rounded.""" if self._is_special: ans = self._check_nans(context=context) if ans: return ans if self._exp >= 0: return self if context is None: context = getcontext() flags = context._ignore_flags(Rounded, Inexact) ans = self._rescale(0, rounding, context=context) context._regard_flags(flags) return ans
dab988dd23e6328dadfe8408cd96abf4b017380d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dab988dd23e6328dadfe8408cd96abf4b017380d/decimal.py
ans = ans._fix(context=context)
ans = ans._fix(context)
def sqrt(self, context=None): """Return the square root of self.
dab988dd23e6328dadfe8408cd96abf4b017380d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dab988dd23e6328dadfe8408cd96abf4b017380d/decimal.py
return ans._fix(context=context)
return ans._fix(context)
def sqrt(self, context=None): """Return the square root of self.
dab988dd23e6328dadfe8408cd96abf4b017380d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dab988dd23e6328dadfe8408cd96abf4b017380d/decimal.py
return ans._fix(context=context)
return ans._fix(context)
def max(self, other, context=None): """Returns the larger value.
dab988dd23e6328dadfe8408cd96abf4b017380d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dab988dd23e6328dadfe8408cd96abf4b017380d/decimal.py
return ans._fix(context=context)
return ans._fix(context)
def min(self, other, context=None): """Returns the smaller value.
dab988dd23e6328dadfe8408cd96abf4b017380d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dab988dd23e6328dadfe8408cd96abf4b017380d/decimal.py
return d._fix(context=self)
return d._fix(self)
def create_decimal(self, num='0'): """Creates a new Decimal instance but using self as context.""" d = Decimal(num, context=self) return d._fix(context=self)
dab988dd23e6328dadfe8408cd96abf4b017380d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dab988dd23e6328dadfe8408cd96abf4b017380d/decimal.py
return str(a._fix(context=self))
return str(a._fix(self))
def _apply(self, a): return str(a._fix(context=self))
dab988dd23e6328dadfe8408cd96abf4b017380d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dab988dd23e6328dadfe8408cd96abf4b017380d/decimal.py
vesion string using the format major.minor.build (or patchlevel).
version string using the format major.minor.build (or patchlevel).
def _norm_version(version,build=''): """ Normalize the version and build strings and return a single vesion string using the format major.minor.build (or patchlevel). """ l = string.split(version,'.') if build: l.append(build) try: ints = map(int,l) except ValueError: strings = l else: strings = map(str,ints) version = string.join(strings[:3],'.') return version
e5a7fad356a98f931bbe0d2c9e4b18854510c3dd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e5a7fad356a98f931bbe0d2c9e4b18854510c3dd/platform.py
"setparameters%r: returned %r" % (config + result))
"setparameters%r: returned %r" % (config, result))
def test_setparameters(dsp): # Two configurations for testing: # config1 (8-bit, mono, 8 kHz) should work on even the most # ancient and crufty sound card, but maybe not on special- # purpose high-end hardware # config2 (16-bit, stereo, 44.1kHz) should work on all but the # most ancient and crufty hardware config1 = (ossaudiodev.AFMT_U8, 1, 8000) config2 = (AFMT_S16_NE, 2, 44100) for config in [config1, config2]: (fmt, channels, rate) = config if (dsp.setfmt(fmt) == fmt and dsp.channels(channels) == channels and dsp.speed(rate) == rate): break else: raise RuntimeError("unable to set audio sampling parameters: " "you must have really weird audio hardware") # setparameters() should be able to set this configuration in # either strict or non-strict mode. result = dsp.setparameters(fmt, channels, rate, False) _assert(result == (fmt, channels, rate), "setparameters%r: returned %r" % (config + result)) result = dsp.setparameters(fmt, channels, rate, True) _assert(result == (fmt, channels, rate), "setparameters%r: returned %r" % (config + result))
813669f911d362b12daed634324453df0d6917b0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/813669f911d362b12daed634324453df0d6917b0/test_ossaudiodev.py
"setparameters%r: returned %r" % (config + result))
"setparameters%r: returned %r" % (config, result))
def test_setparameters(dsp): # Two configurations for testing: # config1 (8-bit, mono, 8 kHz) should work on even the most # ancient and crufty sound card, but maybe not on special- # purpose high-end hardware # config2 (16-bit, stereo, 44.1kHz) should work on all but the # most ancient and crufty hardware config1 = (ossaudiodev.AFMT_U8, 1, 8000) config2 = (AFMT_S16_NE, 2, 44100) for config in [config1, config2]: (fmt, channels, rate) = config if (dsp.setfmt(fmt) == fmt and dsp.channels(channels) == channels and dsp.speed(rate) == rate): break else: raise RuntimeError("unable to set audio sampling parameters: " "you must have really weird audio hardware") # setparameters() should be able to set this configuration in # either strict or non-strict mode. result = dsp.setparameters(fmt, channels, rate, False) _assert(result == (fmt, channels, rate), "setparameters%r: returned %r" % (config + result)) result = dsp.setparameters(fmt, channels, rate, True) _assert(result == (fmt, channels, rate), "setparameters%r: returned %r" % (config + result))
813669f911d362b12daed634324453df0d6917b0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/813669f911d362b12daed634324453df0d6917b0/test_ossaudiodev.py
if host[0] == '[' and host[-1] == ']':
if host and host[0] == '[' and host[-1] == ']':
def _set_hostport(self, host, port): if port is None: i = host.rfind(':') j = host.rfind(']') # ipv6 addresses have [...] if i > j: try: port = int(host[i+1:]) except ValueError: raise InvalidURL("nonnumeric port: '%s'" % host[i+1:]) host = host[:i] else: port = self.default_port if host[0] == '[' and host[-1] == ']': host = host[1:-1] self.host = host self.port = port
4d03791632a9b7a6d96640df09466969aec81b71 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4d03791632a9b7a6d96640df09466969aec81b71/httplib.py
if url[:2] == '//' and url[2:3] != '/':
if url[:2] == '//' and url[2:3] != '/' and url[2:12] != 'localhost/':
def open_file(self, url): """Use local file or FTP depending on form of URL.""" if url[:2] == '//' and url[2:3] != '/': return self.open_ftp(url) else: return self.open_local_file(url)
3ae2dc5e5ea7521426ce3f34afa18147435ede5c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ae2dc5e5ea7521426ce3f34afa18147435ede5c/urllib.py
__version__ = "1.0b2"
__version__ = "1.0b3"
def _stringify(string): return string
78eedce3ffabc0c8d5af988ab7f72d3749f995db /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/78eedce3ffabc0c8d5af988ab7f72d3749f995db/xmlrpclib.py
class Error:
class Error(Exception):
def _stringify(string): return string
78eedce3ffabc0c8d5af988ab7f72d3749f995db /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/78eedce3ffabc0c8d5af988ab7f72d3749f995db/xmlrpclib.py
t = type(value) if not isinstance(t, StringType): if not isinstance(t, TupleType):
if not isinstance(value, StringType): if not isinstance(value, TupleType):
def __init__(self, value=0): t = type(value) if not isinstance(t, StringType): if not isinstance(t, TupleType): if value == 0: value = time.time() value = time.localtime(value) value = time.strftime("%Y%m%dT%H:%M:%S", value) self.value = value
78eedce3ffabc0c8d5af988ab7f72d3749f995db /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/78eedce3ffabc0c8d5af988ab7f72d3749f995db/xmlrpclib.py
"<Server proxy for %s%s>" %
"<ServerProxy for %s%s>" %
def __repr__(self): return ( "<Server proxy for %s%s>" % (self.__host, self.__handler) )
78eedce3ffabc0c8d5af988ab7f72d3749f995db /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/78eedce3ffabc0c8d5af988ab7f72d3749f995db/xmlrpclib.py
server = Server("http://betty.userland.com")
server = ServerProxy("http://betty.userland.com")
def __getattr__(self, name): # magic method dispatcher return _Method(self.__request, name)
78eedce3ffabc0c8d5af988ab7f72d3749f995db /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/78eedce3ffabc0c8d5af988ab7f72d3749f995db/xmlrpclib.py
if _arguments.has_key('errn'):
if _arguments.get('errn', 0):
def run(self, _no_object=None, _attributes={}, **_arguments): """run: Run the Terminal application Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'core' _subcode = 'oapp'
65300f17c3abaf647ba793930097f7d2658cc716 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/65300f17c3abaf647ba793930097f7d2658cc716/Terminal_Suite.py
if _arguments.has_key('errn'):
if _arguments.get('errn', 0):
def quit(self, _no_object=None, _attributes={}, **_arguments): """quit: Quit the Terminal application Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'core' _subcode = 'quit'
65300f17c3abaf647ba793930097f7d2658cc716 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/65300f17c3abaf647ba793930097f7d2658cc716/Terminal_Suite.py
if _arguments.has_key('errn'):
if _arguments.get('errn', 0):
def count(self, _object=None, _attributes={}, **_arguments): """count: Return the number of elements of a particular class within an object Required argument: a reference to the objects to be counted Keyword argument _attributes: AppleEvent attribute dictionary Returns: the number of objects counted """ _code = 'core' _subcode = 'cnte'
65300f17c3abaf647ba793930097f7d2658cc716 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/65300f17c3abaf647ba793930097f7d2658cc716/Terminal_Suite.py
if _arguments.has_key('errn'):
if _arguments.get('errn', 0):
def do_script(self, _no_object=None, _attributes={}, **_arguments): """do script: Run a UNIX shell script or command Keyword argument with_command: data to be passed to the Terminal application as the command line Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'core' _subcode = 'dosc'
65300f17c3abaf647ba793930097f7d2658cc716 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/65300f17c3abaf647ba793930097f7d2658cc716/Terminal_Suite.py
The function prototype can be called in three ways to create a
The function prototype can be called in different ways to create a
def CFUNCTYPE(restype, *argtypes): """CFUNCTYPE(restype, *argtypes) -> function prototype. restype: the result type argtypes: a sequence specifying the argument types The function prototype can be called in three ways to create a callable object: prototype(integer address) -> foreign function prototype(callable) -> create and return a C callable function from callable prototype(integer index, method name[, paramflags]) -> foreign function calling a COM method prototype((ordinal number, dll object)[, paramflags]) -> foreign function exported by ordinal prototype((function name, dll object)[, paramflags]) -> foreign function exported by name """ try: return _c_functype_cache[(restype, argtypes)] except KeyError: class CFunctionType(_CFuncPtr): _argtypes_ = argtypes _restype_ = restype _flags_ = _FUNCFLAG_CDECL _c_functype_cache[(restype, argtypes)] = CFunctionType return CFunctionType
866a5d89b29903735379fe778c1a08ef3314ba78 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/866a5d89b29903735379fe778c1a08ef3314ba78/__init__.py
f = codecs.getwriter(self.encoding)(s)
f = codecs.getreader(self.encoding)(s)
def test_badbom(self): s = StringIO.StringIO("\xff\xff") f = codecs.getwriter(self.encoding)(s) self.assertRaises(UnicodeError, f.read)
a9620d1e2b9501481aefdb1be1960585eb701534 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a9620d1e2b9501481aefdb1be1960585eb701534/test_codecs.py
f = codecs.getwriter(self.encoding)(s)
f = codecs.getreader(self.encoding)(s)
def test_badbom(self): s = StringIO.StringIO("\xff\xff") f = codecs.getwriter(self.encoding)(s) self.assertRaises(UnicodeError, f.read)
a9620d1e2b9501481aefdb1be1960585eb701534 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a9620d1e2b9501481aefdb1be1960585eb701534/test_codecs.py
if msg[0] in (errno.EACCES, errno.ENODEV):
if msg[0] in (errno.EACCES, errno.ENODEV, errno.EBUSY):
def play_sound_file(path): fp = open(path, 'r') size, enc, rate, nchannels, extra = sunaudio.gethdr(fp) data = fp.read() fp.close() if enc != SND_FORMAT_MULAW_8: print "Expect .au file with 8-bit mu-law samples" return try: a = linuxaudiodev.open('w') except linuxaudiodev.error, msg: if msg[0] in (errno.EACCES, errno.ENODEV): raise TestSkipped, msg raise TestFailed, msg # convert the data to 16-bit signed data = audioop.ulaw2lin(data, 2) # set the data format if sys.byteorder == 'little': fmt = linuxaudiodev.AFMT_S16_LE else: fmt = linuxaudiodev.AFMT_S16_BE # at least check that these methods can be invoked a.bufsize() a.obufcount() a.obuffree() a.getptr() a.fileno() # set parameters based on .au file headers a.setparameters(rate, 16, nchannels, fmt) a.write(data) a.flush() a.close()
4ce6b351cce6e202568ec499fc0d717d65c0c1d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4ce6b351cce6e202568ec499fc0d717d65c0c1d7/test_linuxaudiodev.py
typ, val, tb = sys.exc_info()
typ, val, tb = excinfo = sys.exc_info() sys.last_type, sys.last_value, sys.last_traceback = excinfo
def print_exception(): flush_stdout() efile = sys.stderr typ, val, tb = sys.exc_info() tbe = traceback.extract_tb(tb) print >>efile, '\nTraceback (most recent call last):' exclude = ("run.py", "rpc.py", "threading.py", "Queue.py", "RemoteDebugger.py", "bdb.py") cleanup_traceback(tbe, exclude) traceback.print_list(tbe, file=efile) lines = traceback.format_exception_only(typ, val) for line in lines: print>>efile, line,
924f6164215f59e04fa8aa62ed62ce8a50991267 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/924f6164215f59e04fa8aa62ed62ce8a50991267/run.py
db_incs = find_file('db_185.h', inc_dirs, []) if (db_incs is not None and self.compiler.find_library_file(lib_dirs, 'db') ):
dblib = [] if self.compiler.find_library_file(lib_dirs, 'db'): dblib = ['db'] db185_incs = find_file('db_185.h', inc_dirs, ['/usr/include/db3', '/usr/include/db2']) db_inc = find_file('db.h', inc_dirs, ['/usr/include/db1']) if db185_incs is not None:
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
e06337a9285ce50ba86dd7dff27df0b56905a8b0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e06337a9285ce50ba86dd7dff27df0b56905a8b0/setup.py
include_dirs = db_incs, libraries = ['db'] ) ) else: db_incs = find_file('db.h', inc_dirs, []) if db_incs is not None: exts.append( Extension('bsddb', ['bsddbmodule.c'], include_dirs = db_incs) )
include_dirs = db185_incs, define_macros=[('HAVE_DB_185_H',1)], libraries = dblib ) ) elif db_inc is not None: exts.append( Extension('bsddb', ['bsddbmodule.c'], include_dirs = db_inc, libraries = dblib) )
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
e06337a9285ce50ba86dd7dff27df0b56905a8b0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e06337a9285ce50ba86dd7dff27df0b56905a8b0/setup.py
self.in_list_item = True
self.in_list_item = 1
def _indent_formatter(self, match, fullmatch): depth = int((len(fullmatch.group('idepth')) + 1) / 2) list_depth = len(self._list_stack) if list_depth > 0 and depth == list_depth + 1: self.in_list_item = True else: self.open_indentation(depth) return ''
4414ffb97450b23b1fd6508603724203f67ac289 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/4414ffb97450b23b1fd6508603724203f67ac289/WikiFormatter.py
self.send_header('ETag', etag) return self.send_response(304) self.end_headers() raise NotModifiedException()
self._headers.append(('ETag', etag)) else: self.send_response(304) self.end_headers() raise NotModifiedException()
def check_modified(self, timesecs, extra=''): etag = 'W"%s/%d/%s"' % (self.authname, timesecs, extra) inm = self.get_header('If-None-Match') if (not inm or inm != etag): self.send_header('ETag', etag) return self.send_response(304) self.end_headers() raise NotModifiedException()
2af6cce938242e4dcf8a1e947d4a0ce7dd42dd05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/2af6cce938242e4dcf8a1e947d4a0ce7dd42dd05/core.py
options = field.get('options', []) if default and default not in field.get('options', []):
options = field.get('options') if default and options and default not in options:
def _init_defaults(self, db=None): for field in self.fields: default = None if not field.get('custom'): default = self.env.config.get('ticket', 'default_' + field['name']) else: default = field.get('value') options = field.get('options', []) if default and default not in field.get('options', []): try: default_idx = int(default) if default_idx > len(options): raise ValueError default = options[default_idx] except ValueError: self.env.log.warning('Invalid default value for ' 'custom field "%s"' % field['name']) if default: self.values.setdefault(field['name'], default)
321b4d73402e6e4cc4485e71a29eeaa478fee158 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/321b4d73402e6e4cc4485e71a29eeaa478fee158/model.py
"""Check the request "If-None-Match" header against an entity tag generated from the specified last modified time in seconds (`timesecs`), optionally appending an `extra` string to indicate variants of the requested resource. That `extra` parameter can also be a list, in which case the MD5 sum of the list content will be used.
"""Check the request "If-None-Match" header against an entity tag. The entity tag is generated from the specified last modified time in seconds (`timesecs`), optionally appending an `extra` string to indicate variants of the requested resource. That `extra` parameter can also be a list, in which case the MD5 sum of the list content will be used.
def check_modified(self, timesecs, extra=''): """Check the request "If-None-Match" header against an entity tag generated from the specified last modified time in seconds (`timesecs`), optionally appending an `extra` string to indicate variants of the requested resource. That `extra` parameter can also be a list, in which case the MD5 sum of the list content will be used.
906cc78e5c6aa84099039f5fd08e2cbbbfa343e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/906cc78e5c6aa84099039f5fd08e2cbbbfa343e0/api.py
Otherwise, it adds the entity tag as as "ETag" header to the response so that consequetive requests can be cached.
Otherwise, it adds the entity tag as an "ETag" header to the response so that consecutive requests can be cached.
def check_modified(self, timesecs, extra=''): """Check the request "If-None-Match" header against an entity tag generated from the specified last modified time in seconds (`timesecs`), optionally appending an `extra` string to indicate variants of the requested resource. That `extra` parameter can also be a list, in which case the MD5 sum of the list content will be used.
906cc78e5c6aa84099039f5fd08e2cbbbfa343e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/906cc78e5c6aa84099039f5fd08e2cbbbfa343e0/api.py
'value': field['value']
'value': value
def insert_custom_fields(env, hdf, vals={}): for idx, field in util.enum(TicketSystem(env).get_custom_fields()): name = field['name'] value = vals.get('custom_' + name, field['value']) prefix = 'ticket.custom.%d' % idx hdf[prefix] = { 'name': field['name'], 'type': field['type'], 'label': field['label'] or field['name'], 'value': field['value'] } if field['type'] == 'select' or field['type'] == 'radio': for optidx, option in util.enum(field['options']): hdf['%s.option.%d' % (prefix, optidx)] = option if value and (option == value or str(optidx) == value): hdf['%s.option.%d.selected' % (prefix, optidx)] = True elif field['type'] == 'checkbox': if value in util.TRUE: hdf['%s.selected' % prefix] = True elif field['type'] == 'textarea': hdf['%s.width' % prefix] = field['width'] hdf['%s.height' % prefix] = field['height']
bb7ec9b4be98190ff31ee84afde51546cf4eb4b2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/bb7ec9b4be98190ff31ee84afde51546cf4eb4b2/web_ui.py
from optparse import OptionParser
from optparse import OptionParser, OptionValueError
def main(): from optparse import OptionParser parser = OptionParser(usage='usage: %prog [options] [projenv] ...', version='%%prog %s' % __version__) auths = {} def _auth_callback(option, opt_str, value, parser, auths, cls): info = value.split(',', 3) if len(info) != 3: usage() env_name, filename, realm = info if env_name in auths: print >>sys.stderr, 'Ignoring duplicate authentication option for ' \ 'project: %s' % env_name else: auths[env_name] = cls(filename, realm) parser.add_option('-a', '--auth', action='callback', type='string', metavar='DIGESTAUTH', callback=_auth_callback, callback_args=(auths, DigestAuth), help='[project],[htdigest_file],[realm]') parser.add_option('--basic-auth', action='callback', type='string', metavar='BASICAUTH', callback=_auth_callback, callback_args=(auths, BasicAuth), help='[project],[htpasswd_file],[realm]') parser.add_option('-p', '--port', action='store', type='int', dest='port', help='the port number to bind to') parser.add_option('-b', '--hostname', action='store', dest='hostname', help='the host name or IP address to bind to') parser.add_option('-e', '--env-parent-dir', action='store', dest='env_parent_dir', metavar='PARENTDIR', help='parent directory of the project environments') if os.name == 'posix': parser.add_option('-d', '--daemonize', action='store_true', dest='daemonize', help='run in the background as a daemon') parser.set_defaults(port=80, hostname='', daemonize=False) options, args = parser.parse_args() if not args and not options.env_parent_dir: parser.error('either the --env_parent_dir option or at least one ' 'environment must be specified') server_address = (options.hostname, options.port) httpd = TracHTTPServer(server_address, options.env_parent_dir, args, auths) try: if options.daemonize: daemonize() httpd.serve_forever() except OSError: sys.exit(1) except KeyboardInterrupt: pass
dc34bc3151c7905c94fd6e4e13dd2b05f7116c62 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/dc34bc3151c7905c94fd6e4e13dd2b05f7116c62/standalone.py
usage()
raise OptionValueError("Incorrect number of parameters for %s" % option) usage()
def _auth_callback(option, opt_str, value, parser, auths, cls): info = value.split(',', 3) if len(info) != 3: usage() env_name, filename, realm = info if env_name in auths: print >>sys.stderr, 'Ignoring duplicate authentication option for ' \ 'project: %s' % env_name else: auths[env_name] = cls(filename, realm)
dc34bc3151c7905c94fd6e4e13dd2b05f7116c62 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/dc34bc3151c7905c94fd6e4e13dd2b05f7116c62/standalone.py
if os.name == 'posix' and options.daemonize: daemon.daemonize()
if os.name == 'posix': if options.pidfile: options.pidfile = os.path.abspath(options.pidfile) if os.path.exists(options.pidfile): pidfile = open(options.pidfile) try: pid = int(pidfile.read()) finally: pidfile.close() try: os.kill(pid, 0) except OSError, e: if e.errno != errno.ESRCH: raise else: sys.exit("tracd is already running with pid %s" % pid) realserve = serve def serve(): try: pidfile = open(options.pidfile, 'w') try: pidfile.write(str(os.getpid())) finally: pidfile.close() realserve() finally: if os.path.exists(options.pidfile): os.remove(options.pidfile) if options.daemonize: daemon.daemonize()
def serve(): server_cls = __import__('flup.server.%s' % options.protocol, None, None, ['']).WSGIServer ret = server_cls(wsgi_app, bindAddress=server_address).run() sys.exit(ret and 42 or 0) # if SIGHUP exit with status 42
3429d3818a8c73f1f150ad00c7b73a7112f990d8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/3429d3818a8c73f1f150ad00c7b73a7112f990d8/standalone.py
old = self.db_query("SELECT text FROM wiki WHERE name='%s' " "ORDER BY version DESC LIMIT 1" % title, cursor)
rows = self.db_query("SELECT text FROM wiki WHERE name='%s' " "ORDER BY version DESC LIMIT 1" % title, cursor) old = list(rows)
def _do_wiki_import(self, filename, title, cursor=None): if not os.path.isfile(filename): print "%s is not a file" % filename return f = open(filename,'r') data = util.to_utf8(f.read())
44cc2f3d23461aedec41ea2677267e27765e70f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/44cc2f3d23461aedec41ea2677267e27765e70f9/admin.py
logfile = os.path.join(self.get_log_dir(), logfile)
if not os.path.isabs(logfile): logfile = os.path.join(self.get_log_dir(), logfile)
def setup_log(self): """Initialize the logging sub-system.""" from trac.log import logger_factory logtype = self.config.get('logging', 'log_type') loglevel = self.config.get('logging', 'log_level') logfile = self.config.get('logging', 'log_file') logfile = os.path.join(self.get_log_dir(), logfile) logid = self.path # Env-path provides process-unique ID self.log = logger_factory(logtype, logfile, loglevel, logid)
eb24c1d41ca17f27f45f92ec35ea17edd972324b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/eb24c1d41ca17f27f45f92ec35ea17edd972324b/env.py
icalhref = '?format=ics'
icalhref = '?format=ics'
def render(self, req): self.perm.assert_permission(perm.ROADMAP_VIEW) req.hdf.setValue('title', 'Roadmap')
31e6c8840e7a5ba1af258cce35576951eb94a541 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/31e6c8840e7a5ba1af258cce35576951eb94a541/Roadmap.py
if milestone.has_key('date'):
if milestone.has_key('due'):
def write_utctime(name, value, params={}): write_prop(name, strftime('%Y%m%dT%H%M%SZ', value), params)
31e6c8840e7a5ba1af258cce35576951eb94a541 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/31e6c8840e7a5ba1af258cce35576951eb94a541/Roadmap.py
if milestone.has_key('date'): write_date('DTSTART', localtime(milestone['due']))
write_date('DTSTART', localtime(milestone['due']))
def write_utctime(name, value, params={}): write_prop(name, strftime('%Y%m%dT%H%M%SZ', value), params)
31e6c8840e7a5ba1af258cce35576951eb94a541 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/31e6c8840e7a5ba1af258cce35576951eb94a541/Roadmap.py
req.hdf['%s.real' % prefix] = col[0]
req.hdf['%s.real' % prefix] = col
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'] = req.href.report(id)
a76d9194077f777eb0da363472df67e2af0b2947 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/a76d9194077f777eb0da363472df67e2af0b2947/report.py
while req.hdf.get('links.%s.%d.href' % (rel, idx)):
while req.hdf.get('chrome.links.%s.%d.href' % (rel, idx)):
def add_link(req, rel, href, title=None, type=None, class_name=None): link = {'href': escape(href)} if title: link['title'] = escape(title) if type: link['type'] = type if class_name: link['class'] = class_name idx = 0 while req.hdf.get('links.%s.%d.href' % (rel, idx)): idx += 1 req.hdf['links.%s.%d' % (rel, idx)] = link
97f28a5f59785b14feb1dcd067fe5544ba0b71b0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/97f28a5f59785b14feb1dcd067fe5544ba0b71b0/chrome.py
req.hdf['links.%s.%d' % (rel, idx)] = link
req.hdf['chrome.links.%s.%d' % (rel, idx)] = link
def add_link(req, rel, href, title=None, type=None, class_name=None): link = {'href': escape(href)} if title: link['title'] = escape(title) if type: link['type'] = type if class_name: link['class'] = class_name idx = 0 while req.hdf.get('links.%s.%d.href' % (rel, idx)): idx += 1 req.hdf['links.%s.%d' % (rel, idx)] = link
97f28a5f59785b14feb1dcd067fe5544ba0b71b0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/97f28a5f59785b14feb1dcd067fe5544ba0b71b0/chrome.py
if not logo_src[0] == '/' and not logo_src_abs:
if not logo_src.startswith('/') and not logo_src_abs:
def populate_hdf(self, req, handler): """ Add chrome-related data to the HDF. """
97f28a5f59785b14feb1dcd067fe5544ba0b71b0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/97f28a5f59785b14feb1dcd067fe5544ba0b71b0/chrome.py
req.hdf['header_logo'] = {
req.hdf['chrome.logo'] = {
def populate_hdf(self, req, handler): """ Add chrome-related data to the HDF. """
97f28a5f59785b14feb1dcd067fe5544ba0b71b0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/97f28a5f59785b14feb1dcd067fe5544ba0b71b0/chrome.py
req.hdf['chrome.%s.%s' % (category, name)] = text
req.hdf['chrome.nav.%s.%s' % (category, name)] = text
def populate_hdf(self, req, handler): """ Add chrome-related data to the HDF. """
97f28a5f59785b14feb1dcd067fe5544ba0b71b0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/97f28a5f59785b14feb1dcd067fe5544ba0b71b0/chrome.py
req.hdf['chrome.%s.%s.active' % (category, name)] = 1
req.hdf['chrome.nav.%s.%s.active' % (category, name)] = 1
def populate_hdf(self, req, handler): """ Add chrome-related data to the HDF. """
97f28a5f59785b14feb1dcd067fe5544ba0b71b0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/97f28a5f59785b14feb1dcd067fe5544ba0b71b0/chrome.py
module, id = req.hdf['HTTP.PathInfo'].split('/', 3)[1:]
module, id = 'wiki', 'WikiStart' path_info = req.path_info.split('/',2) if len(path_info) > 1: module = path_info[1] if len(path_info) > 2: id = path_info[2]
def render_macro(self, req, name, content): # args will be null if the macro is called without parenthesis. if not content: return '' # parse arguments # we expect the 1st argument to be a filename (filespec) args = content.split(',') if len(args) == 0: raise Exception("No argument.") filespec = args[0] size_re = re.compile('^[0-9]+%?$') align_re = re.compile('^(?:left|right|top|bottom)$') keyval_re = re.compile('^([-a-z0-9]+)([=:])(.*)') quoted_re = re.compile("^(?:&#34;|')(.*)(?:&#34;|')$") attr = {} style = {} for arg in args[1:]: arg = arg.strip() if size_re.search(arg): # 'width' keyword attr['width'] = arg continue if align_re.search(arg): # 'align' keyword attr['align'] = arg continue match = keyval_re.search(arg) if match: key = match.group(1) sep = match.group(2) val = match.group(3) m = quoted_re.search(val) # unquote &#34; character " if m: val = m.group(1) if sep == '=': attr[key] = val; elif sep == ':': style[key] = val
f4e41101296b8282dcf97c9f5631d38597459b59 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/f4e41101296b8282dcf97c9f5631d38597459b59/macros.py
'order': 0, 'optional': False},
'order': 0},
def test_custom_field_select(self): self.env.config.set('ticket-custom', 'test', 'select') self.env.config.set('ticket-custom', 'test.label', 'Test') self.env.config.set('ticket-custom', 'test.value', '1') self.env.config.set('ticket-custom', 'test.options', 'option1|option2') fields = TicketSystem(self.env).get_custom_fields() self.assertEqual({'name': 'test', 'type': 'select', 'label': 'Test', 'value': '1', 'options': ['option1', 'option2'], 'order': 0, 'optional': False}, fields[0])
b23c1b24aa99abd3abeca3890de1b991b3d0fd5a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/b23c1b24aa99abd3abeca3890de1b991b3d0fd5a/api.py
'value': '1', 'options': ['', 'option1', 'option2'],
'value': '1', 'options': ['option1', 'option2'],
def test_custom_field_optional_select(self): self.env.config.set('ticket-custom', 'test', 'select') self.env.config.set('ticket-custom', 'test.label', 'Test') self.env.config.set('ticket-custom', 'test.value', '1') self.env.config.set('ticket-custom', 'test.options', '|option1|option2') fields = TicketSystem(self.env).get_custom_fields() self.assertEqual({'name': 'test', 'type': 'select', 'label': 'Test', 'value': '1', 'options': ['', 'option1', 'option2'], 'order': 0, 'optional': True}, fields[0])
b23c1b24aa99abd3abeca3890de1b991b3d0fd5a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/b23c1b24aa99abd3abeca3890de1b991b3d0fd5a/api.py
Generator that produces a (path, kind, change, base_rev, base_path)
Generator that produces a (path, kind, change, base_path, base_rev)
def get_changes(self): """ Generator that produces a (path, kind, change, base_rev, base_path) tuple for every change in the changeset, where change can be one of Changeset.ADD, Changeset.COPY, Changeset.DELETE, Changeset.EDIT or Changeset.MOVE, and kind is one of Node.FILE or Node.DIRECTORY. """ raise NotImplementedError
3d7970248ecb760a2690fbe49562be5277616118 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/3d7970248ecb760a2690fbe49562be5277616118/api.py
milestone = Milestone(self.env, req.args.get('id'), db)
milestone = Milestone(self.env, milestone_id, db)
def process_request(self, req): req.perm.assert_permission('MILESTONE_VIEW')
435f44068b47c0f7bde76aa8076706ab8fa919d2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/435f44068b47c0f7bde76aa8076706ab8fa919d2/roadmap.py
xlist = ['summary', 'description', 'link', 'comment']
xlist = ['summary', 'description', 'link', 'comment', 'new']
def _validate_mimebody(self, mime, ticket, newtk): """Validate the body of a ticket notification message""" (mime_decoder, mime_name, mime_charset) = mime tn = TicketNotifyEmail(self.env) tn.notify(ticket, newticket=newtk) message = notifysuite.smtpd.get_message() (headers, body) = parse_smtp_message(message) self.failIf('MIME-Version' not in headers) self.failIf('Content-Type' not in headers) self.failIf('Content-Transfer-Encoding' not in headers) self.failIf(not re.compile(r"1.\d").match(headers['MIME-Version'])) type_re = re.compile(r'^text/plain;\scharset="([\w\-\d]+)"$') charset = type_re.match(headers['Content-Type']) self.failIf(not charset) charset = charset.group(1) self.assertEqual(charset, mime_charset) self.assertEqual(headers['Content-Transfer-Encoding'], mime_name) # checks the width of each body line for line in body.splitlines(): self.failIf(len(line) > MAXBODYWIDTH) # attempts to decode the body, following the specified MIME endoding # and charset try: if mime_decoder: body = mime_decoder.decodestring(body) body = unicode(body, charset) except Exception, e: raise AssertionError, e # now processes each line of the body bodylines = body.splitlines() # body starts with one of more summary lines, first line is prefixed # with the ticket number such as #<n>: summary # finds the banner after the summary banner_delim_re = re.compile(r'^\-+\+\-+$') bodyheader = [] while ( not banner_delim_re.match(bodylines[0]) ): bodyheader.append(bodylines.pop(0)) # summary should be present self.failIf(not bodyheader) # banner should not be empty self.failIf(not bodylines) # extracts the ticket ID from the first line (tknum, bodyheader[0]) = bodyheader[0].split(' ', 1) self.assertEqual(tknum[0], '#') try: tkid = int(tknum[1:-1]) self.assertEqual(tkid, 1) except ValueError: raise AssertionError, "invalid ticket number" self.assertEqual(tknum[-1], ':') summary = ' '.join(bodyheader) self.assertEqual(summary, ticket['summary']) # now checks the banner contents self.failIf(not banner_delim_re.match(bodylines[0])) banner = True footer = None props = {} for line in bodylines[1:]: # detect end of banner if banner_delim_re.match(line): banner = False continue if banner: # parse banner and fill in a property dict properties = line.split('|') self.assertEqual(len(properties), 2) for prop in properties: if prop.strip() == '': continue (k, v) = prop.split(':') props[k.strip().lower()] = v.strip() # detect footer marker (weak detection) if not footer: if line.strip() == '--': footer = 0 continue # check footer if footer != None: footer += 1 # invalid footer detection self.failIf(footer > 3) # check ticket link if line[:11] == 'Ticket URL:': self.assertEqual(line[12:].strip(), "<%s>" % ticket['link'].strip()) # note project title / URL are not validated yet
8adeb545093184ff70333c9a00dd0473e01426df /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/8adeb545093184ff70333c9a00dd0473e01426df/notification.py
q.append('SELECT 2 as type, summary AS title, ' ' description AS message, reporter AS author, keywords,' ' id AS data, time,0 AS ver' ' FROM ticket WHERE %s OR %s OR %s OR %s OR %s' % (self.query_to_sql(query, 'summary'),
q.append('SELECT DISTINCT 2 as type, a.summary AS title, ' ' a.description AS message, a.reporter AS author, a.keywords as keywords,' ' a.id AS data, a.time as time, 0 AS ver' ' FROM ticket a LEFT JOIN ticket_change b ON a.id = b.ticket' ' WHERE (b.field=\'comment\' AND %s ) OR' ' %s OR %s OR %s OR %s OR %s' % (self.query_to_sql(query, 'b.newvalue'), self.query_to_sql(query, 'summary'),
def perform_query (self, query, changeset, tickets, wiki, page=0): keywords = query.split(' ')
b6e5c7c3f923b426c893284b757311fef3461c79 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/b6e5c7c3f923b426c893284b757311fef3461c79/Search.py
q.append('SELECT 2 as type, a.summary AS title, ' ' b.newvalue AS message, a.reporter AS author,' ' a.keywords as keywords,' ' a.id AS data, a.time AS time,0 AS ver' ' FROM ticket a, ticket_change b' ' WHERE a.id = b.ticket AND b.field=\'comment\' AND %s' % (self.query_to_sql(query, 'b.newvalue')))
def perform_query (self, query, changeset, tickets, wiki, page=0): keywords = query.split(' ')
b6e5c7c3f923b426c893284b757311fef3461c79 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/b6e5c7c3f923b426c893284b757311fef3461c79/Search.py
q_str += ' ORDER BY time DESC LIMIT %d OFFSET %d' % \
q_str += ' ORDER BY 7 DESC LIMIT %d OFFSET %d' % \
def perform_query (self, query, changeset, tickets, wiki, page=0): keywords = query.split(' ')
b6e5c7c3f923b426c893284b757311fef3461c79 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/b6e5c7c3f923b426c893284b757311fef3461c79/Search.py
for f in os.listdir(trac.siteconfig.__default_macro_dir__):
for f in os.listdir(trac.siteconfig.__default_macros_dir__):
def do_initenv(self, line): if self.env_check(): print "Initenv for '%s' failed.\nDoes an environment already exist?" % self.envname return arg = self.arg_tokenize(line) project_name = None repository_dir = None templates_dir = None if len(arg) == 1: returnvals = self.get_initenv_args() project_name = returnvals[0] repository_dir = returnvals[1] templates_dir = returnvals[2] elif len(arg)!= 3: print 'Wrong number of arguments to initenv %d' % len(arg) return else: project_name = arg[0] repository_dir = arg[1] templates_dir = arg[2]
7e1ab333e2e97763a8002ec82ef6a02a4dca5791 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/7e1ab333e2e97763a8002ec82ef6a02a4dca5791/admin.py
src = os.path.join(trac.siteconfig.__default_macro_dir__, f)
src = os.path.join(trac.siteconfig.__default_macros_dir__, f)
def do_initenv(self, line): if self.env_check(): print "Initenv for '%s' failed.\nDoes an environment already exist?" % self.envname return arg = self.arg_tokenize(line) project_name = None repository_dir = None templates_dir = None if len(arg) == 1: returnvals = self.get_initenv_args() project_name = returnvals[0] repository_dir = returnvals[1] templates_dir = returnvals[2] elif len(arg)!= 3: print 'Wrong number of arguments to initenv %d' % len(arg) return else: project_name = arg[0] repository_dir = arg[1] templates_dir = arg[2]
7e1ab333e2e97763a8002ec82ef6a02a4dca5791 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/7e1ab333e2e97763a8002ec82ef6a02a4dca5791/admin.py
default_idx = int(default) if default_idx > len(options): raise ValueError default = options[default_idx] except ValueError: self.env.log.warning('Invalid default value for ' 'custom field "%s"' % field['name'])
default = options[int(default)] except (ValueError, IndexError): self.env.log.warning('Invalid default value "%s" ' 'for custom field "%s"' % (default, field['name']))
def _init_defaults(self, db=None): for field in self.fields: default = None if not field.get('custom'): default = self.env.config.get('ticket', 'default_' + field['name']) else: default = field.get('value') options = field.get('options') if default and options and default not in options: try: default_idx = int(default) if default_idx > len(options): raise ValueError default = options[default_idx] except ValueError: self.env.log.warning('Invalid default value for ' 'custom field "%s"' % field['name']) if default: self.values.setdefault(field['name'], default)
dae5a769454400bb55b47d1ca03ea78ad9378170 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/dae5a769454400bb55b47d1ca03ea78ad9378170/model.py
break
try: cnx.cursor() break except Exception: cnx.close()
def get_cnx(self, timeout=None): start = time.time() self._available.acquire() try: tid = threading._get_ident() if tid in self._active: self._active[tid][0] += 1 return PooledConnection(self, self._active[tid][1]) while True: if self._dormant: cnx = self._dormant.pop() break elif self._maxsize and self._cursize < self._maxsize: cnx = self._connector.get_connection(**self._kwargs) self._cursize += 1 break else: if timeout: self._available.wait(timeout) if (time.time() - start) >= timeout: raise TimeoutError, 'Unable to get database ' \ 'connection within %d seconds' \ % timeout else: self._available.wait() self._active[tid] = [1, cnx] return PooledConnection(self, cnx) finally: self._available.release()
a59364df2f44ddde98966688922ce7085852c6f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/a59364df2f44ddde98966688922ce7085852c6f7/pool.py
for line in difflines: if line.startswith('--- '): words = line.split(None, 2) filename, fromrev = words[1], 'old' groups, blocks = None, None
lines = iter(difflines) for line in lines: if not line.startswith('--- '):
def htmlify(match): div, mod = divmod(len(match.group(0)), 2) return div * '&nbsp; ' + mod * '&nbsp;'
81b657b816d8b094d2886fe500c5decefefc5342 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/81b657b816d8b094d2886fe500c5decefefc5342/patch.py
if line.startswith('+++ '): words = line.split(None, 2) if len(words[1]) < len(filename): filename = words[1] groups = [] output.append({'filename' : filename, 'oldrev' : fromrev, 'newrev' : 'new', 'diff' : groups}) continue if line.startswith('Index: ') or line.startswith('======') or line == '': continue if groups == None:
words = line.split(None, 2) filename, fromrev = words[1], 'old' groups, blocks = None, None line = lines.next() if not line.startswith('+++ '):
def htmlify(match): div, mod = divmod(len(match.group(0)), 2) return div * '&nbsp; ' + mod * '&nbsp;'
81b657b816d8b094d2886fe500c5decefefc5342 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/81b657b816d8b094d2886fe500c5decefefc5342/patch.py
if line.startswith('@@ '): r = re.match(r'@@ -(\d+),\d+ \+(\d+),\d+ @@', line)
words = line.split(None, 2) if len(words[1]) < len(filename): filename = words[1] groups = [] output.append({'filename' : filename, 'oldrev' : fromrev, 'newrev' : 'new', 'diff' : groups}) for line in lines: r = re.match(r'@@ -(\d+),(\d+) \+(\d+),(\d+) @@', line)
def htmlify(match): div, mod = divmod(len(match.group(0)), 2) return div * '&nbsp; ' + mod * '&nbsp;'
81b657b816d8b094d2886fe500c5decefefc5342 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/81b657b816d8b094d2886fe500c5decefefc5342/patch.py
return None
break
def htmlify(match): div, mod = divmod(len(match.group(0)), 2) return div * '&nbsp; ' + mod * '&nbsp;'
81b657b816d8b094d2886fe500c5decefefc5342 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/81b657b816d8b094d2886fe500c5decefefc5342/patch.py
fromline,toline = map(int, r.groups())
fromline,fromend,toline,toend = map(int, r.groups())
def htmlify(match): div, mod = divmod(len(match.group(0)), 2) return div * '&nbsp; ' + mod * '&nbsp;'
81b657b816d8b094d2886fe500c5decefefc5342 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/81b657b816d8b094d2886fe500c5decefefc5342/patch.py
continue if blocks == None: return None
def htmlify(match): div, mod = divmod(len(match.group(0)), 2) return div * '&nbsp; ' + mod * '&nbsp;'
81b657b816d8b094d2886fe500c5decefefc5342 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/81b657b816d8b094d2886fe500c5decefefc5342/patch.py
command, line = line[0], line[1:]
fromend += fromline toend += toline
def htmlify(match): div, mod = divmod(len(match.group(0)), 2) return div * '&nbsp; ' + mod * '&nbsp;'
81b657b816d8b094d2886fe500c5decefefc5342 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/81b657b816d8b094d2886fe500c5decefefc5342/patch.py
if (command == ' ') != last_type: last_type = command == ' ' blocks.append({'type': last_type and 'unmod' or 'mod', 'base.offset': fromline - 1, 'base.lines': [], 'changed.offset': toline - 1, 'changed.lines': []}) if command == ' ': blocks[-1]['changed.lines'].append(line) blocks[-1]['base.lines'].append(line) fromline += 1 toline += 1 elif command == '+': blocks[-1]['changed.lines'].append(line) toline += 1 elif command == '-': blocks[-1]['base.lines'].append(line) fromline += 1 else: return None
while fromline < fromend or toline < toend: line = lines.next() command, line = line[0], line[1:] if (command == ' ') != last_type: last_type = command == ' ' blocks.append({'type': last_type and 'unmod' or 'mod', 'base.offset': fromline - 1, 'base.lines': [], 'changed.offset': toline - 1, 'changed.lines': []}) if command == ' ': blocks[-1]['changed.lines'].append(line) blocks[-1]['base.lines'].append(line) fromline += 1 toline += 1 elif command == '+': blocks[-1]['changed.lines'].append(line) toline += 1 elif command == '-': blocks[-1]['base.lines'].append(line) fromline += 1 else: return None
def htmlify(match): div, mod = divmod(len(match.group(0)), 2) return div * '&nbsp; ' + mod * '&nbsp;'
81b657b816d8b094d2886fe500c5decefefc5342 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/81b657b816d8b094d2886fe500c5decefefc5342/patch.py
pass
version = None
def _insert_ticket_data(self, req, db, ticket, data, reporter_id): """Insert ticket data into the hdf""" replyto = req.args.get('replyto') version = req.args.get('version', None) data['replyto'] = replyto if version: try: version = int(version) data['version'] = version except ValueError: pass
25a83acacd059223a07e67b59ac2c5a4e9520aa7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/25a83acacd059223a07e67b59ac2c5a4e9520aa7/web_ui.py
if version is not None and cnum > version: for k, v in change['fields'].iteritems(): if k not in values: values[k] = v['old'] continue changes.append(change)
def quote_original(author, original, link): if 'comment' not in req.args: # i.e. the comment was not yet edited data['comment'] = '\n'.join( ['Replying to [%s %s]:' % (link, author)] + ['> %s' % line for line in original.splitlines()] + [''])
25a83acacd059223a07e67b59ac2c5a4e9520aa7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/25a83acacd059223a07e67b59ac2c5a4e9520aa7/web_ui.py
if 'replyto' in change: replies.setdefault(change['replyto'], []).append(cnum) comment = '' if replyto == str(cnum): quote_original(change['author'], comment, 'comment:%s' % replyto) if version:
if version is not None and cnum > version:
def quote_original(author, original, link): if 'comment' not in req.args: # i.e. the comment was not yet edited data['comment'] = '\n'.join( ['Replying to [%s %s]:' % (link, author)] + ['> %s' % line for line in original.splitlines()] + [''])
25a83acacd059223a07e67b59ac2c5a4e9520aa7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/25a83acacd059223a07e67b59ac2c5a4e9520aa7/web_ui.py
values[k] = v['new'] if 'description' in change['fields']: data['description_change'] = change
if k not in values: values[k] = v['old'] skip = True else: if 'replyto' in change: replies.setdefault(change['replyto'], []).append(cnum) comment = '' if replyto == str(cnum): quote_original(change['author'], comment, 'comment:%s' % replyto) if version: for k, v in change['fields'].iteritems(): values[k] = v['new'] if 'description' in change['fields']: data['description_change'] = change if not skip: changes.append(change)
def quote_original(author, original, link): if 'comment' not in req.args: # i.e. the comment was not yet edited data['comment'] = '\n'.join( ['Replying to [%s %s]:' % (link, author)] + ['> %s' % line for line in original.splitlines()] + [''])
25a83acacd059223a07e67b59ac2c5a4e9520aa7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/25a83acacd059223a07e67b59ac2c5a4e9520aa7/web_ui.py
if not row: raise TracError('Report %d does not exist.' % id,
try: if not row: raise TracError('Report %d does not exist.' % id,
def get_info(self, id, args): cursor = self.db.cursor()
492b2ab83de258eaaa4c56c6a8ccb4a69e2ae57e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/492b2ab83de258eaaa4c56c6a8ccb4a69e2ae57e/Report.py
title = row[0] try:
title = row[0]
def get_info(self, id, args): cursor = self.db.cursor()
492b2ab83de258eaaa4c56c6a8ccb4a69e2ae57e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/492b2ab83de258eaaa4c56c6a8ccb4a69e2ae57e/Report.py
if path.startswith(self.scope):
if rev > 0 and path.startswith(self.scope):
def get_history(self): history = _get_history(self.scope + self.path, self.authz, self.fs_ptr, self.pool, self.rev) for path, rev in history: if path.startswith(self.scope): yield path[len(self.scope):], rev
be5729e969e69fa7555860360e34c03711d8cd1f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/be5729e969e69fa7555860360e34c03711d8cd1f/svn_fs.py
title = Markup('Ticket <em title="%s"> summary, id, type, verb, author)
if format == 'rss': title = 'Ticket (id, type.lower(), verb, summary) else: title = Markup('Ticket <em title="%s"> summary, id, type, verb, author)
def produce((id, t, author, type, summary), status, fields, comment, cid): if status == 'edit': if 'ticket_details' in filters: info = '' if len(fields) > 0: info = ', '.join(['<i>%s</i>' % f for f in \ fields.keys()]) + ' changed<br />' else: return None elif 'ticket' in filters: if status == 'closed' and fields.has_key('resolution'): info = fields['resolution'] if info and comment: info = '%s: ' % info else: info = '' else: return None kind, verb = status_map[status] title = Markup('Ticket <em title="%s">#%s</em> (%s) %s by %s', summary, id, type, verb, author) href = format == 'rss' and req.abs_href.ticket(id) or \ req.href.ticket(id) if cid: href += '#comment:' + cid if status == 'new': message = summary else: message = Markup(info) if comment: if format == 'rss': message += wiki_to_html(comment, self.env, req, db, absurls=True) else: message += wiki_to_oneliner(comment, self.env, db, shorten=True) return kind, href, title, t, author, message
7356b09985ee21df80d7dceca9c158115a3eb6d0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/7356b09985ee21df80d7dceca9c158115a3eb6d0/web_ui.py
defaults = {} for section, options in self.env.get_default_config().iteritems(): defaults[section] = default_options = {} for opt in options: default_options[opt.name] = opt.default
def _render_config(self, req): req.perm.assert_permission('CONFIG_VIEW') req.hdf['about.page'] = 'config' # Gather default values defaults = {} for section, options in self.env.get_default_config().iteritems(): defaults[section] = default_options = {} for opt in options: default_options[opt.name] = opt.default # Export the config table to hdf sections = [] for section in self.config.sections(): options = [] default_options = defaults.get(section) for name,value in self.config.options(section): default = default_options and default_options.get(name) or '' options.append({'name': name, 'value': value, 'valueclass': (value == default and \ 'defaultvalue' or 'value')}) options.sort(lambda x,y: cmp(x['name'], y['name'])) sections.append({'name': section, 'options': options}) sections.sort(lambda x,y: cmp(x['name'], y['name'])) req.hdf['about.config'] = sections # TODO: # We should probably export more info here like: # permissions, components...
5d09296f2bf19c6ff50e7748cf2e11102e0398f1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/5d09296f2bf19c6ff50e7748cf2e11102e0398f1/About.py
default_options = defaults.get(section)
default_options = self.config.getdefaults().get(section)
def _render_config(self, req): req.perm.assert_permission('CONFIG_VIEW') req.hdf['about.page'] = 'config' # Gather default values defaults = {} for section, options in self.env.get_default_config().iteritems(): defaults[section] = default_options = {} for opt in options: default_options[opt.name] = opt.default # Export the config table to hdf sections = [] for section in self.config.sections(): options = [] default_options = defaults.get(section) for name,value in self.config.options(section): default = default_options and default_options.get(name) or '' options.append({'name': name, 'value': value, 'valueclass': (value == default and \ 'defaultvalue' or 'value')}) options.sort(lambda x,y: cmp(x['name'], y['name'])) sections.append({'name': section, 'options': options}) sections.sort(lambda x,y: cmp(x['name'], y['name'])) req.hdf['about.config'] = sections # TODO: # We should probably export more info here like: # permissions, components...
5d09296f2bf19c6ff50e7748cf2e11102e0398f1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/5d09296f2bf19c6ff50e7748cf2e11102e0398f1/About.py
options.append({'name': name, 'value': value, 'valueclass': (value == default and \ 'defaultvalue' or 'value')})
options.append({ 'name': name, 'value': value, 'valueclass': (unicode(value) == unicode(default) and 'defaultvalue' or 'value')})
def _render_config(self, req): req.perm.assert_permission('CONFIG_VIEW') req.hdf['about.page'] = 'config' # Gather default values defaults = {} for section, options in self.env.get_default_config().iteritems(): defaults[section] = default_options = {} for opt in options: default_options[opt.name] = opt.default # Export the config table to hdf sections = [] for section in self.config.sections(): options = [] default_options = defaults.get(section) for name,value in self.config.options(section): default = default_options and default_options.get(name) or '' options.append({'name': name, 'value': value, 'valueclass': (value == default and \ 'defaultvalue' or 'value')}) options.sort(lambda x,y: cmp(x['name'], y['name'])) sections.append({'name': section, 'options': options}) sections.sort(lambda x,y: cmp(x['name'], y['name'])) req.hdf['about.config'] = sections # TODO: # We should probably export more info here like: # permissions, components...
5d09296f2bf19c6ff50e7748cf2e11102e0398f1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/5d09296f2bf19c6ff50e7748cf2e11102e0398f1/About.py
self.path = path
self.path = path
def __init__(self, path, authz, log): self.path = path self.log = log if core.SVN_VER_MAJOR < 1: raise TracError("Subversion >= 1.0 required: Found %d.%d.%d" % \ (core.SVN_VER_MAJOR, core.SVN_VER_MINOR, core.SVN_VER_MICRO)) self.pool = Pool() # Remove any trailing slash or else subversion might abort path = os.path.normpath(path).replace('\\', '/') self.path = repos.svn_repos_find_root_path(path, self.pool()) if self.path is None: raise TracError("%s does not appear to be a Subversion repository." \ % path)
1e7fbc587c7afba5631f3ae6002cef1e3992ec11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/1e7fbc587c7afba5631f3ae6002cef1e3992ec11/svn_fs.py
self._execute('severity change critical end-of-the-world')
self._execute('severity change critical "end-of-the-world"')
def test_severity_change_ok(self): """ Tests the 'severity add' command in trac-admin. This particular test passes valid arguments and checks for success. """ test_name = sys._getframe().f_code.co_name self._execute('severity add critical') self._execute('severity change critical end-of-the-world') test_results = self._execute('severity list') self.assertEquals(self.expected_results[test_name], test_results)
af34672c99198d72bd8a714bfe91d1ead16e70dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/af34672c99198d72bd8a714bfe91d1ead16e70dc/admin.py
return self.default
return self.default(component.env)
def implementation(self, component): cfgvalue = component.config.get(self.cfg_section, self.cfg_property) for impl in self.xtnpt.extensions(component): if impl.__class__.__name__ == cfgvalue: return impl if self.default is not None: return self.default raise AttributeError('Cannot find an implementation of the "%s" ' 'interface named "%s". Please update your ' 'trac.ini setting "%s.%s"' % (self.xtnpt.interface.__name__, cfgvalue, self.cfg_section, self.cfg_property))
8fde65a86a1b2278e4080c5222c27a0eb6df791b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/8fde65a86a1b2278e4080c5222c27a0eb6df791b/core.py
time = int(t or time.time()) self.date = datetime.fromtimestamp(time, utc)
timestamp = int(t or time.time()) self.date = datetime.fromtimestamp(timestamp, utc)
def insert(self, filename, fileobj, size, t=None, db=None): # FIXME: `t` should probably be switched to `datetime` too if not db: db = self.env.get_db_cnx() handle_ta = True else: handle_ta = False
29a9ed0865c900850ccdf96878a1c351093bffe6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/29a9ed0865c900850ccdf96878a1c351093bffe6/attachment.py
self.size, time, self.description, self.author, self.ipnr))
self.size, timestamp, self.description, self.author, self.ipnr))
def insert(self, filename, fileobj, size, t=None, db=None): # FIXME: `t` should probably be switched to `datetime` too if not db: db = self.env.get_db_cnx() handle_ta = True else: handle_ta = False
29a9ed0865c900850ccdf96878a1c351093bffe6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/29a9ed0865c900850ccdf96878a1c351093bffe6/attachment.py
def get_ticket (self, id):
def get_ticket (self, id, escape_values=1):
def get_ticket (self, id): global fields cnx = db.get_connection () cursor = cnx.cursor ()
8ed3b4e22773597d1e4623a4cd0ca5dbcc438c8f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/8ed3b4e22773597d1e4623a4cd0ca5dbcc438c8f/Ticket.py
info[fields[i]] = escape(row[i])
info[fields[i]] = row[i]
def get_ticket (self, id): global fields cnx = db.get_connection () cursor = cnx.cursor ()
8ed3b4e22773597d1e4623a4cd0ca5dbcc438c8f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/8ed3b4e22773597d1e4623a4cd0ca5dbcc438c8f/Ticket.py
hdf.setValue('ticket.changes.%d.author' % idx, author) hdf.setValue('ticket.changes.%d.field' % idx, field)
hdf.setValue('ticket.changes.%d.time' % idx, str(date)) hdf.setValue('ticket.changes.%d.author' % idx, author) hdf.setValue('ticket.changes.%d.field' % idx, field)
def insert_ticket_data(self, hdf, id): """Inserts ticket data into the hdf""" cnx = db.get_connection () cursor = cnx.cursor() cursor.execute('SELECT time, author, field, oldvalue, newvalue ' 'FROM ticket_change ' 'WHERE ticket=%s ORDER BY time', id) curr_author = None curr_date = 0 comment = None idx = 0
8ed3b4e22773597d1e4623a4cd0ca5dbcc438c8f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/8ed3b4e22773597d1e4623a4cd0ca5dbcc438c8f/Ticket.py
old = self.get_ticket(id)
old = self.get_ticket(id, 0)
def render (self): action = dict_get_with_default(self.args, 'action', 'view') if action == 'create': self.create_ticket () try: id = int(self.args['id']) except: redirect (href.menu())
8ed3b4e22773597d1e4623a4cd0ca5dbcc438c8f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/8ed3b4e22773597d1e4623a4cd0ca5dbcc438c8f/Ticket.py
class BasicAuthentication(HTTPAuthentication):
class PasswordFileAuthentication(HTTPAuthentication): def __init__(self, filename): self.filename = filename self.mtime = os.stat(filename).st_mtime self.load(self.filename) self._lock = threading.Lock() def check_reload(self): self._lock.acquire() try: mtime = os.stat(self.filename).st_mtime if mtime > self.mtime: self.mtime = mtime self.load(self.filename) finally: self._lock.release() class BasicAuthentication(PasswordFileAuthentication):
def do_auth(self, environ, start_response): raise NotImplementedError
c763c03a734eb2f621130258e8329c20e5c8d194 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/c763c03a734eb2f621130258e8329c20e5c8d194/auth.py
self.hash = {}
def __init__(self, htpasswd, realm): self.hash = {} self.realm = realm try: import crypt self.crypt = crypt.crypt except ImportError: self.crypt = None self.load(htpasswd)
c763c03a734eb2f621130258e8329c20e5c8d194 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/c763c03a734eb2f621130258e8329c20e5c8d194/auth.py
self.load(htpasswd)
PasswordFileAuthentication.__init__(self, htpasswd)
def __init__(self, htpasswd, realm): self.hash = {} self.realm = realm try: import crypt self.crypt = crypt.crypt except ImportError: self.crypt = None self.load(htpasswd)
c763c03a734eb2f621130258e8329c20e5c8d194 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/c763c03a734eb2f621130258e8329c20e5c8d194/auth.py
class DigestAuthentication(HTTPAuthentication):
class DigestAuthentication(PasswordFileAuthentication):
def do_auth(self, environ, start_response): header = environ.get('HTTP_AUTHORIZATION') if header and header.startswith('Basic'): auth = b64decode(header[6:]).split(':') if len(auth) == 2: user, password = auth if self.test(user, password): return user
c763c03a734eb2f621130258e8329c20e5c8d194 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/c763c03a734eb2f621130258e8329c20e5c8d194/auth.py
self.hash = {}
def __init__(self, htdigest, realm): self.active_nonces = [] self.hash = {} self.realm = realm self.load_htdigest(htdigest, realm)
c763c03a734eb2f621130258e8329c20e5c8d194 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/c763c03a734eb2f621130258e8329c20e5c8d194/auth.py
self.load_htdigest(htdigest, realm) def load_htdigest(self, filename, realm):
PasswordFileAuthentication.__init__(self, htdigest) def load(self, filename):
def __init__(self, htdigest, realm): self.active_nonces = [] self.hash = {} self.realm = realm self.load_htdigest(htdigest, realm)
c763c03a734eb2f621130258e8329c20e5c8d194 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/c763c03a734eb2f621130258e8329c20e5c8d194/auth.py
if r == realm:
if r == self.realm:
def load_htdigest(self, filename, realm): """Load account information from apache style htdigest files, only users from the specified realm are used """ fd = open(filename, 'r') for line in fd.readlines(): line = line.strip() if not line: continue try: u, r, a1 = line.split(':') except ValueError: print >>sys.stderr, 'Warning: invalid digest line in %s: %s' \ % (filename, line) continue if r == realm: self.hash[u] = a1 if self.hash == {}: print >> sys.stderr, "Warning: found no users in realm:", realm
c763c03a734eb2f621130258e8329c20e5c8d194 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/c763c03a734eb2f621130258e8329c20e5c8d194/auth.py
print >> sys.stderr, "Warning: found no users in realm:", realm
print >> sys.stderr, "Warning: found no users in realm:", self.realm
def load_htdigest(self, filename, realm): """Load account information from apache style htdigest files, only users from the specified realm are used """ fd = open(filename, 'r') for line in fd.readlines(): line = line.strip() if not line: continue try: u, r, a1 = line.split(':') except ValueError: print >>sys.stderr, 'Warning: invalid digest line in %s: %s' \ % (filename, line) continue if r == realm: self.hash[u] = a1 if self.hash == {}: print >> sys.stderr, "Warning: found no users in realm:", realm
c763c03a734eb2f621130258e8329c20e5c8d194 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/c763c03a734eb2f621130258e8329c20e5c8d194/auth.py
fd = None
fd = open(os.path.join(self.path, 'VERSION'), 'r')
def verify(self): """Verify that the provided path points to a valid Trac environment directory.""" fd = None try: fd = open(os.path.join(self.path, 'VERSION'), 'r') assert fd.read(26) == 'Trac Environment Version 1' finally: if fd: fd.close()
0546711392cb077bb975f25d209fd308cc3b641b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/0546711392cb077bb975f25d209fd308cc3b641b/env.py
fd = open(os.path.join(self.path, 'VERSION'), 'r')
def verify(self): """Verify that the provided path points to a valid Trac environment directory.""" fd = None try: fd = open(os.path.join(self.path, 'VERSION'), 'r') assert fd.read(26) == 'Trac Environment Version 1' finally: if fd: fd.close()
0546711392cb077bb975f25d209fd308cc3b641b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9317/0546711392cb077bb975f25d209fd308cc3b641b/env.py