rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
inc_dir = os.curdir
inc_dir = argv0_path
def get_config_h_filename(): """Return full pathname of installed pyconfig.h file.""" if python_build: inc_dir = os.curdir else: inc_dir = get_python_inc(plat_specific=1) if get_python_version() < '2.2': config_h = 'config.h' else: # The name of the config.h file changed in 2.2 config_h = 'pyconfig.h' return os.path.join(inc_dir, config_h)
dfde91a79e235e2e1ca121d6164dd1818cbba395 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dfde91a79e235e2e1ca121d6164dd1818cbba395/sysconfig.py
return 'pwpc'
return 'pwpc', 1
def interact(scriptname): if PPC_ONLY: return 'pwpc' d = Dlg.GetNewDialog(DLG_ID, -1) if not d: print "Can't get DLOG resource with id =", DLG_ID return d.SetDialogDefaultItem(OK_BUTTON) d.SetDialogCancelItem(CANCEL_BUTTON) Dlg.ParamText(scriptname, "", "", "") radiogroup = radio(d, GENFAT_BUTTON, GENPPC_BUTTON, GEN68K_BUTTON) radiogroup.set(GENFAT_BUTTON) gentype = 'fat' while 1: n = Dlg.ModalDialog(None) if n == OK_BUTTON or n == CANCEL_BUTTON: break elif radiogroup.hasitem(n): radiogroup.set(n) genitem = radiogroup.get() del radiogroup del d if genitem == GENFAT_BUTTON: gentype = 'fat' elif genitem == GENPPC_BUTTON: gentype = 'pwpc' elif genitem == GEN68K_BUTTON: gentype = 'm68k' return gentype, n == OK_BUTTON
f0d750803dc78ea6fefed17de4fd785e80fb66b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f0d750803dc78ea6fefed17de4fd785e80fb66b5/BuildApplication.py
print "Can't get DLOG resource with id =", DLG_ID return
raise "Can't get DLOG resource with id =", DLG_ID
def interact(scriptname): if PPC_ONLY: return 'pwpc' d = Dlg.GetNewDialog(DLG_ID, -1) if not d: print "Can't get DLOG resource with id =", DLG_ID return d.SetDialogDefaultItem(OK_BUTTON) d.SetDialogCancelItem(CANCEL_BUTTON) Dlg.ParamText(scriptname, "", "", "") radiogroup = radio(d, GENFAT_BUTTON, GENPPC_BUTTON, GEN68K_BUTTON) radiogroup.set(GENFAT_BUTTON) gentype = 'fat' while 1: n = Dlg.ModalDialog(None) if n == OK_BUTTON or n == CANCEL_BUTTON: break elif radiogroup.hasitem(n): radiogroup.set(n) genitem = radiogroup.get() del radiogroup del d if genitem == GENFAT_BUTTON: gentype = 'fat' elif genitem == GENPPC_BUTTON: gentype = 'pwpc' elif genitem == GEN68K_BUTTON: gentype = 'm68k' return gentype, n == OK_BUTTON
f0d750803dc78ea6fefed17de4fd785e80fb66b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f0d750803dc78ea6fefed17de4fd785e80fb66b5/BuildApplication.py
self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', '/GX' ]
self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', '/GX' , '/DNDEBUG']
def __init__ (self, verbose=0, dry_run=0, force=0):
2683ac755d5fcb164926bdb2bc320dcb33bb58b0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2683ac755d5fcb164926bdb2bc320dcb33bb58b0/msvccompiler.py
def _read(self, size=1024): if self.fileobj is None: raise EOFError, "Reached EOF"
41616ee194e65b23fa508326d7b3788f2d63f362 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/41616ee194e65b23fa508326d7b3788f2d63f362/gzip.py
def readline(self):
def readline(self, size=-1): if size < 0: size = sys.maxint
def readline(self): bufs = [] readsize = 100 while 1: c = self.read(readsize) i = string.find(c, '\n') if i >= 0 or c == '': bufs.append(c[:i+1]) self._unread(c[i+1:]) return string.join(bufs, '') bufs.append(c) readsize = readsize * 2
41616ee194e65b23fa508326d7b3788f2d63f362 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/41616ee194e65b23fa508326d7b3788f2d63f362/gzip.py
readsize = 100
orig_size = size readsize = min(100, size)
def readline(self): bufs = [] readsize = 100 while 1: c = self.read(readsize) i = string.find(c, '\n') if i >= 0 or c == '': bufs.append(c[:i+1]) self._unread(c[i+1:]) return string.join(bufs, '') bufs.append(c) readsize = readsize * 2
41616ee194e65b23fa508326d7b3788f2d63f362 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/41616ee194e65b23fa508326d7b3788f2d63f362/gzip.py
bufs.append(c[:i+1]) self._unread(c[i+1:]) return string.join(bufs, '')
bufs.append(c[:i+1]) self._unread(c[i+1:]) return string.join(bufs, '')
def readline(self): bufs = [] readsize = 100 while 1: c = self.read(readsize) i = string.find(c, '\n') if i >= 0 or c == '': bufs.append(c[:i+1]) self._unread(c[i+1:]) return string.join(bufs, '') bufs.append(c) readsize = readsize * 2
41616ee194e65b23fa508326d7b3788f2d63f362 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/41616ee194e65b23fa508326d7b3788f2d63f362/gzip.py
readsize = readsize * 2 def readlines(self, ignored=None): buf = self.read() lines = string.split(buf, '\n') for i in range(len(lines)-1): lines[i] = lines[i] + '\n' if lines and not lines[-1]: del lines[-1] return lines
size = size - len(c) readsize = min(size, readsize * 2) def readlines(self, sizehint=0): if sizehint <= 0: sizehint = sys.maxint L = [] while sizehint > 0: line = self.readline() if line == "": break L.append( line ) sizehint = sizehint - len(line) return L
def readline(self): bufs = [] readsize = 100 while 1: c = self.read(readsize) i = string.find(c, '\n') if i >= 0 or c == '': bufs.append(c[:i+1]) self._unread(c[i+1:]) return string.join(bufs, '') bufs.append(c) readsize = readsize * 2
41616ee194e65b23fa508326d7b3788f2d63f362 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/41616ee194e65b23fa508326d7b3788f2d63f362/gzip.py
if proxy_auth: h.putheader('Proxy-Authorization: Basic %s' % proxy_auth) if auth: h.putheader('Authorization: Basic %s' % auth)
if proxy_auth: h.putheader('Proxy-Authorization', 'Basic %s' % proxy_auth) if auth: h.putheader('Authorization', 'Basic %s' % auth)
def open_https(self, url, data=None): """Use HTTPS protocol.""" import httplib user_passwd = None proxy_passwd = None if isinstance(url, str): host, selector = splithost(url) if host: user_passwd, host = splituser(host) host = unquote(host) realhost = host else: host, selector = url # here, we determine, whether the proxy contains authorization information proxy_passwd, host = splituser(host) urltype, rest = splittype(selector) url = rest user_passwd = None if urltype.lower() != 'https': realhost = None else: realhost, rest = splithost(rest) if realhost: user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) #print "proxy via https:", host, selector if not host: raise IOError, ('https error', 'no host given') if proxy_passwd: import base64 proxy_auth = base64.b64encode(proxy_passwd).strip() else: proxy_auth = None if user_passwd: import base64 auth = base64.b64encode(user_passwd).strip() else: auth = None h = httplib.HTTPS(host, 0, key_file=self.key_file, cert_file=self.cert_file) if data is not None: h.putrequest('POST', selector) h.putheader('Content-Type', 'application/x-www-form-urlencoded') h.putheader('Content-Length', '%d' % len(data)) else: h.putrequest('GET', selector) if proxy_auth: h.putheader('Proxy-Authorization: Basic %s' % proxy_auth) if auth: h.putheader('Authorization: Basic %s' % auth) if realhost: h.putheader('Host', realhost) for args in self.addheaders: h.putheader(*args) h.endheaders() if data is not None: h.send(data) errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, "https:" + url) else: if data is None: return self.http_error(url, fp, errcode, errmsg, headers) else: return self.http_error(url, fp, errcode, errmsg, headers, data)
522785732f09b0be6d4bc06a2782ecda66fc83af /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/522785732f09b0be6d4bc06a2782ecda66fc83af/urllib.py
out.write("
out.write("
typedef struct
a4657f736c34e4bb1802b40246028c5bec545fe6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a4657f736c34e4bb1802b40246028c5bec545fe6/GenUCNHash.py
import linecache
def formatwarning(message, category, filename, lineno): """Function to format a warning the standard way.""" import linecache s = "%s:%s: %s: %s\n" % (filename, lineno, category.__name__, message) line = linecache.getline(filename, lineno).strip() if line: s = s + " " + line + "\n" return s
a43fd0c8996eec2bdd0ec59edc252cb4f4ff4436 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a43fd0c8996eec2bdd0ec59edc252cb4f4ff4436/warnings.py
ValueError if 'pathname' is absolute (starts with '/') or contains local directory separators (unless the local separator is '/', of course).
ValueError on non-Unix-ish systems if 'pathname' either starts or ends with a slash.
def convert_path (pathname): """Return 'pathname' as a name that will work on the native filesystem, i.e. split it on '/' and put it back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local convention before we can actually use them in the filesystem. Raises ValueError if 'pathname' is absolute (starts with '/') or contains local directory separators (unless the local separator is '/', of course). """ if os.sep == '/': return pathname if pathname[0] == '/': raise ValueError, "path '%s' cannot be absolute" % pathname if pathname[-1] == '/': raise ValueError, "path '%s' cannot end with '/'" % pathname paths = string.split(pathname, '/') return apply(os.path.join, paths)
4752769d08c3ef950d31b926751d5e4d1dae294f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4752769d08c3ef950d31b926751d5e4d1dae294f/util.py
occurrence of '$' followed by a name, or a name enclosed in braces, is considered a variable. Every variable is substituted by the value found in the 'local_vars' dictionary, or in 'os.environ' if it's not in 'local_vars'. 'os.environ' is first checked/ augmented to guarantee that it contains certain values: see '_check_environ()'. Raise ValueError for any variables not found in either 'local_vars' or 'os.environ'.
occurrence of '$' followed by a name is considered a variable, and variable is substituted by the value found in the 'local_vars' dictionary, or in 'os.environ' if it's not in 'local_vars'. 'os.environ' is first checked/augmented to guarantee that it contains certain values: see 'check_environ()'. Raise ValueError for any variables not found in either 'local_vars' or 'os.environ'.
def subst_vars (str, local_vars): """Perform shell/Perl-style variable substitution on 'string'. Every occurrence of '$' followed by a name, or a name enclosed in braces, is considered a variable. Every variable is substituted by the value found in the 'local_vars' dictionary, or in 'os.environ' if it's not in 'local_vars'. 'os.environ' is first checked/ augmented to guarantee that it contains certain values: see '_check_environ()'. Raise ValueError for any variables not found in either 'local_vars' or 'os.environ'. """ check_environ() def _subst (match, local_vars=local_vars): var_name = match.group(1) if local_vars.has_key(var_name): return str(local_vars[var_name]) else: return os.environ[var_name] return re.sub(r'\$([a-zA-Z_][a-zA-Z_0-9]*)', _subst, str)
4752769d08c3ef950d31b926751d5e4d1dae294f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4752769d08c3ef950d31b926751d5e4d1dae294f/util.py
return re.sub(r'\$([a-zA-Z_][a-zA-Z_0-9]*)', _subst, str)
try: return re.sub(r'\$([a-zA-Z_][a-zA-Z_0-9]*)', _subst, str) except KeyError, var: raise ValueError, "invalid variable '$%s'" % var
def _subst (match, local_vars=local_vars): var_name = match.group(1) if local_vars.has_key(var_name): return str(local_vars[var_name]) else: return os.environ[var_name]
4752769d08c3ef950d31b926751d5e4d1dae294f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4752769d08c3ef950d31b926751d5e4d1dae294f/util.py
if os.sep != '/': paths = string.split (pathname, '/') return apply (os.path.join, paths) else: return pathname
paths = string.split(pathname, '/') return apply(os.path.join, paths)
def convert_path (pathname): """Return 'pathname' as a name that will work on the native filesystem, i.e. split it on '/' and put it back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local convention before we can actually use them in the filesystem. Raises ValueError if 'pathname' is absolute (starts with '/') or contains local directory separators (unless the local separator is '/', of course).""" if pathname[0] == '/': raise ValueError, "path '%s' cannot be absolute" % pathname if pathname[-1] == '/': raise ValueError, "path '%s' cannot end with '/'" % pathname if os.sep != '/': paths = string.split (pathname, '/') return apply (os.path.join, paths) else: return pathname
7ec053544cf4849a138e70329ffeec1d6ab93e62 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7ec053544cf4849a138e70329ffeec1d6ab93e62/util.py
if version > 7.0: self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1") else: self.set_macro("FrameworkSDKDir", net, "sdkinstallroot")
try: if version > 7.0: self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1") else: self.set_macro("FrameworkSDKDir", net, "sdkinstallroot") except KeyError, exc: raise DistutilsPlatformError, \ ("The .NET Framework SDK needs to be installed before " "building extensions for Python.")
def load_macros(self, version): vsbase = r"Software\Microsoft\VisualStudio\%0.1f" % version self.set_macro("VCInstallDir", vsbase + r"\Setup\VC", "productdir") self.set_macro("VSInstallDir", vsbase + r"\Setup\VS", "productdir") net = r"Software\Microsoft\.NETFramework" self.set_macro("FrameworkDir", net, "installroot") if version > 7.0: self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1") else: self.set_macro("FrameworkSDKDir", net, "sdkinstallroot")
cb328f393e9ca0278491a97fad48c225ad9c5484 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cb328f393e9ca0278491a97fad48c225ad9c5484/msvccompiler.py
from UserDict import DictMixin class SeqDict(DictMixin):
class SeqDict(UserDict.DictMixin):
def display(self): print self
e28be5968683241e4a785108a0023fc49ecbb03a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e28be5968683241e4a785108a0023fc49ecbb03a/test_userdict.py
s = SeqDict() s[10] = 'ten' s[20] = 'twenty' s[30] = 'thirty' del s[20] verify(s[10] == 'ten') verify(s.keys() == [10, 30]) verify(s.has_key(10)) verify(not s.has_key(20)) verify(10 in s) verify(20 not in s) verify([k for k in s] == [10, 30]) verify(len(s) == 2) verify(list(s.iteritems()) == [(10,'ten'), (30, 'thirty')]) verify(list(s.iterkeys()) == [10, 30]) verify(list(s.itervalues()) == ['ten', 'thirty']) verify(s.values() == ['ten', 'thirty']) verify(s.items() == [(10,'ten'), (30, 'thirty')]) verify(s.get(10) == 'ten') verify(s.get(15,'fifteen') == 'fifteen') verify(s.get(15) == None) verify(s.setdefault(40, 'forty') == 'forty') verify(s.setdefault(10, 'null') == 'ten') del s[40] verify(s.pop(10) == 'ten') verify(10 not in s) s[10] = 'ten' k, v = s.popitem() verify(k not in s) s[k] = v s.clear() verify(len(s) == 0) try: s.popitem() except KeyError: pass else: verify(0, "popitem from an empty list should raise KeyError") s.update({10: 'ten', 20:'twenty'}) verify(s[10]=='ten' and s[20]=='twenty') verify(s == {10: 'ten', 20:'twenty'}) t = SeqDict() t[20] = 'twenty' t[10] = 'ten' verify(s == t)
class UserDictMixinTest(unittest.TestCase): def test_all(self): s = SeqDict() s[10] = 'ten' s[20] = 'twenty' s[30] = 'thirty' del s[20] self.assertEqual(s[10], 'ten') self.assertEqual(s.keys(), [10, 30]) self.assert_(s.has_key(10)) self.assert_(not s.has_key(20)) self.assert_(10 in s) self.assert_(20 not in s) self.assertEqual([k for k in s], [10, 30]) self.assertEqual(len(s), 2) self.assertEqual(list(s.iteritems()), [(10,'ten'), (30, 'thirty')]) self.assertEqual(list(s.iterkeys()), [10, 30]) self.assertEqual(list(s.itervalues()), ['ten', 'thirty']) self.assertEqual(s.values(), ['ten', 'thirty']) self.assertEqual(s.items(), [(10,'ten'), (30, 'thirty')]) self.assertEqual(s.get(10), 'ten') self.assertEqual(s.get(15,'fifteen'), 'fifteen') self.assertEqual(s.get(15), None) self.assertEqual(s.setdefault(40, 'forty'), 'forty') self.assertEqual(s.setdefault(10, 'null'), 'ten') del s[40] self.assertEqual(s.pop(10), 'ten') self.assert_(10 not in s) s[10] = 'ten' k, v = s.popitem() self.assert_(k not in s) s[k] = v s.clear() self.assertEqual(len(s), 0) self.assertRaises(KeyError, s.popitem) s.update({10: 'ten', 20:'twenty'}) self.assertEqual(s[10], 'ten') self.assertEqual(s[20], 'twenty') self.assertEqual(s, {10: 'ten', 20:'twenty'}) t = SeqDict() t[20] = 'twenty' t[10] = 'ten' self.assertEqual(s, t) def test_main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(UserDictTest)) suite.addTest(unittest.makeSuite(UserDictMixinTest)) test.test_support.run_suite(suite) if __name__ == "__main__": test_main()
def keys(self): return list(self.keylist)
e28be5968683241e4a785108a0023fc49ecbb03a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e28be5968683241e4a785108a0023fc49ecbb03a/test_userdict.py
if node.nodeType==Node.ELEMENT_NODE and self.documentElement: raise TypeError, "Two document elements disallowed" else: self.documentElement=node
if node.nodeType==Node.ELEMENT_NODE: if self.documentElement: raise TypeError, "Two document elements disallowed" else: self.documentElement=node
def appendChild( self, node ): if node.nodeType==Node.ELEMENT_NODE and self.documentElement: raise TypeError, "Two document elements disallowed" else: self.documentElement=node Node.appendChild( self, node ) return node
ce88db02303409ae8b19f8aaf5e540c2f99f47c1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ce88db02303409ae8b19f8aaf5e540c2f99f47c1/minidom.py
def cmp(f1, f2, shallow=1, use_statcache=0):
def cmp(f1, f2, shallow=1, use_statcache=None):
def cmp(f1, f2, shallow=1, use_statcache=0): """Compare two files. Arguments: f1 -- First file name f2 -- Second file name shallow -- Just check stat signature (do not read the files). defaults to 1. use_statcache -- obsolete argument. Return value: True if the files are the same, False otherwise. This function uses a cache for past comparisons and the results, with a cache invalidation mechanism relying on stale signatures. """ s1 = _sig(os.stat(f1)) s2 = _sig(os.stat(f2)) if s1[0] != stat.S_IFREG or s2[0] != stat.S_IFREG: return False if shallow and s1 == s2: return True if s1[1] != s2[1]: return False result = _cache.get((f1, f2)) if result and (s1, s2) == result[:2]: return result[2] outcome = _do_cmp(f1, f2) _cache[f1, f2] = s1, s2, outcome return outcome
83e879d99fc855dfca597d222b4c5a372d1611eb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/83e879d99fc855dfca597d222b4c5a372d1611eb/filecmp.py
def cmpfiles(a, b, common, shallow=1, use_statcache=0):
def cmpfiles(a, b, common, shallow=1, use_statcache=None):
def cmpfiles(a, b, common, shallow=1, use_statcache=0): """Compare common files in two directories. a, b -- directory names common -- list of file names found in both directories shallow -- if true, do comparison based solely on stat() information use_statcache -- obsolete argument Returns a tuple of three lists: files that compare equal files that are different filenames that aren't regular files. """ res = ([], [], []) for x in common: ax = os.path.join(a, x) bx = os.path.join(b, x) res[_cmp(ax, bx, shallow)].append(x) return res
83e879d99fc855dfca597d222b4c5a372d1611eb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/83e879d99fc855dfca597d222b4c5a372d1611eb/filecmp.py
raise getopt.error, 'need exactly two args'
raise getopt.GetoptError('need exactly two args', None)
def demo(): import sys import getopt options, args = getopt.getopt(sys.argv[1:], 'r') if len(args) != 2: raise getopt.error, 'need exactly two args' dd = dircmp(args[0], args[1]) if ('-r', '') in options: dd.report_full_closure() else: dd.report()
83e879d99fc855dfca597d222b4c5a372d1611eb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/83e879d99fc855dfca597d222b4c5a372d1611eb/filecmp.py
self.bytebuffer = ""
self.buffer = ""
def reset(self): IncrementalDecoder.reset(self) self.bytebuffer = ""
b17f12bbc6e6fc61e28aaf5d796cd83df1591779 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b17f12bbc6e6fc61e28aaf5d796cd83df1591779/codecs.py
if __debug__: class Foo: version = 1 class Foo: version = 2 class Foo: version = 3 def execfunc(x): exec x in y
def get_namespace(self): """Returns the single namespace bound to this name.
101651c128825a05a7ba7c1c556c90e22bfb86c2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/101651c128825a05a7ba7c1c556c90e22bfb86c2/symtable.py
def generate_header(self, structName): header = """
e3f257e6819327e40544315cae2ad838de8ff2e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e3f257e6819327e40544315cae2ad838de8ff2e1/perfect_hash.py
""" static PyObject *codec_tuple(PyObject *unicode, int len) { PyObject *v,*w; if (unicode == NULL) return NULL; v = PyTuple_New(2); if (v == NULL) { Py_DECREF(unicode); return NULL; } PyTuple_SET_ITEM(v,0,unicode); w = PyInt_FromLong(len); if (w == NULL) { Py_DECREF(v); return NULL; } PyTuple_SET_ITEM(v,1,w); return v; } static PyObject * ucn_decode(PyObject *self, PyObject *args) { const char *data; int size; const char *errors = NULL; PyObject *mapping = NULL; if (!PyArg_ParseTuple(args, "t &data, &size, &errors)) return NULL; if (mapping == Py_None) mapping = NULL; return codec_tuple(PyUnicode_DecodeNamedUnicodeEscape(data, size, errors), size); } static PyMethodDef _codecs_functions[] = { { "ucn_decode", ucn_decode, 1 }, }; DL_EXPORT(void) init_ucn() { Py_InitModule("_ucn", _codecs_functions); } """
def generate_hash(keys, caseInsensitive=0, minC=None, initC=None, f1Seed=None, f2Seed=None, cIncrement=None, cTries=None): """Print out code for a perfect minimal hash. Input is a list of (key, desired hash value) tuples. """ # K is the number of keys. K = len(keys) # We will be generating graphs of size N, where N = c * K. # The larger C is, the fewer trial graphs will need to be made, but # the resulting table is also larger. Increase this starting value # if you're impatient. After 50 failures, c will be increased by 0.025. if initC is None: initC = 1.5 c = initC if cIncrement is None: cIncrement = 0.0025 if cTries is None: cTries = 50 # Number of trial graphs so far num_graphs = 0 sys.stderr.write('Generating graphs... ') while 1: # N is the number of vertices in the graph G N = int(c*K) num_graphs = num_graphs + 1 if (num_graphs % cTries) == 0: # Enough failures at this multiplier, # increase the multiplier and keep trying.... c = c + cIncrement # Whats good with searching for a better # hash function if we exceed the size # of a function we've generated in the past.... if minC is not None and \ c > minC: c = initC sys.stderr.write(' -- c > minC, resetting c to %0.4f\n' % c) else: sys.stderr.write(' -- increasing c to %0.4f\n' % c) sys.stderr.write('Generating graphs... ') # Output a progress message sys.stderr.write( str(num_graphs) + ' ') sys.stderr.flush() # Create graph w/ N vertices G = Graph(N) # Save the seeds used to generate # the following two hash functions. _seeds = whrandom._inst._seed # Create 2 random hash functions f1 = Hash(N, caseInsensitive) f2 = Hash(N, caseInsensitive) # Set the initial hash function seed values if passed in. # Doing this protects our hash functions from # changes to whrandom's behavior. if f1Seed is not None: f1.seed = f1Seed f1Seed = None fSpecifiedSeeds = 1 if f2Seed is not None: f2.seed = f2Seed f2Seed = None fSpecifiedSeeds = 1 # Connect vertices given by the values of the two hash functions # for each key. Associate the desired hash value with each # edge. for k, v in keys: h1 = f1(k) ; h2 = f2(k) G.connect( h1,h2, v) # Check if the resulting graph is acyclic; if it is, # we're done with step 1. if G.is_acyclic(): break elif fSpecifiedSeeds: sys.stderr.write('\nThe initial f1/f2 seeds you specified didn\'t generate a perfect hash function: \n') sys.stderr.write('f1 seed: %s\n' % f1.seed) sys.stderr.write('f2 seed: %s\n' % f2.seed) sys.stderr.write('multipler: %s\n' % c) sys.stderr.write('Your data has likely changed, or you forgot what your initial multiplier should be.\n') sys.stderr.write('continuing the search for a perfect hash function......\n') fSpecifiedSeeds = 0 # Now we have an acyclic graph, so we assign values to each vertex # such that, for each edge, you can add the values for the two vertices # involved and get the desired value for that edge -- which is the # desired hash key. This task is dead easy, because the graph is acyclic. sys.stderr.write('\nAcyclic graph found; computing vertex values...\n') G.assign_values() sys.stderr.write('Checking uniqueness of hash values...\n') # Sanity check the result by actually verifying that all the keys # hash to the right value. cchMaxKey = 0 maxHashValue = 0 for k, v in keys: hash1 = G.values[ f1(k) ] hash2 = G.values[ f2(k) ] if hash1 > maxHashValue: maxHashValue = hash1 if hash2 > maxHashValue: maxHashValue = hash2 perfecthash = (hash1 + hash2) % N assert perfecthash == v cch = len(k) if cch > cchMaxKey: cchMaxKey = cch sys.stderr.write('Found perfect hash function!\n') sys.stderr.write('\nIn order to regenerate this hash function, \n') sys.stderr.write('you need to pass these following values back in:\n') sys.stderr.write('f1 seed: %s\n' % repr(f1.seed)) sys.stderr.write('f2 seed: %s\n' % repr(f2.seed)) sys.stderr.write('initial multipler: %s\n' % c) return PerfectHash(cchMaxKey, f1, f2, G, N, len(keys), maxHashValue)
e3f257e6819327e40544315cae2ad838de8ff2e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e3f257e6819327e40544315cae2ad838de8ff2e1/perfect_hash.py
try: os.mkdir(homeDir) except os.error: pass
try: os.mkdir(homeDir) except os.error: import glob files = glob.glob(os.path.join(self.homeDir, '*')) for file in files: os.remove(file)
def setUp(self): self.filename = self.__class__.__name__ + '.db' homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home') self.homeDir = homeDir try: os.mkdir(homeDir) except os.error: pass self.env = db.DBEnv() self.env.open(homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
c9321ccdfc51bc5e6317151467eb008720a86fe7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c9321ccdfc51bc5e6317151467eb008720a86fe7/test_associate.py
try: os.mkdir(homeDir) except os.error: pass
try: os.mkdir(homeDir) except os.error: import glob files = glob.glob(os.path.join(self.homeDir, '*')) for file in files: os.remove(file)
def setUp(self): self.filename = self.__class__.__name__ + '.db' homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home') self.homeDir = homeDir try: os.mkdir(homeDir) except os.error: pass self.env = db.DBEnv() self.env.open(homeDir, db.DB_CREATE | db.DB_INIT_MPOOL | db.DB_INIT_LOCK | db.DB_THREAD | self.envFlags)
c9321ccdfc51bc5e6317151467eb008720a86fe7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c9321ccdfc51bc5e6317151467eb008720a86fe7/test_associate.py
secDB = db.DB(self.env) secDB.set_flags(db.DB_DUP) secDB.set_get_returns_none(2) secDB.open(self.filename, "secondary", db.DB_BTREE,
self.secDB = db.DB(self.env) self.secDB.set_flags(db.DB_DUP) self.secDB.set_get_returns_none(2) self.secDB.open(self.filename, "secondary", db.DB_BTREE,
def test01_associateWithDB(self): if verbose: print '\n', '-=' * 30 print "Running %s.test01_associateWithDB..." % \ self.__class__.__name__
c9321ccdfc51bc5e6317151467eb008720a86fe7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c9321ccdfc51bc5e6317151467eb008720a86fe7/test_associate.py
self.getDB().associate(secDB, self.getGenre)
self.getDB().associate(self.secDB, self.getGenre)
def test01_associateWithDB(self): if verbose: print '\n', '-=' * 30 print "Running %s.test01_associateWithDB..." % \ self.__class__.__name__
c9321ccdfc51bc5e6317151467eb008720a86fe7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c9321ccdfc51bc5e6317151467eb008720a86fe7/test_associate.py
self.finish_test(secDB)
self.finish_test(self.secDB)
def test01_associateWithDB(self): if verbose: print '\n', '-=' * 30 print "Running %s.test01_associateWithDB..." % \ self.__class__.__name__
c9321ccdfc51bc5e6317151467eb008720a86fe7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c9321ccdfc51bc5e6317151467eb008720a86fe7/test_associate.py
secDB = db.DB(self.env) secDB.set_flags(db.DB_DUP) secDB.open(self.filename, "secondary", db.DB_BTREE,
self.secDB = db.DB(self.env) self.secDB.set_flags(db.DB_DUP) self.secDB.open(self.filename, "secondary", db.DB_BTREE,
def test02_associateAfterDB(self): if verbose: print '\n', '-=' * 30 print "Running %s.test02_associateAfterDB..." % \ self.__class__.__name__
c9321ccdfc51bc5e6317151467eb008720a86fe7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c9321ccdfc51bc5e6317151467eb008720a86fe7/test_associate.py
self.getDB().associate(secDB, self.getGenre, db.DB_CREATE) self.finish_test(secDB)
self.getDB().associate(self.secDB, self.getGenre, db.DB_CREATE) self.finish_test(self.secDB)
def test02_associateAfterDB(self): if verbose: print '\n', '-=' * 30 print "Running %s.test02_associateAfterDB..." % \ self.__class__.__name__
c9321ccdfc51bc5e6317151467eb008720a86fe7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c9321ccdfc51bc5e6317151467eb008720a86fe7/test_associate.py
c = self.getDB().cursor(txn)
self.cur = self.getDB().cursor(txn)
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
c9321ccdfc51bc5e6317151467eb008720a86fe7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c9321ccdfc51bc5e6317151467eb008720a86fe7/test_associate.py
rec = c.first()
rec = self.cur.first()
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
c9321ccdfc51bc5e6317151467eb008720a86fe7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c9321ccdfc51bc5e6317151467eb008720a86fe7/test_associate.py
rec = c.next()
rec = self.cur.next()
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
c9321ccdfc51bc5e6317151467eb008720a86fe7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c9321ccdfc51bc5e6317151467eb008720a86fe7/test_associate.py
c = secDB.cursor(txn)
self.cur = secDB.cursor(txn)
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
c9321ccdfc51bc5e6317151467eb008720a86fe7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c9321ccdfc51bc5e6317151467eb008720a86fe7/test_associate.py
vals = c.pget('Unknown', flags=db.DB_LAST)
vals = self.cur.pget('Unknown', flags=db.DB_LAST)
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
c9321ccdfc51bc5e6317151467eb008720a86fe7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c9321ccdfc51bc5e6317151467eb008720a86fe7/test_associate.py
vals = c.pget('Unknown', data='wrong value', flags=db.DB_GET_BOTH)
vals = self.cur.pget('Unknown', data='wrong value', flags=db.DB_GET_BOTH)
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
c9321ccdfc51bc5e6317151467eb008720a86fe7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c9321ccdfc51bc5e6317151467eb008720a86fe7/test_associate.py
rec = c.first()
rec = self.cur.first()
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
c9321ccdfc51bc5e6317151467eb008720a86fe7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c9321ccdfc51bc5e6317151467eb008720a86fe7/test_associate.py
rec = c.next()
rec = self.cur.next()
def finish_test(self, secDB, txn=None): # 'Blues' should not be in the secondary database vals = secDB.pget('Blues', txn=txn) assert vals == None, vals
c9321ccdfc51bc5e6317151467eb008720a86fe7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c9321ccdfc51bc5e6317151467eb008720a86fe7/test_associate.py
def test13_associateAutoCommit(self):
def txn_finish_test(self, sDB, txn): try: self.finish_test(sDB, txn=txn) finally: if self.cur: self.cur.close() self.cur = None if txn: txn.commit() def test13_associate_in_transaction(self):
def test13_associateAutoCommit(self): if verbose: print '\n', '-=' * 30 print "Running %s.test13_associateAutoCommit..." % \ self.__class__.__name__
c9321ccdfc51bc5e6317151467eb008720a86fe7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c9321ccdfc51bc5e6317151467eb008720a86fe7/test_associate.py
secDB = db.DB(self.env) secDB.set_flags(db.DB_DUP) secDB.set_get_returns_none(2) secDB.open(self.filename, "secondary", db.DB_BTREE,
self.secDB = db.DB(self.env) self.secDB.set_flags(db.DB_DUP) self.secDB.set_get_returns_none(2) self.secDB.open(self.filename, "secondary", db.DB_BTREE,
def test13_associateAutoCommit(self): if verbose: print '\n', '-=' * 30 print "Running %s.test13_associateAutoCommit..." % \ self.__class__.__name__
c9321ccdfc51bc5e6317151467eb008720a86fe7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c9321ccdfc51bc5e6317151467eb008720a86fe7/test_associate.py
self.getDB().associate(secDB, self.getGenre, txn=txn)
self.getDB().associate(self.secDB, self.getGenre, txn=txn)
def test13_associateAutoCommit(self): if verbose: print '\n', '-=' * 30 print "Running %s.test13_associateAutoCommit..." % \ self.__class__.__name__
c9321ccdfc51bc5e6317151467eb008720a86fe7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c9321ccdfc51bc5e6317151467eb008720a86fe7/test_associate.py
self.finish_test(secDB, txn=txn) finally: txn.commit()
except: txn.abort() raise self.txn_finish_test(self.secDB, txn=txn)
def test13_associateAutoCommit(self): if verbose: print '\n', '-=' * 30 print "Running %s.test13_associateAutoCommit..." % \ self.__class__.__name__
c9321ccdfc51bc5e6317151467eb008720a86fe7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c9321ccdfc51bc5e6317151467eb008720a86fe7/test_associate.py
def test( tests ): failed=[] for t in tests: if get_arg_text(t) != t.__doc__: failed.append(t) print "%s - expected %s, but got %s" % (t, `t.__doc__`, `get_arg_text(t)`) print "%d of %d tests failed" % (len(failed), len(tests))
class container: def __init__(self): root = Tk() text = self.text = Text(root) text.pack(side=LEFT, fill=BOTH, expand=1) text.insert("insert", "string.split") root.update() self.calltip = CallTip(text)
def test( tests ): failed=[] for t in tests: if get_arg_text(t) != t.__doc__: failed.append(t) print "%s - expected %s, but got %s" % (t, `t.__doc__`, `get_arg_text(t)`) print "%d of %d tests failed" % (len(failed), len(tests))
85b973576887f174f4f12fa643eeb232dba2be66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/85b973576887f174f4f12fa643eeb232dba2be66/CallTipWindow.py
tc = TC() tests = t1, t2, t3, t4, t5, t6, \ tc.t1, tc.t2, tc.t3, tc.t4, tc.t5, tc.t6
text.event_add("<<calltip-show>>", "(") text.event_add("<<calltip-hide>>", ")") text.bind("<<calltip-show>>", self.calltip_show) text.bind("<<calltip-hide>>", self.calltip_hide) text.focus_set()
def test( tests ): failed=[] for t in tests: if get_arg_text(t) != t.__doc__: failed.append(t) print "%s - expected %s, but got %s" % (t, `t.__doc__`, `get_arg_text(t)`) print "%d of %d tests failed" % (len(failed), len(tests))
85b973576887f174f4f12fa643eeb232dba2be66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/85b973576887f174f4f12fa643eeb232dba2be66/CallTipWindow.py
test(tests)
def calltip_show(self, event): self.calltip.showtip("Hello world") def calltip_hide(self, event): self.calltip.hidetip() def main(): c=container() if __name__=='__main__': main()
def test( tests ): failed=[] for t in tests: if get_arg_text(t) != t.__doc__: failed.append(t) print "%s - expected %s, but got %s" % (t, `t.__doc__`, `get_arg_text(t)`) print "%d of %d tests failed" % (len(failed), len(tests))
85b973576887f174f4f12fa643eeb232dba2be66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/85b973576887f174f4f12fa643eeb232dba2be66/CallTipWindow.py
adlist = None
adlist = ""
def getrouteaddr(self): """Parse a route address (Return-path value).
f830a529961b54d136aac71e1e499e6735627d99 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f830a529961b54d136aac71e1e499e6735627d99/rfc822.py
if path.startswith(dir) and path[len(dir)] == os.path.sep:
dir = os.path.normcase(dir) if comparepath.startswith(dir) and comparepath[len(dir)] == os.sep:
def fullmodname(path): """Return a plausible module name for the path.""" # If the file 'path' is part of a package, then the filename isn't # enough to uniquely identify it. Try to do the right thing by # looking in sys.path for the longest matching prefix. We'll # assume that the rest is the package name. longest = "" for dir in sys.path: if path.startswith(dir) and path[len(dir)] == os.path.sep: if len(dir) > len(longest): longest = dir if longest: base = path[len(longest) + 1:] else: base = path base = base.replace(os.sep, ".") if os.altsep: base = base.replace(os.altsep, ".") filename, ext = os.path.splitext(base) return filename
7a1af770b9fbf73e967fac9ad224e6caad62e4cc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a1af770b9fbf73e967fac9ad224e6caad62e4cc/trace.py
if self.text.get("insert-1c") not in (')',']','}'):
closer = self.text.get("insert-1c") if closer not in _openers:
def paren_closed_event(self, event): # If it was a shortcut and not really a closing paren, quit. if self.text.get("insert-1c") not in (')',']','}'): return hp = HyperParser(self.editwin, "insert-1c") if not hp.is_in_code(): return indices = hp.get_surrounding_brackets(keysym_opener[event.keysym], True) if indices is None: self.warn_mismatched() return self.activate_restore() self.create_tag(indices) self.set_timeout()
43476e009b2f3b9fd6c3d600bb41a0298907bad5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/43476e009b2f3b9fd6c3d600bb41a0298907bad5/ParenMatch.py
indices = hp.get_surrounding_brackets(keysym_opener[event.keysym], True)
indices = hp.get_surrounding_brackets(_openers[closer], True)
def paren_closed_event(self, event): # If it was a shortcut and not really a closing paren, quit. if self.text.get("insert-1c") not in (')',']','}'): return hp = HyperParser(self.editwin, "insert-1c") if not hp.is_in_code(): return indices = hp.get_surrounding_brackets(keysym_opener[event.keysym], True) if indices is None: self.warn_mismatched() return self.activate_restore() self.create_tag(indices) self.set_timeout()
43476e009b2f3b9fd6c3d600bb41a0298907bad5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/43476e009b2f3b9fd6c3d600bb41a0298907bad5/ParenMatch.py
log.info("changing mode of %s to %o", file, mode)
log.info("changing mode of %s", file)
def run (self): if not self.skip_build: self.run_command('build_scripts') self.outfiles = self.copy_tree(self.build_dir, self.install_dir) if os.name == 'posix': # Set the executable bits (owner, group, and world) on # all the scripts we just installed. for file in self.get_outputs(): if self.dry_run: log.info("changing mode of %s to %o", file, mode) else: mode = ((os.stat(file)[ST_MODE]) | 0111) & 07777 log.info("changing mode of %s to %o", file, mode) os.chmod(file, mode)
e6f40ea4b668ae615b1f48461a4875d966b2915a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e6f40ea4b668ae615b1f48461a4875d966b2915a/install_scripts.py
prog = prog + self.compiler.exe_extension
if self.compiler.exe_extension is not None: prog = prog + self.compiler.exe_extension
def _link (self, body, headers, include_dirs, libraries, library_dirs, lang): (src, obj) = self._compile(body, headers, include_dirs, lang) prog = os.path.splitext(os.path.basename(src))[0] self.compiler.link_executable([obj], prog, libraries=libraries, library_dirs=library_dirs, target_lang=lang)
ca3fec716203db814e297894c09e1daa8fbbef25 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ca3fec716203db814e297894c09e1daa8fbbef25/config.py
host, port = splitport(host) if port is None: port = ftplib.FTP_PORT user, host = splituser(host) if user: user, passwd = splitpasswd(user) else: passwd = None host = unquote(host) user = unquote(user or '') passwd = unquote(passwd or '')
def ftp_open(self, req): host = req.get_host() if not host: raise IOError, ('ftp error', 'no host given') # XXX handle custom username & password try: host = socket.gethostbyname(host) except socket.error, msg: raise URLError(msg) host, port = splitport(host) if port is None: port = ftplib.FTP_PORT path, attrs = splitattr(req.get_selector()) dirs = path.split('/') dirs = map(unquote, dirs) dirs, file = dirs[:-1], dirs[-1] if dirs and not dirs[0]: dirs = dirs[1:] user = passwd = '' # XXX try: fw = self.connect_ftp(user, passwd, host, port, dirs) type = file and 'I' or 'D' for attr in attrs: attr, value = splitattr(attr) if attr.lower() == 'type' and \ value in ('a', 'A', 'i', 'I', 'd', 'D'): type = value.upper() fp, retrlen = fw.retrfile(file, type) headers = "" mtype = mimetypes.guess_type(req.get_full_url())[0] if mtype: headers += "Content-type: %s\n" % mtype if retrlen is not None and retrlen >= 0: headers += "Content-length: %d\n" % retrlen sf = StringIO(headers) headers = mimetools.Message(sf) return addinfourl(fp, headers, req.get_full_url()) except ftplib.all_errors, msg: raise IOError, ('ftp error', msg), sys.exc_info()[2]
a79449e7a2c34daa622c01b66b8a8bd681089176 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a79449e7a2c34daa622c01b66b8a8bd681089176/urllib2.py
host, port = splitport(host) if port is None: port = ftplib.FTP_PORT
def ftp_open(self, req): host = req.get_host() if not host: raise IOError, ('ftp error', 'no host given') # XXX handle custom username & password try: host = socket.gethostbyname(host) except socket.error, msg: raise URLError(msg) host, port = splitport(host) if port is None: port = ftplib.FTP_PORT path, attrs = splitattr(req.get_selector()) dirs = path.split('/') dirs = map(unquote, dirs) dirs, file = dirs[:-1], dirs[-1] if dirs and not dirs[0]: dirs = dirs[1:] user = passwd = '' # XXX try: fw = self.connect_ftp(user, passwd, host, port, dirs) type = file and 'I' or 'D' for attr in attrs: attr, value = splitattr(attr) if attr.lower() == 'type' and \ value in ('a', 'A', 'i', 'I', 'd', 'D'): type = value.upper() fp, retrlen = fw.retrfile(file, type) headers = "" mtype = mimetypes.guess_type(req.get_full_url())[0] if mtype: headers += "Content-type: %s\n" % mtype if retrlen is not None and retrlen >= 0: headers += "Content-length: %d\n" % retrlen sf = StringIO(headers) headers = mimetools.Message(sf) return addinfourl(fp, headers, req.get_full_url()) except ftplib.all_errors, msg: raise IOError, ('ftp error', msg), sys.exc_info()[2]
a79449e7a2c34daa622c01b66b8a8bd681089176 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a79449e7a2c34daa622c01b66b8a8bd681089176/urllib2.py
user = passwd = ''
def ftp_open(self, req): host = req.get_host() if not host: raise IOError, ('ftp error', 'no host given') # XXX handle custom username & password try: host = socket.gethostbyname(host) except socket.error, msg: raise URLError(msg) host, port = splitport(host) if port is None: port = ftplib.FTP_PORT path, attrs = splitattr(req.get_selector()) dirs = path.split('/') dirs = map(unquote, dirs) dirs, file = dirs[:-1], dirs[-1] if dirs and not dirs[0]: dirs = dirs[1:] user = passwd = '' # XXX try: fw = self.connect_ftp(user, passwd, host, port, dirs) type = file and 'I' or 'D' for attr in attrs: attr, value = splitattr(attr) if attr.lower() == 'type' and \ value in ('a', 'A', 'i', 'I', 'd', 'D'): type = value.upper() fp, retrlen = fw.retrfile(file, type) headers = "" mtype = mimetypes.guess_type(req.get_full_url())[0] if mtype: headers += "Content-type: %s\n" % mtype if retrlen is not None and retrlen >= 0: headers += "Content-length: %d\n" % retrlen sf = StringIO(headers) headers = mimetools.Message(sf) return addinfourl(fp, headers, req.get_full_url()) except ftplib.all_errors, msg: raise IOError, ('ftp error', msg), sys.exc_info()[2]
a79449e7a2c34daa622c01b66b8a8bd681089176 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a79449e7a2c34daa622c01b66b8a8bd681089176/urllib2.py
_copy_reg.pickle(stat_result, _pickle_stat_result,_make_stat_result)
try: _copy_reg.pickle(stat_result, _pickle_stat_result, _make_stat_result) except NameError: pass
def _pickle_stat_result(sr): (type, args) = sr.__reduce__() return (_make_stat_result, args)
ce00b735cde4e4d0c56e02723fb0b459c403ace3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ce00b735cde4e4d0c56e02723fb0b459c403ace3/os.py
def test_main():
def test_basic():
def test_main(): test_support.requires('network') if not hasattr(socket, "ssl"): raise test_support.TestSkipped("socket module has no ssl support") import urllib socket.RAND_status() try: socket.RAND_egd(1) except TypeError: pass else: print "didn't raise TypeError" socket.RAND_add("this is a random string", 75.0) f = urllib.urlopen('https://sf.net') buf = f.read() f.close()
a9002f824bdca26700a9a6e7b7e6b36a9482e345 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a9002f824bdca26700a9a6e7b7e6b36a9482e345/test_socket_ssl.py
prefix = buf[345:500] while prefix and prefix[-1] == NUL: prefix = prefix[:-1] if len(prefix.split(NUL)) == 1: tarinfo.prefix = prefix tarinfo.name = normpath(os.path.join(tarinfo.prefix, tarinfo.name)) else: tarinfo.prefix = buf[345:500]
if tarinfo.type != GNUTYPE_SPARSE: tarinfo.name = normpath(os.path.join(nts(tarinfo.prefix), tarinfo.name))
def frombuf(cls, buf): """Construct a TarInfo object from a 512 byte string buffer. """ tarinfo = cls() tarinfo.name = nts(buf[0:100]) tarinfo.mode = int(buf[100:108], 8) tarinfo.uid = int(buf[108:116],8) tarinfo.gid = int(buf[116:124],8) tarinfo.size = long(buf[124:136], 8) tarinfo.mtime = long(buf[136:148], 8) tarinfo.chksum = int(buf[148:156], 8) tarinfo.type = buf[156:157] tarinfo.linkname = nts(buf[157:257]) tarinfo.uname = nts(buf[265:297]) tarinfo.gname = nts(buf[297:329]) try: tarinfo.devmajor = int(buf[329:337], 8) tarinfo.devminor = int(buf[337:345], 8) except ValueError: tarinfo.devmajor = tarinfo.devmajor = 0
2b4b5a54d6138e1d8be56b83574a16146306e630 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2b4b5a54d6138e1d8be56b83574a16146306e630/tarfile.py
print 'ParsedDate:', time.asctime(date[:-1]), hhmmss = date[-1]
print 'ParsedDate:', time.asctime(date), hhmmss = tz
def formatdate(timeval=None): """Returns time format preferred for Internet standards. Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 """ if timeval is None: timeval = time.time() return "%s" % time.strftime('%a, %d %b %Y %H:%M:%S GMT', time.gmtime(timeval))
1d2b23ef22856ae90a2947ab29ebfbf6f83f134a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1d2b23ef22856ae90a2947ab29ebfbf6f83f134a/rfc822.py
if isinstance(host, TupleType): host, x509 = host else: x509 = {}
host, extra_headers, x509 = self.get_host_info(host)
def make_connection(self, host): # create a HTTPS connection object from a host descriptor # host may be a string, or a (host, x509-dict) tuple import httplib if isinstance(host, TupleType): host, x509 = host else: x509 = {} try: HTTPS = httplib.HTTPS except AttributeError: raise NotImplementedError,\ "your version of httplib doesn't support HTTPS" else: return apply(HTTPS, (host, None), x509)
1303c7cb166ed404945ac79a3a20c06b702c6224 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1303c7cb166ed404945ac79a3a20c06b702c6224/xmlrpclib.py
raise NotImplementedError,\ "your version of httplib doesn't support HTTPS"
raise NotImplementedError( "your version of httplib doesn't support HTTPS" )
def make_connection(self, host): # create a HTTPS connection object from a host descriptor # host may be a string, or a (host, x509-dict) tuple import httplib if isinstance(host, TupleType): host, x509 = host else: x509 = {} try: HTTPS = httplib.HTTPS except AttributeError: raise NotImplementedError,\ "your version of httplib doesn't support HTTPS" else: return apply(HTTPS, (host, None), x509)
1303c7cb166ed404945ac79a3a20c06b702c6224 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1303c7cb166ed404945ac79a3a20c06b702c6224/xmlrpclib.py
return apply(HTTPS, (host, None), x509) def send_host(self, connection, host): if isinstance(host, TupleType): host, x509 = host connection.putheader("Host", host)
return apply(HTTPS, (host, None), x509 or {})
def make_connection(self, host): # create a HTTPS connection object from a host descriptor # host may be a string, or a (host, x509-dict) tuple import httplib if isinstance(host, TupleType): host, x509 = host else: x509 = {} try: HTTPS = httplib.HTTPS except AttributeError: raise NotImplementedError,\ "your version of httplib doesn't support HTTPS" else: return apply(HTTPS, (host, None), x509)
1303c7cb166ed404945ac79a3a20c06b702c6224 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1303c7cb166ed404945ac79a3a20c06b702c6224/xmlrpclib.py
res[i] = '%%%02x' % ord(c)
res[i] = '%%%02X' % ord(c)
def _fast_quote(s): global _fast_safe if _fast_safe is None: _fast_safe = {} for c in _fast_safe_test: _fast_safe[c] = c res = list(s) for i in range(len(res)): c = res[i] if not _fast_safe.has_key(c): res[i] = '%%%02x' % ord(c) return ''.join(res)
e27a7b80748c902ce956287f14857666db523c4b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e27a7b80748c902ce956287f14857666db523c4b/urllib.py
res[i] = '%%%02x' % ord(c)
res[i] = '%%%02X' % ord(c)
def quote(s, safe = '/'): """quote('abc def') -> 'abc%20def' Each part of a URL, e.g. the path info, the query, etc., has a different set of reserved characters that must be quoted. RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax lists the following reserved characters. reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | "," Each of these characters is reserved in some component of a URL, but not necessarily in all of them. By default, the quote function is intended for quoting the path section of a URL. Thus, it will not encode '/'. This character is reserved, but in typical usage the quote function is being called on a path where the existing slash characters are used as reserved characters. """ safe = always_safe + safe if _fast_safe_test == safe: return _fast_quote(s) res = list(s) for i in range(len(res)): c = res[i] if c not in safe: res[i] = '%%%02x' % ord(c) return ''.join(res)
e27a7b80748c902ce956287f14857666db523c4b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e27a7b80748c902ce956287f14857666db523c4b/urllib.py
for filename in self._built_objects: os.remove(filename)
try: for filename in self._built_objects: os.remove(filename) except AttributeError: self.announce('unable to remove files (ignored)')
def build_extension(self, ext):
03ffbcd393319cfd34341974829fd010fad4b053 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/03ffbcd393319cfd34341974829fd010fad4b053/setup.py
extra_link_args=['-framework', 'Carbon']) )
extra_link_args=['-framework', 'Carbon']) )
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
03ffbcd393319cfd34341974829fd010fad4b053 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/03ffbcd393319cfd34341974829fd010fad4b053/setup.py
simple_err(struct.calcsize, 'Q')
simple_err(struct.calcsize, 'Z')
def simple_err(func, *args): try: apply(func, args) except struct.error: pass else: raise TestFailed, "%s%s did not raise struct.error" % ( func.__name__, args)
7b9542a3f747787aedf056ddaef99e4469777aa9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7b9542a3f747787aedf056ddaef99e4469777aa9/test_struct.py
def badpack(fmt, arg, got, exp): return def badunpack(fmt, arg, got, exp): return "unpack(%s, %s) -> (%s,) `fmt`, `arg`, `got`, `exp`) isbigendian = struct.pack('=h', 1) == '\0\1'
isbigendian = struct.pack('=i', 1)[0] == chr(0)
def badpack(fmt, arg, got, exp): return
7b9542a3f747787aedf056ddaef99e4469777aa9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7b9542a3f747787aedf056ddaef99e4469777aa9/test_struct.py
"""Pretty-print a Python object to a stream [default is sys.sydout]."""
"""Pretty-print a Python object to a stream [default is sys.stdout]."""
def pprint(object, stream=None, indent=1, width=80, depth=None): """Pretty-print a Python object to a stream [default is sys.sydout].""" printer = PrettyPrinter( stream=stream, indent=indent, width=width, depth=depth) printer.pprint(object)
2dc0c138400cb562fbf10632a11a1703d99973e2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2dc0c138400cb562fbf10632a11a1703d99973e2/pprint.py
nframes = self.calcnframes()
nframes = self.calcnframes(memsize)
def burst_capture(self): self.setwatch() gl.winset(self.window) x, y = gl.getsize() if self.use_24: fl.show_message('Sorry, no 24 bit continuous capture yet', '', '') return vformat = SV.RGB8_FRAMES nframes = self.getint(self.in_nframes, 0) if nframes == 0: maxmem = self.getint(self.in_maxmem, 1.0) memsize = int(maxmem * 1024 * 1024) nframes = self.calcnframes() info = (vformat, x, y, nframes, 1) try: info2, data, bitvec = self.video.CaptureBurst(info) except sv.error, msg: self.b_capture.set_button(0) self.setarrow() fl.show_message('Capture error:', str(msg), '') return if info <> info2: print info, '<>', info2 self.save_burst(info2, data, bitvec) self.setarrow()
546185075cbfde306021d8cbf913a1a575286eb0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/546185075cbfde306021d8cbf913a1a575286eb0/Vb.py
def calcnframes(self):
def calcnframes(self, memsize):
def calcnframes(self): gl.winset(self.window) x, y = gl.getsize() pixels = x*y pixels = pixels/2 # XXX always assume fields if self.mono or self.grey: n = memsize/pixels else: n = memsize/(4*pixels) return max(1, n)
546185075cbfde306021d8cbf913a1a575286eb0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/546185075cbfde306021d8cbf913a1a575286eb0/Vb.py
("CompilePyc", 18, "python.exe", r"[TARGETDIR]Lib\compileall.py [TARGETDIR]Lib"), ("CompilePyo", 18, "python.exe", r"-O [TARGETDIR]Lib\compileall.py [TARGETDIR]Lib")
("CompilePyc", 18, "python.exe", compileargs), ("CompilePyo", 18, "python.exe", "-O "+compileargs),
def add_ui(db): x = y = 50 w = 370 h = 300 title = "[ProductName] Setup" # see "Dialog Style Bits" modal = 3 # visible | modal modeless = 1 # visible track_disk_space = 32 add_data(db, 'ActionText', uisample.ActionText) add_data(db, 'UIText', uisample.UIText) # Bitmaps if not os.path.exists(srcdir+r"\PC\python_icon.exe"): raise "Run icons.mak in PC directory" add_data(db, "Binary", [("PythonWin", msilib.Binary(srcdir+r"\PCbuild\installer.bmp")), # 152x328 pixels ("py.ico",msilib.Binary(srcdir+r"\PC\py.ico")), ]) add_data(db, "Icon", [("python_icon.exe", msilib.Binary(srcdir+r"\PC\python_icon.exe"))]) # Scripts # CheckDir sets TargetExists if TARGETDIR exists. # UpdateEditIDLE sets the REGISTRY.tcl component into # the installed/uninstalled state according to both the # Extensions and TclTk features. open("inst.vbs","w").write(""" Function CheckDir() Set FSO = CreateObject("Scripting.FileSystemObject") if FSO.FolderExists(Session.Property("TARGETDIR")) then Session.Property("TargetExists") = "1" else Session.Property("TargetExists") = "0" end if End Function Function UpdateEditIDLE() Dim ext_new, tcl_new, regtcl_old ext_new = Session.FeatureRequestState("Extensions") tcl_new = Session.FeatureRequestState("TclTk") if ext_new=-1 then ext_new = Session.FeatureCurrentState("Extensions") end if if tcl_new=-1 then tcl_new = Session.FeatureCurrentState("TclTk") end if regtcl_old = Session.ComponentCurrentState("REGISTRY.tcl") if ext_new=3 and (tcl_new=3 or tcl_new=4) and regtcl_old<>3 then Session.ComponentRequestState("REGISTRY.tcl")=3 end if if (ext_new=2 or tcl_new=2) and regtcl_old<>2 then Session.ComponentRequestState("REGISTRY.tcl")=2 end if End Function """) # To add debug messages into scripts, the following fragment can be used # set objRec = Session.Installer.CreateRecord(1) # objRec.StringData(1) = "Debug message" # Session.message &H04000000, objRec add_data(db, "Binary", [("Script", msilib.Binary("inst.vbs"))]) # See "Custom Action Type 6" add_data(db, "CustomAction", [("CheckDir", 6, "Script", "CheckDir"), ("UpdateEditIDLE", 6, "Script", "UpdateEditIDLE")]) os.unlink("inst.vbs") # UI customization properties add_data(db, "Property", # See "DefaultUIFont Property" [("DefaultUIFont", "DlgFont8"), # See "ErrorDialog Style Bit" ("ErrorDialog", "ErrorDlg"), ("Progress1", "Install"), # modified in maintenance type dlg ("Progress2", "installs"), ("MaintenanceForm_Action", "Repair")]) # Fonts, see "TextStyle Table" add_data(db, "TextStyle", [("DlgFont8", "Tahoma", 9, None, 0), ("DlgFontBold8", "Tahoma", 8, None, 1), #bold ("VerdanaBold10", "Verdana", 10, None, 1), ]) # See "CustomAction Table" add_data(db, "CustomAction", [ # msidbCustomActionTypeFirstSequence + msidbCustomActionTypeTextData + msidbCustomActionTypeProperty # See "Custom Action Type 51", # "Custom Action Execution Scheduling Options" ("InitialTargetDir", 307, "TARGETDIR", "[WindowsVolume]Python%s%s" % (major, minor)), ("SetDLLDirToTarget", 307, "DLLDIR", "[TARGETDIR]"), ("SetDLLDirToSystem32", 307, "DLLDIR", SystemFolderName), # msidbCustomActionTypeExe + msidbCustomActionTypeSourceFile # See "Custom Action Type 18" ("CompilePyc", 18, "python.exe", r"[TARGETDIR]Lib\compileall.py [TARGETDIR]Lib"), ("CompilePyo", 18, "python.exe", r"-O [TARGETDIR]Lib\compileall.py [TARGETDIR]Lib") ]) # UI Sequences, see "InstallUISequence Table", "Using a Sequence Table" # Numbers indicate sequence; see sequence.py for how these action integrate add_data(db, "InstallUISequence", [("PrepareDlg", "Not Privileged or Windows9x or Installed", 140), ("WhichUsersDlg", "Privileged and not Windows9x and not Installed", 141), ("InitialTargetDir", 'TARGETDIR=""', 750), # In the user interface, assume all-users installation if privileged. ("SetDLLDirToSystem32", 'DLLDIR="" and ' + sys32cond, 751), ("SetDLLDirToTarget", 'DLLDIR="" and not ' + sys32cond, 752), ("SelectDirectoryDlg", "Not Installed", 1230), # XXX no support for resume installations yet #("ResumeDlg", "Installed AND (RESUME OR Preselected)", 1240), ("MaintenanceTypeDlg", "Installed AND NOT RESUME AND NOT Preselected", 1250), ("ProgressDlg", None, 1280)]) add_data(db, "AdminUISequence", [("InitialTargetDir", 'TARGETDIR=""', 750), ("SetDLLDirToTarget", 'DLLDIR=""', 751), ]) # Execute Sequences add_data(db, "InstallExecuteSequence", [("InitialTargetDir", 'TARGETDIR=""', 750), ("SetDLLDirToSystem32", 'DLLDIR="" and ' + sys32cond, 751), ("SetDLLDirToTarget", 'DLLDIR="" and not ' + sys32cond, 752), ("UpdateEditIDLE", None, 1050), ("CompilePyc", "COMPILEALL", 6800), ("CompilePyo", "COMPILEALL", 6801), ]) add_data(db, "AdminExecuteSequence", [("InitialTargetDir", 'TARGETDIR=""', 750), ("SetDLLDirToTarget", 'DLLDIR=""', 751), ("CompilePyc", "COMPILEALL", 6800), ("CompilePyo", "COMPILEALL", 6801), ]) ##################################################################### # Standard dialogs: FatalError, UserExit, ExitDialog fatal=PyDialog(db, "FatalError", x, y, w, h, modal, title, "Finish", "Finish", "Finish") fatal.title("[ProductName] Installer ended prematurely") fatal.back("< Back", "Finish", active = 0) fatal.cancel("Cancel", "Back", active = 0) fatal.text("Description1", 135, 70, 220, 80, 0x30003, "[ProductName] setup ended prematurely because of an error. Your system has not been modified. To install this program at a later time, please run the installation again.") fatal.text("Description2", 135, 155, 220, 20, 0x30003, "Click the Finish button to exit the Installer.") c=fatal.next("Finish", "Cancel", name="Finish") # See "ControlEvent Table". Parameters are the event, the parameter # to the action, and optionally the condition for the event, and the order # of events. c.event("EndDialog", "Exit") user_exit=PyDialog(db, "UserExit", x, y, w, h, modal, title, "Finish", "Finish", "Finish") user_exit.title("[ProductName] Installer was interrupted") user_exit.back("< Back", "Finish", active = 0) user_exit.cancel("Cancel", "Back", active = 0) user_exit.text("Description1", 135, 70, 220, 80, 0x30003, "[ProductName] setup was interrupted. Your system has not been modified. " "To install this program at a later time, please run the installation again.") user_exit.text("Description2", 135, 155, 220, 20, 0x30003, "Click the Finish button to exit the Installer.") c = user_exit.next("Finish", "Cancel", name="Finish") c.event("EndDialog", "Exit") exit_dialog = PyDialog(db, "ExitDialog", x, y, w, h, modal, title, "Finish", "Finish", "Finish") exit_dialog.title("Completing the [ProductName] Installer") exit_dialog.back("< Back", "Finish", active = 0) exit_dialog.cancel("Cancel", "Back", active = 0) exit_dialog.text("Acknowledgements", 135, 95, 220, 120, 0x30003, "Special Windows thanks to:\n" " LettError, Erik van Blokland, for the \n" " Python for Windows graphic.\n" " http://www.letterror.com/\n" "\n" " Mark Hammond, without whose years of freely \n" " shared Windows expertise, Python for Windows \n" " would still be Python for DOS.") exit_dialog.text("Description", 135, 235, 220, 20, 0x30003, "Click the Finish button to exit the Installer.") c = exit_dialog.next("Finish", "Cancel", name="Finish") c.event("EndDialog", "Return") ##################################################################### # Required dialog: FilesInUse, ErrorDlg inuse = PyDialog(db, "FilesInUse", x, y, w, h, 19, # KeepModeless|Modal|Visible title, "Retry", "Retry", "Retry", bitmap=False) inuse.text("Title", 15, 6, 200, 15, 0x30003, r"{\DlgFontBold8}Files in Use") inuse.text("Description", 20, 23, 280, 20, 0x30003, "Some files that need to be updated are currently in use.") inuse.text("Text", 20, 55, 330, 50, 3, "The following applications are using files that need to be updated by this setup. Close these applications and then click Retry to continue the installation or Cancel to exit it.") inuse.control("List", "ListBox", 20, 107, 330, 130, 7, "FileInUseProcess", None, None, None) c=inuse.back("Exit", "Ignore", name="Exit") c.event("EndDialog", "Exit") c=inuse.next("Ignore", "Retry", name="Ignore") c.event("EndDialog", "Ignore") c=inuse.cancel("Retry", "Exit", name="Retry") c.event("EndDialog","Retry") # See "Error Dialog". See "ICE20" for the required names of the controls. error = Dialog(db, "ErrorDlg", 50, 10, 330, 101, 65543, # Error|Minimize|Modal|Visible title, "ErrorText", None, None) error.text("ErrorText", 50,9,280,48,3, "") error.control("ErrorIcon", "Icon", 15, 9, 24, 24, 5242881, None, "py.ico", None, None) error.pushbutton("N",120,72,81,21,3,"No",None).event("EndDialog","ErrorNo") error.pushbutton("Y",240,72,81,21,3,"Yes",None).event("EndDialog","ErrorYes") error.pushbutton("A",0,72,81,21,3,"Abort",None).event("EndDialog","ErrorAbort") error.pushbutton("C",42,72,81,21,3,"Cancel",None).event("EndDialog","ErrorCancel") error.pushbutton("I",81,72,81,21,3,"Ignore",None).event("EndDialog","ErrorIgnore") error.pushbutton("O",159,72,81,21,3,"Ok",None).event("EndDialog","ErrorOk") error.pushbutton("R",198,72,81,21,3,"Retry",None).event("EndDialog","ErrorRetry") ##################################################################### # Global "Query Cancel" dialog cancel = Dialog(db, "CancelDlg", 50, 10, 260, 85, 3, title, "No", "No", "No") cancel.text("Text", 48, 15, 194, 30, 3, "Are you sure you want to cancel [ProductName] installation?") cancel.control("Icon", "Icon", 15, 15, 24, 24, 5242881, None, "py.ico", None, None) c=cancel.pushbutton("Yes", 72, 57, 56, 17, 3, "Yes", "No") c.event("EndDialog", "Exit") c=cancel.pushbutton("No", 132, 57, 56, 17, 3, "No", "Yes") c.event("EndDialog", "Return") ##################################################################### # Global "Wait for costing" dialog costing = Dialog(db, "WaitForCostingDlg", 50, 10, 260, 85, modal, title, "Return", "Return", "Return") costing.text("Text", 48, 15, 194, 30, 3, "Please wait while the installer finishes determining your disk space requirements.") costing.control("Icon", "Icon", 15, 15, 24, 24, 5242881, None, "py.ico", None, None) c = costing.pushbutton("Return", 102, 57, 56, 17, 3, "Return", None) c.event("EndDialog", "Exit") ##################################################################### # Preparation dialog: no user input except cancellation prep = PyDialog(db, "PrepareDlg", x, y, w, h, modeless, title, "Cancel", "Cancel", "Cancel") prep.text("Description", 135, 70, 220, 40, 0x30003, "Please wait while the Installer prepares to guide you through the installation.") prep.title("Welcome to the [ProductName] Installer") c=prep.text("ActionText", 135, 110, 220, 20, 0x30003, "Pondering...") c.mapping("ActionText", "Text") c=prep.text("ActionData", 135, 135, 220, 30, 0x30003, None) c.mapping("ActionData", "Text") prep.back("Back", None, active=0) prep.next("Next", None, active=0) c=prep.cancel("Cancel", None) c.event("SpawnDialog", "CancelDlg") ##################################################################### # Target directory selection seldlg = PyDialog(db, "SelectDirectoryDlg", x, y, w, h, modal, title, "Next", "Next", "Cancel") seldlg.title("Select Destination Directory") seldlg.text("Description", 135, 50, 220, 40, 0x30003, "Please select a directory for the [ProductName] files.") seldlg.back("< Back", None, active=0) c = seldlg.next("Next >", "Cancel") c.event("DoAction", "CheckDir", "TargetExistsOk<>1", order=1) # If the target exists, but we found that we are going to remove old versions, don't bother # confirming that the target directory exists. Strictly speaking, we should determine that # the target directory is indeed the target of the product that we are going to remove, but # I don't know how to do that. c.event("SpawnDialog", "ExistingDirectoryDlg", 'TargetExists=1 and REMOVEOLDVERSION="" and REMOVEOLDSNAPSHOT=""', 2) c.event("SetTargetPath", "TARGETDIR", 'TargetExists=0 or REMOVEOLDVERSION<>"" or REMOVEOLDSNAPSHOT<>""', 3) c.event("SpawnWaitDialog", "WaitForCostingDlg", "CostingComplete=1", 4) c.event("NewDialog", "SelectFeaturesDlg", 'TargetExists=0 or REMOVEOLDVERSION<>"" or REMOVEOLDSNAPSHOT<>""', 5) c = seldlg.cancel("Cancel", "DirectoryCombo") c.event("SpawnDialog", "CancelDlg") seldlg.control("DirectoryCombo", "DirectoryCombo", 135, 70, 172, 80, 393219, "TARGETDIR", None, "DirectoryList", None) seldlg.control("DirectoryList", "DirectoryList", 135, 90, 208, 136, 3, "TARGETDIR", None, "PathEdit", None) seldlg.control("PathEdit", "PathEdit", 135, 230, 206, 16, 3, "TARGETDIR", None, "Next", None) c = seldlg.pushbutton("Up", 306, 70, 18, 18, 3, "Up", None) c.event("DirectoryListUp", "0") c = seldlg.pushbutton("NewDir", 324, 70, 30, 18, 3, "New", None) c.event("DirectoryListNew", "0") ##################################################################### # SelectFeaturesDlg features = PyDialog(db, "SelectFeaturesDlg", x, y, w, h, modal|track_disk_space, title, "Tree", "Next", "Cancel") features.title("Customize [ProductName]") features.text("Description", 135, 35, 220, 15, 0x30003, "Select the way you want features to be installed.") features.text("Text", 135,45,220,30, 3, "Click on the icons in the tree below to change the way features will be installed.") c=features.back("< Back", "Next") c.event("NewDialog", "SelectDirectoryDlg") c=features.next("Next >", "Cancel") c.mapping("SelectionNoItems", "Enabled") c.event("SpawnDialog", "DiskCostDlg", "OutOfDiskSpace=1", order=1) c.event("EndDialog", "Return", "OutOfDiskSpace<>1", order=2) c=features.cancel("Cancel", "Tree") c.event("SpawnDialog", "CancelDlg") # The browse property is not used, since we have only a single target path (selected already) features.control("Tree", "SelectionTree", 135, 75, 220, 95, 7, "_BrowseProperty", "Tree of selections", "Back", None) #c=features.pushbutton("Reset", 42, 243, 56, 17, 3, "Reset", "DiskCost") #c.mapping("SelectionNoItems", "Enabled") #c.event("Reset", "0") features.control("Box", "GroupBox", 135, 170, 225, 90, 1, None, None, None, None) c=features.xbutton("DiskCost", "Disk &Usage", None, 0.10) c.mapping("SelectionNoItems","Enabled") c.event("SpawnDialog", "DiskCostDlg") c=features.xbutton("Advanced", "Advanced", None, 0.30) c.event("SpawnDialog", "AdvancedDlg") c=features.text("ItemDescription", 140, 180, 210, 30, 3, "Multiline description of the currently selected item.") c.mapping("SelectionDescription","Text") c=features.text("ItemSize", 140, 210, 210, 45, 3, "The size of the currently selected item.") c.mapping("SelectionSize", "Text") ##################################################################### # Disk cost cost = PyDialog(db, "DiskCostDlg", x, y, w, h, modal, title, "OK", "OK", "OK", bitmap=False) cost.text("Title", 15, 6, 200, 15, 0x30003, "{\DlgFontBold8}Disk Space Requirements") cost.text("Description", 20, 20, 280, 20, 0x30003, "The disk space required for the installation of the selected features.") cost.text("Text", 20, 53, 330, 60, 3, "The highlighted volumes (if any) do not have enough disk space " "available for the currently selected features. You can either " "remove some files from the highlighted volumes, or choose to " "install less features onto local drive(s), or select different " "destination drive(s).") cost.control("VolumeList", "VolumeCostList", 20, 100, 330, 150, 393223, None, "{120}{70}{70}{70}{70}", None, None) cost.xbutton("OK", "Ok", None, 0.5).event("EndDialog", "Return") ##################################################################### # WhichUsers Dialog. Only available on NT, and for privileged users. # This must be run before FindRelatedProducts, because that will # take into account whether the previous installation was per-user # or per-machine. We currently don't support going back to this # dialog after "Next" was selected; to support this, we would need to # find how to reset the ALLUSERS property, and how to re-run # FindRelatedProducts. # On Windows9x, the ALLUSERS property is ignored on the command line # and in the Property table, but installer fails according to the documentation # if a dialog attempts to set ALLUSERS. whichusers = PyDialog(db, "WhichUsersDlg", x, y, w, h, modal, title, "AdminInstall", "Next", "Cancel") whichusers.title("Select whether to install [ProductName] for all users of this computer.") # A radio group with two options: allusers, justme g = whichusers.radiogroup("AdminInstall", 135, 60, 160, 50, 3, "WhichUsers", "", "Next") g.add("ALL", 0, 5, 150, 20, "Install for all users") g.add("JUSTME", 0, 25, 150, 20, "Install just for me") whichusers.back("Back", None, active=0) c = whichusers.next("Next >", "Cancel") c.event("[ALLUSERS]", "1", 'WhichUsers="ALL"', 1) c.event("EndDialog", "Return", order = 2) c = whichusers.cancel("Cancel", "AdminInstall") c.event("SpawnDialog", "CancelDlg") ##################################################################### # Advanced Dialog. advanced = PyDialog(db, "AdvancedDlg", x, y, w, h, modal, title, "CompilePyc", "Next", "Cancel") advanced.title("Advanced Options for [ProductName]") # A radio group with two options: allusers, justme advanced.checkbox("CompilePyc", 135, 60, 230, 50, 3, "COMPILEALL", "Compile .py files to byte code after installation", "Next") c = advanced.next("Finish", "Cancel") c.event("EndDialog", "Return") c = advanced.cancel("Cancel", "CompilePyc") c.event("SpawnDialog", "CancelDlg") ##################################################################### # Existing Directory dialog dlg = Dialog(db, "ExistingDirectoryDlg", 50, 30, 200, 80, modal, title, "No", "No", "No") dlg.text("Title", 10, 20, 180, 40, 3, "[TARGETDIR] exists. Are you sure you want to overwrite existing files?") c=dlg.pushbutton("Yes", 30, 60, 55, 17, 3, "Yes", "No") c.event("[TargetExists]", "0", order=1) c.event("[TargetExistsOk]", "1", order=2) c.event("EndDialog", "Return", order=3) c=dlg.pushbutton("No", 115, 60, 55, 17, 3, "No", "Yes") c.event("EndDialog", "Return") ##################################################################### # Installation Progress dialog (modeless) progress = PyDialog(db, "ProgressDlg", x, y, w, h, modeless, title, "Cancel", "Cancel", "Cancel", bitmap=False) progress.text("Title", 20, 15, 200, 15, 0x30003, "{\DlgFontBold8}[Progress1] [ProductName]") progress.text("Text", 35, 65, 300, 30, 3, "Please wait while the Installer [Progress2] [ProductName]. " "This may take several minutes.") progress.text("StatusLabel", 35, 100, 35, 20, 3, "Status:") c=progress.text("ActionText", 70, 100, w-70, 20, 3, "Pondering...") c.mapping("ActionText", "Text") #c=progress.text("ActionData", 35, 140, 300, 20, 3, None) #c.mapping("ActionData", "Text") c=progress.control("ProgressBar", "ProgressBar", 35, 120, 300, 10, 65537, None, "Progress done", None, None) c.mapping("SetProgress", "Progress") progress.back("< Back", "Next", active=False) progress.next("Next >", "Cancel", active=False) progress.cancel("Cancel", "Back").event("SpawnDialog", "CancelDlg") # Maintenance type: repair/uninstall maint = PyDialog(db, "MaintenanceTypeDlg", x, y, w, h, modal, title, "Next", "Next", "Cancel") maint.title("Welcome to the [ProductName] Setup Wizard") maint.text("BodyText", 135, 63, 230, 42, 3, "Select whether you want to repair or remove [ProductName].") g=maint.radiogroup("RepairRadioGroup", 135, 108, 230, 60, 3, "MaintenanceForm_Action", "", "Next") g.add("Change", 0, 0, 200, 17, "&Change [ProductName]") g.add("Repair", 0, 18, 200, 17, "&Repair [ProductName]") g.add("Remove", 0, 36, 200, 17, "Re&move [ProductName]") maint.back("< Back", None, active=False) c=maint.next("Finish", "Cancel") # Change installation: Change progress dialog to "Change", then ask # for feature selection c.event("[Progress1]", "Change", 'MaintenanceForm_Action="Change"', 1) c.event("[Progress2]", "changes", 'MaintenanceForm_Action="Change"', 2) # Reinstall: Change progress dialog to "Repair", then invoke reinstall # Also set list of reinstalled features to "ALL" c.event("[REINSTALL]", "ALL", 'MaintenanceForm_Action="Repair"', 5) c.event("[Progress1]", "Repairing", 'MaintenanceForm_Action="Repair"', 6) c.event("[Progress2]", "repaires", 'MaintenanceForm_Action="Repair"', 7) c.event("Reinstall", "ALL", 'MaintenanceForm_Action="Repair"', 8) # Uninstall: Change progress to "Remove", then invoke uninstall # Also set list of removed features to "ALL" c.event("[REMOVE]", "ALL", 'MaintenanceForm_Action="Remove"', 11) c.event("[Progress1]", "Removing", 'MaintenanceForm_Action="Remove"', 12) c.event("[Progress2]", "removes", 'MaintenanceForm_Action="Remove"', 13) c.event("Remove", "ALL", 'MaintenanceForm_Action="Remove"', 14) # Close dialog when maintenance action scheduled c.event("EndDialog", "Return", 'MaintenanceForm_Action<>"Change"', 20) c.event("NewDialog", "SelectFeaturesDlg", 'MaintenanceForm_Action="Change"', 21) maint.cancel("Cancel", "RepairRadioGroup").event("SpawnDialog", "CancelDlg")
7b2563bc802c00b13b4411b020b501763efebf23 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7b2563bc802c00b13b4411b020b501763efebf23/msi.py
while True:
while self.pos < len(self.field):
def getaddrlist(self): """Parse all addresses.
fa348c876f990c16e7f9057358765f34396e7d76 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fa348c876f990c16e7f9057358765f34396e7d76/_parseaddr.py
break
result.append(('', ''))
def getaddrlist(self): """Parse all addresses.
fa348c876f990c16e7f9057358765f34396e7d76 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fa348c876f990c16e7f9057358765f34396e7d76/_parseaddr.py
def formatmonthname(self, theyear, themonth, width):
def formatmonthname(self, theyear, themonth, width, withyear=True):
def formatmonthname(self, theyear, themonth, width): """ Return a formatted month name. """ s = "%s %r" % (month_name[themonth], theyear) return s.center(width)
48d5e508ebc136f8f67a2cb2bdd29e55324f5a95 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/48d5e508ebc136f8f67a2cb2bdd29e55324f5a95/calendar.py
s = "%s %r" % (month_name[themonth], theyear)
s = month_name[themonth] if withyear: s = "%s %r" % (s, theyear)
def formatmonthname(self, theyear, themonth, width): """ Return a formatted month name. """ s = "%s %r" % (month_name[themonth], theyear) return s.center(width)
48d5e508ebc136f8f67a2cb2bdd29e55324f5a95 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/48d5e508ebc136f8f67a2cb2bdd29e55324f5a95/calendar.py
a(formatstring((month_name[k] for k in months), colwidth, c).rstrip())
names = (self.formatmonthname(theyear, k, colwidth, False) for k in months) a(formatstring(names, colwidth, c).rstrip())
def formatyear(self, theyear, w=2, l=1, c=6, m=3): """ Returns a year's calendar as a multi-line string. """ w = max(2, w) l = max(1, l) c = max(2, c) colwidth = (w + 1) * 7 - 1 v = [] a = v.append a(repr(theyear).center(colwidth*m+c*(m-1)).rstrip()) a('\n'*l) header = self.formatweekheader(w) for (i, row) in enumerate(self.yeardays2calendar(theyear, m)): # months in this row months = xrange(m*i+1, min(m*(i+1)+1, 13)) a('\n'*l) a(formatstring((month_name[k] for k in months), colwidth, c).rstrip()) a('\n'*l) a(formatstring((header for k in months), colwidth, c).rstrip()) a('\n'*l) # max number of weeks for this row height = max(len(cal) for cal in row) for j in xrange(height): weeks = [] for cal in row: if j >= len(cal): weeks.append('') else: weeks.append(self.formatweek(cal[j], w)) a(formatstring(weeks, colwidth, c).rstrip()) a('\n' * l) return ''.join(v)
48d5e508ebc136f8f67a2cb2bdd29e55324f5a95 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/48d5e508ebc136f8f67a2cb2bdd29e55324f5a95/calendar.py
a(formatstring((header for k in months), colwidth, c).rstrip())
headers = (header for k in months) a(formatstring(headers, colwidth, c).rstrip())
def formatyear(self, theyear, w=2, l=1, c=6, m=3): """ Returns a year's calendar as a multi-line string. """ w = max(2, w) l = max(1, l) c = max(2, c) colwidth = (w + 1) * 7 - 1 v = [] a = v.append a(repr(theyear).center(colwidth*m+c*(m-1)).rstrip()) a('\n'*l) header = self.formatweekheader(w) for (i, row) in enumerate(self.yeardays2calendar(theyear, m)): # months in this row months = xrange(m*i+1, min(m*(i+1)+1, 13)) a('\n'*l) a(formatstring((month_name[k] for k in months), colwidth, c).rstrip()) a('\n'*l) a(formatstring((header for k in months), colwidth, c).rstrip()) a('\n'*l) # max number of weeks for this row height = max(len(cal) for cal in row) for j in xrange(height): weeks = [] for cal in row: if j >= len(cal): weeks.append('') else: weeks.append(self.formatweek(cal[j], w)) a(formatstring(weeks, colwidth, c).rstrip()) a('\n' * l) return ''.join(v)
48d5e508ebc136f8f67a2cb2bdd29e55324f5a95 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/48d5e508ebc136f8f67a2cb2bdd29e55324f5a95/calendar.py
return ''.join(v).encode(encoding)
return ''.join(v).encode(encoding, "xmlcharrefreplace") class LocaleTextCalendar(TextCalendar): """ This class can be passed a locale name in the constructor and will return month and weekday names in the specified locale. If this locale includes an encoding all strings containing month and weekday names will be returned as unicode. """ def __init__(self, firstweekday=0, locale=None): TextCalendar.__init__(self, firstweekday) if locale is None: locale = locale.getdefaultlocale() self.locale = locale def formatweekday(self, day, width): oldlocale = locale.setlocale(locale.LC_TIME, self.locale) try: encoding = locale.getlocale(locale.LC_TIME)[1] if width >= 9: names = day_name else: names = day_abbr name = names[day] if encoding is not None: name = name.decode(encoding) result = name[:width].center(width) finally: locale.setlocale(locale.LC_TIME, oldlocale) return result def formatmonthname(self, theyear, themonth, width, withyear=True): oldlocale = locale.setlocale(locale.LC_TIME, self.locale) try: encoding = locale.getlocale(locale.LC_TIME)[1] s = month_name[themonth] if encoding is not None: s = s.decode(encoding) if withyear: s = "%s %r" % (s, theyear) result = s.center(width) finally: locale.setlocale(locale.LC_TIME, oldlocale) return result class LocaleHTMLCalendar(HTMLCalendar): """ This class can be passed a locale name in the constructor and will return month and weekday names in the specified locale. If this locale includes an encoding all strings containing month and weekday names will be returned as unicode. """ def __init__(self, firstweekday=0, locale=None): HTMLCalendar.__init__(self, firstweekday) if locale is None: locale = locale.getdefaultlocale() self.locale = locale def formatweekday(self, day): oldlocale = locale.setlocale(locale.LC_TIME, self.locale) try: encoding = locale.getlocale(locale.LC_TIME)[1] s = day_abbr[day] if encoding is not None: s = s.decode(encoding) result = '<th class="%s">%s</th>' % (self.cssclasses[day], s) finally: locale.setlocale(locale.LC_TIME, oldlocale) return result def formatmonthname(self, theyear, themonth, withyear=True): oldlocale = locale.setlocale(locale.LC_TIME, self.locale) try: encoding = locale.getlocale(locale.LC_TIME)[1] s = month_name[themonth] if encoding is not None: s = s.decode(encoding) if withyear: s = '%s %s' % (s, theyear) result = '<tr><th colspan="7" class="month">%s</th></tr>' % s finally: locale.setlocale(locale.LC_TIME, oldlocale) return result
def formatyearpage(self, theyear, width=3, css='calendar.css', encoding=None): """ Return a formatted year as a complete HTML page. """ if encoding is None: encoding = sys.getdefaultencoding() v = [] a = v.append a('<?xml version="1.0" encoding="%s"?>\n' % encoding) a('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n') a('<html>\n') a('<head>\n') a('<meta http-equiv="Content-Type" content="text/html; charset=%s" />\n' % encoding) if css is not None: a('<link rel="stylesheet" type="text/css" href="%s" />\n' % css) a('<title>Calendar for %d</title\n' % theyear) a('</head>\n') a('<body>\n') a(self.formatyear(theyear, width)) a('</body>\n') a('</html>\n') return ''.join(v).encode(encoding)
48d5e508ebc136f8f67a2cb2bdd29e55324f5a95 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/48d5e508ebc136f8f67a2cb2bdd29e55324f5a95/calendar.py
parser = optparse.OptionParser(usage="usage: %prog [options] [year] [month]") parser.add_option("-w", "--width", dest="width", type="int", default=2, help="width of date column (default 2, text only)") parser.add_option("-l", "--lines", dest="lines", type="int", default=1, help="number of lines for each week (default 1, text only)") parser.add_option("-s", "--spacing", dest="spacing", type="int", default=6, help="spacing between months (default 6, text only)") parser.add_option("-m", "--months", dest="months", type="int", default=3, help="months per row (default 3, text only)") parser.add_option("-c", "--css", dest="css", default="calendar.css", help="CSS to use for page (html only)") parser.add_option("-e", "--encoding", dest="encoding", default=None, help="Encoding to use for CSS output (html only)") parser.add_option("-t", "--type", dest="type", default="text", choices=("text", "html"), help="output type (text or html)")
parser = optparse.OptionParser(usage="usage: %prog [options] [year [month]]") parser.add_option( "-w", "--width", dest="width", type="int", default=2, help="width of date column (default 2, text only)" ) parser.add_option( "-l", "--lines", dest="lines", type="int", default=1, help="number of lines for each week (default 1, text only)" ) parser.add_option( "-s", "--spacing", dest="spacing", type="int", default=6, help="spacing between months (default 6, text only)" ) parser.add_option( "-m", "--months", dest="months", type="int", default=3, help="months per row (default 3, text only)" ) parser.add_option( "-c", "--css", dest="css", default="calendar.css", help="CSS to use for page (html only)" ) parser.add_option( "-L", "--locale", dest="locale", default=None, help="locale to be used from month and weekday names" ) parser.add_option( "-e", "--encoding", dest="encoding", default=None, help="Encoding to use for output" ) parser.add_option( "-t", "--type", dest="type", default="text", choices=("text", "html"), help="output type (text or html)" )
def main(args): import optparse parser = optparse.OptionParser(usage="usage: %prog [options] [year] [month]") parser.add_option("-w", "--width", dest="width", type="int", default=2, help="width of date column (default 2, text only)") parser.add_option("-l", "--lines", dest="lines", type="int", default=1, help="number of lines for each week (default 1, text only)") parser.add_option("-s", "--spacing", dest="spacing", type="int", default=6, help="spacing between months (default 6, text only)") parser.add_option("-m", "--months", dest="months", type="int", default=3, help="months per row (default 3, text only)") parser.add_option("-c", "--css", dest="css", default="calendar.css", help="CSS to use for page (html only)") parser.add_option("-e", "--encoding", dest="encoding", default=None, help="Encoding to use for CSS output (html only)") parser.add_option("-t", "--type", dest="type", default="text", choices=("text", "html"), help="output type (text or html)") (options, args) = parser.parse_args(args) if options.type == "html": cal = HTMLCalendar() encoding = options.encoding if encoding is None: encoding = sys.getdefaultencoding() optdict = dict(encoding=encoding, css=options.css) if len(args) == 1: print cal.formatyearpage(datetime.date.today().year, **optdict) elif len(args) == 2: print cal.formatyearpage(int(args[1]), **optdict) else: parser.error("incorrect number of arguments") sys.exit(1) else: cal = TextCalendar() optdict = dict(w=options.width, l=options.lines) if len(args) != 3: optdict["c"] = options.spacing optdict["m"] = options.months if len(args) == 1: print cal.formatyear(datetime.date.today().year, **optdict) elif len(args) == 2: print cal.formatyear(int(args[1]), **optdict) elif len(args) == 3: print cal.formatmonth(int(args[1]), int(args[2]), **optdict) else: parser.error("incorrect number of arguments") sys.exit(1)
48d5e508ebc136f8f67a2cb2bdd29e55324f5a95 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/48d5e508ebc136f8f67a2cb2bdd29e55324f5a95/calendar.py
cal = HTMLCalendar()
if options.locale: cal = LocaleHTMLCalendar(locale=options.locale) else: cal = HTMLCalendar()
def main(args): import optparse parser = optparse.OptionParser(usage="usage: %prog [options] [year] [month]") parser.add_option("-w", "--width", dest="width", type="int", default=2, help="width of date column (default 2, text only)") parser.add_option("-l", "--lines", dest="lines", type="int", default=1, help="number of lines for each week (default 1, text only)") parser.add_option("-s", "--spacing", dest="spacing", type="int", default=6, help="spacing between months (default 6, text only)") parser.add_option("-m", "--months", dest="months", type="int", default=3, help="months per row (default 3, text only)") parser.add_option("-c", "--css", dest="css", default="calendar.css", help="CSS to use for page (html only)") parser.add_option("-e", "--encoding", dest="encoding", default=None, help="Encoding to use for CSS output (html only)") parser.add_option("-t", "--type", dest="type", default="text", choices=("text", "html"), help="output type (text or html)") (options, args) = parser.parse_args(args) if options.type == "html": cal = HTMLCalendar() encoding = options.encoding if encoding is None: encoding = sys.getdefaultencoding() optdict = dict(encoding=encoding, css=options.css) if len(args) == 1: print cal.formatyearpage(datetime.date.today().year, **optdict) elif len(args) == 2: print cal.formatyearpage(int(args[1]), **optdict) else: parser.error("incorrect number of arguments") sys.exit(1) else: cal = TextCalendar() optdict = dict(w=options.width, l=options.lines) if len(args) != 3: optdict["c"] = options.spacing optdict["m"] = options.months if len(args) == 1: print cal.formatyear(datetime.date.today().year, **optdict) elif len(args) == 2: print cal.formatyear(int(args[1]), **optdict) elif len(args) == 3: print cal.formatmonth(int(args[1]), int(args[2]), **optdict) else: parser.error("incorrect number of arguments") sys.exit(1)
48d5e508ebc136f8f67a2cb2bdd29e55324f5a95 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/48d5e508ebc136f8f67a2cb2bdd29e55324f5a95/calendar.py
cal = TextCalendar()
if options.locale: cal = LocaleTextCalendar(locale=options.locale) else: cal = TextCalendar()
def main(args): import optparse parser = optparse.OptionParser(usage="usage: %prog [options] [year] [month]") parser.add_option("-w", "--width", dest="width", type="int", default=2, help="width of date column (default 2, text only)") parser.add_option("-l", "--lines", dest="lines", type="int", default=1, help="number of lines for each week (default 1, text only)") parser.add_option("-s", "--spacing", dest="spacing", type="int", default=6, help="spacing between months (default 6, text only)") parser.add_option("-m", "--months", dest="months", type="int", default=3, help="months per row (default 3, text only)") parser.add_option("-c", "--css", dest="css", default="calendar.css", help="CSS to use for page (html only)") parser.add_option("-e", "--encoding", dest="encoding", default=None, help="Encoding to use for CSS output (html only)") parser.add_option("-t", "--type", dest="type", default="text", choices=("text", "html"), help="output type (text or html)") (options, args) = parser.parse_args(args) if options.type == "html": cal = HTMLCalendar() encoding = options.encoding if encoding is None: encoding = sys.getdefaultencoding() optdict = dict(encoding=encoding, css=options.css) if len(args) == 1: print cal.formatyearpage(datetime.date.today().year, **optdict) elif len(args) == 2: print cal.formatyearpage(int(args[1]), **optdict) else: parser.error("incorrect number of arguments") sys.exit(1) else: cal = TextCalendar() optdict = dict(w=options.width, l=options.lines) if len(args) != 3: optdict["c"] = options.spacing optdict["m"] = options.months if len(args) == 1: print cal.formatyear(datetime.date.today().year, **optdict) elif len(args) == 2: print cal.formatyear(int(args[1]), **optdict) elif len(args) == 3: print cal.formatmonth(int(args[1]), int(args[2]), **optdict) else: parser.error("incorrect number of arguments") sys.exit(1)
48d5e508ebc136f8f67a2cb2bdd29e55324f5a95 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/48d5e508ebc136f8f67a2cb2bdd29e55324f5a95/calendar.py
print cal.formatyear(datetime.date.today().year, **optdict)
result = cal.formatyear(datetime.date.today().year, **optdict)
def main(args): import optparse parser = optparse.OptionParser(usage="usage: %prog [options] [year] [month]") parser.add_option("-w", "--width", dest="width", type="int", default=2, help="width of date column (default 2, text only)") parser.add_option("-l", "--lines", dest="lines", type="int", default=1, help="number of lines for each week (default 1, text only)") parser.add_option("-s", "--spacing", dest="spacing", type="int", default=6, help="spacing between months (default 6, text only)") parser.add_option("-m", "--months", dest="months", type="int", default=3, help="months per row (default 3, text only)") parser.add_option("-c", "--css", dest="css", default="calendar.css", help="CSS to use for page (html only)") parser.add_option("-e", "--encoding", dest="encoding", default=None, help="Encoding to use for CSS output (html only)") parser.add_option("-t", "--type", dest="type", default="text", choices=("text", "html"), help="output type (text or html)") (options, args) = parser.parse_args(args) if options.type == "html": cal = HTMLCalendar() encoding = options.encoding if encoding is None: encoding = sys.getdefaultencoding() optdict = dict(encoding=encoding, css=options.css) if len(args) == 1: print cal.formatyearpage(datetime.date.today().year, **optdict) elif len(args) == 2: print cal.formatyearpage(int(args[1]), **optdict) else: parser.error("incorrect number of arguments") sys.exit(1) else: cal = TextCalendar() optdict = dict(w=options.width, l=options.lines) if len(args) != 3: optdict["c"] = options.spacing optdict["m"] = options.months if len(args) == 1: print cal.formatyear(datetime.date.today().year, **optdict) elif len(args) == 2: print cal.formatyear(int(args[1]), **optdict) elif len(args) == 3: print cal.formatmonth(int(args[1]), int(args[2]), **optdict) else: parser.error("incorrect number of arguments") sys.exit(1)
48d5e508ebc136f8f67a2cb2bdd29e55324f5a95 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/48d5e508ebc136f8f67a2cb2bdd29e55324f5a95/calendar.py
print cal.formatyear(int(args[1]), **optdict)
result = cal.formatyear(int(args[1]), **optdict)
def main(args): import optparse parser = optparse.OptionParser(usage="usage: %prog [options] [year] [month]") parser.add_option("-w", "--width", dest="width", type="int", default=2, help="width of date column (default 2, text only)") parser.add_option("-l", "--lines", dest="lines", type="int", default=1, help="number of lines for each week (default 1, text only)") parser.add_option("-s", "--spacing", dest="spacing", type="int", default=6, help="spacing between months (default 6, text only)") parser.add_option("-m", "--months", dest="months", type="int", default=3, help="months per row (default 3, text only)") parser.add_option("-c", "--css", dest="css", default="calendar.css", help="CSS to use for page (html only)") parser.add_option("-e", "--encoding", dest="encoding", default=None, help="Encoding to use for CSS output (html only)") parser.add_option("-t", "--type", dest="type", default="text", choices=("text", "html"), help="output type (text or html)") (options, args) = parser.parse_args(args) if options.type == "html": cal = HTMLCalendar() encoding = options.encoding if encoding is None: encoding = sys.getdefaultencoding() optdict = dict(encoding=encoding, css=options.css) if len(args) == 1: print cal.formatyearpage(datetime.date.today().year, **optdict) elif len(args) == 2: print cal.formatyearpage(int(args[1]), **optdict) else: parser.error("incorrect number of arguments") sys.exit(1) else: cal = TextCalendar() optdict = dict(w=options.width, l=options.lines) if len(args) != 3: optdict["c"] = options.spacing optdict["m"] = options.months if len(args) == 1: print cal.formatyear(datetime.date.today().year, **optdict) elif len(args) == 2: print cal.formatyear(int(args[1]), **optdict) elif len(args) == 3: print cal.formatmonth(int(args[1]), int(args[2]), **optdict) else: parser.error("incorrect number of arguments") sys.exit(1)
48d5e508ebc136f8f67a2cb2bdd29e55324f5a95 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/48d5e508ebc136f8f67a2cb2bdd29e55324f5a95/calendar.py
print cal.formatmonth(int(args[1]), int(args[2]), **optdict)
result = cal.formatmonth(int(args[1]), int(args[2]), **optdict)
def main(args): import optparse parser = optparse.OptionParser(usage="usage: %prog [options] [year] [month]") parser.add_option("-w", "--width", dest="width", type="int", default=2, help="width of date column (default 2, text only)") parser.add_option("-l", "--lines", dest="lines", type="int", default=1, help="number of lines for each week (default 1, text only)") parser.add_option("-s", "--spacing", dest="spacing", type="int", default=6, help="spacing between months (default 6, text only)") parser.add_option("-m", "--months", dest="months", type="int", default=3, help="months per row (default 3, text only)") parser.add_option("-c", "--css", dest="css", default="calendar.css", help="CSS to use for page (html only)") parser.add_option("-e", "--encoding", dest="encoding", default=None, help="Encoding to use for CSS output (html only)") parser.add_option("-t", "--type", dest="type", default="text", choices=("text", "html"), help="output type (text or html)") (options, args) = parser.parse_args(args) if options.type == "html": cal = HTMLCalendar() encoding = options.encoding if encoding is None: encoding = sys.getdefaultencoding() optdict = dict(encoding=encoding, css=options.css) if len(args) == 1: print cal.formatyearpage(datetime.date.today().year, **optdict) elif len(args) == 2: print cal.formatyearpage(int(args[1]), **optdict) else: parser.error("incorrect number of arguments") sys.exit(1) else: cal = TextCalendar() optdict = dict(w=options.width, l=options.lines) if len(args) != 3: optdict["c"] = options.spacing optdict["m"] = options.months if len(args) == 1: print cal.formatyear(datetime.date.today().year, **optdict) elif len(args) == 2: print cal.formatyear(int(args[1]), **optdict) elif len(args) == 3: print cal.formatmonth(int(args[1]), int(args[2]), **optdict) else: parser.error("incorrect number of arguments") sys.exit(1)
48d5e508ebc136f8f67a2cb2bdd29e55324f5a95 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/48d5e508ebc136f8f67a2cb2bdd29e55324f5a95/calendar.py
waste = self.rfile.read(1)
if not self.rfile.read(1): break
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 (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `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 (%s)" % `scriptname`) return if not self.is_executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return
e2f18377ff21c0e3217d561c8509e6816ecb362d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e2f18377ff21c0e3217d561c8509e6816ecb362d/CGIHTTPServer.py
waste = self.rfile._sock.recv(1)
if not self.rfile._sock.recv(1): break
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 (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `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 (%s)" % `scriptname`) return if not self.is_executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return
e2f18377ff21c0e3217d561c8509e6816ecb362d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e2f18377ff21c0e3217d561c8509e6816ecb362d/CGIHTTPServer.py
def test_compresscopy(self): data0 = HAMLET_SCENE data1 = HAMLET_SCENE.swapcase() c0 = zlib.compressobj(zlib.Z_BEST_COMPRESSION) bufs0 = [] bufs0.append(c0.compress(data0)) c1 = c0.copy() bufs1 = bufs0[:] bufs0.append(c0.compress(data0)) bufs0.append(c0.flush()) s0 = ''.join(bufs0) bufs1.append(c1.compress(data1)) bufs1.append(c1.flush()) s1 = ''.join(bufs1) self.assertEqual(zlib.decompress(s0),data0+data0) self.assertEqual(zlib.decompress(s1),data0+data1) def test_badcompresscopy(self): c = zlib.compressobj() c.compress(HAMLET_SCENE) c.flush() self.assertRaises(ValueError, c.copy) def test_decompresscopy(self): data = HAMLET_SCENE comp = zlib.compress(data) d0 = zlib.decompressobj() bufs0 = [] bufs0.append(d0.decompress(comp[:32])) d1 = d0.copy() bufs1 = bufs0[:] bufs0.append(d0.decompress(comp[32:])) s0 = ''.join(bufs0) bufs1.append(d1.decompress(comp[32:])) s1 = ''.join(bufs1) self.assertEqual(s0,s1) self.assertEqual(s0,data) def test_baddecompresscopy(self): data = zlib.compress(HAMLET_SCENE) d = zlib.decompressobj() d.decompress(data) d.flush() self.assertRaises(ValueError, d.copy)
if hasattr(zlib.compressobj(), "copy"): def test_compresscopy(self): data0 = HAMLET_SCENE data1 = HAMLET_SCENE.swapcase() c0 = zlib.compressobj(zlib.Z_BEST_COMPRESSION) bufs0 = [] bufs0.append(c0.compress(data0)) c1 = c0.copy() bufs1 = bufs0[:] bufs0.append(c0.compress(data0)) bufs0.append(c0.flush()) s0 = ''.join(bufs0) bufs1.append(c1.compress(data1)) bufs1.append(c1.flush()) s1 = ''.join(bufs1) self.assertEqual(zlib.decompress(s0),data0+data0) self.assertEqual(zlib.decompress(s1),data0+data1) def test_badcompresscopy(self): c = zlib.compressobj() c.compress(HAMLET_SCENE) c.flush() self.assertRaises(ValueError, c.copy) if hasattr(zlib.decompressobj(), "copy"): def test_decompresscopy(self): data = HAMLET_SCENE comp = zlib.compress(data) d0 = zlib.decompressobj() bufs0 = [] bufs0.append(d0.decompress(comp[:32])) d1 = d0.copy() bufs1 = bufs0[:] bufs0.append(d0.decompress(comp[32:])) s0 = ''.join(bufs0) bufs1.append(d1.decompress(comp[32:])) s1 = ''.join(bufs1) self.assertEqual(s0,s1) self.assertEqual(s0,data) def test_baddecompresscopy(self): data = zlib.compress(HAMLET_SCENE) d = zlib.decompressobj() d.decompress(data) d.flush() self.assertRaises(ValueError, d.copy)
def test_compresscopy(self): # Test copying a compression object data0 = HAMLET_SCENE data1 = HAMLET_SCENE.swapcase() c0 = zlib.compressobj(zlib.Z_BEST_COMPRESSION) bufs0 = [] bufs0.append(c0.compress(data0))
6e73aaab474ab9df512e8f24029ed1c57f39c619 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6e73aaab474ab9df512e8f24029ed1c57f39c619/test_zlib.py
['extract-all', 'default-domain', 'escape', 'help',
['extract-all', 'default-domain=', 'escape', 'help',
def main(): global default_keywords try: opts, args = getopt.getopt( sys.argv[1:], 'ad:DEhk:Kno:p:S:Vvw:x:', ['extract-all', 'default-domain', 'escape', 'help', 'keyword=', 'no-default-keywords', 'add-location', 'no-location', 'output=', 'output-dir=', 'style=', 'verbose', 'version', 'width=', 'exclude-file=', 'docstrings', ]) except getopt.error, msg: usage(1, msg) # for holding option values class Options: # constants GNU = 1 SOLARIS = 2 # defaults extractall = 0 # FIXME: currently this option has no effect at all. escape = 0 keywords = [] outpath = '' outfile = 'messages.pot' writelocations = 1 locationstyle = GNU verbose = 0 width = 78 excludefilename = '' docstrings = 0 options = Options() locations = {'gnu' : options.GNU, 'solaris' : options.SOLARIS, } # parse options for opt, arg in opts: if opt in ('-h', '--help'): usage(0) elif opt in ('-a', '--extract-all'): options.extractall = 1 elif opt in ('-d', '--default-domain'): options.outfile = arg + '.pot' elif opt in ('-E', '--escape'): options.escape = 1 elif opt in ('-D', '--docstrings'): options.docstrings = 1 elif opt in ('-k', '--keyword'): options.keywords.append(arg) elif opt in ('-K', '--no-default-keywords'): default_keywords = [] elif opt in ('-n', '--add-location'): options.writelocations = 1 elif opt in ('--no-location',): options.writelocations = 0 elif opt in ('-S', '--style'): options.locationstyle = locations.get(arg.lower()) if options.locationstyle is None: usage(1, _('Invalid value for --style: %s') % arg) elif opt in ('-o', '--output'): options.outfile = arg elif opt in ('-p', '--output-dir'): options.outpath = arg elif opt in ('-v', '--verbose'): options.verbose = 1 elif opt in ('-V', '--version'): print _('pygettext.py (xgettext for Python) %s') % __version__ sys.exit(0) elif opt in ('-w', '--width'): try: options.width = int(arg) except ValueError: usage(1, _('--width argument must be an integer: %s') % arg) elif opt in ('-x', '--exclude-file'): options.excludefilename = arg # calculate escapes make_escapes(options.escape) # calculate all keywords options.keywords.extend(default_keywords) # initialize list of strings to exclude if options.excludefilename: try: fp = open(options.excludefilename) options.toexclude = fp.readlines() fp.close() except IOError: print >> sys.stderr, _( "Can't read --exclude-file: %s") % options.excludefilename sys.exit(1) else: options.toexclude = [] # slurp through all the files eater = TokenEater(options) for filename in args: if filename == '-': if options.verbose: print _('Reading standard input') fp = sys.stdin closep = 0 else: if options.verbose: print _('Working on %s') % filename fp = open(filename) closep = 1 try: eater.set_filename(filename) try: tokenize.tokenize(fp.readline, eater) except tokenize.TokenError, e: print >> sys.stderr, '%s: %s, line %d, column %d' % ( e[0], filename, e[1][0], e[1][1]) finally: if closep: fp.close() # write the output if options.outfile == '-': fp = sys.stdout closep = 0 else: if options.outpath: options.outfile = os.path.join(options.outpath, options.outfile) fp = open(options.outfile, 'w') closep = 1 try: eater.write(fp) finally: if closep: fp.close()
2b63969a5adbc43a3843102f95b45424da229745 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2b63969a5adbc43a3843102f95b45424da229745/pygettext.py
if sys.platform == 'aix4': python_lib = get_python_lib(standard_lib=1) ld_so_aix = os.path.join(python_lib, 'config', 'ld_so_aix') python_exp = os.path.join(python_lib, 'config', 'python.exp') g['LDSHARED'] = "%s %s -bI:%s" % (ld_so_aix, g['CC'], python_exp) elif sys.platform == 'beos': python_lib = get_python_lib(standard_lib=1) linkerscript_name = os.path.basename(string.split(g['LDSHARED'])[0]) linkerscript = os.path.join(python_lib, 'config', linkerscript_name) g['LDSHARED'] = ("%s -L%s/lib -lpython%s" % (linkerscript, PREFIX, sys.version[0:3]))
if python_build: g['LDSHARED'] = g['BLDSHARED']
def _init_posix(): """Initialize the module as appropriate for POSIX systems.""" g = {} # load the installed Makefile: try: filename = get_makefile_filename() parse_makefile(filename, g) except IOError, msg: my_msg = "invalid Python installation: unable to open %s" % filename if hasattr(msg, "strerror"): my_msg = my_msg + " (%s)" % msg.strerror raise DistutilsPlatformError, my_msg # On AIX, there are wrong paths to the linker scripts in the Makefile # -- these paths are relative to the Python source, but when installed # the scripts are in another directory. if sys.platform == 'aix4': # what about AIX 3.x ? # Linker script is in the config directory, not in Modules as the # Makefile says. python_lib = get_python_lib(standard_lib=1) ld_so_aix = os.path.join(python_lib, 'config', 'ld_so_aix') python_exp = os.path.join(python_lib, 'config', 'python.exp') g['LDSHARED'] = "%s %s -bI:%s" % (ld_so_aix, g['CC'], python_exp) elif sys.platform == 'beos': # Linker script is in the config directory. In the Makefile it is # relative to the srcdir, which after installation no longer makes # sense. python_lib = get_python_lib(standard_lib=1) linkerscript_name = os.path.basename(string.split(g['LDSHARED'])[0]) linkerscript = os.path.join(python_lib, 'config', linkerscript_name) # XXX this isn't the right place to do this: adding the Python # library to the link, if needed, should be in the "build_ext" # command. (It's also needed for non-MS compilers on Windows, and # it's taken care of for them by the 'build_ext.get_libraries()' # method.) g['LDSHARED'] = ("%s -L%s/lib -lpython%s" % (linkerscript, PREFIX, sys.version[0:3])) global _config_vars _config_vars = g
1a020868857cc58be9c2f36400b6e1c178750a49 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1a020868857cc58be9c2f36400b6e1c178750a49/sysconfig.py
a = -1 b = -1 c = -1
Unpack list
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
3981511070311e958bd2cd48b1ab16b24f8b350e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3981511070311e958bd2cd48b1ab16b24f8b350e/test_unpack.py
if verbose: print 'unpack tuple' a, b, c = t if a != 1 or b != 2 or c != 3: raise TestFailed
>>> l = [4, 5, 6] >>> a, b, c = l >>> a == 4 and b == 5 and c == 6 True
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
3981511070311e958bd2cd48b1ab16b24f8b350e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3981511070311e958bd2cd48b1ab16b24f8b350e/test_unpack.py
if verbose: print 'unpack list' a, b, c = l if a != 4 or b != 5 or c != 6: raise TestFailed
Unpack implied tuple
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
3981511070311e958bd2cd48b1ab16b24f8b350e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3981511070311e958bd2cd48b1ab16b24f8b350e/test_unpack.py
if verbose: print 'unpack implied tuple' a, b, c = 7, 8, 9 if a != 7 or b != 8 or c != 9: raise TestFailed
>>> a, b, c = 7, 8, 9 >>> a == 7 and b == 8 and c == 9 True
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
3981511070311e958bd2cd48b1ab16b24f8b350e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3981511070311e958bd2cd48b1ab16b24f8b350e/test_unpack.py
if verbose: print 'unpack string' a, b, c = 'one' if a != 'o' or b != 'n' or c != 'e': raise TestFailed
Unpack string... fun!
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
3981511070311e958bd2cd48b1ab16b24f8b350e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3981511070311e958bd2cd48b1ab16b24f8b350e/test_unpack.py
if verbose: print 'unpack sequence' a, b, c = Seq() if a != 0 or b != 1 or c != 2: raise TestFailed
>>> a, b, c = 'one' >>> a == 'o' and b == 'n' and c == 'e' True
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
3981511070311e958bd2cd48b1ab16b24f8b350e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3981511070311e958bd2cd48b1ab16b24f8b350e/test_unpack.py
if verbose: print 'unpack single tuple/list' st = (99,) sl = [100] a, = st if a != 99: raise TestFailed b, = sl if b != 100: raise TestFailed
Unpack generic sequence
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
3981511070311e958bd2cd48b1ab16b24f8b350e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3981511070311e958bd2cd48b1ab16b24f8b350e/test_unpack.py