rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
re-inserted are alwyas appended to the header list.
re-inserted are always appended to the header list.
def values(self): """Return a list of all the message's header values.
bf7c52c233485b0d95c3a41cb5ae9b580c4469c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bf7c52c233485b0d95c3a41cb5ae9b580c4469c8/Message.py
re-inserted are alwyas appended to the header list.
re-inserted are always appended to the header list.
def items(self): """Get all the message's header fields and values.
bf7c52c233485b0d95c3a41cb5ae9b580c4469c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bf7c52c233485b0d95c3a41cb5ae9b580c4469c8/Message.py
print "File name %s contains a suspicious null byte!" % filename
def __init__(self, filename="NoName", date_time=(1980,1,1,0,0,0)): self.orig_filename = filename # Original file name in archive
9b1587836992c460d213b9bbc6f539516139bdf2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9b1587836992c460d213b9bbc6f539516139bdf2/zipfile.py
rx = re.compile('[ \t]*([^ \t]+)[ \t]+realm="([^"]*)"')
rx = re.compile('[ \t]*([^ \t]+)[ \t]+realm="([^"]*)"', re.I)
def find_user_password(self, realm, authuri): user, password = HTTPPasswordMgr.find_user_password(self,realm,authuri) if user is not None: return user, password return HTTPPasswordMgr.find_user_password(self, None, authuri)
853ddd5cb96981966b935ed75bf8af0cfd0bee24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/853ddd5cb96981966b935ed75bf8af0cfd0bee24/urllib2.py
(to an older frame)."""
(to a newer frame)."""
def help_d(self): print """d(own)
34c4120731b498663e38edc4d975d4a8c3071da0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/34c4120731b498663e38edc4d975d4a8c3071da0/pdb.py
(to a newer frame)."""
(to an older frame)."""
def help_u(self): print """u(p)
34c4120731b498663e38edc4d975d4a8c3071da0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/34c4120731b498663e38edc4d975d4a8c3071da0/pdb.py
for i in range(3):
for count in range(3):
def test_trashcan(): # "trashcan" is a hack to prevent stack overflow when deallocating # very deeply nested tuples etc. It works in part by abusing the # type pointer and refcount fields, and that can yield horrible # problems when gc tries to traverse the structures. # If this test fails (as it does in 2.0, 2.1 and 2.2), it will # most likely die via segfault. gc.enable() N = 200 for i in range(3): t = [] for i in range(N): t = [t, Ouch()] u = [] for i in range(N): u = [u, Ouch()] v = {} for i in range(N): v = {1: v, 2: Ouch()} gc.disable()
d4ce758505d08e669a4752f79294c8aa19a96cf0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d4ce758505d08e669a4752f79294c8aa19a96cf0/test_gc.py
sectname = "formatter_%s" % form
sectname = "formatter_%s" % string.strip(form)
def _create_formatters(cp): """Create and return formatters""" flist = cp.get("formatters", "keys") if not len(flist): return {} flist = string.split(flist, ",") formatters = {} for form in flist: sectname = "formatter_%s" % form opts = cp.options(sectname) if "format" in opts: fs = cp.get(sectname, "format", 1) else: fs = None if "datefmt" in opts: dfs = cp.get(sectname, "datefmt", 1) else: dfs = None c = logging.Formatter if "class" in opts: class_name = cp.get(sectname, "class") if class_name: c = _resolve(class_name) f = c(fs, dfs) formatters[form] = f return formatters
66a17266206cb70bf07c2df93b3536d3c70a5121 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/66a17266206cb70bf07c2df93b3536d3c70a5121/config.py
sectname = "handler_%s" % hand
sectname = "handler_%s" % string.strip(hand)
def _install_handlers(cp, formatters): """Install and return handlers""" hlist = cp.get("handlers", "keys") if not len(hlist): return {} hlist = string.split(hlist, ",") handlers = {} fixups = [] #for inter-handler references for hand in hlist: sectname = "handler_%s" % hand klass = cp.get(sectname, "class") opts = cp.options(sectname) if "formatter" in opts: fmt = cp.get(sectname, "formatter") else: fmt = "" klass = eval(klass, vars(logging)) args = cp.get(sectname, "args") args = eval(args, vars(logging)) h = apply(klass, args) if "level" in opts: level = cp.get(sectname, "level") h.setLevel(logging._levelNames[level]) if len(fmt): h.setFormatter(formatters[fmt]) #temporary hack for FileHandler and MemoryHandler. if klass == logging.handlers.MemoryHandler: if "target" in opts: target = cp.get(sectname,"target") else: target = "" if len(target): #the target handler may not be loaded yet, so keep for later... fixups.append((h, target)) handlers[hand] = h #now all handlers are loaded, fixup inter-handler references... for h, t in fixups: h.setTarget(handlers[t]) return handlers
66a17266206cb70bf07c2df93b3536d3c70a5121 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/66a17266206cb70bf07c2df93b3536d3c70a5121/config.py
log.addHandler(handlers[hand])
log.addHandler(handlers[string.strip(hand)])
def _install_loggers(cp, handlers): """Create and install loggers""" # configure the root first llist = cp.get("loggers", "keys") llist = string.split(llist, ",") llist.remove("root") sectname = "logger_root" root = logging.root log = root opts = cp.options(sectname) if "level" in opts: level = cp.get(sectname, "level") log.setLevel(logging._levelNames[level]) for h in root.handlers[:]: root.removeHandler(h) hlist = cp.get(sectname, "handlers") if len(hlist): hlist = string.split(hlist, ",") for hand in hlist: log.addHandler(handlers[hand]) #and now the others... #we don't want to lose the existing loggers, #since other threads may have pointers to them. #existing is set to contain all existing loggers, #and as we go through the new configuration we #remove any which are configured. At the end, #what's left in existing is the set of loggers #which were in the previous configuration but #which are not in the new configuration. existing = root.manager.loggerDict.keys() #now set up the new ones... for log in llist: sectname = "logger_%s" % log qn = cp.get(sectname, "qualname") opts = cp.options(sectname) if "propagate" in opts: propagate = cp.getint(sectname, "propagate") else: propagate = 1 logger = logging.getLogger(qn) if qn in existing: existing.remove(qn) if "level" in opts: level = cp.get(sectname, "level") logger.setLevel(logging._levelNames[level]) for h in logger.handlers[:]: logger.removeHandler(h) logger.propagate = propagate logger.disabled = 0 hlist = cp.get(sectname, "handlers") if len(hlist): hlist = string.split(hlist, ",") for hand in hlist: logger.addHandler(handlers[hand]) #Disable any old loggers. There's no point deleting #them as other threads may continue to hold references #and by disabling them, you stop them doing any logging. for log in existing: root.manager.loggerDict[log].disabled = 1
66a17266206cb70bf07c2df93b3536d3c70a5121 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/66a17266206cb70bf07c2df93b3536d3c70a5121/config.py
logger.addHandler(handlers[hand])
logger.addHandler(handlers[string.strip(hand)])
def _install_loggers(cp, handlers): """Create and install loggers""" # configure the root first llist = cp.get("loggers", "keys") llist = string.split(llist, ",") llist.remove("root") sectname = "logger_root" root = logging.root log = root opts = cp.options(sectname) if "level" in opts: level = cp.get(sectname, "level") log.setLevel(logging._levelNames[level]) for h in root.handlers[:]: root.removeHandler(h) hlist = cp.get(sectname, "handlers") if len(hlist): hlist = string.split(hlist, ",") for hand in hlist: log.addHandler(handlers[hand]) #and now the others... #we don't want to lose the existing loggers, #since other threads may have pointers to them. #existing is set to contain all existing loggers, #and as we go through the new configuration we #remove any which are configured. At the end, #what's left in existing is the set of loggers #which were in the previous configuration but #which are not in the new configuration. existing = root.manager.loggerDict.keys() #now set up the new ones... for log in llist: sectname = "logger_%s" % log qn = cp.get(sectname, "qualname") opts = cp.options(sectname) if "propagate" in opts: propagate = cp.getint(sectname, "propagate") else: propagate = 1 logger = logging.getLogger(qn) if qn in existing: existing.remove(qn) if "level" in opts: level = cp.get(sectname, "level") logger.setLevel(logging._levelNames[level]) for h in logger.handlers[:]: logger.removeHandler(h) logger.propagate = propagate logger.disabled = 0 hlist = cp.get(sectname, "handlers") if len(hlist): hlist = string.split(hlist, ",") for hand in hlist: logger.addHandler(handlers[hand]) #Disable any old loggers. There's no point deleting #them as other threads may continue to hold references #and by disabling them, you stop them doing any logging. for log in existing: root.manager.loggerDict[log].disabled = 1
66a17266206cb70bf07c2df93b3536d3c70a5121 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/66a17266206cb70bf07c2df93b3536d3c70a5121/config.py
self.assert_(reuse == 0, "Error performing getsockopt.")
self.failIf(reuse != 0, "initial mode is reuse")
def testGetSockOpt(self): """Testing getsockopt().""" # We know a socket should start without reuse==0 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) self.assert_(reuse == 0, "Error performing getsockopt.")
733632ac1f61acc9b96ad316972a71b290e30db0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/733632ac1f61acc9b96ad316972a71b290e30db0/test_socket.py
self.assert_(reuse == 1, "Error performing setsockopt.")
self.failIf(reuse == 0, "failed to set reuse mode")
def testSetSockOpt(self): """Testing setsockopt().""" sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) self.assert_(reuse == 1, "Error performing setsockopt.")
733632ac1f61acc9b96ad316972a71b290e30db0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/733632ac1f61acc9b96ad316972a71b290e30db0/test_socket.py
def set(self, *args): """Set the fractional values of the slider position (upper and lower ends as value between 0 and 1).""" self.tk.call((self._w, 'set') + args)
256705bca7fb848e38d874d21d9a37a70bad4fbf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/256705bca7fb848e38d874d21d9a37a70bad4fbf/Tkinter.py
f_month -- full weekday names (14-item list; dummy value in [0], which
f_month -- full month names (13-item list; dummy value in [0], which
def _getlang(): # Figure out what the current language is set to. return locale.getlocale(locale.LC_TIME)
f5c96fb74d86e844af564acdc54ce3f1e70df56c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f5c96fb74d86e844af564acdc54ce3f1e70df56c/_strptime.py
a_month -- abbreviated weekday names (13-item list, dummy value in
a_month -- abbreviated month names (13-item list, dummy value in
def _getlang(): # Figure out what the current language is set to. return locale.getlocale(locale.LC_TIME)
f5c96fb74d86e844af564acdc54ce3f1e70df56c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f5c96fb74d86e844af564acdc54ce3f1e70df56c/_strptime.py
time.tzname = ("PDT", "PDT")
time.tzname = (tz_name, tz_name)
def test_bad_timezone(self): # Explicitly test possibility of bad timezone; # when time.tzname[0] == time.tzname[1] and time.daylight if sys.platform == "mac": return #MacOS9 has severely broken timezone support. try: original_tzname = time.tzname original_daylight = time.daylight time.tzname = ("PDT", "PDT") time.daylight = 1 tz_value = _strptime.strptime("PDT", "%Z")[8] self.failUnlessEqual(tz_value, -1) finally: time.tzname = original_tzname time.daylight = original_daylight
c83124ab793a28c8995ff381d5867604c60bc07f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c83124ab793a28c8995ff381d5867604c60bc07f/test_strptime.py
tz_value = _strptime.strptime("PDT", "%Z")[8]
tz_value = _strptime.strptime(tz_name, "%Z")[8]
def test_bad_timezone(self): # Explicitly test possibility of bad timezone; # when time.tzname[0] == time.tzname[1] and time.daylight if sys.platform == "mac": return #MacOS9 has severely broken timezone support. try: original_tzname = time.tzname original_daylight = time.daylight time.tzname = ("PDT", "PDT") time.daylight = 1 tz_value = _strptime.strptime("PDT", "%Z")[8] self.failUnlessEqual(tz_value, -1) finally: time.tzname = original_tzname time.daylight = original_daylight
c83124ab793a28c8995ff381d5867604c60bc07f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c83124ab793a28c8995ff381d5867604c60bc07f/test_strptime.py
super(TimeRE,self).__init__({
base = super(TimeRE, self) base.__init__({
def __init__(self, locale_time=LocaleTime()): """Init inst with non-locale regexes and store LocaleTime object.""" # XXX: should 0 be valid for: # day (d), julian day (j), month (m), and hour12 (I)? super(TimeRE,self).__init__({ # The " \d" option is to make %c from ANSI C work 'd': r"(?P<d>3[0-1]|[0-2]\d|\d| \d)", 'H': r"(?P<H>2[0-3]|[0-1]\d|\d)", 'I': r"(?P<I>0\d|1[0-2]|\d)", 'j': r"(?P<j>(?:3[0-5]\d|36[0-6])|[0-2]\d\d|\d\d|\d)", 'm': r"(?P<m>0\d|1[0-2]|\d)", 'M': r"(?P<M>[0-5]\d|\d)", 'S': r"(?P<S>6[0-1]|[0-5]\d|\d)", 'U': r"(?P<U>5[0-3]|[0-4]\d|\d)", 'w': r"(?P<w>[0-6])", 'W': r"(?P<W>5[0-3]|[0-4]\d|\d)", # Same as U 'y': r"(?P<y>\d\d)", 'Y': r"(?P<Y>\d\d\d\d)"}) self.locale_time = locale_time
5efc50d8afd31dc4cb0ef1b58899943eb0e4cb67 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5efc50d8afd31dc4cb0ef1b58899943eb0e4cb67/_strptime.py
'd': r"(?P<d>3[0-1]|[0-2]\d|\d| \d)",
'd': r"(?P<d>3[0-1]|[1-2]\d|0[1-9]|[1-9]| [1-9])",
def __init__(self, locale_time=LocaleTime()): """Init inst with non-locale regexes and store LocaleTime object.""" # XXX: should 0 be valid for: # day (d), julian day (j), month (m), and hour12 (I)? super(TimeRE,self).__init__({ # The " \d" option is to make %c from ANSI C work 'd': r"(?P<d>3[0-1]|[0-2]\d|\d| \d)", 'H': r"(?P<H>2[0-3]|[0-1]\d|\d)", 'I': r"(?P<I>0\d|1[0-2]|\d)", 'j': r"(?P<j>(?:3[0-5]\d|36[0-6])|[0-2]\d\d|\d\d|\d)", 'm': r"(?P<m>0\d|1[0-2]|\d)", 'M': r"(?P<M>[0-5]\d|\d)", 'S': r"(?P<S>6[0-1]|[0-5]\d|\d)", 'U': r"(?P<U>5[0-3]|[0-4]\d|\d)", 'w': r"(?P<w>[0-6])", 'W': r"(?P<W>5[0-3]|[0-4]\d|\d)", # Same as U 'y': r"(?P<y>\d\d)", 'Y': r"(?P<Y>\d\d\d\d)"}) self.locale_time = locale_time
5efc50d8afd31dc4cb0ef1b58899943eb0e4cb67 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5efc50d8afd31dc4cb0ef1b58899943eb0e4cb67/_strptime.py
'I': r"(?P<I>0\d|1[0-2]|\d)", 'j': r"(?P<j>(?:3[0-5]\d|36[0-6])|[0-2]\d\d|\d\d|\d)", 'm': r"(?P<m>0\d|1[0-2]|\d)",
'I': r"(?P<I>1[0-2]|0[1-9]|[1-9])", 'j': r"(?P<j>36[0-6]|3[0-5]\d|[1-2]\d\d|0[1-9]\d|00[1-9]|[1-9]\d|0[1-9]|[1-9])", 'm': r"(?P<m>1[0-2]|0[1-9]|[1-9])",
def __init__(self, locale_time=LocaleTime()): """Init inst with non-locale regexes and store LocaleTime object.""" # XXX: should 0 be valid for: # day (d), julian day (j), month (m), and hour12 (I)? super(TimeRE,self).__init__({ # The " \d" option is to make %c from ANSI C work 'd': r"(?P<d>3[0-1]|[0-2]\d|\d| \d)", 'H': r"(?P<H>2[0-3]|[0-1]\d|\d)", 'I': r"(?P<I>0\d|1[0-2]|\d)", 'j': r"(?P<j>(?:3[0-5]\d|36[0-6])|[0-2]\d\d|\d\d|\d)", 'm': r"(?P<m>0\d|1[0-2]|\d)", 'M': r"(?P<M>[0-5]\d|\d)", 'S': r"(?P<S>6[0-1]|[0-5]\d|\d)", 'U': r"(?P<U>5[0-3]|[0-4]\d|\d)", 'w': r"(?P<w>[0-6])", 'W': r"(?P<W>5[0-3]|[0-4]\d|\d)", # Same as U 'y': r"(?P<y>\d\d)", 'Y': r"(?P<Y>\d\d\d\d)"}) self.locale_time = locale_time
5efc50d8afd31dc4cb0ef1b58899943eb0e4cb67 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5efc50d8afd31dc4cb0ef1b58899943eb0e4cb67/_strptime.py
'W': r"(?P<W>5[0-3]|[0-4]\d|\d)",
def __init__(self, locale_time=LocaleTime()): """Init inst with non-locale regexes and store LocaleTime object.""" # XXX: should 0 be valid for: # day (d), julian day (j), month (m), and hour12 (I)? super(TimeRE,self).__init__({ # The " \d" option is to make %c from ANSI C work 'd': r"(?P<d>3[0-1]|[0-2]\d|\d| \d)", 'H': r"(?P<H>2[0-3]|[0-1]\d|\d)", 'I': r"(?P<I>0\d|1[0-2]|\d)", 'j': r"(?P<j>(?:3[0-5]\d|36[0-6])|[0-2]\d\d|\d\d|\d)", 'm': r"(?P<m>0\d|1[0-2]|\d)", 'M': r"(?P<M>[0-5]\d|\d)", 'S': r"(?P<S>6[0-1]|[0-5]\d|\d)", 'U': r"(?P<U>5[0-3]|[0-4]\d|\d)", 'w': r"(?P<w>[0-6])", 'W': r"(?P<W>5[0-3]|[0-4]\d|\d)", # Same as U 'y': r"(?P<y>\d\d)", 'Y': r"(?P<Y>\d\d\d\d)"}) self.locale_time = locale_time
5efc50d8afd31dc4cb0ef1b58899943eb0e4cb67 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5efc50d8afd31dc4cb0ef1b58899943eb0e4cb67/_strptime.py
a_gusi = ResLoader(fss, 'GU\267I', OVERRIDE_GUSI_ID, default=gusi_loader) a_path = StrListLoader(fss, 'STR
a_gusi = GusiLoader( ResLoader(fss, 'GU\267I', OVERRIDE_GUSI_ID, default=gusi_loader)) a_path = StrListLoader( ResLoader(fss, 'STR
def AppletOptions(file): fss = macfs.FSSpec(file) a_popt = PoptLoader(ResLoader(fss, 'Popt', OVERRIDE_POPT_ID, default=popt_loader)) a_dir = ResLoader(fss, 'alis', OVERRIDE_DIR_ID, default=dir) a_gusi = ResLoader(fss, 'GU\267I', OVERRIDE_GUSI_ID, default=gusi_loader) a_path = StrListLoader(fss, 'STR#', OVERRIDE_PATH_ID, default=path_loader) return PythonOptions(a_popt, a_dir, a_gusi, a_path)
e86d2870c45d76b5550c2debfca808bfd557edb9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e86d2870c45d76b5550c2debfca808bfd557edb9/pythonprefs.py
for name in ('lib', 'purelib', 'platlib', 'scripts', 'data'):
for name in ('lib', 'purelib', 'platlib', 'scripts', 'data', 'headers'):
def finalize_options (self):
e2383a6c774e41357824db4ea1db0b06182fe672 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e2383a6c774e41357824db4ea1db0b06182fe672/install.py
host = [host] try: addr = socket.gethostbyname(host[0]) if addr != host:
rawHost, port = splitport(host) host = [rawHost] try: addr = socket.gethostbyname(rawHost) if addr != rawHost:
def proxy_bypass(host): try: import _winreg import re except ImportError: # Std modules, so should be around - but you never know! return 0 try: internetSettings = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, r'Software\Microsoft\Windows\CurrentVersion\Internet Settings') proxyEnable = _winreg.QueryValueEx(internetSettings, 'ProxyEnable')[0] proxyOverride = str(_winreg.QueryValueEx(internetSettings, 'ProxyOverride')[0]) # ^^^^ Returned as Unicode but problems if not converted to ASCII except WindowsError: return 0 if not proxyEnable or not proxyOverride: return 0 # try to make a host list from name and IP address. host = [host] try: addr = socket.gethostbyname(host[0]) if addr != host: host.append(addr) except socket.error: pass # make a check value list from the registry entry: replace the # '<local>' string by the localhost entry and the corresponding # canonical entry. proxyOverride = proxyOverride.split(';') i = 0 while i < len(proxyOverride): if proxyOverride[i] == '<local>': proxyOverride[i:i+1] = ['localhost', '127.0.0.1', socket.gethostname(), socket.gethostbyname( socket.gethostname())] i += 1 # print proxyOverride # now check if we match one of the registry values. for test in proxyOverride: test = test.replace(".", r"\.") # mask dots test = test.replace("*", r".*") # change glob sequence test = test.replace("?", r".") # change glob char for val in host: # print "%s <--> %s" %( test, val ) if re.match(test, val, re.I): return 1 return 0
1f63670a2a0e66c049c2cfe8a2ec62a663e5c754 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1f63670a2a0e66c049c2cfe8a2ec62a663e5c754/urllib.py
self.stack = get_stack(tb) self.text = get_exception()
self.stack = self.get_stack(tb) self.text = self.get_exception() def get_stack(self, tb): if tb is None: tb = sys.last_traceback stack = [] if tb and tb.tb_frame is None: tb = tb.tb_next while tb is not None: stack.append((tb.tb_frame, tb.tb_lineno)) tb = tb.tb_next return stack def get_exception(self): type = sys.last_type value = sys.last_value if hasattr(type, "__name__"): type = type.__name__ s = str(type) if value is not None: s = s + ": " + str(value) return s
def __init__(self, flist=None, tb=None): self.flist = flist self.stack = get_stack(tb) self.text = get_exception()
5f7c4b34b91171da1755af9b6bf69eda07b811aa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5f7c4b34b91171da1755af9b6bf69eda07b811aa/StackViewer.py
def GetText(self): frame, lineno = self.info try: modname = frame.f_globals["__name__"] except: modname = "?" code = frame.f_code filename = code.co_filename funcname = code.co_name sourceline = linecache.getline(filename, lineno) sourceline = sourceline.strip() if funcname in ("?", "", None): item = "%s, line %d: %s" % (modname, lineno, sourceline) else: item = "%s.%s(...), line %d: %s" % (modname, funcname, lineno, sourceline)
5f7c4b34b91171da1755af9b6bf69eda07b811aa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5f7c4b34b91171da1755af9b6bf69eda07b811aa/StackViewer.py
def get_stack(t=None, f=None): if t is None: t = sys.last_traceback stack = [] if t and t.tb_frame is f: t = t.tb_next while f is not None: stack.append((f, f.f_lineno)) if f is self.botframe: break f = f.f_back stack.reverse() while t is not None: stack.append((t.tb_frame, t.tb_lineno)) t = t.tb_next return stack def get_exception(type=None, value=None): if type is None: type = sys.last_type value = sys.last_value if hasattr(type, "__name__"): type = type.__name__ s = str(type) if value is not None: s = s + ": " + str(value) return s
def get_stack(t=None, f=None): if t is None: t = sys.last_traceback stack = [] if t and t.tb_frame is f: t = t.tb_next while f is not None: stack.append((f, f.f_lineno)) if f is self.botframe: break f = f.f_back stack.reverse() while t is not None: stack.append((t.tb_frame, t.tb_lineno)) t = t.tb_next return stack
5f7c4b34b91171da1755af9b6bf69eda07b811aa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5f7c4b34b91171da1755af9b6bf69eda07b811aa/StackViewer.py
import traceback print "Exception in Tkinter callback"
import traceback, sys sys.stderr.write("Exception in Tkinter callback\n")
def report_callback_exception(self, exc, val, tb): import traceback print "Exception in Tkinter callback" traceback.print_exception(exc, val, tb)
da654505307c766169915e133cd03e78b240acaf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/da654505307c766169915e133cd03e78b240acaf/Tkinter.py
if not _default_root: _default_root = master
def _setup(self, master, cnf): if _support_default_root: global _default_root if not master: if not _default_root: _default_root = Tk() master = _default_root if not _default_root: _default_root = master self.master = master self.tk = master.tk name = None if cnf.has_key('name'): name = cnf['name'] del cnf['name'] if not name: name = `id(self)` self._name = name if master._w=='.': self._w = '.' + name else: self._w = master._w + '.' + name self.children = {} if self.master.children.has_key(self._name): self.master.children[self._name].destroy() self.master.children[self._name] = self
da654505307c766169915e133cd03e78b240acaf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/da654505307c766169915e133cd03e78b240acaf/Tkinter.py
SetDialogItemText(h, string.joinfields(list, '\r'))
h.data = string.joinfields(list, '\r') d.SelectDialogItemText(TEXT_ITEM, 0, 32767) d.SelectDialogItemText(TEXT_ITEM, 0, 0)
def interact(list, pythondir, options, title): """Let the user interact with the dialog""" opythondir = pythondir try: # Try to go to the "correct" dir for GetDirectory os.chdir(pythondir.as_pathname()) except os.error: pass d = GetNewDialog(DIALOG_ID, -1) tp, h, rect = d.GetDialogItem(TITLE_ITEM) SetDialogItemText(h, title) tp, h, rect = d.GetDialogItem(TEXT_ITEM) SetDialogItemText(h, string.joinfields(list, '\r'))
a918b8c4f64a90dc2fa298d5269f042891c20fd3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a918b8c4f64a90dc2fa298d5269f042891c20fd3/EditPythonPrefs.py
tmp = string.splitfields(GetDialogItemText(h), '\r')
tmp = string.splitfields(h.data, '\r')
def interact(list, pythondir, options, title): """Let the user interact with the dialog""" opythondir = pythondir try: # Try to go to the "correct" dir for GetDirectory os.chdir(pythondir.as_pathname()) except os.error: pass d = GetNewDialog(DIALOG_ID, -1) tp, h, rect = d.GetDialogItem(TITLE_ITEM) SetDialogItemText(h, title) tp, h, rect = d.GetDialogItem(TEXT_ITEM) SetDialogItemText(h, string.joinfields(list, '\r'))
a918b8c4f64a90dc2fa298d5269f042891c20fd3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a918b8c4f64a90dc2fa298d5269f042891c20fd3/EditPythonPrefs.py
def handler1(): print "handler1"
One public function, register, is defined. """
def handler1(): print "handler1"
c19425d520527d93b82755cc8a9854388306515a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c19425d520527d93b82755cc8a9854388306515a/atexit.py
def handler2(*args, **kargs): print "handler2", args, kargs
_exithandlers = [] def _run_exitfuncs(): """run any registered exit functions
def handler2(*args, **kargs): print "handler2", args, kargs
c19425d520527d93b82755cc8a9854388306515a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c19425d520527d93b82755cc8a9854388306515a/atexit.py
_exithandlers = atexit._exithandlers atexit._exithandlers = []
_exithandlers is traversed in reverse order so functions are executed last in, first out. """ while _exithandlers: func, targs, kargs = _exithandlers[-1] apply(func, targs, kargs) _exithandlers.remove(_exithandlers[-1])
def handler2(*args, **kargs): print "handler2", args, kargs
c19425d520527d93b82755cc8a9854388306515a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c19425d520527d93b82755cc8a9854388306515a/atexit.py
atexit.register(handler1) atexit.register(handler2) atexit.register(handler2, 7, kw="abc")
def register(func, *targs, **kargs): """register a function to be executed upon normal program termination
def handler2(*args, **kargs): print "handler2", args, kargs
c19425d520527d93b82755cc8a9854388306515a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c19425d520527d93b82755cc8a9854388306515a/atexit.py
atexit._run_exitfuncs()
func - function to be called at exit targs - optional arguments to pass to func kargs - optional keyword arguments to pass to func """ _exithandlers.append((func, targs, kargs))
def handler2(*args, **kargs): print "handler2", args, kargs
c19425d520527d93b82755cc8a9854388306515a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c19425d520527d93b82755cc8a9854388306515a/atexit.py
atexit._exithandlers = _exithandlers
import sys try: x = sys.exitfunc except AttributeError: sys.exitfunc = _run_exitfuncs else: if x != _run_exitfuncs: register(x) del sys if __name__ == "__main__": def x1(): print "running x1" def x2(n): print "running x2(%s)" % `n` def x3(n, kwd=None): print "running x3(%s, kwd=%s)" % (`n`, `kwd`) register(x1) register(x2, 12) register(x3, 5, "bar") register(x3, "no kwd args")
def handler2(*args, **kargs): print "handler2", args, kargs
c19425d520527d93b82755cc8a9854388306515a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c19425d520527d93b82755cc8a9854388306515a/atexit.py
try: _os.unlink(self._bakfile) except _os.error:
try: self._os.unlink(self._bakfile) except self._os.error:
def _commit(self): try: _os.unlink(self._bakfile) except _os.error: pass
d7472ec13a65c6c5ff00365b1477677d1fecbb3c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d7472ec13a65c6c5ff00365b1477677d1fecbb3c/dumbdbm.py
_os.rename(self._dirfile, self._bakfile) except _os.error:
self._os.rename(self._dirfile, self._bakfile) except self._os.error:
def _commit(self): try: _os.unlink(self._bakfile) except _os.error: pass
d7472ec13a65c6c5ff00365b1477677d1fecbb3c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d7472ec13a65c6c5ff00365b1477677d1fecbb3c/dumbdbm.py
f = _open(self._dirfile, 'w', self._mode)
f = self._open(self._dirfile, 'w', self._mode)
def _commit(self): try: _os.unlink(self._bakfile) except _os.error: pass
d7472ec13a65c6c5ff00365b1477677d1fecbb3c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d7472ec13a65c6c5ff00365b1477677d1fecbb3c/dumbdbm.py
def test_SEH(self): import sys if not hasattr(sys, "getobjects"):
import _ctypes if _ctypes.uses_seh(): def test_SEH(self):
def test_SEH(self): # Call functions with invalid arguments, and make sure that access violations # are trapped and raise an exception. # # Normally, in a debug build of the _ctypes extension # module, exceptions are not trapped, so we can only run # this test in a release build. import sys if not hasattr(sys, "getobjects"): self.assertRaises(WindowsError, windll.kernel32.GetModuleHandleA, 32)
f780be4239817192a93c34b768f6565aee8c2130 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f780be4239817192a93c34b768f6565aee8c2130/test_win32.py
class Boolean: """Boolean-value wrapper. Use True or False to generate a "boolean" XML-RPC value. """ def __init__(self, value = 0): self.value = operator.truth(value) def encode(self, out): out.write("<value><boolean>%d</boolean></value>\n" % self.value) def __cmp__(self, other): if isinstance(other, Boolean): other = other.value return cmp(self.value, other) def __repr__(self): if self.value: return "<Boolean True at %x>" % id(self) else: return "<Boolean False at %x>" % id(self) def __int__(self): return self.value def __nonzero__(self): return self.value True, False = Boolean(1), Boolean(0) def boolean(value, _truefalse=(False, True)): """Convert any Python value to XML-RPC 'boolean'.""" return _truefalse[operator.truth(value)]
if _bool_is_builtin: boolean = Boolean = bool True, False = True, False else: class Boolean: """Boolean-value wrapper. Use True or False to generate a "boolean" XML-RPC value. """ def __init__(self, value = 0): self.value = operator.truth(value) def encode(self, out): out.write("<value><boolean>%d</boolean></value>\n" % self.value) def __cmp__(self, other): if isinstance(other, Boolean): other = other.value return cmp(self.value, other) def __repr__(self): if self.value: return "<Boolean True at %x>" % id(self) else: return "<Boolean False at %x>" % id(self) def __int__(self): return self.value def __nonzero__(self): return self.value True, False = Boolean(1), Boolean(0) def boolean(value, _truefalse=(False, True)): """Convert any Python value to XML-RPC 'boolean'.""" return _truefalse[operator.truth(value)]
def __repr__(self): return ( "<Fault %s: %s>" % (self.faultCode, repr(self.faultString)) )
9a7c96a2bca4342f70b05f5d1e00ad5be142bf24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9a7c96a2bca4342f70b05f5d1e00ad5be142bf24/xmlrpclib.py
WRAPPERS = DateTime, Binary, Boolean
WRAPPERS = (DateTime, Binary) if not _bool_is_builtin: WRAPPERS = WRAPPERS + (Boolean,)
def _binary(data): # decode xml element contents into a Binary structure value = Binary() value.decode(data) return value
9a7c96a2bca4342f70b05f5d1e00ad5be142bf24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9a7c96a2bca4342f70b05f5d1e00ad5be142bf24/xmlrpclib.py
"exclude=", "include=", "package=", "strip", "iconfile=")
"exclude=", "include=", "package=", "strip", "iconfile=", "lib=")
def main(builder=None): if builder is None: builder = AppBuilder(verbosity=1) shortopts = "b:n:r:f:e:m:c:p:lx:i:hvqa" longopts = ("builddir=", "name=", "resource=", "file=", "executable=", "mainprogram=", "creator=", "nib=", "plist=", "link", "link-exec", "help", "verbose", "quiet", "argv", "standalone", "exclude=", "include=", "package=", "strip", "iconfile=") try: options, args = getopt.getopt(sys.argv[1:], shortopts, longopts) except getopt.error: usage() for opt, arg in options: if opt in ('-b', '--builddir'): builder.builddir = arg elif opt in ('-n', '--name'): builder.name = arg elif opt in ('-r', '--resource'): builder.resources.append(arg) elif opt in ('-f', '--file'): srcdst = arg.split(':') if len(srcdst) != 2: usage("-f or --file argument must be two paths, " "separated by a colon") builder.files.append(srcdst) elif opt in ('-e', '--executable'): builder.executable = arg elif opt in ('-m', '--mainprogram'): builder.mainprogram = arg elif opt in ('-a', '--argv'): builder.argv_emulation = 1 elif opt in ('-c', '--creator'): builder.creator = arg elif opt == '--iconfile': builder.iconfile = arg elif opt == "--nib": builder.nibname = arg elif opt in ('-p', '--plist'): builder.plist = Plist.fromFile(arg) elif opt in ('-l', '--link'): builder.symlink = 1 elif opt == '--link-exec': builder.symlink_exec = 1 elif opt in ('-h', '--help'): usage() elif opt in ('-v', '--verbose'): builder.verbosity += 1 elif opt in ('-q', '--quiet'): builder.verbosity -= 1 elif opt == '--standalone': builder.standalone = 1 elif opt in ('-x', '--exclude'): builder.excludeModules.append(arg) elif opt in ('-i', '--include'): builder.includeModules.append(arg) elif opt == '--package': builder.includePackages.append(arg) elif opt == '--strip': builder.strip = 1 if len(args) != 1: usage("Must specify one command ('build', 'report' or 'help')") command = args[0] if command == "build": builder.setup() builder.build() elif command == "report": builder.setup() builder.report() elif command == "help": usage() else: usage("Unknown command '%s'" % command)
15624d850b65a0be8e944e9f17849799e3e7ede5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/15624d850b65a0be8e944e9f17849799e3e7ede5/bundlebuilder.py
from distutils.ccompiler import new_compiler from distutils.sysconfig import customize_compiler
def build_extensions(self): from distutils.ccompiler import new_compiler from distutils.sysconfig import customize_compiler
5bbc7b9283c40996c198511f57211d4f77d6a12d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5bbc7b9283c40996c198511f57211d4f77d6a12d/setup.py
compiler = os.environ.get('CC') linker_so = os.environ.get('LDSHARED') args = {} if compiler is not None: args['compiler_so'] = compiler if linker_so is not None: args['linker_so'] = linker_so + ' -shared' self.compiler.set_executables(**args)
def build_extensions(self): from distutils.ccompiler import new_compiler from distutils.sysconfig import customize_compiler
5bbc7b9283c40996c198511f57211d4f77d6a12d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5bbc7b9283c40996c198511f57211d4f77d6a12d/setup.py
exts.append( Extension('unicodedata', ['unicodedata.c', 'unicodedatabase.c']) )
exts.append( Extension('unicodedata', ['unicodedata.c', 'unicodedatabase.c']) )
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
5bbc7b9283c40996c198511f57211d4f77d6a12d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5bbc7b9283c40996c198511f57211d4f77d6a12d/setup.py
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
5bbc7b9283c40996c198511f57211d4f77d6a12d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5bbc7b9283c40996c198511f57211d4f77d6a12d/setup.py
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
5bbc7b9283c40996c198511f57211d4f77d6a12d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5bbc7b9283c40996c198511f57211d4f77d6a12d/setup.py
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
5bbc7b9283c40996c198511f57211d4f77d6a12d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5bbc7b9283c40996c198511f57211d4f77d6a12d/setup.py
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
5bbc7b9283c40996c198511f57211d4f77d6a12d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5bbc7b9283c40996c198511f57211d4f77d6a12d/setup.py
def main(): setup(name = 'Python standard library', version = '%d.%d' % sys.version_info[:2], cmdclass = {'build_ext':PyBuildExt}, # The struct module is defined here, because build_ext won't be # called unless there's at least one extension module defined. ext_modules=[Extension('struct', ['structmodule.c'])] )
5bbc7b9283c40996c198511f57211d4f77d6a12d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5bbc7b9283c40996c198511f57211d4f77d6a12d/setup.py
raise ValueError, "CRC check failed"
raise IOError, "CRC check failed"
def _read_eof(self): # We've read to the end of the file, so we have to rewind in order # to reread the 8 bytes containing the CRC and the file size. # We check the that the computed CRC and size of the # uncompressed data matches the stored values. Note that the size # stored is the true file size mod 2**32. self.fileobj.seek(-8, 1) crc32 = read32(self.fileobj) isize = U32(read32(self.fileobj)) # may exceed 2GB if U32(crc32) != U32(self.crc): raise ValueError, "CRC check failed" elif isize != LOWU32(self.size): raise ValueError, "Incorrect length of data produced"
64edd6ac1ddb29f7817ee44e9b376b096ffa1d55 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/64edd6ac1ddb29f7817ee44e9b376b096ffa1d55/gzip.py
raise ValueError, "Incorrect length of data produced"
raise IOError, "Incorrect length of data produced"
def _read_eof(self): # We've read to the end of the file, so we have to rewind in order # to reread the 8 bytes containing the CRC and the file size. # We check the that the computed CRC and size of the # uncompressed data matches the stored values. Note that the size # stored is the true file size mod 2**32. self.fileobj.seek(-8, 1) crc32 = read32(self.fileobj) isize = U32(read32(self.fileobj)) # may exceed 2GB if U32(crc32) != U32(self.crc): raise ValueError, "CRC check failed" elif isize != LOWU32(self.size): raise ValueError, "Incorrect length of data produced"
64edd6ac1ddb29f7817ee44e9b376b096ffa1d55 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/64edd6ac1ddb29f7817ee44e9b376b096ffa1d55/gzip.py
if sys.platform[:4] != 'java': int(testme) long(testme) float(testme) oct(testme) hex(testme) else: print "__int__: ()" print "__long__: ()" print "__float__: ()" print "__oct__: ()" print "__hex__: ()"
int(testme) long(testme) float(testme) oct(testme) hex(testme)
def __%(method)s__(self, *args): print "__%(method)s__:", args
3a313e36555a3416799f3c049b8ebb41e9edeb8a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3a313e36555a3416799f3c049b8ebb41e9edeb8a/test_class.py
try: hash(C1()) except TypeError: pass else: raise TestFailed, "hash(C1()) should raise an exception"
check_exc("hash(C1())", TypeError)
def __cmp__(self, other): return 0
3a313e36555a3416799f3c049b8ebb41e9edeb8a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3a313e36555a3416799f3c049b8ebb41e9edeb8a/test_class.py
try: hash(C2()) except TypeError: pass else: raise TestFailed, "hash(C2()) should raise an exception"
check_exc("hash(C2())", TypeError)
def __eq__(self, other): return 1
3a313e36555a3416799f3c049b8ebb41e9edeb8a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3a313e36555a3416799f3c049b8ebb41e9edeb8a/test_class.py
args = ('wm', 'colormapwindows', self._w) + _flatten(wlist)
if len(wlist) > 1: wlist = (wlist,) args = ('wm', 'colormapwindows', self._w) + wlist
def wm_colormapwindows(self, *wlist): args = ('wm', 'colormapwindows', self._w) + _flatten(wlist) return map(self._nametowidget, self.tk.call(args))
8fa42af978f1494d0475f6ceb9af38923e024030 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8fa42af978f1494d0475f6ceb9af38923e024030/Tkinter.py
self.emit('PyObject_SetAttrString(result, "%s", value);' % a.name, 1)
self.emit('if (PyObject_SetAttrString(result, "%s", value) < 0)' % a.name, 1) self.emit('goto failed;', 2) self.emit('Py_DECREF(value);', 1)
def visitSum(self, sum, name): if is_simple(sum): self.simpleSum(sum, name) return self.func_begin(name) self.emit("switch (o->kind) {", 1) for i in range(len(sum.types)): t = sum.types[i] self.visitConstructor(t, i + 1, name) self.emit("}", 1) for a in sum.attributes: self.emit("value = ast2obj_%s(o->%s);" % (a.type, a.name), 1) self.emit("if (!value) goto failed;", 1) self.emit('PyObject_SetAttrString(result, "%s", value);' % a.name, 1) self.func_end()
03e5bc02c9744640f4d228ff7686c2392ab17812 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/03e5bc02c9744640f4d228ff7686c2392ab17812/asdl_c.py
if self._file: self.close()
self.close()
def __del__(self): if self._file: self.close()
cfc4178e843f5f2b0f190bacd222c0f72ab91e53 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cfc4178e843f5f2b0f190bacd222c0f72ab91e53/wave.py
self._ensure_header_written(0) if self._datalength != self._datawritten: self._patchheader() self._file.flush() self._file = None
if self._file: self._ensure_header_written(0) if self._datalength != self._datawritten: self._patchheader() self._file.flush() self._file = None if self._i_opened_the_file: self._i_opened_the_file.close() self._i_opened_the_file = None
def close(self): self._ensure_header_written(0) if self._datalength != self._datawritten: self._patchheader() self._file.flush() self._file = None
cfc4178e843f5f2b0f190bacd222c0f72ab91e53 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cfc4178e843f5f2b0f190bacd222c0f72ab91e53/wave.py
def _split(self, s, charset, firstline=False): # Split up a header safely for use with encode_chunks. BAW: this # appears to be a private convenience method. splittable = charset.to_splittable(s) encoded = charset.from_splittable(splittable) elen = charset.encoded_header_len(encoded)
5e3bcff651f77bd7504751a581b4db7d4b937cac /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5e3bcff651f77bd7504751a581b4db7d4b937cac/Header.py
self.apply() self.cancel()
try: self.apply() finally: self.cancel()
def ok(self, event=None):
e350c840b389f645b25f00f1fa35f6ea1fec03b3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e350c840b389f645b25f00f1fa35f6ea1fec03b3/tkSimpleDialog.py
compileargs = r"-Wi [TARGETDIR]Lib\compileall.py -f -x badsyntax [TARGETDIR]Lib"
compileargs = r"-Wi [TARGETDIR]Lib\compileall.py -f -x bad_coding|badsyntax|site-packages [TARGETDIR]Lib"
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. if os.system("nmake /nologo /c /f msisupport.mak") != 0: raise "'nmake /f msisupport.mak' failed" add_data(db, "Binary", [("Script", msilib.Binary("msisupport.dll"))]) # See "Custom Action Type 1" if msilib.Win64: CheckDir = "CheckDir" UpdateEditIDLE = "UpdateEditIDLE" else: CheckDir = "_CheckDir@4" UpdateEditIDLE = "_UpdateEditIDLE@4" add_data(db, "CustomAction", [("CheckDir", 1, "Script", CheckDir)]) if have_tcl: add_data(db, "CustomAction", [("UpdateEditIDLE", 1, "Script", UpdateEditIDLE)]) # 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), ("VerdanaRed9", "Verdana", 9, 255, 0), ]) compileargs = r"-Wi [TARGETDIR]Lib\compileall.py -f -x badsyntax [TARGETDIR]Lib" # 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", compileargs), ("CompilePyo", 18, "python.exe", "-O "+compileargs), ]) # 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.") c = exit_dialog.text("warning", 135, 200, 220, 40, 0x30003, "{\\VerdanaRed9}Warning: Python 2.5.x is the last " "Python release for Windows 9x.") c.condition("Hide", "NOT Version9X") 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") c = seldlg.text("Existing", 135, 25, 235, 30, 0x30003, "{\VerdanaRed9}This update will replace your existing [ProductLine] installation.") c.condition("Hide", 'REMOVEOLDVERSION="" and REMOVEOLDSNAPSHOT=""') 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]", "repairs", '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")
9fbc44cc34aa1521c4d7467d75f189e955e8f247 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9fbc44cc34aa1521c4d7467d75f189e955e8f247/msi.py
type, address = splittype(address) if not type:
import re if not re.match('^([^/:]+)://', address):
def getproxies_registry(): """Return a dictionary of scheme -> proxy server URL mappings.
64e5aa93919bb0ffd95a11a5da7bac64faaf9faf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/64e5aa93919bb0ffd95a11a5da7bac64faaf9faf/urllib.py
for dir in sys.path:
path = sys.path try: path = [os.path.dirname(__file__)] + path except NameError: pass for dir in path:
def get_qualified_path(name): """ return a more qualified path to name""" import sys import os for dir in sys.path: fullname = os.path.join(dir, name) if os.path.exists(fullname): return fullname return name
f1b0009a7807e18fad3e2e17c8cb3b4a4eb20b07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f1b0009a7807e18fad3e2e17c8cb3b4a4eb20b07/test_imageop.py
assert gc.collect() == 1
if gc.collect() != 1: raise TestFailed
def test_list(): l = [] l.append(l) gc.collect() del l assert gc.collect() == 1
faae266e89d19f5dfea81db0771b6fa671e9b1ac /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/faae266e89d19f5dfea81db0771b6fa671e9b1ac/test_gc.py
assert gc.collect() == 1
if gc.collect() != 1: raise TestFailed
def test_dict(): d = {} d[1] = d gc.collect() del d assert gc.collect() == 1
faae266e89d19f5dfea81db0771b6fa671e9b1ac /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/faae266e89d19f5dfea81db0771b6fa671e9b1ac/test_gc.py
assert gc.collect() == 2
if gc.collect() != 2: raise TestFailed
def test_tuple(): # since tuples are immutable we close the loop with a list l = [] t = (l,) l.append(t) gc.collect() del t del l assert gc.collect() == 2
faae266e89d19f5dfea81db0771b6fa671e9b1ac /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/faae266e89d19f5dfea81db0771b6fa671e9b1ac/test_gc.py
assert gc.collect() > 0
if gc.collect() == 0: raise TestFailed
def test_class(): class A: pass A.a = A gc.collect() del A assert gc.collect() > 0
faae266e89d19f5dfea81db0771b6fa671e9b1ac /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/faae266e89d19f5dfea81db0771b6fa671e9b1ac/test_gc.py
assert gc.collect() > 0
if gc.collect() == 0: raise TestFailed
def test_instance(): class A: pass a = A() a.a = a gc.collect() del a assert gc.collect() > 0
faae266e89d19f5dfea81db0771b6fa671e9b1ac /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/faae266e89d19f5dfea81db0771b6fa671e9b1ac/test_gc.py
assert gc.collect() > 0
if gc.collect() == 0: raise TestFailed
def __init__(self): self.init = self.__init__
faae266e89d19f5dfea81db0771b6fa671e9b1ac /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/faae266e89d19f5dfea81db0771b6fa671e9b1ac/test_gc.py
gc.garbage[:] = []
def __del__(self): pass
faae266e89d19f5dfea81db0771b6fa671e9b1ac /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/faae266e89d19f5dfea81db0771b6fa671e9b1ac/test_gc.py
assert gc.collect() > 0 assert id(gc.garbage[0]) == id_a
if gc.collect() == 0: raise TestFailed for obj in gc.garbage: if id(obj) == id_a: del obj.a break else: raise TestFailed gc.garbage.remove(obj)
def __del__(self): pass
faae266e89d19f5dfea81db0771b6fa671e9b1ac /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/faae266e89d19f5dfea81db0771b6fa671e9b1ac/test_gc.py
assert gc.collect() == 2
if gc.collect() != 2: raise TestFailed def test_saveall(): debug = gc.get_debug() gc.set_debug(debug | gc.DEBUG_SAVEALL) l = [] l.append(l) id_l = id(l) del l gc.collect() try: for obj in gc.garbage: if id(obj) == id_l: del obj[:] break else: raise TestFailed gc.garbage.remove(obj) finally: gc.set_debug(debug)
exec("def f(): pass\n") in d
faae266e89d19f5dfea81db0771b6fa671e9b1ac /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/faae266e89d19f5dfea81db0771b6fa671e9b1ac/test_gc.py
sys.stderr.write("*** %s\n" % s)
ewrite("*** %s\n" % s)
def para_msg(s): sys.stderr.write("*** %s\n" % s)
080c1b5af693afd471728e7fa66f744a61e75ed4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/080c1b5af693afd471728e7fa66f744a61e75ed4/docfixer.py
def find_all_elements_from_set(doc, gi_set, nodes=None): if nodes is None: nodes = []
def find_all_child_elements(doc, gi): nodes = [] for child in doc.childNodes: if child.nodeType == ELEMENT: if child.tagName == gi: nodes.append(child) return nodes def find_all_elements_from_set(doc, gi_set): return __find_all_elements_from_set(doc, gi_set, []) def __find_all_elements_from_set(doc, gi_set, nodes):
def find_all_elements_from_set(doc, gi_set, nodes=None): if nodes is None: nodes = [] if doc.nodeType == ELEMENT and doc.tagName in gi_set: nodes.append(doc) for child in doc.childNodes: if child.nodeType == ELEMENT: find_all_elements_from_set(child, gi_set, nodes) return nodes
080c1b5af693afd471728e7fa66f744a61e75ed4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/080c1b5af693afd471728e7fa66f744a61e75ed4/docfixer.py
find_all_elements_from_set(child, gi_set, nodes)
__find_all_elements_from_set(child, gi_set, nodes)
def find_all_elements_from_set(doc, gi_set, nodes=None): if nodes is None: nodes = [] if doc.nodeType == ELEMENT and doc.tagName in gi_set: nodes.append(doc) for child in doc.childNodes: if child.nodeType == ELEMENT: find_all_elements_from_set(child, gi_set, nodes) return nodes
080c1b5af693afd471728e7fa66f744a61e75ed4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/080c1b5af693afd471728e7fa66f744a61e75ed4/docfixer.py
def rewrite_descriptor(doc, descriptor): # # Do these things: # 1. Add an "index=noindex" attribute to the element if the tagName # ends in 'ni', removing the 'ni' from the name. # 2. Create a <signature> from the name attribute and <args>. # 3. Create additional <signature>s from <*line{,ni}> elements, # if found. # 4. If a <versionadded> is found, move it to an attribute on the # descriptor. # 5. Move remaining child nodes to a <description> element. # 6. Put it back together. # descname = descriptor.tagName index = 1 if descname[-2:] == "ni": descname = descname[:-2] descriptor.setAttribute("index", "noindex") descriptor._node.name = descname index = 0 desctype = descname[:-4] # remove 'desc' linename = desctype + "line" if not index: linename = linename + "ni" # 2. signature = doc.createElement("signature") name = doc.createElement("name") signature.appendChild(doc.createTextNode("\n ")) signature.appendChild(name) name.appendChild(doc.createTextNode(descriptor.getAttribute("name"))) descriptor.removeAttribute("name") if descriptor.attributes.has_key("var"): variable = descriptor.getAttribute("var") if variable: args = doc.createElement("args") args.appendChild(doc.createTextNode(variable)) signature.appendChild(doc.createTextNode("\n ")) signature.appendChild(args) descriptor.removeAttribute("var") newchildren = [signature] children = descriptor.childNodes pos = skip_leading_nodes(children, 0) if pos < len(children): child = children[pos] if child.nodeType == ELEMENT and child.tagName == "args": # create an <args> in <signature>: args = doc.createElement("args") argchildren = [] map(argchildren.append, child.childNodes) for n in argchildren: child.removeChild(n) args.appendChild(n) signature.appendChild(doc.createTextNode("\n ")) signature.appendChild(args) signature.appendChild(doc.createTextNode("\n ")) # 3, 4. pos = skip_leading_nodes(children, pos + 1) while pos < len(children) \ and children[pos].nodeType == ELEMENT \ and children[pos].tagName in (linename, "versionadded"): if children[pos].tagName == linename: # this is really a supplemental signature, create <signature> sig = methodline_to_signature(doc, children[pos]) newchildren.append(sig) else: # <versionadded added=...> descriptor.setAttribute( "added", children[pos].getAttribute("version")) pos = skip_leading_nodes(children, pos + 1) # 5. description = doc.createElement("description") description.appendChild(doc.createTextNode("\n")) newchildren.append(description) move_children(descriptor, description, pos) last = description.childNodes[-1] if last.nodeType == TEXT: last.data = string.rstrip(last.data) + "\n " # 6. # should have nothing but whitespace and signature lines in <descriptor>; # discard them while descriptor.childNodes: descriptor.removeChild(descriptor.childNodes[0]) for node in newchildren: descriptor.appendChild(doc.createTextNode("\n ")) descriptor.appendChild(node) descriptor.appendChild(doc.createTextNode("\n"))
080c1b5af693afd471728e7fa66f744a61e75ed4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/080c1b5af693afd471728e7fa66f744a61e75ed4/docfixer.py
descriptor.setAttribute("index", "noindex")
descriptor.setAttribute("index", "no")
def rewrite_descriptor(doc, descriptor): # # Do these things: # 1. Add an "index=noindex" attribute to the element if the tagName # ends in 'ni', removing the 'ni' from the name. # 2. Create a <signature> from the name attribute and <args>. # 3. Create additional <signature>s from <*line{,ni}> elements, # if found. # 4. If a <versionadded> is found, move it to an attribute on the # descriptor. # 5. Move remaining child nodes to a <description> element. # 6. Put it back together. # descname = descriptor.tagName index = 1 if descname[-2:] == "ni": descname = descname[:-2] descriptor.setAttribute("index", "noindex") descriptor._node.name = descname index = 0 desctype = descname[:-4] # remove 'desc' linename = desctype + "line" if not index: linename = linename + "ni" # 2. signature = doc.createElement("signature") name = doc.createElement("name") signature.appendChild(doc.createTextNode("\n ")) signature.appendChild(name) name.appendChild(doc.createTextNode(descriptor.getAttribute("name"))) descriptor.removeAttribute("name") if descriptor.attributes.has_key("var"): variable = descriptor.getAttribute("var") if variable: args = doc.createElement("args") args.appendChild(doc.createTextNode(variable)) signature.appendChild(doc.createTextNode("\n ")) signature.appendChild(args) descriptor.removeAttribute("var") newchildren = [signature] children = descriptor.childNodes pos = skip_leading_nodes(children, 0) if pos < len(children): child = children[pos] if child.nodeType == ELEMENT and child.tagName == "args": # create an <args> in <signature>: args = doc.createElement("args") argchildren = [] map(argchildren.append, child.childNodes) for n in argchildren: child.removeChild(n) args.appendChild(n) signature.appendChild(doc.createTextNode("\n ")) signature.appendChild(args) signature.appendChild(doc.createTextNode("\n ")) # 3, 4. pos = skip_leading_nodes(children, pos + 1) while pos < len(children) \ and children[pos].nodeType == ELEMENT \ and children[pos].tagName in (linename, "versionadded"): if children[pos].tagName == linename: # this is really a supplemental signature, create <signature> sig = methodline_to_signature(doc, children[pos]) newchildren.append(sig) else: # <versionadded added=...> descriptor.setAttribute( "added", children[pos].getAttribute("version")) pos = skip_leading_nodes(children, pos + 1) # 5. description = doc.createElement("description") description.appendChild(doc.createTextNode("\n")) newchildren.append(description) move_children(descriptor, description, pos) last = description.childNodes[-1] if last.nodeType == TEXT: last.data = string.rstrip(last.data) + "\n " # 6. # should have nothing but whitespace and signature lines in <descriptor>; # discard them while descriptor.childNodes: descriptor.removeChild(descriptor.childNodes[0]) for node in newchildren: descriptor.appendChild(doc.createTextNode("\n ")) descriptor.appendChild(node) descriptor.appendChild(doc.createTextNode("\n"))
080c1b5af693afd471728e7fa66f744a61e75ed4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/080c1b5af693afd471728e7fa66f744a61e75ed4/docfixer.py
sys.stderr.write( "module name in title doesn't match" " <declaremodule>; no <short-synopsis>\n")
ewrite("module name in title doesn't match" " <declaremodule/>; no <short-synopsis/>\n")
def create_module_info(doc, section): # Heavy. node = extract_first_element(section, "modulesynopsis") if node is None: return node._node.name = "synopsis" lastchild = node.childNodes[-1] if lastchild.nodeType == TEXT \ and lastchild.data[-1:] == ".": lastchild.data = lastchild.data[:-1] modauthor = extract_first_element(section, "moduleauthor") if modauthor: modauthor._node.name = "author" modauthor.appendChild(doc.createTextNode( modauthor.getAttribute("name"))) modauthor.removeAttribute("name") platform = extract_first_element(section, "platform") if section.tagName == "section": modinfo_pos = 2 modinfo = doc.createElement("moduleinfo") moddecl = extract_first_element(section, "declaremodule") name = None if moddecl: modinfo.appendChild(doc.createTextNode("\n ")) name = moddecl.attributes["name"].value namenode = doc.createElement("name") namenode.appendChild(doc.createTextNode(name)) modinfo.appendChild(namenode) type = moddecl.attributes.get("type") if type: type = type.value modinfo.appendChild(doc.createTextNode("\n ")) typenode = doc.createElement("type") typenode.appendChild(doc.createTextNode(type)) modinfo.appendChild(typenode) versionadded = extract_first_element(section, "versionadded") if versionadded: modinfo.setAttribute("added", versionadded.getAttribute("version")) title = get_first_element(section, "title") if title: children = title.childNodes if len(children) >= 2 \ and children[0].nodeType == ELEMENT \ and children[0].tagName == "module" \ and children[0].childNodes[0].data == name: # this is it; morph the <title> into <short-synopsis> first_data = children[1] if first_data.data[:4] == " ---": first_data.data = string.lstrip(first_data.data[4:]) title._node.name = "short-synopsis" if children[-1].nodeType == TEXT \ and children[-1].data[-1:] == ".": children[-1].data = children[-1].data[:-1] section.removeChild(title) section.removeChild(section.childNodes[0]) title.removeChild(children[0]) modinfo_pos = 0 else: sys.stderr.write( "module name in title doesn't match" " <declaremodule>; no <short-synopsis>\n") else: sys.stderr.write( "Unexpected condition: <section> without <title>\n") modinfo.appendChild(doc.createTextNode("\n ")) modinfo.appendChild(node) if title and not contents_match(title, node): # The short synopsis is actually different, # and needs to be stored: modinfo.appendChild(doc.createTextNode("\n ")) modinfo.appendChild(title) if modauthor: modinfo.appendChild(doc.createTextNode("\n ")) modinfo.appendChild(modauthor) if platform: modinfo.appendChild(doc.createTextNode("\n ")) modinfo.appendChild(platform) modinfo.appendChild(doc.createTextNode("\n ")) section.insertBefore(modinfo, section.childNodes[modinfo_pos]) section.insertBefore(doc.createTextNode("\n "), modinfo) # # The rest of this removes extra newlines from where we cut out # a lot of elements. A lot of code for minimal value, but keeps # keeps the generated SGML from being too funny looking. # section.normalize() children = section.childNodes for i in range(len(children)): node = children[i] if node.nodeType == ELEMENT \ and node.tagName == "moduleinfo": nextnode = children[i+1] if nextnode.nodeType == TEXT: data = nextnode.data if len(string.lstrip(data)) < (len(data) - 4): nextnode.data = "\n\n\n" + string.lstrip(data)
080c1b5af693afd471728e7fa66f744a61e75ed4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/080c1b5af693afd471728e7fa66f744a61e75ed4/docfixer.py
sys.stderr.write( "Unexpected condition: <section> without <title>\n")
ewrite("Unexpected condition: <section/> without <title/>\n")
def create_module_info(doc, section): # Heavy. node = extract_first_element(section, "modulesynopsis") if node is None: return node._node.name = "synopsis" lastchild = node.childNodes[-1] if lastchild.nodeType == TEXT \ and lastchild.data[-1:] == ".": lastchild.data = lastchild.data[:-1] modauthor = extract_first_element(section, "moduleauthor") if modauthor: modauthor._node.name = "author" modauthor.appendChild(doc.createTextNode( modauthor.getAttribute("name"))) modauthor.removeAttribute("name") platform = extract_first_element(section, "platform") if section.tagName == "section": modinfo_pos = 2 modinfo = doc.createElement("moduleinfo") moddecl = extract_first_element(section, "declaremodule") name = None if moddecl: modinfo.appendChild(doc.createTextNode("\n ")) name = moddecl.attributes["name"].value namenode = doc.createElement("name") namenode.appendChild(doc.createTextNode(name)) modinfo.appendChild(namenode) type = moddecl.attributes.get("type") if type: type = type.value modinfo.appendChild(doc.createTextNode("\n ")) typenode = doc.createElement("type") typenode.appendChild(doc.createTextNode(type)) modinfo.appendChild(typenode) versionadded = extract_first_element(section, "versionadded") if versionadded: modinfo.setAttribute("added", versionadded.getAttribute("version")) title = get_first_element(section, "title") if title: children = title.childNodes if len(children) >= 2 \ and children[0].nodeType == ELEMENT \ and children[0].tagName == "module" \ and children[0].childNodes[0].data == name: # this is it; morph the <title> into <short-synopsis> first_data = children[1] if first_data.data[:4] == " ---": first_data.data = string.lstrip(first_data.data[4:]) title._node.name = "short-synopsis" if children[-1].nodeType == TEXT \ and children[-1].data[-1:] == ".": children[-1].data = children[-1].data[:-1] section.removeChild(title) section.removeChild(section.childNodes[0]) title.removeChild(children[0]) modinfo_pos = 0 else: sys.stderr.write( "module name in title doesn't match" " <declaremodule>; no <short-synopsis>\n") else: sys.stderr.write( "Unexpected condition: <section> without <title>\n") modinfo.appendChild(doc.createTextNode("\n ")) modinfo.appendChild(node) if title and not contents_match(title, node): # The short synopsis is actually different, # and needs to be stored: modinfo.appendChild(doc.createTextNode("\n ")) modinfo.appendChild(title) if modauthor: modinfo.appendChild(doc.createTextNode("\n ")) modinfo.appendChild(modauthor) if platform: modinfo.appendChild(doc.createTextNode("\n ")) modinfo.appendChild(platform) modinfo.appendChild(doc.createTextNode("\n ")) section.insertBefore(modinfo, section.childNodes[modinfo_pos]) section.insertBefore(doc.createTextNode("\n "), modinfo) # # The rest of this removes extra newlines from where we cut out # a lot of elements. A lot of code for minimal value, but keeps # keeps the generated SGML from being too funny looking. # section.normalize() children = section.childNodes for i in range(len(children)): node = children[i] if node.nodeType == ELEMENT \ and node.tagName == "moduleinfo": nextnode = children[i+1] if nextnode.nodeType == TEXT: data = nextnode.data if len(string.lstrip(data)) < (len(data) - 4): nextnode.data = "\n\n\n" + string.lstrip(data)
080c1b5af693afd471728e7fa66f744a61e75ed4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/080c1b5af693afd471728e7fa66f744a61e75ed4/docfixer.py
def create_module_info(doc, section): # Heavy. node = extract_first_element(section, "modulesynopsis") if node is None: return node._node.name = "synopsis" lastchild = node.childNodes[-1] if lastchild.nodeType == TEXT \ and lastchild.data[-1:] == ".": lastchild.data = lastchild.data[:-1] modauthor = extract_first_element(section, "moduleauthor") if modauthor: modauthor._node.name = "author" modauthor.appendChild(doc.createTextNode( modauthor.getAttribute("name"))) modauthor.removeAttribute("name") platform = extract_first_element(section, "platform") if section.tagName == "section": modinfo_pos = 2 modinfo = doc.createElement("moduleinfo") moddecl = extract_first_element(section, "declaremodule") name = None if moddecl: modinfo.appendChild(doc.createTextNode("\n ")) name = moddecl.attributes["name"].value namenode = doc.createElement("name") namenode.appendChild(doc.createTextNode(name)) modinfo.appendChild(namenode) type = moddecl.attributes.get("type") if type: type = type.value modinfo.appendChild(doc.createTextNode("\n ")) typenode = doc.createElement("type") typenode.appendChild(doc.createTextNode(type)) modinfo.appendChild(typenode) versionadded = extract_first_element(section, "versionadded") if versionadded: modinfo.setAttribute("added", versionadded.getAttribute("version")) title = get_first_element(section, "title") if title: children = title.childNodes if len(children) >= 2 \ and children[0].nodeType == ELEMENT \ and children[0].tagName == "module" \ and children[0].childNodes[0].data == name: # this is it; morph the <title> into <short-synopsis> first_data = children[1] if first_data.data[:4] == " ---": first_data.data = string.lstrip(first_data.data[4:]) title._node.name = "short-synopsis" if children[-1].nodeType == TEXT \ and children[-1].data[-1:] == ".": children[-1].data = children[-1].data[:-1] section.removeChild(title) section.removeChild(section.childNodes[0]) title.removeChild(children[0]) modinfo_pos = 0 else: sys.stderr.write( "module name in title doesn't match" " <declaremodule>; no <short-synopsis>\n") else: sys.stderr.write( "Unexpected condition: <section> without <title>\n") modinfo.appendChild(doc.createTextNode("\n ")) modinfo.appendChild(node) if title and not contents_match(title, node): # The short synopsis is actually different, # and needs to be stored: modinfo.appendChild(doc.createTextNode("\n ")) modinfo.appendChild(title) if modauthor: modinfo.appendChild(doc.createTextNode("\n ")) modinfo.appendChild(modauthor) if platform: modinfo.appendChild(doc.createTextNode("\n ")) modinfo.appendChild(platform) modinfo.appendChild(doc.createTextNode("\n ")) section.insertBefore(modinfo, section.childNodes[modinfo_pos]) section.insertBefore(doc.createTextNode("\n "), modinfo) # # The rest of this removes extra newlines from where we cut out # a lot of elements. A lot of code for minimal value, but keeps # keeps the generated SGML from being too funny looking. # section.normalize() children = section.childNodes for i in range(len(children)): node = children[i] if node.nodeType == ELEMENT \ and node.tagName == "moduleinfo": nextnode = children[i+1] if nextnode.nodeType == TEXT: data = nextnode.data if len(string.lstrip(data)) < (len(data) - 4): nextnode.data = "\n\n\n" + string.lstrip(data)
080c1b5af693afd471728e7fa66f744a61e75ed4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/080c1b5af693afd471728e7fa66f744a61e75ed4/docfixer.py
def cleanup_synopses(doc): for node in find_all_elements(doc, "section"):
def cleanup_synopses(doc, fragment): for node in find_all_elements(fragment, "section"):
def cleanup_synopses(doc): for node in find_all_elements(doc, "section"): create_module_info(doc, node)
080c1b5af693afd471728e7fa66f744a61e75ed4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/080c1b5af693afd471728e7fa66f744a61e75ed4/docfixer.py
"moduleauthor",
"moduleauthor", "indexterm",
def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep))
080c1b5af693afd471728e7fa66f744a61e75ed4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/080c1b5af693afd471728e7fa66f744a61e75ed4/docfixer.py
parent.insertBefore(para, parent.childNodes[start])
nextnode = parent.childNodes[start] if nextnode.nodeType == TEXT: if nextnode.data and nextnode.data[0] != "\n": nextnode.data = "\n" + nextnode.data else: newnode = doc.createTextNode("\n") parent.insertBefore(newnode, nextnode) nextnode = newnode start = start + 1 parent.insertBefore(para, nextnode)
def build_para(doc, parent, start, i): children = parent.childNodes after = start + 1 have_last = 0 BREAK_ELEMENTS = PARA_LEVEL_ELEMENTS + RECURSE_INTO_PARA_CONTAINERS # Collect all children until \n\n+ is found in a text node or a # member of BREAK_ELEMENTS is found. for j in range(start, i): after = j + 1 child = children[j] nodeType = child.nodeType if nodeType == ELEMENT: if child.tagName in BREAK_ELEMENTS: after = j break elif nodeType == TEXT: pos = string.find(child.data, "\n\n") if pos == 0: after = j break if pos >= 1: child.splitText(pos) break else: have_last = 1 if (start + 1) > after: raise ConversionError( "build_para() could not identify content to turn into a paragraph") if children[after - 1].nodeType == TEXT: # we may need to split off trailing white space: child = children[after - 1] data = child.data if string.rstrip(data) != data: have_last = 0 child.splitText(len(string.rstrip(data))) para = doc.createElement(PARA_ELEMENT) prev = None indexes = range(start, after) indexes.reverse() for j in indexes: node = parent.childNodes[j] parent.removeChild(node) para.insertBefore(node, prev) prev = node if have_last: parent.appendChild(para) return len(parent.childNodes) else: parent.insertBefore(para, parent.childNodes[start]) return start + 1
080c1b5af693afd471728e7fa66f744a61e75ed4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/080c1b5af693afd471728e7fa66f744a61e75ed4/docfixer.py
sys.stderr.write("--- fixup_refmodindexes_chunk(%s)\n" % container)
bwrite("--- fixup_refmodindexes_chunk(%s)\n" % container)
def fixup_refmodindexes_chunk(container): # node is probably a <para>; let's see how often it isn't: if container.tagName != PARA_ELEMENT: sys.stderr.write("--- fixup_refmodindexes_chunk(%s)\n" % container) module_entries = find_all_elements(container, "module") if not module_entries: return index_entries = find_all_elements_from_set(container, REFMODINDEX_ELEMENTS) removes = [] for entry in index_entries: children = entry.childNodes if len(children) != 0: sys.stderr.write( "--- unexpected number of children for %s node:\n" % entry.tagName) sys.stderr.write(entry.toxml() + "\n") continue found = 0 module_name = entry.getAttribute("name") for node in module_entries: if len(node.childNodes) != 1: continue this_name = node.childNodes[0].data if this_name == module_name: found = 1 node.setAttribute("index", "index") if found: removes.append(entry) for node in removes: container.removeChild(node)
080c1b5af693afd471728e7fa66f744a61e75ed4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/080c1b5af693afd471728e7fa66f744a61e75ed4/docfixer.py
sys.stderr.write( "--- unexpected number of children for %s node:\n" % entry.tagName) sys.stderr.write(entry.toxml() + "\n")
bwrite("--- unexpected number of children for %s node:\n" % entry.tagName) ewrite(entry.toxml() + "\n")
def fixup_refmodindexes_chunk(container): # node is probably a <para>; let's see how often it isn't: if container.tagName != PARA_ELEMENT: sys.stderr.write("--- fixup_refmodindexes_chunk(%s)\n" % container) module_entries = find_all_elements(container, "module") if not module_entries: return index_entries = find_all_elements_from_set(container, REFMODINDEX_ELEMENTS) removes = [] for entry in index_entries: children = entry.childNodes if len(children) != 0: sys.stderr.write( "--- unexpected number of children for %s node:\n" % entry.tagName) sys.stderr.write(entry.toxml() + "\n") continue found = 0 module_name = entry.getAttribute("name") for node in module_entries: if len(node.childNodes) != 1: continue this_name = node.childNodes[0].data if this_name == module_name: found = 1 node.setAttribute("index", "index") if found: removes.append(entry) for node in removes: container.removeChild(node)
080c1b5af693afd471728e7fa66f744a61e75ed4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/080c1b5af693afd471728e7fa66f744a61e75ed4/docfixer.py
node.setAttribute("index", "index")
node.setAttribute("index", "yes")
def fixup_refmodindexes_chunk(container): # node is probably a <para>; let's see how often it isn't: if container.tagName != PARA_ELEMENT: sys.stderr.write("--- fixup_refmodindexes_chunk(%s)\n" % container) module_entries = find_all_elements(container, "module") if not module_entries: return index_entries = find_all_elements_from_set(container, REFMODINDEX_ELEMENTS) removes = [] for entry in index_entries: children = entry.childNodes if len(children) != 0: sys.stderr.write( "--- unexpected number of children for %s node:\n" % entry.tagName) sys.stderr.write(entry.toxml() + "\n") continue found = 0 module_name = entry.getAttribute("name") for node in module_entries: if len(node.childNodes) != 1: continue this_name = node.childNodes[0].data if this_name == module_name: found = 1 node.setAttribute("index", "index") if found: removes.append(entry) for node in removes: container.removeChild(node)
080c1b5af693afd471728e7fa66f744a61e75ed4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/080c1b5af693afd471728e7fa66f744a61e75ed4/docfixer.py
entries = find_all_elements(container, "bifuncindex") function_entries = find_all_elements(container, "function")
entries = find_all_child_elements(container, "bifuncindex") function_entries = find_all_child_elements(container, "function")
def fixup_bifuncindexes_chunk(container): removes = [] entries = find_all_elements(container, "bifuncindex") function_entries = find_all_elements(container, "function") for entry in entries: function_name = entry.getAttribute("name") found = 0 for func_entry in function_entries: t2 = func_entry.childNodes[0].data if t2[-2:] != "()": continue t2 = t2[:-2] if t2 == function_name: func_entry.setAttribute("index", "index") func_entry.setAttribute("module", "__builtin__") if not found: removes.append(entry) found = 1 for entry in removes: container.removeChild(entry)
080c1b5af693afd471728e7fa66f744a61e75ed4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/080c1b5af693afd471728e7fa66f744a61e75ed4/docfixer.py
func_entry.setAttribute("index", "index")
func_entry.setAttribute("index", "yes")
def fixup_bifuncindexes_chunk(container): removes = [] entries = find_all_elements(container, "bifuncindex") function_entries = find_all_elements(container, "function") for entry in entries: function_name = entry.getAttribute("name") found = 0 for func_entry in function_entries: t2 = func_entry.childNodes[0].data if t2[-2:] != "()": continue t2 = t2[:-2] if t2 == function_name: func_entry.setAttribute("index", "index") func_entry.setAttribute("module", "__builtin__") if not found: removes.append(entry) found = 1 for entry in removes: container.removeChild(entry)
080c1b5af693afd471728e7fa66f744a61e75ed4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/080c1b5af693afd471728e7fa66f744a61e75ed4/docfixer.py
found = 1
def fixup_bifuncindexes_chunk(container): removes = [] entries = find_all_elements(container, "bifuncindex") function_entries = find_all_elements(container, "function") for entry in entries: function_name = entry.getAttribute("name") found = 0 for func_entry in function_entries: t2 = func_entry.childNodes[0].data if t2[-2:] != "()": continue t2 = t2[:-2] if t2 == function_name: func_entry.setAttribute("index", "index") func_entry.setAttribute("module", "__builtin__") if not found: removes.append(entry) found = 1 for entry in removes: container.removeChild(entry)
080c1b5af693afd471728e7fa66f744a61e75ed4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/080c1b5af693afd471728e7fa66f744a61e75ed4/docfixer.py
cleanup_trailing_parens(doc, ["function", "method", "cfunction"]) cleanup_synopses(doc)
cleanup_trailing_parens(fragment, ["function", "method", "cfunction"]) cleanup_synopses(doc, fragment)
def convert(ifp, ofp): p = esistools.ExtendedEsisBuilder() p.feed(ifp.read()) doc = p.document fragment = p.fragment normalize(fragment) simplify(doc, fragment) handle_labels(doc, fragment) handle_appendix(doc, fragment) fixup_trailing_whitespace(doc, { "abstract": "\n", "title": "", "chapter": "\n\n", "section": "\n\n", "subsection": "\n\n", "subsubsection": "\n\n", "paragraph": "\n\n", "subparagraph": "\n\n", }) cleanup_root_text(doc) cleanup_trailing_parens(doc, ["function", "method", "cfunction"]) cleanup_synopses(doc) fixup_descriptors(doc, fragment) fixup_verbatims(fragment) normalize(fragment) fixup_paras(doc, fragment) fixup_sectionauthors(doc, fragment) remap_element_names(fragment, { "tableii": ("table", {"cols": "2"}), "tableiii": ("table", {"cols": "3"}), "tableiv": ("table", {"cols": "4"}), "lineii": ("row", {}), "lineiii": ("row", {}), "lineiv": ("row", {}), "refmodule": ("module", {"link": "link"}), }) fixup_table_structures(doc, fragment) fixup_rfc_references(doc, fragment) fixup_signatures(doc, fragment) add_node_ids(fragment) fixup_refmodindexes(fragment) fixup_bifuncindexes(fragment) # d = {} for gi in p.get_empties(): d[gi] = gi if d.has_key("rfc"): del d["rfc"] knownempty = d.has_key # try: write_esis(fragment, ofp, knownempty) except IOError, (err, msg): # Ignore EPIPE; it just means that whoever we're writing to stopped # reading. The rest of the output would be ignored. All other errors # should still be reported, if err != errno.EPIPE: raise
080c1b5af693afd471728e7fa66f744a61e75ed4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/080c1b5af693afd471728e7fa66f744a61e75ed4/docfixer.py
_tryorder = ["galeon", "skipstone", "mozilla", "netscape",
_tryorder = ["galeon", "skipstone", "mozilla-firefox", "mozilla-firebird", "mozilla", "netscape",
def open_new(self, url): self.open(url)
9a2a1cb031f9149ca6bfaf7b43ae0955d16db9b1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9a2a1cb031f9149ca6bfaf7b43ae0955d16db9b1/webbrowser.py
if _iscommand("mozilla"): register("mozilla", None, Netscape("mozilla")) if _iscommand("netscape"): register("netscape", None, Netscape("netscape"))
for browser in ("mozilla-firefox", "mozilla-firebird", "mozilla", "netscape"): if _iscommand(browser): register(browser, None, Netscape(browser))
def open_new(self, url): self.open(url)
9a2a1cb031f9149ca6bfaf7b43ae0955d16db9b1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9a2a1cb031f9149ca6bfaf7b43ae0955d16db9b1/webbrowser.py
try: port = int(host[i+1:]) except ValueError, msg: raise socket.error, str(msg)
port = int(host[i+1:])
def _set_hostport(self, host, port): if port is None: i = host.find(':') if i >= 0: try: port = int(host[i+1:]) except ValueError, msg: raise socket.error, str(msg) host = host[:i] else: port = self.default_port self.host = host self.port = port
fd97a919ffc075e5704cfd834986bada0f243165 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fd97a919ffc075e5704cfd834986bada0f243165/httplib.py
self.rfile = self.connection.makefile('rb')
self.rfile = self.connection.makefile('rb', 0)
def setup(self):
d804bab721208a8691b554443c8cbf1a8ebb6c2d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d804bab721208a8691b554443c8cbf1a8ebb6c2d/SocketServer.py
if self.libraries is None: self.libraries = [] if self.library_dirs is None: self.library_dirs = [] if self.rpath is None: self.rpath = [] if os.name == 'nt': self.library_dirs.append (os.path.join(sys.exec_prefix, 'libs')) if self.debug: self.build_temp = os.path.join (self.build_temp, "Debug") else: self.build_temp = os.path.join (self.build_temp, "Release")
def finalize_options (self): from distutils import sysconfig
842296480e80873de5f5042da42533044a9586dd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/842296480e80873de5f5042da42533044a9586dd/build_ext.py
if self.libraries is None: self.libraries = [] if self.library_dirs is None: self.library_dirs = [] if self.rpath is None: self.rpath = []
def run (self):
842296480e80873de5f5042da42533044a9586dd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/842296480e80873de5f5042da42533044a9586dd/build_ext.py