rem
stringlengths 1
322k
| add
stringlengths 0
2.05M
| context
stringlengths 4
228k
| meta
stringlengths 156
215
|
---|---|---|---|
self.send_error(403, "CGI script is not a plain file (%r)" % | self.send_error(403, "CGI script is not a plain file (%r)" % | def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%r)" % scriptname) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%r)" % scriptname) return ispy = self.is_python(scriptname) if not ispy: if not (self.have_fork or self.have_popen2 or self.have_popen3): self.send_error(403, "CGI script is not a Python script (%r)" % scriptname) return if not self.is_executable(scriptfile): self.send_error(403, "CGI script is not executable (%r)" % scriptname) return | aa793d710aff96365ddaae869ec50a64b9a5b1df /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/aa793d710aff96365ddaae869ec50a64b9a5b1df/CGIHTTPServer.py |
print socket.error | try: raise socket.error except socket.error: print "socket.error" | def missing_ok(str): try: getattr(socket, str) except AttributeError: pass | 89a22626cde4cc40df2d6aee29a281cfb574add1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/89a22626cde4cc40df2d6aee29a281cfb574add1/test_socket.py |
width=80, | width=79, | def __init__ (self, indent_increment=2, max_help_position=24, width=80, short_first=1): HelpFormatter.__init__( self, indent_increment, max_help_position, width, short_first) | fc3dbfc84e3af080915ba55bdda8f6007f4fc4fb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fc3dbfc84e3af080915ba55bdda8f6007f4fc4fb/optparse.py |
width=80, | width=79, | def __init__ (self, indent_increment=0, max_help_position=24, width=80, short_first=0): HelpFormatter.__init__ ( self, indent_increment, max_help_position, width, short_first) | fc3dbfc84e3af080915ba55bdda8f6007f4fc4fb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fc3dbfc84e3af080915ba55bdda8f6007f4fc4fb/optparse.py |
self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) try: self.socket.connect(address) except socket.error: self.socket.close() self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) self.socket.connect(address) | self._connect_unixsocket(address) | def __init__(self, address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER): """ Initialize a handler. | 64d4cf6e6f18f8bbf06b2d2f7ef60bf87da3afe0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/64d4cf6e6f18f8bbf06b2d2f7ef60bf87da3afe0/handlers.py |
self.socket.send(msg) | try: self.socket.send(msg) except socket.error: self._connect_unixsocket(self.address) self.socket.send(msg) | def emit(self, record): """ Emit a record. | 64d4cf6e6f18f8bbf06b2d2f7ef60bf87da3afe0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/64d4cf6e6f18f8bbf06b2d2f7ef60bf87da3afe0/handlers.py |
if sys.platform in ('win', 'mac'): | if sys.platform[:3] in ('win', 'mac'): | def test(): import sys if sys.platform in ('win', 'mac'): if verbose: print "Can't test select easily" return cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done' p = os.popen(cmd, 'r') for tout in (0, 1, 2, 4, 8, 16) + (None,)*10: if verbose: print 'timeout =', tout rfd, wfd, xfd = select.select([p], [], [], tout) | 59b5eca9043fdffadbc7ee96cc36dead128982b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/59b5eca9043fdffadbc7ee96cc36dead128982b5/test_select.py |
print "Can't test select easily" | print "Can't test select easily on", sys.platform | def test(): import sys if sys.platform in ('win', 'mac'): if verbose: print "Can't test select easily" return cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done' p = os.popen(cmd, 'r') for tout in (0, 1, 2, 4, 8, 16) + (None,)*10: if verbose: print 'timeout =', tout rfd, wfd, xfd = select.select([p], [], [], tout) | 59b5eca9043fdffadbc7ee96cc36dead128982b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/59b5eca9043fdffadbc7ee96cc36dead128982b5/test_select.py |
current_lang = locale.getlocale(locale.LC_TIME)[0] if current_lang: self.__lang = current_lang else: current_lang = locale.getdefaultlocale()[0] if current_lang: self.__lang = current_lang else: self.__lang = '' | self.__lang = _getlang() | def __calc_lang(self): # Set self.__lang by using locale.getlocale() or # locale.getdefaultlocale(). If both turn up empty, set the attribute # to ''. This is to stop calls to this method and to make sure # strptime() can produce an re object correctly. current_lang = locale.getlocale(locale.LC_TIME)[0] if current_lang: self.__lang = current_lang else: current_lang = locale.getdefaultlocale()[0] if current_lang: self.__lang = current_lang else: self.__lang = '' | 4fe325560fa86dd8f551af9bf0a13259a862c5ed /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4fe325560fa86dd8f551af9bf0a13259a862c5ed/_strptime.py |
for whitespace in whitespace_string: format = format.replace(whitespace, r'\s*') | whitespace_replacement = re_compile('\s+') format = whitespace_replacement.sub('\s*', format) | def pattern(self, format): """Return re pattern for the format string.""" processed_format = '' for whitespace in whitespace_string: format = format.replace(whitespace, r'\s*') while format.find('%') != -1: directive_index = format.index('%')+1 processed_format = "%s%s%s" % (processed_format, format[:directive_index-1], self[format[directive_index]]) format = format[directive_index+1:] return "%s%s" % (processed_format, format) | 4fe325560fa86dd8f551af9bf0a13259a862c5ed /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4fe325560fa86dd8f551af9bf0a13259a862c5ed/_strptime.py |
format = "(? | def compile(self, format): """Return a compiled re object for the format string.""" format = "(?#%s)%s" % (self.locale_time.lang,format) return re_compile(self.pattern(format), IGNORECASE) | 4fe325560fa86dd8f551af9bf0a13259a862c5ed /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4fe325560fa86dd8f551af9bf0a13259a862c5ed/_strptime.py |
|
locale_time = LocaleTime() compiled_re = TimeRE(locale_time).compile(format) found = compiled_re.match(data_string) | global _locale_cache global _regex_cache locale_time = _locale_cache.locale_time if locale_time.lang != _getlang(): _locale_cache = TimeRE() _regex_cache.clear() format_regex = _regex_cache.get(format) if not format_regex: if len(_regex_cache) > 5: _regex_cache.clear() format_regex = _locale_cache.compile(format) _regex_cache[format] = format_regex found = format_regex.match(data_string) | def strptime(data_string, format="%a %b %d %H:%M:%S %Y"): """Return a time struct based on the input data and the format string.""" locale_time = LocaleTime() compiled_re = TimeRE(locale_time).compile(format) found = compiled_re.match(data_string) if not found: raise ValueError("time data did not match format") year = 1900 month = day = 1 hour = minute = second = 0 tz = -1 # Defaulted to -1 so as to signal using functions to calc values weekday = julian = -1 found_dict = found.groupdict() for group_key in found_dict.iterkeys(): if group_key == 'y': year = int(found_dict['y']) # Open Group specification for strptime() states that a %y #value in the range of [00, 68] is in the century 2000, while #[69,99] is in the century 1900 if year <= 68: year += 2000 else: year += 1900 elif group_key == 'Y': year = int(found_dict['Y']) elif group_key == 'm': month = int(found_dict['m']) elif group_key == 'B': month = _insensitiveindex(locale_time.f_month, found_dict['B']) elif group_key == 'b': month = _insensitiveindex(locale_time.a_month, found_dict['b']) elif group_key == 'd': day = int(found_dict['d']) elif group_key is 'H': hour = int(found_dict['H']) elif group_key == 'I': hour = int(found_dict['I']) ampm = found_dict.get('p', '').lower() # If there was no AM/PM indicator, we'll treat this like AM if ampm in ('', locale_time.am_pm[0].lower()): # We're in AM so the hour is correct unless we're # looking at 12 midnight. # 12 midnight == 12 AM == hour 0 if hour == 12: hour = 0 elif ampm == locale_time.am_pm[1].lower(): # We're in PM so we need to add 12 to the hour unless # we're looking at 12 noon. # 12 noon == 12 PM == hour 12 if hour != 12: hour += 12 elif group_key == 'M': minute = int(found_dict['M']) elif group_key == 'S': second = int(found_dict['S']) elif group_key == 'A': weekday = _insensitiveindex(locale_time.f_weekday, found_dict['A']) elif group_key == 'a': weekday = _insensitiveindex(locale_time.a_weekday, found_dict['a']) elif group_key == 'w': weekday = int(found_dict['w']) if weekday == 0: weekday = 6 else: weekday -= 1 elif group_key == 'j': julian = int(found_dict['j']) elif group_key == 'Z': found_zone = found_dict['Z'].lower() if locale_time.timezone[0] == locale_time.timezone[1]: pass #Deals with bad locale setup where timezone info is # the same; first found on FreeBSD 4.4. elif locale_time.timezone[0].lower() == found_zone: tz = 0 elif locale_time.timezone[1].lower() == found_zone: tz = 1 elif locale_time.timezone[2].lower() == found_zone: tz = -1 #XXX <bc>: If calculating fxns are never exposed to the general #populous then just inline calculations. Also might be able to use #``datetime`` and the methods it provides. if julian == -1: julian = julianday(year, month, day) else: # Assuming that if they bothered to include Julian day it will #be accurate year, month, day = gregorian(julian, year) if weekday == -1: weekday = dayofweek(year, month, day) return time.struct_time((year, month, day, hour, minute, second, weekday, julian, tz)) | 4fe325560fa86dd8f551af9bf0a13259a862c5ed /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4fe325560fa86dd8f551af9bf0a13259a862c5ed/_strptime.py |
_wordchars_re = re.compile(r'[^\\\'\"\ ]*') | _wordchars_re = re.compile(r'[^\\\'\"%s ]*' % string.whitespace) | def grok_environment_error (exc, prefix="error: "): """Generate a useful error message from an EnvironmentError (IOError or OSError) exception object. Handles Python 1.5.1 and 1.5.2 styles, and does what it can to deal with exception objects that don't have a filename (which happens when the error is due to a two-file operation, such as 'rename()' or 'link()'. Returns the error message as a string prefixed with 'prefix'. """ # check for Python 1.5.2-style {IO,OS}Error exception objects if hasattr (exc, 'filename') and hasattr (exc, 'strerror'): if exc.filename: error = prefix + "%s: %s" % (exc.filename, exc.strerror) else: # two-argument functions in posix module don't # include the filename in the exception object! error = prefix + "%s" % exc.strerror else: error = prefix + str(exc[-1]) return error | 808d09497c0f1bdb0f5c30f4816d58ac8eb49002 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/808d09497c0f1bdb0f5c30f4816d58ac8eb49002/util.py |
if s[end] == ' ': | if s[end] in string.whitespace: | def split_quoted (s): """Split a string up according to Unix shell-like rules for quotes and backslashes. In short: words are delimited by spaces, as long as those spaces are not escaped by a backslash, or inside a quoted string. Single and double quotes are equivalent, and the quote characters can be backslash-escaped. The backslash is stripped from any two-character escape sequence, leaving only the escaped character. The quote characters are stripped from any quoted string. Returns a list of words. """ # This is a nice algorithm for splitting up a single string, since it # doesn't require character-by-character examination. It was a little # bit of a brain-bender to get it working right, though... s = string.strip(s) words = [] pos = 0 while s: m = _wordchars_re.match(s, pos) end = m.end() if end == len(s): words.append(s[:end]) break if s[end] == ' ': # unescaped, unquoted space: now words.append(s[:end]) # we definitely have a word delimiter s = string.lstrip(s[end:]) pos = 0 elif s[end] == '\\': # preserve whatever is being escaped; # will become part of the current word s = s[:end] + s[end+1:] pos = end+1 else: if s[end] == "'": # slurp singly-quoted string m = _squote_re.match(s, end) elif s[end] == '"': # slurp doubly-quoted string m = _dquote_re.match(s, end) else: raise RuntimeError, \ "this can't happen (bad char '%c')" % s[end] if m is None: raise ValueError, \ "bad string (mismatched %s quotes?)" % s[end] (beg, end) = m.span() s = s[:beg] + s[beg+1:end-1] + s[end:] pos = m.end() - 2 if pos >= len(s): words.append(s) break return words | 808d09497c0f1bdb0f5c30f4816d58ac8eb49002 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/808d09497c0f1bdb0f5c30f4816d58ac8eb49002/util.py |
self.file.write('\n' + '\n'*blankline) | self.file.write('\n'*blankline) | def send_paragraph(self, blankline): self.file.write('\n' + '\n'*blankline) self.col = 0 self.atbreak = 0 | 258a7da7630c5d61ef4c65c48c48a0a92374f355 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/258a7da7630c5d61ef4c65c48c48a0a92374f355/formatter.py |
A2 = "%s:%s" % (req.has_data() and 'POST' or 'GET', | A2 = "%s:%s" % (req.get_method(), | def get_authorization(self, req, chal): try: realm = chal['realm'] nonce = chal['nonce'] qop = chal.get('qop') algorithm = chal.get('algorithm', 'MD5') # mod_digest doesn't send an opaque, even though it isn't # supposed to be optional opaque = chal.get('opaque', None) except KeyError: return None | b0ee45bafd61a59004ae62cf17ef04e1e2f61079 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b0ee45bafd61a59004ae62cf17ef04e1e2f61079/urllib2.py |
os.chmod(p, stat.S_IMODE(st.st_mode) | stat.S_IXGRP) | os.chmod(p, stat.S_IMODE(st.st_mode) | stat.S_IWGRP) os.chown(p, -1, gid) | def buildPython(): print "Building a universal python" buildDir = os.path.join(WORKDIR, '_bld', 'python') rootDir = os.path.join(WORKDIR, '_root') if os.path.exists(buildDir): shutil.rmtree(buildDir) if os.path.exists(rootDir): shutil.rmtree(rootDir) os.mkdir(buildDir) os.mkdir(rootDir) os.mkdir(os.path.join(rootDir, 'empty-dir')) curdir = os.getcwd() os.chdir(buildDir) # Not sure if this is still needed, the original build script # claims that parts of the install assume python.exe exists. os.symlink('python', os.path.join(buildDir, 'python.exe')) # Extract the version from the configure file, needed to calculate # several paths. version = getVersion() print "Running configure..." runCommand("%s -C --enable-framework --enable-universalsdk=%s LDFLAGS='-g -L%s/libraries/usr/local/lib' OPT='-g -O3 -I%s/libraries/usr/local/include' 2>&1"%( shellQuote(os.path.join(SRCDIR, 'configure')), shellQuote(SDKPATH), shellQuote(WORKDIR)[1:-1], shellQuote(WORKDIR)[1:-1])) print "Running make" runCommand("make") print "Runing make frameworkinstall" runCommand("make frameworkinstall DESTDIR=%s"%( shellQuote(rootDir))) print "Runing make frameworkinstallextras" runCommand("make frameworkinstallextras DESTDIR=%s"%( shellQuote(rootDir))) print "Copy required shared libraries" if os.path.exists(os.path.join(WORKDIR, 'libraries', 'Library')): runCommand("mv %s/* %s"%( shellQuote(os.path.join( WORKDIR, 'libraries', 'Library', 'Frameworks', 'Python.framework', 'Versions', getVersion(), 'lib')), shellQuote(os.path.join(WORKDIR, '_root', 'Library', 'Frameworks', 'Python.framework', 'Versions', getVersion(), 'lib')))) print "Fix file modes" frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework') for dirpath, dirnames, filenames in os.walk(frmDir): for dn in dirnames: os.chmod(os.path.join(dirpath, dn), 0775) for fn in filenames: if os.path.islink(fn): continue # "chmod g+w $fn" p = os.path.join(dirpath, fn) st = os.stat(p) os.chmod(p, stat.S_IMODE(st.st_mode) | stat.S_IXGRP) # We added some directories to the search path during the configure # phase. Remove those because those directories won't be there on # the end-users system. path =os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework', 'Versions', version, 'lib', 'python%s'%(version,), 'config', 'Makefile') fp = open(path, 'r') data = fp.read() fp.close() data = data.replace('-L%s/libraries/usr/local/lib'%(WORKDIR,), '') data = data.replace('-I%s/libraries/usr/local/include'%(WORKDIR,), '') fp = open(path, 'w') fp.write(data) fp.close() # Add symlinks in /usr/local/bin, using relative links usr_local_bin = os.path.join(rootDir, 'usr', 'local', 'bin') to_framework = os.path.join('..', '..', '..', 'Library', 'Frameworks', 'Python.framework', 'Versions', version, 'bin') if os.path.exists(usr_local_bin): shutil.rmtree(usr_local_bin) os.makedirs(usr_local_bin) for fn in os.listdir( os.path.join(frmDir, 'Versions', version, 'bin')): os.symlink(os.path.join(to_framework, fn), os.path.join(usr_local_bin, fn)) os.chdir(curdir) | 9699456287b9f4df3c6f99bd76aba0ccb2f8b658 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9699456287b9f4df3c6f99bd76aba0ccb2f8b658/build-installer.py |
decoded[-1] = (decoded[-1][0] + dec, None) | decoded[-1] = (decoded[-1][0] + SPACE + unenc, None) | def decode_header(header): """Decode a message header value without converting charset. Returns a list of (decoded_string, charset) pairs containing each of the decoded parts of the header. Charset is None for non-encoded parts of the header, otherwise a lower-case string containing the name of the character set specified in the encoded string. An email.Errors.HeaderParseError may be raised when certain decoding error occurs (e.g. a base64 decoding exception). """ # If no encoding, just return the header header = str(header) if not ecre.search(header): return [(header, None)] decoded = [] dec = '' for line in header.splitlines(): # This line might not have an encoding in it if not ecre.search(line): decoded.append((line, None)) continue parts = ecre.split(line) while parts: unenc = parts.pop(0).strip() if unenc: # Should we continue a long line? if decoded and decoded[-1][1] is None: decoded[-1] = (decoded[-1][0] + dec, None) else: decoded.append((unenc, None)) if parts: charset, encoding = [s.lower() for s in parts[0:2]] encoded = parts[2] dec = None if encoding == 'q': dec = email.quopriMIME.header_decode(encoded) elif encoding == 'b': try: dec = email.base64MIME.decode(encoded) except binascii.Error: # Turn this into a higher level exception. BAW: Right # now we throw the lower level exception away but # when/if we get exception chaining, we'll preserve it. raise HeaderParseError if dec is None: dec = encoded if decoded and decoded[-1][1] == charset: decoded[-1] = (decoded[-1][0] + dec, decoded[-1][1]) else: decoded.append((dec, charset)) del parts[0:3] return decoded | 5cc519b7e473b4b621d295a7ca9e8948e6642ebc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5cc519b7e473b4b621d295a7ca9e8948e6642ebc/Header.py |
else: raise TestFailed, '1 and 1 is false instead of false' | else: raise TestFailed, '1 and 1 is false instead of true' | def f(): pass | 73b3ac2657f0097461eba25237c86cb7c379eb74 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/73b3ac2657f0097461eba25237c86cb7c379eb74/test_types.py |
if inspect.ismodule(object): return self.docmodule(*args) if inspect.isclass(object): return self.docclass(*args) if inspect.isroutine(object): return self.docroutine(*args) | try: if inspect.ismodule(object): return self.docmodule(*args) if inspect.isclass(object): return self.docclass(*args) if inspect.isroutine(object): return self.docroutine(*args) except AttributeError: pass | def document(self, object, name=None, *args): """Generate documentation for an object.""" args = (object, name) + args if inspect.ismodule(object): return self.docmodule(*args) if inspect.isclass(object): return self.docclass(*args) if inspect.isroutine(object): return self.docroutine(*args) return self.docother(*args) | 0e26179dae213d8021e04c72542a2d77c7abc1cf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0e26179dae213d8021e04c72542a2d77c7abc1cf/pydoc.py |
Returns a list describing the signiture of the method. In the | Returns a list describing the signature of the method. In the | def system_methodSignature(self, method_name): """system.methodSignature('add') => [double, int, int] | 724cf2969d1f7ada415886f4fef1942ff4a6279a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/724cf2969d1f7ada415886f4fef1942ff4a6279a/SimpleXMLRPCServer.py |
n = 100 | n = 200 | def test_tee(self): n = 100 def irange(n): for i in xrange(n): yield i | 9d7f0ec6c4ab535fc3d876ab7bbdc46393ad5147 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9d7f0ec6c4ab535fc3d876ab7bbdc46393ad5147/test_itertools.py |
self.assertEqual(a.next(), 0) self.assertEqual(a.next(), 1) | for i in xrange(100): self.assertEqual(a.next(), i) | def irange(n): for i in xrange(n): yield i | 9d7f0ec6c4ab535fc3d876ab7bbdc46393ad5147 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9d7f0ec6c4ab535fc3d876ab7bbdc46393ad5147/test_itertools.py |
self.assertEqual(a.next(), 0) self.assertEqual(a.next(), 1) | for i in xrange(100): self.assertEqual(a.next(), i) | def irange(n): for i in xrange(n): yield i | 9d7f0ec6c4ab535fc3d876ab7bbdc46393ad5147 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9d7f0ec6c4ab535fc3d876ab7bbdc46393ad5147/test_itertools.py |
self.assertEqual(list(a), range(2, n)) | self.assertEqual(list(a), range(100, n)) | def irange(n): for i in xrange(n): yield i | 9d7f0ec6c4ab535fc3d876ab7bbdc46393ad5147 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9d7f0ec6c4ab535fc3d876ab7bbdc46393ad5147/test_itertools.py |
try: class A(tee): pass except TypeError: pass else: self.fail("tee constructor should not be subclassable") a, b = tee(xrange(10)) self.assertRaises(TypeError, type(a)) self.assert_(a is iter(a)) | self.assertRaises(TypeError, tee, [1,2], 3, 'x') a, b = tee('abc') c = type(a)('def') self.assertEqual(list(c), list('def')) a, b, c = tee(xrange(2000), 3) for i in xrange(100): self.assertEqual(a.next(), i) self.assertEqual(list(b), range(2000)) self.assertEqual([c.next(), c.next()], range(2)) self.assertEqual(list(a), range(100,2000)) self.assertEqual(list(c), range(2,2000)) a, b = tee('abc') c, d = tee(a) self.assert_(a is c) | def irange(n): for i in xrange(n): yield i | 9d7f0ec6c4ab535fc3d876ab7bbdc46393ad5147 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9d7f0ec6c4ab535fc3d876ab7bbdc46393ad5147/test_itertools.py |
def test_tee(self): a = [] p, q = t = tee([a]*2) a += [a, p, q, t] p.next() del a, p, q, t | def test_starmap(self): a = [] self.makecycle(starmap(lambda *t: t, [(a,a)]*2), a) | 9d7f0ec6c4ab535fc3d876ab7bbdc46393ad5147 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9d7f0ec6c4ab535fc3d876ab7bbdc46393ad5147/test_itertools.py |
|
... return izip(a, islice(b, 1, None)) | ... try: ... b.next() ... except StopIteration: ... pass ... return izip(a, b) | >>> def pairwise(iterable): | 9d7f0ec6c4ab535fc3d876ab7bbdc46393ad5147 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9d7f0ec6c4ab535fc3d876ab7bbdc46393ad5147/test_itertools.py |
start += stop | start += step | def frange(start, stop, step): while start <= stop: yield start start += stop | 8783c37ca945fe2c656d1d7d62ed7a3ea7ff0047 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8783c37ca945fe2c656d1d7d62ed7a3ea7ff0047/test_colorsys.py |
self.status = status = int(status) | try: self.status = status = int(status) if status < 100 or status > 999: raise BadStatusLine(line) except ValueError: raise BadStatusLine(line) | def begin(self): if self.msg is not None: # we've already started reading the response return | 69e792add597fcf057a9cd2418be7febabbeaaa3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/69e792add597fcf057a9cd2418be7febabbeaaa3/httplib.py |
self.includepath = [':', INCLUDEDIR] | self.includepath = [os.curdir, INCLUDEDIR] | def initpaths(self): self.includepath = [':', INCLUDEDIR] | 0546c5d79ec2028b33fb95a97b748c8c5505e1b8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0546c5d79ec2028b33fb95a97b748c8c5505e1b8/scantools.py |
if MacOS: | if MacOS and CREATOR: | def initosspecifics(self): if MacOS: self.filetype = 'TEXT' self.filecreator = CREATOR else: self.filetype = self.filecreator = None | 0546c5d79ec2028b33fb95a97b748c8c5505e1b8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0546c5d79ec2028b33fb95a97b748c8c5505e1b8/scantools.py |
save_warnings_filters = warnings.filters[:] globals = func.func_globals if '__warningregistry__' in globals: del globals['__warningregistry__'] warnings.filterwarnings("error", r"""^struct.*""", DeprecationWarning) warnings.filterwarnings("error", r""".*format requires.*""", DeprecationWarning) | def deprecated_err(func, *args): # The `warnings` module doesn't have an advertised way to restore # its filter list. Cheat. save_warnings_filters = warnings.filters[:] # Grrr, we need this function to warn every time. Without removing # the warningregistry, running test_tarfile then test_struct would fail # on 64-bit platforms. globals = func.func_globals if '__warningregistry__' in globals: del globals['__warningregistry__'] warnings.filterwarnings("error", r"""^struct.*""", DeprecationWarning) warnings.filterwarnings("error", r""".*format requires.*""", DeprecationWarning) try: try: func(*args) except (struct.error, TypeError): pass except DeprecationWarning: if not PY_STRUCT_OVERFLOW_MASKING: raise TestFailed, "%s%s expected to raise struct.error" % ( func.__name__, args) else: raise TestFailed, "%s%s did not raise error" % ( func.__name__, args) finally: warnings.filters[:] = save_warnings_filters[:] | bd08296c6dcfa6a8a786d64bbdf427821481ec76 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/bd08296c6dcfa6a8a786d64bbdf427821481ec76/test_struct.py |
|
try: func(*args) except (struct.error, TypeError): pass except DeprecationWarning: if not PY_STRUCT_OVERFLOW_MASKING: raise TestFailed, "%s%s expected to raise struct.error" % ( func.__name__, args) else: raise TestFailed, "%s%s did not raise error" % ( | func(*args) except (struct.error, TypeError): pass except DeprecationWarning: if not PY_STRUCT_OVERFLOW_MASKING: raise TestFailed, "%s%s expected to raise struct.error" % ( | def deprecated_err(func, *args): # The `warnings` module doesn't have an advertised way to restore # its filter list. Cheat. save_warnings_filters = warnings.filters[:] # Grrr, we need this function to warn every time. Without removing # the warningregistry, running test_tarfile then test_struct would fail # on 64-bit platforms. globals = func.func_globals if '__warningregistry__' in globals: del globals['__warningregistry__'] warnings.filterwarnings("error", r"""^struct.*""", DeprecationWarning) warnings.filterwarnings("error", r""".*format requires.*""", DeprecationWarning) try: try: func(*args) except (struct.error, TypeError): pass except DeprecationWarning: if not PY_STRUCT_OVERFLOW_MASKING: raise TestFailed, "%s%s expected to raise struct.error" % ( func.__name__, args) else: raise TestFailed, "%s%s did not raise error" % ( func.__name__, args) finally: warnings.filters[:] = save_warnings_filters[:] | bd08296c6dcfa6a8a786d64bbdf427821481ec76 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/bd08296c6dcfa6a8a786d64bbdf427821481ec76/test_struct.py |
finally: warnings.filters[:] = save_warnings_filters[:] | else: raise TestFailed, "%s%s did not raise error" % ( func.__name__, args) deprecated_err = with_warning_restore(deprecated_err) | def deprecated_err(func, *args): # The `warnings` module doesn't have an advertised way to restore # its filter list. Cheat. save_warnings_filters = warnings.filters[:] # Grrr, we need this function to warn every time. Without removing # the warningregistry, running test_tarfile then test_struct would fail # on 64-bit platforms. globals = func.func_globals if '__warningregistry__' in globals: del globals['__warningregistry__'] warnings.filterwarnings("error", r"""^struct.*""", DeprecationWarning) warnings.filterwarnings("error", r""".*format requires.*""", DeprecationWarning) try: try: func(*args) except (struct.error, TypeError): pass except DeprecationWarning: if not PY_STRUCT_OVERFLOW_MASKING: raise TestFailed, "%s%s expected to raise struct.error" % ( func.__name__, args) else: raise TestFailed, "%s%s did not raise error" % ( func.__name__, args) finally: warnings.filters[:] = save_warnings_filters[:] | bd08296c6dcfa6a8a786d64bbdf427821481ec76 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/bd08296c6dcfa6a8a786d64bbdf427821481ec76/test_struct.py |
mime_header = regex.compile('\\([ \t(]\\)\\([-a-zA-Z0-9_+]*[\240-\377][-a-zA-Z0-9_+\240-\377]*\\)\\([ \t)]\\|$\\)') | mime_header = regex.compile('\\([ \t(]\\|^\\)\\([-a-zA-Z0-9_+]*[\240-\377][-a-zA-Z0-9_+\240-\377]*\\)\\([ \t)]\\|$\\)') | def mime_encode(line, header): '''Code a single line as quoted-printable. If header is set, quote some extra characters.''' if header: reg = mime_header_char else: reg = mime_char newline = '' if len(line) >= 5 and line[:5] == 'From ': # quote 'From ' at the start of a line for stupid mailers newline = string.upper('=%02x' % ord('F')) line = line[1:] while 1: i = reg.search(line) if i < 0: break newline = newline + line[:i] + \ string.upper('=%02x' % ord(line[i])) line = line[i+1:] line = newline + line newline = '' while len(line) >= 75: i = 73 while line[i] == '=' or line[i-1] == '=': i = i - 1 i = i + 1 newline = newline + line[:i] + '=\n' line = line[i:] return newline + line | b0aa07b643488574b46fd4e3a04cdc1409cd3f2d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b0aa07b643488574b46fd4e3a04cdc1409cd3f2d/mimify.py |
QSIZE = 16 TIME = 5 | format = SV.RGB8_FRAMES qsize = 2 | def main(): QSIZE = 16 TIME = 5 audio = 0 num, den = 1, 1 opts, args = getopt.getopt(sys.argv[1:], 'aq:r:t:') for opt, arg in opts: if opt == '-a': audio = 1 elif opt == '-q': QSIZE = string.atoi(arg) elif opt == '-r': [nstr, dstr] = string.splitfields(arg, '/') num, den = string.atoi(nstr), string.atoi(dstr) elif opt == '-t': TIME = string.atoi(arg) if args[2:]: sys.stderr.write('usage: Vrec [options] [file [audiofile]]\n') sys.exit(2) if args: filename = args[0] else: filename = 'film.video' if args[1:] and not audio: sys.stderr.write('-a turned on by appearance of 2nd file\n') audio = 1 if audio: if args[1:]: audiofilename = args[1] else: audiofilename = 'film.aiff' else: audiofilename = None gl.foreground() x, y = SV.PAL_XMAX / 4, SV.PAL_YMAX / 4 print x, 'x', y gl.minsize(40, 30) gl.stepunit(8, 6) gl.maxsize(SV.PAL_XMAX, SV.PAL_YMAX) gl.keepaspect(SV.PAL_XMAX, SV.PAL_YMAX) win = gl.winopen(filename) x, y = gl.getsize() print x, 'x', y v = sv.OpenVideo() v.BindGLWindow(win, SV.IN_REPLACE) v.SetSize(x, y) v.BindGLWindow(win, SV.IN_REPLACE) v.SetCaptureFormat(SV.RGB_FRAMES) v.SetCaptureMode(SV.BLOCKING_CAPTURE) v.SetQueueSize(QSIZE) v.InitCapture() if v.GetQueueSize() != QSIZE: QSIZE = v.GetQueueSize() print 'Warning: QSIZE reduced to', QSIZE | 15728b345d96a6162fd564e1c123ee9961ee23dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/15728b345d96a6162fd564e1c123ee9961ee23dc/Vrec.py |
num, den = 1, 1 opts, args = getopt.getopt(sys.argv[1:], 'aq:r:t:') | rate = 2 opts, args = getopt.getopt(sys.argv[1:], 'aq:r:') | def main(): QSIZE = 16 TIME = 5 audio = 0 num, den = 1, 1 opts, args = getopt.getopt(sys.argv[1:], 'aq:r:t:') for opt, arg in opts: if opt == '-a': audio = 1 elif opt == '-q': QSIZE = string.atoi(arg) elif opt == '-r': [nstr, dstr] = string.splitfields(arg, '/') num, den = string.atoi(nstr), string.atoi(dstr) elif opt == '-t': TIME = string.atoi(arg) if args[2:]: sys.stderr.write('usage: Vrec [options] [file [audiofile]]\n') sys.exit(2) if args: filename = args[0] else: filename = 'film.video' if args[1:] and not audio: sys.stderr.write('-a turned on by appearance of 2nd file\n') audio = 1 if audio: if args[1:]: audiofilename = args[1] else: audiofilename = 'film.aiff' else: audiofilename = None gl.foreground() x, y = SV.PAL_XMAX / 4, SV.PAL_YMAX / 4 print x, 'x', y gl.minsize(40, 30) gl.stepunit(8, 6) gl.maxsize(SV.PAL_XMAX, SV.PAL_YMAX) gl.keepaspect(SV.PAL_XMAX, SV.PAL_YMAX) win = gl.winopen(filename) x, y = gl.getsize() print x, 'x', y v = sv.OpenVideo() v.BindGLWindow(win, SV.IN_REPLACE) v.SetSize(x, y) v.BindGLWindow(win, SV.IN_REPLACE) v.SetCaptureFormat(SV.RGB_FRAMES) v.SetCaptureMode(SV.BLOCKING_CAPTURE) v.SetQueueSize(QSIZE) v.InitCapture() if v.GetQueueSize() != QSIZE: QSIZE = v.GetQueueSize() print 'Warning: QSIZE reduced to', QSIZE | 15728b345d96a6162fd564e1c123ee9961ee23dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/15728b345d96a6162fd564e1c123ee9961ee23dc/Vrec.py |
QSIZE = string.atoi(arg) | qsize = string.atoi(arg) | def main(): QSIZE = 16 TIME = 5 audio = 0 num, den = 1, 1 opts, args = getopt.getopt(sys.argv[1:], 'aq:r:t:') for opt, arg in opts: if opt == '-a': audio = 1 elif opt == '-q': QSIZE = string.atoi(arg) elif opt == '-r': [nstr, dstr] = string.splitfields(arg, '/') num, den = string.atoi(nstr), string.atoi(dstr) elif opt == '-t': TIME = string.atoi(arg) if args[2:]: sys.stderr.write('usage: Vrec [options] [file [audiofile]]\n') sys.exit(2) if args: filename = args[0] else: filename = 'film.video' if args[1:] and not audio: sys.stderr.write('-a turned on by appearance of 2nd file\n') audio = 1 if audio: if args[1:]: audiofilename = args[1] else: audiofilename = 'film.aiff' else: audiofilename = None gl.foreground() x, y = SV.PAL_XMAX / 4, SV.PAL_YMAX / 4 print x, 'x', y gl.minsize(40, 30) gl.stepunit(8, 6) gl.maxsize(SV.PAL_XMAX, SV.PAL_YMAX) gl.keepaspect(SV.PAL_XMAX, SV.PAL_YMAX) win = gl.winopen(filename) x, y = gl.getsize() print x, 'x', y v = sv.OpenVideo() v.BindGLWindow(win, SV.IN_REPLACE) v.SetSize(x, y) v.BindGLWindow(win, SV.IN_REPLACE) v.SetCaptureFormat(SV.RGB_FRAMES) v.SetCaptureMode(SV.BLOCKING_CAPTURE) v.SetQueueSize(QSIZE) v.InitCapture() if v.GetQueueSize() != QSIZE: QSIZE = v.GetQueueSize() print 'Warning: QSIZE reduced to', QSIZE | 15728b345d96a6162fd564e1c123ee9961ee23dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/15728b345d96a6162fd564e1c123ee9961ee23dc/Vrec.py |
[nstr, dstr] = string.splitfields(arg, '/') num, den = string.atoi(nstr), string.atoi(dstr) elif opt == '-t': TIME = string.atoi(arg) | rate = string.atoi(arg) if rate < 2: sys.stderr.write('-r rate must be >= 2\n') sys.exit(2) | def main(): QSIZE = 16 TIME = 5 audio = 0 num, den = 1, 1 opts, args = getopt.getopt(sys.argv[1:], 'aq:r:t:') for opt, arg in opts: if opt == '-a': audio = 1 elif opt == '-q': QSIZE = string.atoi(arg) elif opt == '-r': [nstr, dstr] = string.splitfields(arg, '/') num, den = string.atoi(nstr), string.atoi(dstr) elif opt == '-t': TIME = string.atoi(arg) if args[2:]: sys.stderr.write('usage: Vrec [options] [file [audiofile]]\n') sys.exit(2) if args: filename = args[0] else: filename = 'film.video' if args[1:] and not audio: sys.stderr.write('-a turned on by appearance of 2nd file\n') audio = 1 if audio: if args[1:]: audiofilename = args[1] else: audiofilename = 'film.aiff' else: audiofilename = None gl.foreground() x, y = SV.PAL_XMAX / 4, SV.PAL_YMAX / 4 print x, 'x', y gl.minsize(40, 30) gl.stepunit(8, 6) gl.maxsize(SV.PAL_XMAX, SV.PAL_YMAX) gl.keepaspect(SV.PAL_XMAX, SV.PAL_YMAX) win = gl.winopen(filename) x, y = gl.getsize() print x, 'x', y v = sv.OpenVideo() v.BindGLWindow(win, SV.IN_REPLACE) v.SetSize(x, y) v.BindGLWindow(win, SV.IN_REPLACE) v.SetCaptureFormat(SV.RGB_FRAMES) v.SetCaptureMode(SV.BLOCKING_CAPTURE) v.SetQueueSize(QSIZE) v.InitCapture() if v.GetQueueSize() != QSIZE: QSIZE = v.GetQueueSize() print 'Warning: QSIZE reduced to', QSIZE | 15728b345d96a6162fd564e1c123ee9961ee23dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/15728b345d96a6162fd564e1c123ee9961ee23dc/Vrec.py |
v.BindGLWindow(win, SV.IN_REPLACE) | def main(): QSIZE = 16 TIME = 5 audio = 0 num, den = 1, 1 opts, args = getopt.getopt(sys.argv[1:], 'aq:r:t:') for opt, arg in opts: if opt == '-a': audio = 1 elif opt == '-q': QSIZE = string.atoi(arg) elif opt == '-r': [nstr, dstr] = string.splitfields(arg, '/') num, den = string.atoi(nstr), string.atoi(dstr) elif opt == '-t': TIME = string.atoi(arg) if args[2:]: sys.stderr.write('usage: Vrec [options] [file [audiofile]]\n') sys.exit(2) if args: filename = args[0] else: filename = 'film.video' if args[1:] and not audio: sys.stderr.write('-a turned on by appearance of 2nd file\n') audio = 1 if audio: if args[1:]: audiofilename = args[1] else: audiofilename = 'film.aiff' else: audiofilename = None gl.foreground() x, y = SV.PAL_XMAX / 4, SV.PAL_YMAX / 4 print x, 'x', y gl.minsize(40, 30) gl.stepunit(8, 6) gl.maxsize(SV.PAL_XMAX, SV.PAL_YMAX) gl.keepaspect(SV.PAL_XMAX, SV.PAL_YMAX) win = gl.winopen(filename) x, y = gl.getsize() print x, 'x', y v = sv.OpenVideo() v.BindGLWindow(win, SV.IN_REPLACE) v.SetSize(x, y) v.BindGLWindow(win, SV.IN_REPLACE) v.SetCaptureFormat(SV.RGB_FRAMES) v.SetCaptureMode(SV.BLOCKING_CAPTURE) v.SetQueueSize(QSIZE) v.InitCapture() if v.GetQueueSize() != QSIZE: QSIZE = v.GetQueueSize() print 'Warning: QSIZE reduced to', QSIZE | 15728b345d96a6162fd564e1c123ee9961ee23dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/15728b345d96a6162fd564e1c123ee9961ee23dc/Vrec.py |
|
v.SetCaptureFormat(SV.RGB_FRAMES) v.SetCaptureMode(SV.BLOCKING_CAPTURE) v.SetQueueSize(QSIZE) v.InitCapture() if v.GetQueueSize() != QSIZE: QSIZE = v.GetQueueSize() print 'Warning: QSIZE reduced to', QSIZE | def main(): QSIZE = 16 TIME = 5 audio = 0 num, den = 1, 1 opts, args = getopt.getopt(sys.argv[1:], 'aq:r:t:') for opt, arg in opts: if opt == '-a': audio = 1 elif opt == '-q': QSIZE = string.atoi(arg) elif opt == '-r': [nstr, dstr] = string.splitfields(arg, '/') num, den = string.atoi(nstr), string.atoi(dstr) elif opt == '-t': TIME = string.atoi(arg) if args[2:]: sys.stderr.write('usage: Vrec [options] [file [audiofile]]\n') sys.exit(2) if args: filename = args[0] else: filename = 'film.video' if args[1:] and not audio: sys.stderr.write('-a turned on by appearance of 2nd file\n') audio = 1 if audio: if args[1:]: audiofilename = args[1] else: audiofilename = 'film.aiff' else: audiofilename = None gl.foreground() x, y = SV.PAL_XMAX / 4, SV.PAL_YMAX / 4 print x, 'x', y gl.minsize(40, 30) gl.stepunit(8, 6) gl.maxsize(SV.PAL_XMAX, SV.PAL_YMAX) gl.keepaspect(SV.PAL_XMAX, SV.PAL_YMAX) win = gl.winopen(filename) x, y = gl.getsize() print x, 'x', y v = sv.OpenVideo() v.BindGLWindow(win, SV.IN_REPLACE) v.SetSize(x, y) v.BindGLWindow(win, SV.IN_REPLACE) v.SetCaptureFormat(SV.RGB_FRAMES) v.SetCaptureMode(SV.BLOCKING_CAPTURE) v.SetQueueSize(QSIZE) v.InitCapture() if v.GetQueueSize() != QSIZE: QSIZE = v.GetQueueSize() print 'Warning: QSIZE reduced to', QSIZE | 15728b345d96a6162fd564e1c123ee9961ee23dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/15728b345d96a6162fd564e1c123ee9961ee23dc/Vrec.py |
|
recorded = 0 | def main(): QSIZE = 16 TIME = 5 audio = 0 num, den = 1, 1 opts, args = getopt.getopt(sys.argv[1:], 'aq:r:t:') for opt, arg in opts: if opt == '-a': audio = 1 elif opt == '-q': QSIZE = string.atoi(arg) elif opt == '-r': [nstr, dstr] = string.splitfields(arg, '/') num, den = string.atoi(nstr), string.atoi(dstr) elif opt == '-t': TIME = string.atoi(arg) if args[2:]: sys.stderr.write('usage: Vrec [options] [file [audiofile]]\n') sys.exit(2) if args: filename = args[0] else: filename = 'film.video' if args[1:] and not audio: sys.stderr.write('-a turned on by appearance of 2nd file\n') audio = 1 if audio: if args[1:]: audiofilename = args[1] else: audiofilename = 'film.aiff' else: audiofilename = None gl.foreground() x, y = SV.PAL_XMAX / 4, SV.PAL_YMAX / 4 print x, 'x', y gl.minsize(40, 30) gl.stepunit(8, 6) gl.maxsize(SV.PAL_XMAX, SV.PAL_YMAX) gl.keepaspect(SV.PAL_XMAX, SV.PAL_YMAX) win = gl.winopen(filename) x, y = gl.getsize() print x, 'x', y v = sv.OpenVideo() v.BindGLWindow(win, SV.IN_REPLACE) v.SetSize(x, y) v.BindGLWindow(win, SV.IN_REPLACE) v.SetCaptureFormat(SV.RGB_FRAMES) v.SetCaptureMode(SV.BLOCKING_CAPTURE) v.SetQueueSize(QSIZE) v.InitCapture() if v.GetQueueSize() != QSIZE: QSIZE = v.GetQueueSize() print 'Warning: QSIZE reduced to', QSIZE | 15728b345d96a6162fd564e1c123ee9961ee23dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/15728b345d96a6162fd564e1c123ee9961ee23dc/Vrec.py |
|
if recorded: gl.ringbell() continue gl.prefsize(x, y) gl.winconstraints() record(v, filename, audiofilename) recorded = 1 print 'Wait until "Done writing" is printed!' | info = format, x, y, qsize, rate record(v, info, filename, audiofilename) | def main(): QSIZE = 16 TIME = 5 audio = 0 num, den = 1, 1 opts, args = getopt.getopt(sys.argv[1:], 'aq:r:t:') for opt, arg in opts: if opt == '-a': audio = 1 elif opt == '-q': QSIZE = string.atoi(arg) elif opt == '-r': [nstr, dstr] = string.splitfields(arg, '/') num, den = string.atoi(nstr), string.atoi(dstr) elif opt == '-t': TIME = string.atoi(arg) if args[2:]: sys.stderr.write('usage: Vrec [options] [file [audiofile]]\n') sys.exit(2) if args: filename = args[0] else: filename = 'film.video' if args[1:] and not audio: sys.stderr.write('-a turned on by appearance of 2nd file\n') audio = 1 if audio: if args[1:]: audiofilename = args[1] else: audiofilename = 'film.aiff' else: audiofilename = None gl.foreground() x, y = SV.PAL_XMAX / 4, SV.PAL_YMAX / 4 print x, 'x', y gl.minsize(40, 30) gl.stepunit(8, 6) gl.maxsize(SV.PAL_XMAX, SV.PAL_YMAX) gl.keepaspect(SV.PAL_XMAX, SV.PAL_YMAX) win = gl.winopen(filename) x, y = gl.getsize() print x, 'x', y v = sv.OpenVideo() v.BindGLWindow(win, SV.IN_REPLACE) v.SetSize(x, y) v.BindGLWindow(win, SV.IN_REPLACE) v.SetCaptureFormat(SV.RGB_FRAMES) v.SetCaptureMode(SV.BLOCKING_CAPTURE) v.SetQueueSize(QSIZE) v.InitCapture() if v.GetQueueSize() != QSIZE: QSIZE = v.GetQueueSize() print 'Warning: QSIZE reduced to', QSIZE | 15728b345d96a6162fd564e1c123ee9961ee23dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/15728b345d96a6162fd564e1c123ee9961ee23dc/Vrec.py |
if not recorded: x, y = gl.getsize() print x, 'x', y v.SetSize(x, y) v.BindGLWindow(win, SV.IN_REPLACE) | x, y = gl.getsize() print x, 'x', y v.SetSize(x, y) v.BindGLWindow(win, SV.IN_REPLACE) | def main(): QSIZE = 16 TIME = 5 audio = 0 num, den = 1, 1 opts, args = getopt.getopt(sys.argv[1:], 'aq:r:t:') for opt, arg in opts: if opt == '-a': audio = 1 elif opt == '-q': QSIZE = string.atoi(arg) elif opt == '-r': [nstr, dstr] = string.splitfields(arg, '/') num, den = string.atoi(nstr), string.atoi(dstr) elif opt == '-t': TIME = string.atoi(arg) if args[2:]: sys.stderr.write('usage: Vrec [options] [file [audiofile]]\n') sys.exit(2) if args: filename = args[0] else: filename = 'film.video' if args[1:] and not audio: sys.stderr.write('-a turned on by appearance of 2nd file\n') audio = 1 if audio: if args[1:]: audiofilename = args[1] else: audiofilename = 'film.aiff' else: audiofilename = None gl.foreground() x, y = SV.PAL_XMAX / 4, SV.PAL_YMAX / 4 print x, 'x', y gl.minsize(40, 30) gl.stepunit(8, 6) gl.maxsize(SV.PAL_XMAX, SV.PAL_YMAX) gl.keepaspect(SV.PAL_XMAX, SV.PAL_YMAX) win = gl.winopen(filename) x, y = gl.getsize() print x, 'x', y v = sv.OpenVideo() v.BindGLWindow(win, SV.IN_REPLACE) v.SetSize(x, y) v.BindGLWindow(win, SV.IN_REPLACE) v.SetCaptureFormat(SV.RGB_FRAMES) v.SetCaptureMode(SV.BLOCKING_CAPTURE) v.SetQueueSize(QSIZE) v.InitCapture() if v.GetQueueSize() != QSIZE: QSIZE = v.GetQueueSize() print 'Warning: QSIZE reduced to', QSIZE | 15728b345d96a6162fd564e1c123ee9961ee23dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/15728b345d96a6162fd564e1c123ee9961ee23dc/Vrec.py |
if not recorded: posix._exit(0) v.EndCapture() | def main(): QSIZE = 16 TIME = 5 audio = 0 num, den = 1, 1 opts, args = getopt.getopt(sys.argv[1:], 'aq:r:t:') for opt, arg in opts: if opt == '-a': audio = 1 elif opt == '-q': QSIZE = string.atoi(arg) elif opt == '-r': [nstr, dstr] = string.splitfields(arg, '/') num, den = string.atoi(nstr), string.atoi(dstr) elif opt == '-t': TIME = string.atoi(arg) if args[2:]: sys.stderr.write('usage: Vrec [options] [file [audiofile]]\n') sys.exit(2) if args: filename = args[0] else: filename = 'film.video' if args[1:] and not audio: sys.stderr.write('-a turned on by appearance of 2nd file\n') audio = 1 if audio: if args[1:]: audiofilename = args[1] else: audiofilename = 'film.aiff' else: audiofilename = None gl.foreground() x, y = SV.PAL_XMAX / 4, SV.PAL_YMAX / 4 print x, 'x', y gl.minsize(40, 30) gl.stepunit(8, 6) gl.maxsize(SV.PAL_XMAX, SV.PAL_YMAX) gl.keepaspect(SV.PAL_XMAX, SV.PAL_YMAX) win = gl.winopen(filename) x, y = gl.getsize() print x, 'x', y v = sv.OpenVideo() v.BindGLWindow(win, SV.IN_REPLACE) v.SetSize(x, y) v.BindGLWindow(win, SV.IN_REPLACE) v.SetCaptureFormat(SV.RGB_FRAMES) v.SetCaptureMode(SV.BLOCKING_CAPTURE) v.SetQueueSize(QSIZE) v.InitCapture() if v.GetQueueSize() != QSIZE: QSIZE = v.GetQueueSize() print 'Warning: QSIZE reduced to', QSIZE | 15728b345d96a6162fd564e1c123ee9961ee23dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/15728b345d96a6162fd564e1c123ee9961ee23dc/Vrec.py |
|
def record(v, filename, audiofilename): | def record(v, info, filename, audiofilename): | def record(v, filename, audiofilename): import thread x, y = gl.getsize() vout = VFile.VoutFile().init(filename) vout.format = 'rgb8' vout.width = x vout.height = y vout.writeheader() buffer = [] thread.start_new_thread(saveframes, (vout, buffer)) if audiofilename: initaudio(audiofilename, buffer) gl.wintitle('(rec) ' + filename) v.StartCapture() t0 = time.millitimer() while not gl.qtest(): if v.GetCaptured() > 2: t = time.millitimer() - t0 cd, st = v.GetCaptureData() data = cd.interleave(x, y) cd.UnlockCaptureData() buffer.append(data, t) else: time.millisleep(10) v.StopCapture() while v.GetCaptured() > 0: t = time.millitimer() - t0 cd, st = v.GetCaptureData() data = cd.interleave(x, y) cd.UnlockCaptureData() buffer.append(data, t) buffer.append(None) # Sentinel gl.wintitle('(done) ' + filename) | 15728b345d96a6162fd564e1c123ee9961ee23dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/15728b345d96a6162fd564e1c123ee9961ee23dc/Vrec.py |
x, y = gl.getsize() | format, x, y, qsize, rate = info fps = 59.64 tpf = 1000.0 / fps | def record(v, filename, audiofilename): import thread x, y = gl.getsize() vout = VFile.VoutFile().init(filename) vout.format = 'rgb8' vout.width = x vout.height = y vout.writeheader() buffer = [] thread.start_new_thread(saveframes, (vout, buffer)) if audiofilename: initaudio(audiofilename, buffer) gl.wintitle('(rec) ' + filename) v.StartCapture() t0 = time.millitimer() while not gl.qtest(): if v.GetCaptured() > 2: t = time.millitimer() - t0 cd, st = v.GetCaptureData() data = cd.interleave(x, y) cd.UnlockCaptureData() buffer.append(data, t) else: time.millisleep(10) v.StopCapture() while v.GetCaptured() > 0: t = time.millitimer() - t0 cd, st = v.GetCaptureData() data = cd.interleave(x, y) cd.UnlockCaptureData() buffer.append(data, t) buffer.append(None) # Sentinel gl.wintitle('(done) ' + filename) | 15728b345d96a6162fd564e1c123ee9961ee23dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/15728b345d96a6162fd564e1c123ee9961ee23dc/Vrec.py |
buffer = [] thread.start_new_thread(saveframes, (vout, buffer)) | MAXSIZE = 20 import Queue queue = Queue.Queue().init(MAXSIZE) done = thread.allocate_lock() done.acquire_lock() thread.start_new_thread(saveframes, (vout, queue, done)) | def record(v, filename, audiofilename): import thread x, y = gl.getsize() vout = VFile.VoutFile().init(filename) vout.format = 'rgb8' vout.width = x vout.height = y vout.writeheader() buffer = [] thread.start_new_thread(saveframes, (vout, buffer)) if audiofilename: initaudio(audiofilename, buffer) gl.wintitle('(rec) ' + filename) v.StartCapture() t0 = time.millitimer() while not gl.qtest(): if v.GetCaptured() > 2: t = time.millitimer() - t0 cd, st = v.GetCaptureData() data = cd.interleave(x, y) cd.UnlockCaptureData() buffer.append(data, t) else: time.millisleep(10) v.StopCapture() while v.GetCaptured() > 0: t = time.millitimer() - t0 cd, st = v.GetCaptureData() data = cd.interleave(x, y) cd.UnlockCaptureData() buffer.append(data, t) buffer.append(None) # Sentinel gl.wintitle('(done) ' + filename) | 15728b345d96a6162fd564e1c123ee9961ee23dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/15728b345d96a6162fd564e1c123ee9961ee23dc/Vrec.py |
initaudio(audiofilename, buffer) | audiodone = thread.allocate_lock() audiodone.acquire_lock() audiostop = [] initaudio(audiofilename, audiostop, audiodone) | def record(v, filename, audiofilename): import thread x, y = gl.getsize() vout = VFile.VoutFile().init(filename) vout.format = 'rgb8' vout.width = x vout.height = y vout.writeheader() buffer = [] thread.start_new_thread(saveframes, (vout, buffer)) if audiofilename: initaudio(audiofilename, buffer) gl.wintitle('(rec) ' + filename) v.StartCapture() t0 = time.millitimer() while not gl.qtest(): if v.GetCaptured() > 2: t = time.millitimer() - t0 cd, st = v.GetCaptureData() data = cd.interleave(x, y) cd.UnlockCaptureData() buffer.append(data, t) else: time.millisleep(10) v.StopCapture() while v.GetCaptured() > 0: t = time.millitimer() - t0 cd, st = v.GetCaptureData() data = cd.interleave(x, y) cd.UnlockCaptureData() buffer.append(data, t) buffer.append(None) # Sentinel gl.wintitle('(done) ' + filename) | 15728b345d96a6162fd564e1c123ee9961ee23dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/15728b345d96a6162fd564e1c123ee9961ee23dc/Vrec.py |
v.StartCapture() | lastid = 0 | def record(v, filename, audiofilename): import thread x, y = gl.getsize() vout = VFile.VoutFile().init(filename) vout.format = 'rgb8' vout.width = x vout.height = y vout.writeheader() buffer = [] thread.start_new_thread(saveframes, (vout, buffer)) if audiofilename: initaudio(audiofilename, buffer) gl.wintitle('(rec) ' + filename) v.StartCapture() t0 = time.millitimer() while not gl.qtest(): if v.GetCaptured() > 2: t = time.millitimer() - t0 cd, st = v.GetCaptureData() data = cd.interleave(x, y) cd.UnlockCaptureData() buffer.append(data, t) else: time.millisleep(10) v.StopCapture() while v.GetCaptured() > 0: t = time.millitimer() - t0 cd, st = v.GetCaptureData() data = cd.interleave(x, y) cd.UnlockCaptureData() buffer.append(data, t) buffer.append(None) # Sentinel gl.wintitle('(done) ' + filename) | 15728b345d96a6162fd564e1c123ee9961ee23dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/15728b345d96a6162fd564e1c123ee9961ee23dc/Vrec.py |
if v.GetCaptured() > 2: t = time.millitimer() - t0 cd, st = v.GetCaptureData() data = cd.interleave(x, y) cd.UnlockCaptureData() buffer.append(data, t) else: time.millisleep(10) v.StopCapture() while v.GetCaptured() > 0: t = time.millitimer() - t0 cd, st = v.GetCaptureData() data = cd.interleave(x, y) | try: cd, id = v.GetCaptureData() except RuntimeError: time.millisleep(10) continue id = id + 2*rate lastid = id data = cd.InterleaveFields(1) | def record(v, filename, audiofilename): import thread x, y = gl.getsize() vout = VFile.VoutFile().init(filename) vout.format = 'rgb8' vout.width = x vout.height = y vout.writeheader() buffer = [] thread.start_new_thread(saveframes, (vout, buffer)) if audiofilename: initaudio(audiofilename, buffer) gl.wintitle('(rec) ' + filename) v.StartCapture() t0 = time.millitimer() while not gl.qtest(): if v.GetCaptured() > 2: t = time.millitimer() - t0 cd, st = v.GetCaptureData() data = cd.interleave(x, y) cd.UnlockCaptureData() buffer.append(data, t) else: time.millisleep(10) v.StopCapture() while v.GetCaptured() > 0: t = time.millitimer() - t0 cd, st = v.GetCaptureData() data = cd.interleave(x, y) cd.UnlockCaptureData() buffer.append(data, t) buffer.append(None) # Sentinel gl.wintitle('(done) ' + filename) | 15728b345d96a6162fd564e1c123ee9961ee23dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/15728b345d96a6162fd564e1c123ee9961ee23dc/Vrec.py |
buffer.append(data, t) buffer.append(None) | queue.put(data, int(id*tpf)) t1 = time.millitimer() gl.wintitle('(busy) ' + filename) print lastid, 'fields in', t1-t0, 'msec', print '--', 0.1 * int(lastid * 10000.0 / (t1-t0)), 'fields/sec' if audiofilename: audiostop.append(None) audiodone.acquire_lock() v.EndContinuousCapture() queue.put(None) done.acquire_lock() | def record(v, filename, audiofilename): import thread x, y = gl.getsize() vout = VFile.VoutFile().init(filename) vout.format = 'rgb8' vout.width = x vout.height = y vout.writeheader() buffer = [] thread.start_new_thread(saveframes, (vout, buffer)) if audiofilename: initaudio(audiofilename, buffer) gl.wintitle('(rec) ' + filename) v.StartCapture() t0 = time.millitimer() while not gl.qtest(): if v.GetCaptured() > 2: t = time.millitimer() - t0 cd, st = v.GetCaptureData() data = cd.interleave(x, y) cd.UnlockCaptureData() buffer.append(data, t) else: time.millisleep(10) v.StopCapture() while v.GetCaptured() > 0: t = time.millitimer() - t0 cd, st = v.GetCaptureData() data = cd.interleave(x, y) cd.UnlockCaptureData() buffer.append(data, t) buffer.append(None) # Sentinel gl.wintitle('(done) ' + filename) | 15728b345d96a6162fd564e1c123ee9961ee23dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/15728b345d96a6162fd564e1c123ee9961ee23dc/Vrec.py |
def saveframes(vout, buffer): | def saveframes(vout, queue, done): | def saveframes(vout, buffer): while 1: if not buffer: time.millisleep(10) else: x = buffer[0] if not x: break del buffer[0] data, t = x vout.writeframe(t, data, None) del data sys.stderr.write('Done writing\n') vout.close() | 15728b345d96a6162fd564e1c123ee9961ee23dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/15728b345d96a6162fd564e1c123ee9961ee23dc/Vrec.py |
if not buffer: time.millisleep(10) else: x = buffer[0] if not x: break del buffer[0] data, t = x vout.writeframe(t, data, None) del data sys.stderr.write('Done writing\n') | x = queue.get() if not x: break data, t = x vout.writeframe(t, data, None) del data sys.stderr.write('Done writing video\n') | def saveframes(vout, buffer): while 1: if not buffer: time.millisleep(10) else: x = buffer[0] if not x: break del buffer[0] data, t = x vout.writeframe(t, data, None) del data sys.stderr.write('Done writing\n') vout.close() | 15728b345d96a6162fd564e1c123ee9961ee23dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/15728b345d96a6162fd564e1c123ee9961ee23dc/Vrec.py |
AQSIZE = 8000 def initaudio(filename, buffer): | AQSIZE = 8000 def initaudio(filename, stop, done): | def saveframes(vout, buffer): while 1: if not buffer: time.millisleep(10) else: x = buffer[0] if not x: break del buffer[0] data, t = x vout.writeframe(t, data, None) del data sys.stderr.write('Done writing\n') vout.close() | 15728b345d96a6162fd564e1c123ee9961ee23dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/15728b345d96a6162fd564e1c123ee9961ee23dc/Vrec.py |
thread.start_new_thread(audiorecord, (afile, aport, buffer)) | thread.start_new_thread(audiorecord, (afile, aport, stop, done)) | def initaudio(filename, buffer): import thread, aiff afile = aiff.Aiff().init(filename, 'w') afile.nchannels = AL.MONO afile.sampwidth = AL.SAMPLE_8 params = [AL.INPUT_RATE, 0] al.getparams(AL.DEFAULT_DEVICE, params) print 'audio sampling rate =', params[1] afile.samprate = params[1] c = al.newconfig() c.setchannels(AL.MONO) c.setqueuesize(AQSIZE) c.setwidth(AL.SAMPLE_8) aport = al.openport(filename, 'r', c) thread.start_new_thread(audiorecord, (afile, aport, buffer)) | 15728b345d96a6162fd564e1c123ee9961ee23dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/15728b345d96a6162fd564e1c123ee9961ee23dc/Vrec.py |
def audiorecord(afile, aport, buffer): while buffer[-1:] <> [None]: | def audiorecord(afile, aport, stop, done): while not stop: | def audiorecord(afile, aport, buffer): while buffer[-1:] <> [None]: data = aport.readsamps(AQSIZE/2) | 15728b345d96a6162fd564e1c123ee9961ee23dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/15728b345d96a6162fd564e1c123ee9961ee23dc/Vrec.py |
"""Testing recfrom() over UDP.""" | """Testing recvfrom() over UDP.""" | def testRecvFrom(self): """Testing recfrom() over UDP.""" msg, addr = self.serv.recvfrom(len(MSG)) hostname, port = addr ##self.assertEqual(hostname, socket.gethostbyname('localhost')) self.assertEqual(msg, MSG) | bf14b5b886295683ec59d1de14200e3c2f9fe130 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/bf14b5b886295683ec59d1de14200e3c2f9fe130/test_socket.py |
self.flags = [] | self.flags = 0 | def __init__(self): | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
def setflag(self, flag): if flag in self.flags: self.flags.append(flag) | def setflag(self, flag): | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
|
self.flags = [] | def __init__(self, pattern, data=None): | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
|
lo = lo + i * av[0] hi = hi + j * av[1] | lo = lo + long(i) * av[0] hi = hi + long(j) * av[1] | def getwidth(self): | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
def set(self, flag): if not flag in self.flags: self.flags.append(flag) def reset(self, flag): if flag in self.flags: self.flags.remove(flag) | def set(self, flag): | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
|
self.string = list(string) | self.index = 0 self.string = string | def __init__(self, string): | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
if not self.string: | if self.index >= len(self.string): | def __next(self): | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
char = self.string[0] | char = self.string[self.index] | def __next(self): | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
c = self.string[1] | c = self.string[self.index + 1] | def __next(self): | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
try: if c == "x": for i in xrange(2, sys.maxint): c = self.string[i] if str(c) not in HEXDIGITS: break char = char + c elif str(c) in DIGITS: for i in xrange(2, sys.maxint): c = self.string[i] if str(c) not in DIGITS: break char = char + c except IndexError: pass del self.string[0:len(char)] | self.index = self.index + len(char) | def __next(self): | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
def _fixescape(escape, character_class=0): if character_class: code = ESCAPES.get(escape) if code: return code code = CATEGORIES.get(escape) else: code = CATEGORIES.get(escape) if code: return code code = ESCAPES.get(escape) | def _group(escape, state): try: group = int(escape[1:]) if group and group < state.groups: return group except ValueError: pass return None def _class_escape(source, escape): code = ESCAPES.get(escape) | def _fixescape(escape, character_class=0): # convert escape to (type, value) if character_class: # inside a character class, we'll look in the character # escapes dictionary first code = ESCAPES.get(escape) if code: return code code = CATEGORIES.get(escape) else: code = CATEGORIES.get(escape) if code: return code code = ESCAPES.get(escape) if code: return code if not character_class: try: group = int(escape[1:]) # FIXME: only valid if group <= current number of groups return GROUP, group except ValueError: pass try: if escape[1:2] == "x": escape = escape[2:] return LITERAL, chr(int(escape[-2:], 16) & 0xff) elif str(escape[1:2]) in DIGITS: return LITERAL, chr(int(escape[1:], 8) & 0xff) elif len(escape) == 2: return LITERAL, escape[1] except ValueError: pass raise SyntaxError, "bogus escape: %s" % repr(escape) | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
if not character_class: try: group = int(escape[1:]) return GROUP, group except ValueError: pass | code = CATEGORIES.get(escape) if code: return code | def _fixescape(escape, character_class=0): # convert escape to (type, value) if character_class: # inside a character class, we'll look in the character # escapes dictionary first code = ESCAPES.get(escape) if code: return code code = CATEGORIES.get(escape) else: code = CATEGORIES.get(escape) if code: return code code = ESCAPES.get(escape) if code: return code if not character_class: try: group = int(escape[1:]) # FIXME: only valid if group <= current number of groups return GROUP, group except ValueError: pass try: if escape[1:2] == "x": escape = escape[2:] return LITERAL, chr(int(escape[-2:], 16) & 0xff) elif str(escape[1:2]) in DIGITS: return LITERAL, chr(int(escape[1:], 8) & 0xff) elif len(escape) == 2: return LITERAL, escape[1] except ValueError: pass raise SyntaxError, "bogus escape: %s" % repr(escape) | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
return LITERAL, chr(int(escape[-2:], 16) & 0xff) elif str(escape[1:2]) in DIGITS: return LITERAL, chr(int(escape[1:], 8) & 0xff) elif len(escape) == 2: | return LITERAL, chr(int(escape[-4:], 16) & 0xff) elif str(escape[1:2]) in OCTDIGITS: while source.next in OCTDIGITS: escape = escape + source.get() escape = escape[1:] return LITERAL, chr(int(escape[-6:], 8) & 0xff) if len(escape) == 2: | def _fixescape(escape, character_class=0): # convert escape to (type, value) if character_class: # inside a character class, we'll look in the character # escapes dictionary first code = ESCAPES.get(escape) if code: return code code = CATEGORIES.get(escape) else: code = CATEGORIES.get(escape) if code: return code code = ESCAPES.get(escape) if code: return code if not character_class: try: group = int(escape[1:]) # FIXME: only valid if group <= current number of groups return GROUP, group except ValueError: pass try: if escape[1:2] == "x": escape = escape[2:] return LITERAL, chr(int(escape[-2:], 16) & 0xff) elif str(escape[1:2]) in DIGITS: return LITERAL, chr(int(escape[1:], 8) & 0xff) elif len(escape) == 2: return LITERAL, escape[1] except ValueError: pass raise SyntaxError, "bogus escape: %s" % repr(escape) | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
def _branch(subpattern, items): | def _escape(source, escape, state): code = CATEGORIES.get(escape) if code: return code code = ESCAPES.get(escape) if code: return code try: if escape[1:2] == "x": while source.next in HEXDIGITS: escape = escape + source.get() escape = escape[2:] return LITERAL, chr(int(escape[-4:], 16) & 0xff) elif str(escape[1:2]) in DIGITS: while 1: group = _group(escape, state) if group: if (not source.next or not _group(escape + source.next, state)): return GROUP, group escape = escape + source.get() elif source.next in OCTDIGITS: escape = escape + source.get() else: break escape = escape[1:] return LITERAL, chr(int(escape[-6:], 8) & 0xff) if len(escape) == 2: return LITERAL, escape[1] except ValueError: pass raise SyntaxError, "bogus escape: %s" % repr(escape) def _branch(pattern, items): | def _branch(subpattern, items): # form a branch operator from a set of items (FIXME: move this # optimization to the compiler module!) # check if all items share a common prefix while 1: prefix = None for item in items: if not item: break if prefix is None: prefix = item[0] elif item[0] != prefix: break else: # all subitems start with a common "prefix". # move it out of the branch for item in items: del item[0] subpattern.append(prefix) continue # check next one break # check if the branch can be replaced by a character set for item in items: if len(item) != 1 or item[0][0] != LITERAL: break else: # we can store this as a character set instead of a # branch (FIXME: use a range if possible) set = [] for item in items: set.append(item[0]) subpattern.append((IN, set)) return subpattern.append((BRANCH, (None, items))) | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
return | return subpattern | def _branch(subpattern, items): # form a branch operator from a set of items (FIXME: move this # optimization to the compiler module!) # check if all items share a common prefix while 1: prefix = None for item in items: if not item: break if prefix is None: prefix = item[0] elif item[0] != prefix: break else: # all subitems start with a common "prefix". # move it out of the branch for item in items: del item[0] subpattern.append(prefix) continue # check next one break # check if the branch can be replaced by a character set for item in items: if len(item) != 1 or item[0][0] != LITERAL: break else: # we can store this as a character set instead of a # branch (FIXME: use a range if possible) set = [] for item in items: set.append(item[0]) subpattern.append((IN, set)) return subpattern.append((BRANCH, (None, items))) | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
def _parse(source, pattern, flags=()): | return subpattern def _parse(source, state, flags=0): | def _branch(subpattern, items): # form a branch operator from a set of items (FIXME: move this # optimization to the compiler module!) # check if all items share a common prefix while 1: prefix = None for item in items: if not item: break if prefix is None: prefix = item[0] elif item[0] != prefix: break else: # all subitems start with a common "prefix". # move it out of the branch for item in items: del item[0] subpattern.append(prefix) continue # check next one break # check if the branch can be replaced by a character set for item in items: if len(item) != 1 or item[0][0] != LITERAL: break else: # we can store this as a character set instead of a # branch (FIXME: use a range if possible) set = [] for item in items: set.append(item[0]) subpattern.append((IN, set)) return subpattern.append((BRANCH, (None, items))) | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
subpattern = SubPattern(pattern) this = None | subpattern = SubPattern(state) | def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = [] | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
code1 = _fixescape(this, 1) | code1 = _class_escape(source, this) | def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = [] | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
code2 = _fixescape(this, 1) | code2 = _class_escape(source, this) | def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = [] | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = [] | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
||
min, max = 0, sys.maxint | min, max = 0, MAXREPEAT | def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = [] | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
min, max = 1, sys.maxint | min, max = 1, MAXREPEAT | def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = [] | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
min, max = 0, sys.maxint | min, max = 0, MAXREPEAT | def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = [] | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = [] | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
||
index = len(subpattern)-1 while subpattern[index][0] is MARK: index = index - 1 item = subpattern[index:index+1] | item = subpattern[-1:] | def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = [] | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
subpattern[index] = (MIN_REPEAT, (min, max, item)) | subpattern[-1] = (MIN_REPEAT, (min, max, item)) | def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = [] | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
subpattern[index] = (MAX_REPEAT, (min, max, item)) | subpattern[-1] = (MAX_REPEAT, (min, max, item)) | def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = [] | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = [] | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
||
if char is None or char == ">": | if char is None: raise SyntaxError, "unterminated name" if char == ">": | def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = [] | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
elif source.match_set("iI"): pattern.setflag("i") elif source.match_set("lL"): pattern.setflag("l") elif source.match_set("mM"): pattern.setflag("m") elif source.match_set("sS"): pattern.setflag("s") elif source.match_set("xX"): pattern.setflag("x") | elif source.match(" while 1: char = source.get() if char is None or char == ")": break else: while FLAGS.has_key(source.next): state.flags = state.flags | FLAGS[source.get()] | def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = [] | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
group = pattern.getgroup(name) if group: subpattern.append((MARK, (group-1)*2)) | group = state.getgroup(name) | def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = [] | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
p = _parse(source, pattern, flags) | p = _parse(source, state, flags) | def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = [] | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
_branch(subpattern, b) else: subpattern.append((SUBPATTERN, (group, p))) | p = _branch(state, b) subpattern.append((SUBPATTERN, (group, p))) | def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = [] | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
if group: subpattern.append((MARK, (group-1)*2+1)) | def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = [] | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
|
def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = [] | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
||
code =_fixescape(this) | code = _escape(source, this, state) | def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. subpattern = SubPattern(pattern) this = None while 1: if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() if this is None: break # end of pattern if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) elif this == "[": # character set set = [] | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
def parse(source, flags=()): s = Tokenizer(source) g = Pattern() | def parse(pattern, flags=0): source = Tokenizer(pattern) state = State() | def parse(source, flags=()): s = Tokenizer(source) g = Pattern() b = [] while 1: p = _parse(s, g, flags) tail = s.get() if tail == "|": b.append(p) elif tail == ")": raise SyntaxError, "unbalanced parenthesis" elif tail is None: if b: b.append(p) p = SubPattern(g) _branch(p, b) break else: raise SyntaxError, "bogus characters at end of regular expression" return p | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
p = _parse(s, g, flags) tail = s.get() | p = _parse(source, state, flags) tail = source.get() | def parse(source, flags=()): s = Tokenizer(source) g = Pattern() b = [] while 1: p = _parse(s, g, flags) tail = s.get() if tail == "|": b.append(p) elif tail == ")": raise SyntaxError, "unbalanced parenthesis" elif tail is None: if b: b.append(p) p = SubPattern(g) _branch(p, b) break else: raise SyntaxError, "bogus characters at end of regular expression" return p | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
p = SubPattern(g) _branch(p, b) | p = _branch(state, b) | def parse(source, flags=()): s = Tokenizer(source) g = Pattern() b = [] while 1: p = _parse(s, g, flags) tail = s.get() if tail == "|": b.append(p) elif tail == ")": raise SyntaxError, "unbalanced parenthesis" elif tail is None: if b: b.append(p) p = SubPattern(g) _branch(p, b) break else: raise SyntaxError, "bogus characters at end of regular expression" return p | d46b2a42eda94cbac3b610e36d5f97230d629068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d46b2a42eda94cbac3b610e36d5f97230d629068/sre_parse.py |
for dir in sys.path: | path = sys.path try: path = [os.path.dirname(__file__)] + path except NameError: pass for dir in path: | def get_qualified_path(name): """ return a more qualified path to name""" import sys import os for dir in sys.path: fullname = os.path.join(dir, name) if os.path.exists(fullname): return fullname return name | bf5fcfb6e21620bced3d44150deafcb648f9a405 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/bf5fcfb6e21620bced3d44150deafcb648f9a405/test_imageop.py |
self._lookup() | assert self._toc is not None self._file.seek(0, 2) cur_len = self._file.tell() if cur_len != self._file_length: raise ExternalClashError('Size of mailbox file changed ' '(expected %i, found %i)' % (self._file_length, cur_len)) | def flush(self): """Write any pending changes to disk.""" if not self._pending: return self._lookup() new_file = _create_temporary(self._path) try: new_toc = {} self._pre_mailbox_hook(new_file) for key in sorted(self._toc.keys()): start, stop = self._toc[key] self._file.seek(start) self._pre_message_hook(new_file) new_start = new_file.tell() while True: buffer = self._file.read(min(4096, stop - self._file.tell())) if buffer == '': break new_file.write(buffer) new_toc[key] = (new_start, new_file.tell()) self._post_message_hook(new_file) except: new_file.close() os.remove(new_file.name) raise _sync_close(new_file) # self._file is about to get replaced, so no need to sync. self._file.close() try: os.rename(new_file.name, self._path) except OSError, e: if e.errno == errno.EEXIST or \ (os.name == 'os2' and e.errno == errno.EACCES): os.remove(self._path) os.rename(new_file.name, self._path) else: raise self._file = open(self._path, 'rb+') self._toc = new_toc self._pending = False if self._locked: _lock_file(self._file, dotlock=False) | 02edb28d051210c4c2067bb5857dcb8965f81bae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/02edb28d051210c4c2067bb5857dcb8965f81bae/mailbox.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.