rem
stringlengths 1
322k
| add
stringlengths 0
2.05M
| context
stringlengths 4
228k
| meta
stringlengths 156
215
|
---|---|---|---|
if not os.path.exists (dest): self.execute (os.link, (file, dest), "linking %s -> %s" % (file, dest)) | if link: if not os.path.exists (dest): self.execute (os.link, (file, dest), "linking %s -> %s" % (file, dest)) else: self.copy_file (file, dest) | def make_release_tree (self, base_dir, files): | 295279b0a41fae4e77cc443c4f7827918bfcba06 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/295279b0a41fae4e77cc443c4f7827918bfcba06/dist.py |
("unable to create zip file '%s.zip':" + | ("unable to create zip file '%s.zip': " + | def make_zipfile (self, base_dir): | 295279b0a41fae4e77cc443c4f7827918bfcba06 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/295279b0a41fae4e77cc443c4f7827918bfcba06/dist.py |
def buildapplet(top, dummy, list): """Create python applets""" template = buildtools.findtemplate() for src, dst in list: if src[-3:] != '.py': raise 'Should end in .py', src base = os.path.basename(src) #dst = os.path.join(top, base)[:-3] src = os.path.join(top, src) dst = os.path.join(top, dst) try: os.unlink(dst) except os.error: pass print 'Building applet', dst buildtools.process(template, src, dst, 1) | 3c23d163ab1b2d840df29822c807dfeaa07fcc9f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3c23d163ab1b2d840df29822c807dfeaa07fcc9f/fullbuild.py |
||
class Konquerer: """Controller for the KDE File Manager (kfm, or Konquerer). | class Konqueror: """Controller for the KDE File Manager (kfm, or Konqueror). | def open_new(self, url): self._remote("openURL(%s, new-window)" % url) | e02b2141ab57f5cdbf02e7a6b55b4eea9e97da84 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e02b2141ab57f5cdbf02e7a6b55b4eea9e97da84/webbrowser.py |
for more information on the Konquerer remote-control interface. | for more information on the Konqueror remote-control interface. | def open_new(self, url): self._remote("openURL(%s, new-window)" % url) | e02b2141ab57f5cdbf02e7a6b55b4eea9e97da84 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e02b2141ab57f5cdbf02e7a6b55b4eea9e97da84/webbrowser.py |
register("kfm", Konquerer) | register("kfm", Konqueror) | def open_new(self, url): self._remote("openURL %s" % url) | e02b2141ab57f5cdbf02e7a6b55b4eea9e97da84 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e02b2141ab57f5cdbf02e7a6b55b4eea9e97da84/webbrowser.py |
self.unixsocket = 1 | def __init__(self, address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER): """ Initialize a handler. | 5fdf48b9a69b627138e98658c92a55390a4c30af /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5fdf48b9a69b627138e98658c92a55390a4c30af/handlers.py |
|
self.unixsocket = 0 | def __init__(self, address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER): """ Initialize a handler. | 5fdf48b9a69b627138e98658c92a55390a4c30af /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5fdf48b9a69b627138e98658c92a55390a4c30af/handlers.py |
|
if not os.isatty(slave_fd): raise TestFailed, "slave_fd is not a tty" | def debug(msg): pass | 17672c56a052cdccc89073dd74a15562a29d6d6e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/17672c56a052cdccc89073dd74a15562a29d6d6e/test_pty.py |
|
args['compiler_so'] = compiler | (ccshared,) = sysconfig.get_config_vars('CCSHARED') args['compiler_so'] = compiler + ' ' + ccshared | def build_extensions(self): | 6f3eef26d04c75653b53d64224391072222b0d07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6f3eef26d04c75653b53d64224391072222b0d07/setup.py |
self.temp_files.append(prog) | def _link (self, body, headers, include_dirs, libraries, library_dirs, lang): (src, obj) = self._compile(body, headers, include_dirs, lang) prog = os.path.splitext(os.path.basename(src))[0] self.temp_files.append(prog) # XXX should be prog + exe_ext self.compiler.link_executable([obj], prog, libraries=libraries, library_dirs=library_dirs) return (src, obj, prog) | 35d55aa44505fc3fe326d00a510c1a6022c363a7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/35d55aa44505fc3fe326d00a510c1a6022c363a7/config.py |
|
self.openedurl = '%s:%s' % (type, url) | def open(self, fullurl, data=None): fullurl = unwrap(fullurl) if self.tempcache and self.tempcache.has_key(fullurl): filename, headers = self.tempcache[fullurl] fp = open(filename, 'rb') return addinfourl(fp, headers, fullurl) type, url = splittype(fullurl) if not type: type = 'file' self.openedurl = '%s:%s' % (type, url) if self.proxies.has_key(type): proxy = self.proxies[type] type, proxy = splittype(proxy) host, selector = splithost(proxy) url = (host, fullurl) # Signal special case to open_*() name = 'open_' + type if '-' in name: # replace - with _ name = string.join(string.split(name, '-'), '_') if not hasattr(self, name): if data is None: return self.open_unknown(fullurl) else: return self.open_unknown(fullurl, data) try: if data is None: return getattr(self, name)(url) else: return getattr(self, name)(url, data) except socket.error, msg: raise IOError, ('socket error', msg), sys.exc_info()[2] | d235b035f3ba4a205107a167f09c5b3e3927e6f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d235b035f3ba4a205107a167f09c5b3e3927e6f5/urllib.py |
|
self.openedurl = url | def retrieve(self, url, filename=None): url = unwrap(url) self.openedurl = url if self.tempcache and self.tempcache.has_key(url): return self.tempcache[url] type, url1 = splittype(url) if not filename and (not type or type == 'file'): try: fp = self.open_local_file(url1) del fp return url2pathname(splithost(url1)[1]), None except IOError, msg: pass fp = self.open(url) headers = fp.info() if not filename: import tempfile filename = tempfile.mktemp() self.__tempfiles.append(filename) result = filename, headers if self.tempcache is not None: self.tempcache[url] = result tfp = open(filename, 'wb') bs = 1024*8 block = fp.read(bs) while block: tfp.write(block) block = fp.read(bs) fp.close() tfp.close() del fp del tfp return result | d235b035f3ba4a205107a167f09c5b3e3927e6f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d235b035f3ba4a205107a167f09c5b3e3927e6f5/urllib.py |
|
return addinfourl(fp, headers, self.openedurl) | return addinfourl(fp, headers, "http:" + url) | def open_http(self, url, data=None): import httplib if type(url) is type(""): host, selector = splithost(url) user_passwd, host = splituser(host) realhost = host else: host, selector = url urltype, rest = splittype(selector) user_passwd = None if string.lower(urltype) != 'http': realhost = None else: realhost, rest = splithost(rest) user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) #print "proxy via http:", host, selector if not host: raise IOError, ('http error', 'no host given') if user_passwd: import base64 auth = string.strip(base64.encodestring(user_passwd)) else: auth = None h = httplib.HTTP(host) if data is not None: h.putrequest('POST', selector) h.putheader('Content-type', 'application/x-www-form-urlencoded') h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', selector) if auth: h.putheader('Authorization', 'Basic %s' % auth) if realhost: h.putheader('Host', realhost) for args in self.addheaders: apply(h.putheader, args) h.endheaders() if data is not None: h.send(data + '\r\n') errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, self.openedurl) else: return self.http_error(url, fp, errcode, errmsg, headers) | d235b035f3ba4a205107a167f09c5b3e3927e6f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d235b035f3ba4a205107a167f09c5b3e3927e6f5/urllib.py |
return addinfourl(fp, noheaders(), self.openedurl) | return addinfourl(fp, noheaders(), "gopher:" + url) | def open_gopher(self, url): import gopherlib host, selector = splithost(url) if not host: raise IOError, ('gopher error', 'no host given') type, selector = splitgophertype(selector) selector, query = splitquery(selector) selector = unquote(selector) if query: query = unquote(query) fp = gopherlib.send_query(selector, query, host) else: fp = gopherlib.send_selector(selector, host) return addinfourl(fp, noheaders(), self.openedurl) | d235b035f3ba4a205107a167f09c5b3e3927e6f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d235b035f3ba4a205107a167f09c5b3e3927e6f5/urllib.py |
ftpwrapper(user, passwd, host, port, dirs) | ftpwrapper(user, passwd, host, port, dirs) | def open_ftp(self, url): host, path = splithost(url) if not host: raise IOError, ('ftp error', 'no host given') host, port = splitport(host) user, host = splituser(host) if user: user, passwd = splitpasswd(user) else: passwd = None host = socket.gethostbyname(host) if not port: import ftplib port = ftplib.FTP_PORT else: port = int(port) path, attrs = splitattr(path) dirs = string.splitfields(path, '/') dirs, file = dirs[:-1], dirs[-1] if dirs and not dirs[0]: dirs = dirs[1:] key = (user, host, port, string.joinfields(dirs, '/')) if len(self.ftpcache) > MAXFTPCACHE: # Prune the cache, rather arbitrarily for k in self.ftpcache.keys(): if k != key: v = self.ftpcache[k] del self.ftpcache[k] v.close() try: if not self.ftpcache.has_key(key): self.ftpcache[key] = \ ftpwrapper(user, passwd, host, port, dirs) if not file: type = 'D' else: type = 'I' for attr in attrs: attr, value = splitvalue(attr) if string.lower(attr) == 'type' and \ value in ('a', 'A', 'i', 'I', 'd', 'D'): type = string.upper(value) return addinfourl( self.ftpcache[key].retrfile(file, type), noheaders(), self.openedurl) except ftperrors(), msg: raise IOError, ('ftp error', msg), sys.exc_info()[2] | d235b035f3ba4a205107a167f09c5b3e3927e6f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d235b035f3ba4a205107a167f09c5b3e3927e6f5/urllib.py |
noheaders(), self.openedurl) | noheaders(), "ftp:" + url) | def open_ftp(self, url): host, path = splithost(url) if not host: raise IOError, ('ftp error', 'no host given') host, port = splitport(host) user, host = splituser(host) if user: user, passwd = splitpasswd(user) else: passwd = None host = socket.gethostbyname(host) if not port: import ftplib port = ftplib.FTP_PORT else: port = int(port) path, attrs = splitattr(path) dirs = string.splitfields(path, '/') dirs, file = dirs[:-1], dirs[-1] if dirs and not dirs[0]: dirs = dirs[1:] key = (user, host, port, string.joinfields(dirs, '/')) if len(self.ftpcache) > MAXFTPCACHE: # Prune the cache, rather arbitrarily for k in self.ftpcache.keys(): if k != key: v = self.ftpcache[k] del self.ftpcache[k] v.close() try: if not self.ftpcache.has_key(key): self.ftpcache[key] = \ ftpwrapper(user, passwd, host, port, dirs) if not file: type = 'D' else: type = 'I' for attr in attrs: attr, value = splitvalue(attr) if string.lower(attr) == 'type' and \ value in ('a', 'A', 'i', 'I', 'd', 'D'): type = string.upper(value) return addinfourl( self.ftpcache[key].retrfile(file, type), noheaders(), self.openedurl) except ftperrors(), msg: raise IOError, ('ftp error', msg), sys.exc_info()[2] | d235b035f3ba4a205107a167f09c5b3e3927e6f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d235b035f3ba4a205107a167f09c5b3e3927e6f5/urllib.py |
return addinfourl(fp, headers, self.openedurl) | return addinfourl(fp, headers, "http:" + url) | def http_error_default(self, url, fp, errcode, errmsg, headers): return addinfourl(fp, headers, self.openedurl) | d235b035f3ba4a205107a167f09c5b3e3927e6f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d235b035f3ba4a205107a167f09c5b3e3927e6f5/urllib.py |
log.warn(("warngin: no files found matching '%s' " + | log.warn(("warning: no files found matching '%s' " + | def process_template_line (self, line): | 615687d879e8110b4414e99d5fbeb52a96276b9f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/615687d879e8110b4414e99d5fbeb52a96276b9f/filelist.py |
self.lineno = self.lineno + string.count(rawdata[i:i], '\n') | self.lineno = self.lineno + string.count(rawdata[i:k], '\n') | def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: if i > 0: self.__at_start = 0 if self.nomoretags: data = rawdata[i:n] self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = n break res = interesting.search(rawdata, i) if res: j = res.start(0) else: j = n if i < j: data = rawdata[i:j] if self.__at_start and space.match(data) is None: self.syntax_error('illegal data at start of file') self.__at_start = 0 if not self.stack and space.match(data) is None: self.syntax_error('data not in content') if not self.__accept_utf8 and illegal.search(data): self.syntax_error('illegal character in content') self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = j if i == n: break if rawdata[i] == '<': if starttagopen.match(rawdata, i): if self.literal: data = rawdata[i] self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = i+1 continue k = self.parse_starttag(i) if k < 0: break self.__seen_starttag = 1 self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue if endtagopen.match(rawdata, i): k = self.parse_endtag(i) if k < 0: break self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue if commentopen.match(rawdata, i): if self.literal: data = rawdata[i] self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = i+1 continue k = self.parse_comment(i) if k < 0: break self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue if cdataopen.match(rawdata, i): k = self.parse_cdata(i) if k < 0: break self.lineno = self.lineno + string.count(rawdata[i:i], '\n') i = k continue res = xmldecl.match(rawdata, i) if res: if not self.__at_start: self.syntax_error("<?xml?> declaration not at start of document") version, encoding, standalone = res.group('version', 'encoding', 'standalone') if version[1:-1] != '1.0': raise RuntimeError, 'only XML version 1.0 supported' if encoding: encoding = encoding[1:-1] if standalone: standalone = standalone[1:-1] self.handle_xml(encoding, standalone) i = res.end(0) continue res = procopen.match(rawdata, i) if res: k = self.parse_proc(i) if k < 0: break self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue res = doctype.match(rawdata, i) if res: if self.literal: data = rawdata[i] self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = i+1 continue if self.__seen_doctype: self.syntax_error('multiple DOCTYPE elements') if self.__seen_starttag: self.syntax_error('DOCTYPE not at beginning of document') k = self.parse_doctype(res) if k < 0: break self.__seen_doctype = res.group('name') if self.__map_case: self.__seen_doctype = string.lower(self.__seen_doctype) self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue elif rawdata[i] == '&': if self.literal: data = rawdata[i] self.handle_data(data) i = i+1 continue res = charref.match(rawdata, i) if res is not None: i = res.end(0) if rawdata[i-1] != ';': self.syntax_error("`;' missing in charref") i = i-1 if not self.stack: self.syntax_error('data not in content') self.handle_charref(res.group('char')[:-1]) self.lineno = self.lineno + string.count(res.group(0), '\n') continue res = entityref.match(rawdata, i) if res is not None: i = res.end(0) if rawdata[i-1] != ';': self.syntax_error("`;' missing in entityref") i = i-1 name = res.group('name') if self.__map_case: name = string.lower(name) if self.entitydefs.has_key(name): self.rawdata = rawdata = rawdata[:res.start(0)] + self.entitydefs[name] + rawdata[i:] n = len(rawdata) i = res.start(0) else: self.unknown_entityref(name) self.lineno = self.lineno + string.count(res.group(0), '\n') continue elif rawdata[i] == ']': if self.literal: data = rawdata[i] self.handle_data(data) i = i+1 continue if n-i < 3: break if cdataclose.match(rawdata, i): self.syntax_error("bogus `]]>'") self.handle_data(rawdata[i]) i = i+1 continue else: raise RuntimeError, 'neither < nor & ??' # We get here only if incomplete matches but # nothing else break # end while if i > 0: self.__at_start = 0 if end and i < n: data = rawdata[i] self.syntax_error("bogus `%s'" % data) if not self.__accept_utf8 and illegal.search(data): self.syntax_error('illegal character in content') self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') self.rawdata = rawdata[i+1:] return self.goahead(end) self.rawdata = rawdata[i:] if end: if not self.__seen_starttag: self.syntax_error('no elements in file') if self.stack: self.syntax_error('missing end tags') while self.stack: self.finish_endtag(self.stack[-1][0]) | 4ff63fb625144f23bffc0b05ca082a326f91bd4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4ff63fb625144f23bffc0b05ca082a326f91bd4a/xmllib.py |
method = self.elements.get(tag, (None, None))[1] if method is not None: self.handle_endtag(tag, method) else: self.unknown_endtag(tag) | def finish_endtag(self, tag): if not tag: self.syntax_error('name-less end tag') found = len(self.stack) - 1 if found < 0: self.unknown_endtag(tag) return else: found = -1 for i in range(len(self.stack)): if tag == self.stack[i][0]: found = i if found == -1: self.syntax_error('unopened end tag') method = self.elements.get(tag, (None, None))[1] if method is not None: self.handle_endtag(tag, method) else: self.unknown_endtag(tag) return while len(self.stack) > found: if found < len(self.stack) - 1: self.syntax_error('missing close tag for %s' % self.stack[-1][2]) nstag = self.stack[-1][2] method = self.elements.get(nstag, (None, None))[1] if method is not None: self.handle_endtag(nstag, method) else: self.unknown_endtag(nstag) if self.__use_namespaces == len(self.stack): self.__use_namespaces = 0 del self.stack[-1] | 4ff63fb625144f23bffc0b05ca082a326f91bd4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4ff63fb625144f23bffc0b05ca082a326f91bd4a/xmllib.py |
|
def maketables(): | def maketables(trace=0): | def maketables(): unicode = UnicodeData(UNICODE_DATA) # extract unicode properties dummy = (0, 0, 0, 0) table = [dummy] cache = {0: dummy} index = [0] * len(unicode.chars) # 1) database properties for char in unicode.chars: record = unicode.table[char] if record: # extract database properties category = CATEGORY_NAMES.index(record[2]) combining = int(record[3]) bidirectional = BIDIRECTIONAL_NAMES.index(record[4]) mirrored = record[9] == "Y" item = ( category, combining, bidirectional, mirrored ) # add entry to index and item tables i = cache.get(item) if i is None: cache[item] = i = len(table) table.append(item) index[char] = i # 2) decomposition data # FIXME: <fl> using the encoding stuff from unidb would save # another 50k or so, but I'll leave that for 2.1... decomp_data = [""] decomp_index = [0] * len(unicode.chars) for char in unicode.chars: record = unicode.table[char] if record: if record[5]: try: i = decomp_data.index(record[5]) except ValueError: i = len(decomp_data) decomp_data.append(record[5]) else: i = 0 decomp_index[char] = i FILE = "Modules/unicodedata_db.h" fp = open(FILE, "w") print >>fp, "/* this file was generated by %s %s */" % (SCRIPT, VERSION) print >>fp print >>fp, "/* a list of unique database records */" print >>fp, \ "const _PyUnicode_DatabaseRecord _PyUnicode_Database_Records[] = {" for item in table: print >>fp, " {%d, %d, %d, %d}," % item print >>fp, "};" print >>fp # FIXME: the following tables should be made static, and # the support code moved into unicodedatabase.c print >>fp, "/* string literals */" print >>fp, "const char *_PyUnicode_CategoryNames[] = {" for name in CATEGORY_NAMES: print >>fp, " \"%s\"," % name print >>fp, " NULL" print >>fp, "};" print >>fp, "const char *_PyUnicode_BidirectionalNames[] = {" for name in BIDIRECTIONAL_NAMES: print >>fp, " \"%s\"," % name print >>fp, " NULL" print >>fp, "};" print >>fp, "static const char *decomp_data[] = {" for name in decomp_data: print >>fp, " \"%s\"," % name print >>fp, " NULL" print >>fp, "};" # split record index table index1, index2, shift = splitbins(index) print >>fp, "/* index tables for the database records */" print >>fp, "#define SHIFT", shift Array("index1", index1).dump(fp) Array("index2", index2).dump(fp) # split decomposition index table index1, index2, shift = splitbins(decomp_index) print >>fp, "/* index tables for the decomposition data */" print >>fp, "#define DECOMP_SHIFT", shift Array("decomp_index1", index1).dump(fp) Array("decomp_index2", index2).dump(fp) # # 3) unicode type data # extract unicode types dummy = (0, 0, 0, 0, 0, 0) table = [dummy] cache = {0: dummy} index = [0] * len(unicode.chars) for char in unicode.chars: record = unicode.table[char] if record: # extract database properties category = record[2] bidirectional = record[4] flags = 0 if category in ["Lm", "Lt", "Lu", "Ll", "Lo"]: flags |= ALPHA_MASK if category == "Ll": flags |= LOWER_MASK if category == "Zl" or bidirectional == "B": flags |= LINEBREAK_MASK if category == "Zs" or bidirectional in ("WS", "B", "S"): flags |= SPACE_MASK if category == "Lt": flags |= TITLE_MASK if category == "Lu": flags |= UPPER_MASK # use delta predictor for upper/lower/title if record[12]: upper = (int(record[12], 16) - char) & 0xffff else: upper = 0 if record[13]: lower = (int(record[13], 16) - char) & 0xffff else: lower = 0 if record[14]: title = (int(record[14], 16) - char) & 0xffff else: title = 0 # decimal digit, integer digit decimal = 0 if record[6]: flags |= DECIMAL_MASK decimal = int(record[6]) digit = 0 if record[7]: flags |= DIGIT_MASK digit = int(record[7]) item = ( flags, upper, lower, title, decimal, digit ) # add entry to index and item tables i = cache.get(item) if i is None: cache[item] = i = len(table) table.append(item) index[char] = i print len(table), "ctype entries" FILE = "Objects/unicodetype_db.h" fp = open(FILE, "w") print >>fp, "/* this file was generated by %s %s */" % (SCRIPT, VERSION) print >>fp print >>fp, "/* a list of unique character type descriptors */" print >>fp, "const _PyUnicode_TypeRecord _PyUnicode_TypeRecords[] = {" for item in table: print >>fp, " {%d, %d, %d, %d, %d, %d}," % item print >>fp, "};" print >>fp # split decomposition index table index1, index2, shift = splitbins(index) print >>fp, "/* type indexes */" print >>fp, "#define SHIFT", shift Array("index1", index1).dump(fp) Array("index2", index2).dump(fp) | f70c0d142ca2d51d6b27a5b66866f40595929c59 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f70c0d142ca2d51d6b27a5b66866f40595929c59/makeunicodedata.py |
index1, index2, shift = splitbins(index) | index1, index2, shift = splitbins(index, trace) | def maketables(): unicode = UnicodeData(UNICODE_DATA) # extract unicode properties dummy = (0, 0, 0, 0) table = [dummy] cache = {0: dummy} index = [0] * len(unicode.chars) # 1) database properties for char in unicode.chars: record = unicode.table[char] if record: # extract database properties category = CATEGORY_NAMES.index(record[2]) combining = int(record[3]) bidirectional = BIDIRECTIONAL_NAMES.index(record[4]) mirrored = record[9] == "Y" item = ( category, combining, bidirectional, mirrored ) # add entry to index and item tables i = cache.get(item) if i is None: cache[item] = i = len(table) table.append(item) index[char] = i # 2) decomposition data # FIXME: <fl> using the encoding stuff from unidb would save # another 50k or so, but I'll leave that for 2.1... decomp_data = [""] decomp_index = [0] * len(unicode.chars) for char in unicode.chars: record = unicode.table[char] if record: if record[5]: try: i = decomp_data.index(record[5]) except ValueError: i = len(decomp_data) decomp_data.append(record[5]) else: i = 0 decomp_index[char] = i FILE = "Modules/unicodedata_db.h" fp = open(FILE, "w") print >>fp, "/* this file was generated by %s %s */" % (SCRIPT, VERSION) print >>fp print >>fp, "/* a list of unique database records */" print >>fp, \ "const _PyUnicode_DatabaseRecord _PyUnicode_Database_Records[] = {" for item in table: print >>fp, " {%d, %d, %d, %d}," % item print >>fp, "};" print >>fp # FIXME: the following tables should be made static, and # the support code moved into unicodedatabase.c print >>fp, "/* string literals */" print >>fp, "const char *_PyUnicode_CategoryNames[] = {" for name in CATEGORY_NAMES: print >>fp, " \"%s\"," % name print >>fp, " NULL" print >>fp, "};" print >>fp, "const char *_PyUnicode_BidirectionalNames[] = {" for name in BIDIRECTIONAL_NAMES: print >>fp, " \"%s\"," % name print >>fp, " NULL" print >>fp, "};" print >>fp, "static const char *decomp_data[] = {" for name in decomp_data: print >>fp, " \"%s\"," % name print >>fp, " NULL" print >>fp, "};" # split record index table index1, index2, shift = splitbins(index) print >>fp, "/* index tables for the database records */" print >>fp, "#define SHIFT", shift Array("index1", index1).dump(fp) Array("index2", index2).dump(fp) # split decomposition index table index1, index2, shift = splitbins(decomp_index) print >>fp, "/* index tables for the decomposition data */" print >>fp, "#define DECOMP_SHIFT", shift Array("decomp_index1", index1).dump(fp) Array("decomp_index2", index2).dump(fp) # # 3) unicode type data # extract unicode types dummy = (0, 0, 0, 0, 0, 0) table = [dummy] cache = {0: dummy} index = [0] * len(unicode.chars) for char in unicode.chars: record = unicode.table[char] if record: # extract database properties category = record[2] bidirectional = record[4] flags = 0 if category in ["Lm", "Lt", "Lu", "Ll", "Lo"]: flags |= ALPHA_MASK if category == "Ll": flags |= LOWER_MASK if category == "Zl" or bidirectional == "B": flags |= LINEBREAK_MASK if category == "Zs" or bidirectional in ("WS", "B", "S"): flags |= SPACE_MASK if category == "Lt": flags |= TITLE_MASK if category == "Lu": flags |= UPPER_MASK # use delta predictor for upper/lower/title if record[12]: upper = (int(record[12], 16) - char) & 0xffff else: upper = 0 if record[13]: lower = (int(record[13], 16) - char) & 0xffff else: lower = 0 if record[14]: title = (int(record[14], 16) - char) & 0xffff else: title = 0 # decimal digit, integer digit decimal = 0 if record[6]: flags |= DECIMAL_MASK decimal = int(record[6]) digit = 0 if record[7]: flags |= DIGIT_MASK digit = int(record[7]) item = ( flags, upper, lower, title, decimal, digit ) # add entry to index and item tables i = cache.get(item) if i is None: cache[item] = i = len(table) table.append(item) index[char] = i print len(table), "ctype entries" FILE = "Objects/unicodetype_db.h" fp = open(FILE, "w") print >>fp, "/* this file was generated by %s %s */" % (SCRIPT, VERSION) print >>fp print >>fp, "/* a list of unique character type descriptors */" print >>fp, "const _PyUnicode_TypeRecord _PyUnicode_TypeRecords[] = {" for item in table: print >>fp, " {%d, %d, %d, %d, %d, %d}," % item print >>fp, "};" print >>fp # split decomposition index table index1, index2, shift = splitbins(index) print >>fp, "/* type indexes */" print >>fp, "#define SHIFT", shift Array("index1", index1).dump(fp) Array("index2", index2).dump(fp) | f70c0d142ca2d51d6b27a5b66866f40595929c59 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f70c0d142ca2d51d6b27a5b66866f40595929c59/makeunicodedata.py |
index1, index2, shift = splitbins(decomp_index) | index1, index2, shift = splitbins(decomp_index, trace) | def maketables(): unicode = UnicodeData(UNICODE_DATA) # extract unicode properties dummy = (0, 0, 0, 0) table = [dummy] cache = {0: dummy} index = [0] * len(unicode.chars) # 1) database properties for char in unicode.chars: record = unicode.table[char] if record: # extract database properties category = CATEGORY_NAMES.index(record[2]) combining = int(record[3]) bidirectional = BIDIRECTIONAL_NAMES.index(record[4]) mirrored = record[9] == "Y" item = ( category, combining, bidirectional, mirrored ) # add entry to index and item tables i = cache.get(item) if i is None: cache[item] = i = len(table) table.append(item) index[char] = i # 2) decomposition data # FIXME: <fl> using the encoding stuff from unidb would save # another 50k or so, but I'll leave that for 2.1... decomp_data = [""] decomp_index = [0] * len(unicode.chars) for char in unicode.chars: record = unicode.table[char] if record: if record[5]: try: i = decomp_data.index(record[5]) except ValueError: i = len(decomp_data) decomp_data.append(record[5]) else: i = 0 decomp_index[char] = i FILE = "Modules/unicodedata_db.h" fp = open(FILE, "w") print >>fp, "/* this file was generated by %s %s */" % (SCRIPT, VERSION) print >>fp print >>fp, "/* a list of unique database records */" print >>fp, \ "const _PyUnicode_DatabaseRecord _PyUnicode_Database_Records[] = {" for item in table: print >>fp, " {%d, %d, %d, %d}," % item print >>fp, "};" print >>fp # FIXME: the following tables should be made static, and # the support code moved into unicodedatabase.c print >>fp, "/* string literals */" print >>fp, "const char *_PyUnicode_CategoryNames[] = {" for name in CATEGORY_NAMES: print >>fp, " \"%s\"," % name print >>fp, " NULL" print >>fp, "};" print >>fp, "const char *_PyUnicode_BidirectionalNames[] = {" for name in BIDIRECTIONAL_NAMES: print >>fp, " \"%s\"," % name print >>fp, " NULL" print >>fp, "};" print >>fp, "static const char *decomp_data[] = {" for name in decomp_data: print >>fp, " \"%s\"," % name print >>fp, " NULL" print >>fp, "};" # split record index table index1, index2, shift = splitbins(index) print >>fp, "/* index tables for the database records */" print >>fp, "#define SHIFT", shift Array("index1", index1).dump(fp) Array("index2", index2).dump(fp) # split decomposition index table index1, index2, shift = splitbins(decomp_index) print >>fp, "/* index tables for the decomposition data */" print >>fp, "#define DECOMP_SHIFT", shift Array("decomp_index1", index1).dump(fp) Array("decomp_index2", index2).dump(fp) # # 3) unicode type data # extract unicode types dummy = (0, 0, 0, 0, 0, 0) table = [dummy] cache = {0: dummy} index = [0] * len(unicode.chars) for char in unicode.chars: record = unicode.table[char] if record: # extract database properties category = record[2] bidirectional = record[4] flags = 0 if category in ["Lm", "Lt", "Lu", "Ll", "Lo"]: flags |= ALPHA_MASK if category == "Ll": flags |= LOWER_MASK if category == "Zl" or bidirectional == "B": flags |= LINEBREAK_MASK if category == "Zs" or bidirectional in ("WS", "B", "S"): flags |= SPACE_MASK if category == "Lt": flags |= TITLE_MASK if category == "Lu": flags |= UPPER_MASK # use delta predictor for upper/lower/title if record[12]: upper = (int(record[12], 16) - char) & 0xffff else: upper = 0 if record[13]: lower = (int(record[13], 16) - char) & 0xffff else: lower = 0 if record[14]: title = (int(record[14], 16) - char) & 0xffff else: title = 0 # decimal digit, integer digit decimal = 0 if record[6]: flags |= DECIMAL_MASK decimal = int(record[6]) digit = 0 if record[7]: flags |= DIGIT_MASK digit = int(record[7]) item = ( flags, upper, lower, title, decimal, digit ) # add entry to index and item tables i = cache.get(item) if i is None: cache[item] = i = len(table) table.append(item) index[char] = i print len(table), "ctype entries" FILE = "Objects/unicodetype_db.h" fp = open(FILE, "w") print >>fp, "/* this file was generated by %s %s */" % (SCRIPT, VERSION) print >>fp print >>fp, "/* a list of unique character type descriptors */" print >>fp, "const _PyUnicode_TypeRecord _PyUnicode_TypeRecords[] = {" for item in table: print >>fp, " {%d, %d, %d, %d, %d, %d}," % item print >>fp, "};" print >>fp # split decomposition index table index1, index2, shift = splitbins(index) print >>fp, "/* type indexes */" print >>fp, "#define SHIFT", shift Array("index1", index1).dump(fp) Array("index2", index2).dump(fp) | f70c0d142ca2d51d6b27a5b66866f40595929c59 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f70c0d142ca2d51d6b27a5b66866f40595929c59/makeunicodedata.py |
print len(table), "ctype entries" | def maketables(): unicode = UnicodeData(UNICODE_DATA) # extract unicode properties dummy = (0, 0, 0, 0) table = [dummy] cache = {0: dummy} index = [0] * len(unicode.chars) # 1) database properties for char in unicode.chars: record = unicode.table[char] if record: # extract database properties category = CATEGORY_NAMES.index(record[2]) combining = int(record[3]) bidirectional = BIDIRECTIONAL_NAMES.index(record[4]) mirrored = record[9] == "Y" item = ( category, combining, bidirectional, mirrored ) # add entry to index and item tables i = cache.get(item) if i is None: cache[item] = i = len(table) table.append(item) index[char] = i # 2) decomposition data # FIXME: <fl> using the encoding stuff from unidb would save # another 50k or so, but I'll leave that for 2.1... decomp_data = [""] decomp_index = [0] * len(unicode.chars) for char in unicode.chars: record = unicode.table[char] if record: if record[5]: try: i = decomp_data.index(record[5]) except ValueError: i = len(decomp_data) decomp_data.append(record[5]) else: i = 0 decomp_index[char] = i FILE = "Modules/unicodedata_db.h" fp = open(FILE, "w") print >>fp, "/* this file was generated by %s %s */" % (SCRIPT, VERSION) print >>fp print >>fp, "/* a list of unique database records */" print >>fp, \ "const _PyUnicode_DatabaseRecord _PyUnicode_Database_Records[] = {" for item in table: print >>fp, " {%d, %d, %d, %d}," % item print >>fp, "};" print >>fp # FIXME: the following tables should be made static, and # the support code moved into unicodedatabase.c print >>fp, "/* string literals */" print >>fp, "const char *_PyUnicode_CategoryNames[] = {" for name in CATEGORY_NAMES: print >>fp, " \"%s\"," % name print >>fp, " NULL" print >>fp, "};" print >>fp, "const char *_PyUnicode_BidirectionalNames[] = {" for name in BIDIRECTIONAL_NAMES: print >>fp, " \"%s\"," % name print >>fp, " NULL" print >>fp, "};" print >>fp, "static const char *decomp_data[] = {" for name in decomp_data: print >>fp, " \"%s\"," % name print >>fp, " NULL" print >>fp, "};" # split record index table index1, index2, shift = splitbins(index) print >>fp, "/* index tables for the database records */" print >>fp, "#define SHIFT", shift Array("index1", index1).dump(fp) Array("index2", index2).dump(fp) # split decomposition index table index1, index2, shift = splitbins(decomp_index) print >>fp, "/* index tables for the decomposition data */" print >>fp, "#define DECOMP_SHIFT", shift Array("decomp_index1", index1).dump(fp) Array("decomp_index2", index2).dump(fp) # # 3) unicode type data # extract unicode types dummy = (0, 0, 0, 0, 0, 0) table = [dummy] cache = {0: dummy} index = [0] * len(unicode.chars) for char in unicode.chars: record = unicode.table[char] if record: # extract database properties category = record[2] bidirectional = record[4] flags = 0 if category in ["Lm", "Lt", "Lu", "Ll", "Lo"]: flags |= ALPHA_MASK if category == "Ll": flags |= LOWER_MASK if category == "Zl" or bidirectional == "B": flags |= LINEBREAK_MASK if category == "Zs" or bidirectional in ("WS", "B", "S"): flags |= SPACE_MASK if category == "Lt": flags |= TITLE_MASK if category == "Lu": flags |= UPPER_MASK # use delta predictor for upper/lower/title if record[12]: upper = (int(record[12], 16) - char) & 0xffff else: upper = 0 if record[13]: lower = (int(record[13], 16) - char) & 0xffff else: lower = 0 if record[14]: title = (int(record[14], 16) - char) & 0xffff else: title = 0 # decimal digit, integer digit decimal = 0 if record[6]: flags |= DECIMAL_MASK decimal = int(record[6]) digit = 0 if record[7]: flags |= DIGIT_MASK digit = int(record[7]) item = ( flags, upper, lower, title, decimal, digit ) # add entry to index and item tables i = cache.get(item) if i is None: cache[item] = i = len(table) table.append(item) index[char] = i print len(table), "ctype entries" FILE = "Objects/unicodetype_db.h" fp = open(FILE, "w") print >>fp, "/* this file was generated by %s %s */" % (SCRIPT, VERSION) print >>fp print >>fp, "/* a list of unique character type descriptors */" print >>fp, "const _PyUnicode_TypeRecord _PyUnicode_TypeRecords[] = {" for item in table: print >>fp, " {%d, %d, %d, %d, %d, %d}," % item print >>fp, "};" print >>fp # split decomposition index table index1, index2, shift = splitbins(index) print >>fp, "/* type indexes */" print >>fp, "#define SHIFT", shift Array("index1", index1).dump(fp) Array("index2", index2).dump(fp) | f70c0d142ca2d51d6b27a5b66866f40595929c59 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f70c0d142ca2d51d6b27a5b66866f40595929c59/makeunicodedata.py |
|
index1, index2, shift = splitbins(index) | index1, index2, shift = splitbins(index, trace) | def maketables(): unicode = UnicodeData(UNICODE_DATA) # extract unicode properties dummy = (0, 0, 0, 0) table = [dummy] cache = {0: dummy} index = [0] * len(unicode.chars) # 1) database properties for char in unicode.chars: record = unicode.table[char] if record: # extract database properties category = CATEGORY_NAMES.index(record[2]) combining = int(record[3]) bidirectional = BIDIRECTIONAL_NAMES.index(record[4]) mirrored = record[9] == "Y" item = ( category, combining, bidirectional, mirrored ) # add entry to index and item tables i = cache.get(item) if i is None: cache[item] = i = len(table) table.append(item) index[char] = i # 2) decomposition data # FIXME: <fl> using the encoding stuff from unidb would save # another 50k or so, but I'll leave that for 2.1... decomp_data = [""] decomp_index = [0] * len(unicode.chars) for char in unicode.chars: record = unicode.table[char] if record: if record[5]: try: i = decomp_data.index(record[5]) except ValueError: i = len(decomp_data) decomp_data.append(record[5]) else: i = 0 decomp_index[char] = i FILE = "Modules/unicodedata_db.h" fp = open(FILE, "w") print >>fp, "/* this file was generated by %s %s */" % (SCRIPT, VERSION) print >>fp print >>fp, "/* a list of unique database records */" print >>fp, \ "const _PyUnicode_DatabaseRecord _PyUnicode_Database_Records[] = {" for item in table: print >>fp, " {%d, %d, %d, %d}," % item print >>fp, "};" print >>fp # FIXME: the following tables should be made static, and # the support code moved into unicodedatabase.c print >>fp, "/* string literals */" print >>fp, "const char *_PyUnicode_CategoryNames[] = {" for name in CATEGORY_NAMES: print >>fp, " \"%s\"," % name print >>fp, " NULL" print >>fp, "};" print >>fp, "const char *_PyUnicode_BidirectionalNames[] = {" for name in BIDIRECTIONAL_NAMES: print >>fp, " \"%s\"," % name print >>fp, " NULL" print >>fp, "};" print >>fp, "static const char *decomp_data[] = {" for name in decomp_data: print >>fp, " \"%s\"," % name print >>fp, " NULL" print >>fp, "};" # split record index table index1, index2, shift = splitbins(index) print >>fp, "/* index tables for the database records */" print >>fp, "#define SHIFT", shift Array("index1", index1).dump(fp) Array("index2", index2).dump(fp) # split decomposition index table index1, index2, shift = splitbins(decomp_index) print >>fp, "/* index tables for the decomposition data */" print >>fp, "#define DECOMP_SHIFT", shift Array("decomp_index1", index1).dump(fp) Array("decomp_index2", index2).dump(fp) # # 3) unicode type data # extract unicode types dummy = (0, 0, 0, 0, 0, 0) table = [dummy] cache = {0: dummy} index = [0] * len(unicode.chars) for char in unicode.chars: record = unicode.table[char] if record: # extract database properties category = record[2] bidirectional = record[4] flags = 0 if category in ["Lm", "Lt", "Lu", "Ll", "Lo"]: flags |= ALPHA_MASK if category == "Ll": flags |= LOWER_MASK if category == "Zl" or bidirectional == "B": flags |= LINEBREAK_MASK if category == "Zs" or bidirectional in ("WS", "B", "S"): flags |= SPACE_MASK if category == "Lt": flags |= TITLE_MASK if category == "Lu": flags |= UPPER_MASK # use delta predictor for upper/lower/title if record[12]: upper = (int(record[12], 16) - char) & 0xffff else: upper = 0 if record[13]: lower = (int(record[13], 16) - char) & 0xffff else: lower = 0 if record[14]: title = (int(record[14], 16) - char) & 0xffff else: title = 0 # decimal digit, integer digit decimal = 0 if record[6]: flags |= DECIMAL_MASK decimal = int(record[6]) digit = 0 if record[7]: flags |= DIGIT_MASK digit = int(record[7]) item = ( flags, upper, lower, title, decimal, digit ) # add entry to index and item tables i = cache.get(item) if i is None: cache[item] = i = len(table) table.append(item) index[char] = i print len(table), "ctype entries" FILE = "Objects/unicodetype_db.h" fp = open(FILE, "w") print >>fp, "/* this file was generated by %s %s */" % (SCRIPT, VERSION) print >>fp print >>fp, "/* a list of unique character type descriptors */" print >>fp, "const _PyUnicode_TypeRecord _PyUnicode_TypeRecords[] = {" for item in table: print >>fp, " {%d, %d, %d, %d, %d, %d}," % item print >>fp, "};" print >>fp # split decomposition index table index1, index2, shift = splitbins(index) print >>fp, "/* type indexes */" print >>fp, "#define SHIFT", shift Array("index1", index1).dump(fp) Array("index2", index2).dump(fp) | f70c0d142ca2d51d6b27a5b66866f40595929c59 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f70c0d142ca2d51d6b27a5b66866f40595929c59/makeunicodedata.py |
def __init__(self, filename): | def __init__(self, filename, expand=1): | def __init__(self, filename): file = open(filename) table = [None] * 65536 while 1: s = file.readline() if not s: break s = string.split(string.strip(s), ";") char = string.atoi(s[0], 16) table[char] = s | f70c0d142ca2d51d6b27a5b66866f40595929c59 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f70c0d142ca2d51d6b27a5b66866f40595929c59/makeunicodedata.py |
If optional arg trace is true (default false), progress info is printed to sys.stderr. | If optional arg trace is non-zero (default zero), progress info is printed to sys.stderr. The higher the value, the more info you'll get. | def splitbins(t, trace=0): """t, trace=0 -> (t1, t2, shift). Split a table to save space. t is a sequence of ints. This function can be useful to save space if many of the ints are the same. t1 and t2 are lists of ints, and shift is an int, chosen to minimize the combined size of t1 and t2 (in C code), and where for each i in range(len(t)), t[i] == t2[(t1[i >> shift] << shift) + (i & mask)] where mask is a bitmask isolating the last "shift" bits. If optional arg trace is true (default false), progress info is printed to sys.stderr. """ import sys if trace: def dump(t1, t2, shift, bytes): print >>sys.stderr, "%d+%d bins at shift %d; %d bytes" % ( len(t1), len(t2), shift, bytes) print >>sys.stderr, "Size of original table:", len(t)*getsize(t), \ "bytes" n = len(t)-1 # last valid index maxshift = 0 # the most we can shift n and still have something left if n > 0: while n >> 1: n >>= 1 maxshift += 1 del n bytes = sys.maxint # smallest total size so far t = tuple(t) # so slices can be dict keys for shift in range(maxshift + 1): t1 = [] t2 = [] size = 2**shift bincache = {} for i in range(0, len(t), size): bin = t[i:i+size] index = bincache.get(bin) if index is None: index = len(t2) bincache[bin] = index t2.extend(bin) t1.append(index >> shift) # determine memory size b = len(t1)*getsize(t1) + len(t2)*getsize(t2) if trace: dump(t1, t2, shift, b) if b < bytes: best = t1, t2, shift bytes = b t1, t2, shift = best if trace: print >>sys.stderr, "Best:", dump(t1, t2, shift, bytes) if __debug__: # exhaustively verify that the decomposition is correct mask = ~((~0) << shift) # i.e., low-bit mask of shift bits for i in xrange(len(t)): assert t[i] == t2[(t1[i >> shift] << shift) + (i & mask)] return best | f70c0d142ca2d51d6b27a5b66866f40595929c59 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f70c0d142ca2d51d6b27a5b66866f40595929c59/makeunicodedata.py |
if trace: | if trace > 1: | def dump(t1, t2, shift, bytes): print >>sys.stderr, "%d+%d bins at shift %d; %d bytes" % ( len(t1), len(t2), shift, bytes) | f70c0d142ca2d51d6b27a5b66866f40595929c59 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f70c0d142ca2d51d6b27a5b66866f40595929c59/makeunicodedata.py |
maketables() | maketables(1) | def dump(t1, t2, shift, bytes): print >>sys.stderr, "%d+%d bins at shift %d; %d bytes" % ( len(t1), len(t2), shift, bytes) | f70c0d142ca2d51d6b27a5b66866f40595929c59 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f70c0d142ca2d51d6b27a5b66866f40595929c59/makeunicodedata.py |
elif sys.platform[:5] == "hp-ux": | elif sys.platform[:5] == "hp-ux": | def runtime_library_dir_option(self, dir): # XXX Hackish, at the very least. See Python bug #445902: # http://sourceforge.net/tracker/index.php # ?func=detail&aid=445902&group_id=5470&atid=105470 # Linkers on different platforms need different options to # specify that directories need to be added to the list of # directories searched for dependencies when a dynamic library # is sought. GCC has to be told to pass the -R option through # to the linker, whereas other compilers just know this. # Other compilers may need something slightly different. At # this time, there's no way to determine this information from # the configuration data stored in the Python installation, so # we use this hack. compiler = os.path.basename(sysconfig.get_config_var("CC")) if sys.platform[:6] == "darwin": # MacOSX's linker doesn't understand the -R flag at all return "-L" + dir elif sys.platform[:5] == "hp-ux": return "+s -L" + dir elif compiler[:3] == "gcc" or compiler[:3] == "g++": return "-Wl,-R" + dir else: return "-R" + dir | 7224f31027a87b615b0f8452134f745d64259381 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7224f31027a87b615b0f8452134f745d64259381/unixccompiler.py |
elif compiler[:3] == "gcc" or compiler[:3] == "g++": | elif compiler[:3] == "gcc" or compiler[:3] == "g++": | def runtime_library_dir_option(self, dir): # XXX Hackish, at the very least. See Python bug #445902: # http://sourceforge.net/tracker/index.php # ?func=detail&aid=445902&group_id=5470&atid=105470 # Linkers on different platforms need different options to # specify that directories need to be added to the list of # directories searched for dependencies when a dynamic library # is sought. GCC has to be told to pass the -R option through # to the linker, whereas other compilers just know this. # Other compilers may need something slightly different. At # this time, there's no way to determine this information from # the configuration data stored in the Python installation, so # we use this hack. compiler = os.path.basename(sysconfig.get_config_var("CC")) if sys.platform[:6] == "darwin": # MacOSX's linker doesn't understand the -R flag at all return "-L" + dir elif sys.platform[:5] == "hp-ux": return "+s -L" + dir elif compiler[:3] == "gcc" or compiler[:3] == "g++": return "-Wl,-R" + dir else: return "-R" + dir | 7224f31027a87b615b0f8452134f745d64259381 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7224f31027a87b615b0f8452134f745d64259381/unixccompiler.py |
gen.startElementNS((ns_uri, "doc"), "ns:doc", {}) gen.endElementNS((ns_uri, "doc"), "ns:doc") | gen.startElementNS((ns_uri, "doc"), "ns1:doc", {}) gen.endElementNS((ns_uri, "doc"), "ns1:doc") | def test_xmlgen_ns(): result = StringIO() gen = XMLGenerator(result) gen.startDocument() gen.startPrefixMapping("ns1", ns_uri) gen.startElementNS((ns_uri, "doc"), "ns:doc", {}) gen.endElementNS((ns_uri, "doc"), "ns:doc") gen.endPrefixMapping("ns1") gen.endDocument() return result.getvalue() == start + ('<ns1:doc xmlns:ns1="%s"></ns1:doc>' % ns_uri) | 638b4bde45f9fa549eaa74f4f76f143beb655065 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/638b4bde45f9fa549eaa74f4f76f143beb655065/test_sax.py |
content = open(filename).read() | content = open(filename,'rb').read() | def upload_file(self, command, pyversion, filename): # Sign if requested if self.sign: spawn(("gpg", "--detach-sign", "-a", filename), dry_run=self.dry_run) | 3e45ebe1bf2afd549df81ef0022eeb45b6844d98 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3e45ebe1bf2afd549df81ef0022eeb45b6844d98/upload.py |
The QUESTION strign ca be at most 255 characters. | The QUESTION string can be at most 255 characters. | def AskYesNoCancel(question, default = 0, yes=None, no=None, cancel=None, id=262): """Display a QUESTION string which can be answered with Yes or No. Return 1 when the user clicks the Yes button. Return 0 when the user clicks the No button. Return -1 when the user clicks the Cancel button. When the user presses Return, the DEFAULT value is returned. If omitted, this is 0 (No). The QUESTION strign ca be at most 255 characters. """ d = GetNewDialog(id, -1) if not d: print "Can't get DLOG resource with id =", id return # Button assignments: # 1 = default (invisible) # 2 = Yes # 3 = No # 4 = Cancel # The question string is item 5 h = d.GetDialogItemAsControl(5) SetDialogItemText(h, lf2cr(question)) if yes != None: if yes == '': d.HideDialogItem(2) else: h = d.GetDialogItemAsControl(2) h.SetControlTitle(yes) if no != None: if no == '': d.HideDialogItem(3) else: h = d.GetDialogItemAsControl(3) h.SetControlTitle(no) if cancel != None: if cancel == '': d.HideDialogItem(4) else: h = d.GetDialogItemAsControl(4) h.SetControlTitle(cancel) d.SetDialogCancelItem(4) if default == 1: d.SetDialogDefaultItem(2) elif default == 0: d.SetDialogDefaultItem(3) elif default == -1: d.SetDialogDefaultItem(4) d.AutoSizeDialog() d.GetDialogWindow().ShowWindow() while 1: n = ModalDialog(None) if n == 1: return default if n == 2: return 1 if n == 3: return 0 if n == 4: return -1 | 405955499eea21b34d0bc76a18d405ad210bf150 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/405955499eea21b34d0bc76a18d405ad210bf150/EasyDialogs.py |
if os.name == "posix" and os.path.basename(sys.path[-1]) == "Modules": | if (os.name == "posix" and sys.path and os.path.basename(sys.path[-1]) == "Modules"): | def makepath(*paths): dir = os.path.abspath(os.path.join(*paths)) return dir, os.path.normcase(dir) | e63aede965557b39e6e5d68d3e3ba3dd5cf7afba /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e63aede965557b39e6e5d68d3e3ba3dd5cf7afba/site.py |
def shared_object_filename (self, source_filename): """Return the shared object filename corresponding to a specified source filename.""" return self._change_extensions( source_filenames, self._shared_lib_ext ) | 8dbd7fc1610d7509e0ca462d411ff9091ae2f737 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8dbd7fc1610d7509e0ca462d411ff9091ae2f737/msvccompiler.py |
||
return "lib%s%s" %( libname, self._static_lib_ext ) | return "%s%s" %( libname, self._static_lib_ext ) | def library_filename (self, libname): """Return the static library filename corresponding to the specified library name.""" return "lib%s%s" %( libname, self._static_lib_ext ) | 8dbd7fc1610d7509e0ca462d411ff9091ae2f737 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8dbd7fc1610d7509e0ca462d411ff9091ae2f737/msvccompiler.py |
return "lib%s%s" %( libname, self._shared_lib_ext ) | return "%s%s" %( libname, self._shared_lib_ext ) | def shared_library_filename (self, libname): """Return the shared library filename corresponding to the specified library name.""" return "lib%s%s" %( libname, self._shared_lib_ext ) | 8dbd7fc1610d7509e0ca462d411ff9091ae2f737 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8dbd7fc1610d7509e0ca462d411ff9091ae2f737/msvccompiler.py |
check_syntax("def f(): global time; import ") | check_syntax("def f(): global time; import ") | 71196b618582b4109b85ab015e5d905d528d83c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/71196b618582b4109b85ab015e5d905d528d83c8/test_grammar.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 | 73cb9cf18ef43f0249d6cf8e9a816681aea3a7c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/73cb9cf18ef43f0249d6cf8e9a816681aea3a7c8/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 | 73cb9cf18ef43f0249d6cf8e9a816681aea3a7c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/73cb9cf18ef43f0249d6cf8e9a816681aea3a7c8/test_strptime.py |
if os.environ.get('TERM') in ('dumb', 'emacs'): return plainpager | def getpager(): """Decide what method to use for paging through text.""" if type(sys.stdout) is not types.FileType: return plainpager if not sys.stdin.isatty() or not sys.stdout.isatty(): return plainpager if os.environ.get('TERM') in ('dumb', 'emacs'): return plainpager if 'PAGER' in os.environ: if sys.platform == 'win32': # pipes completely broken in Windows return lambda text: tempfilepager(plain(text), os.environ['PAGER']) elif os.environ.get('TERM') in ('dumb', 'emacs'): return lambda text: pipepager(plain(text), os.environ['PAGER']) else: return lambda text: pipepager(text, os.environ['PAGER']) if sys.platform == 'win32' or sys.platform.startswith('os2'): return lambda text: tempfilepager(plain(text), 'more <') if hasattr(os, 'system') and os.system('(less) 2>/dev/null') == 0: return lambda text: pipepager(text, 'less') import tempfile (fd, filename) = tempfile.mkstemp() os.close(fd) try: if hasattr(os, 'system') and os.system('more %s' % filename) == 0: return lambda text: pipepager(text, 'more') else: return ttypager finally: os.unlink(filename) | 4cededd55506ce3f67f08d026671725e0fcb101a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4cededd55506ce3f67f08d026671725e0fcb101a/pydoc.py |
|
def __init__(self, completekey='tab'): | def __init__(self, completekey='tab', stdin=None, stdout=None): | def __init__(self, completekey='tab'): """Instantiate a line-oriented interpreter framework. | 5cfb0c082eb272eba0c1782c2d88426ad04a99e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5cfb0c082eb272eba0c1782c2d88426ad04a99e0/cmd.py |
The optional argument is the readline name of a completion key; it defaults to the Tab key. If completekey is not None and the readline module is available, command completion is done automatically. """ | The optional argument 'completekey' is the readline name of a completion key; it defaults to the Tab key. If completekey is not None and the readline module is available, command completion is done automatically. The optional arguments stdin and stdout specify alternate input and output file objects; if not specified, sys.stdin and sys.stdout are used. """ import sys if stdin is not None: self.stdin = stdin else: self.stdin = sys.stdin if stdout is not None: self.stdout = stdout else: self.stdout = sys.stdout | def __init__(self, completekey='tab'): """Instantiate a line-oriented interpreter framework. | 5cfb0c082eb272eba0c1782c2d88426ad04a99e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5cfb0c082eb272eba0c1782c2d88426ad04a99e0/cmd.py |
print self.intro | self.stdout.write(str(self.intro)+"\n") | def cmdloop(self, intro=None): """Repeatedly issue a prompt, accept input, parse an initial prefix off the received input, and dispatch to action methods, passing them the remainder of the line as argument. | 5cfb0c082eb272eba0c1782c2d88426ad04a99e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5cfb0c082eb272eba0c1782c2d88426ad04a99e0/cmd.py |
sys.stdout.write(self.prompt) sys.stdout.flush() line = sys.stdin.readline() | self.stdout.write(self.prompt) self.stdout.flush() line = self.stdin.readline() | def cmdloop(self, intro=None): """Repeatedly issue a prompt, accept input, parse an initial prefix off the received input, and dispatch to action methods, passing them the remainder of the line as argument. | 5cfb0c082eb272eba0c1782c2d88426ad04a99e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5cfb0c082eb272eba0c1782c2d88426ad04a99e0/cmd.py |
print '*** Unknown syntax:', line | self.stdout.write('*** Unknown syntax: %s\n'%line) | def default(self, line): """Called on an input line when the command prefix is not recognized. | 5cfb0c082eb272eba0c1782c2d88426ad04a99e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5cfb0c082eb272eba0c1782c2d88426ad04a99e0/cmd.py |
print doc | self.stdout.write("%s\n"%str(doc)) | def do_help(self, arg): if arg: # XXX check arg syntax try: func = getattr(self, 'help_' + arg) except AttributeError: try: doc=getattr(self, 'do_' + arg).__doc__ if doc: print doc return except AttributeError: pass print self.nohelp % (arg,) return func() else: names = self.get_names() cmds_doc = [] cmds_undoc = [] help = {} for name in names: if name[:5] == 'help_': help[name[5:]]=1 names.sort() # There can be duplicates if routines overridden prevname = '' for name in names: if name[:3] == 'do_': if name == prevname: continue prevname = name cmd=name[3:] if cmd in help: cmds_doc.append(cmd) del help[cmd] elif getattr(self, name).__doc__: cmds_doc.append(cmd) else: cmds_undoc.append(cmd) print self.doc_leader self.print_topics(self.doc_header, cmds_doc, 15,80) self.print_topics(self.misc_header, help.keys(),15,80) self.print_topics(self.undoc_header, cmds_undoc, 15,80) | 5cfb0c082eb272eba0c1782c2d88426ad04a99e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5cfb0c082eb272eba0c1782c2d88426ad04a99e0/cmd.py |
print self.nohelp % (arg,) | self.stdout.write("%s\n"%str(self.nohelp % (arg,))) | def do_help(self, arg): if arg: # XXX check arg syntax try: func = getattr(self, 'help_' + arg) except AttributeError: try: doc=getattr(self, 'do_' + arg).__doc__ if doc: print doc return except AttributeError: pass print self.nohelp % (arg,) return func() else: names = self.get_names() cmds_doc = [] cmds_undoc = [] help = {} for name in names: if name[:5] == 'help_': help[name[5:]]=1 names.sort() # There can be duplicates if routines overridden prevname = '' for name in names: if name[:3] == 'do_': if name == prevname: continue prevname = name cmd=name[3:] if cmd in help: cmds_doc.append(cmd) del help[cmd] elif getattr(self, name).__doc__: cmds_doc.append(cmd) else: cmds_undoc.append(cmd) print self.doc_leader self.print_topics(self.doc_header, cmds_doc, 15,80) self.print_topics(self.misc_header, help.keys(),15,80) self.print_topics(self.undoc_header, cmds_undoc, 15,80) | 5cfb0c082eb272eba0c1782c2d88426ad04a99e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5cfb0c082eb272eba0c1782c2d88426ad04a99e0/cmd.py |
print self.doc_leader | self.stdout.write("%s\n"%str(self.doc_leader)) | def do_help(self, arg): if arg: # XXX check arg syntax try: func = getattr(self, 'help_' + arg) except AttributeError: try: doc=getattr(self, 'do_' + arg).__doc__ if doc: print doc return except AttributeError: pass print self.nohelp % (arg,) return func() else: names = self.get_names() cmds_doc = [] cmds_undoc = [] help = {} for name in names: if name[:5] == 'help_': help[name[5:]]=1 names.sort() # There can be duplicates if routines overridden prevname = '' for name in names: if name[:3] == 'do_': if name == prevname: continue prevname = name cmd=name[3:] if cmd in help: cmds_doc.append(cmd) del help[cmd] elif getattr(self, name).__doc__: cmds_doc.append(cmd) else: cmds_undoc.append(cmd) print self.doc_leader self.print_topics(self.doc_header, cmds_doc, 15,80) self.print_topics(self.misc_header, help.keys(),15,80) self.print_topics(self.undoc_header, cmds_undoc, 15,80) | 5cfb0c082eb272eba0c1782c2d88426ad04a99e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5cfb0c082eb272eba0c1782c2d88426ad04a99e0/cmd.py |
print header | self.stdout.write("%s\n"%str(header)) | def print_topics(self, header, cmds, cmdlen, maxcol): if cmds: print header if self.ruler: print self.ruler * len(header) self.columnize(cmds, maxcol-1) print | 5cfb0c082eb272eba0c1782c2d88426ad04a99e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5cfb0c082eb272eba0c1782c2d88426ad04a99e0/cmd.py |
print self.ruler * len(header) | self.stdout.write("%s\n"%str(self.ruler * len(header))) | def print_topics(self, header, cmds, cmdlen, maxcol): if cmds: print header if self.ruler: print self.ruler * len(header) self.columnize(cmds, maxcol-1) print | 5cfb0c082eb272eba0c1782c2d88426ad04a99e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5cfb0c082eb272eba0c1782c2d88426ad04a99e0/cmd.py |
print | self.stdout.write("\n") | def print_topics(self, header, cmds, cmdlen, maxcol): if cmds: print header if self.ruler: print self.ruler * len(header) self.columnize(cmds, maxcol-1) print | 5cfb0c082eb272eba0c1782c2d88426ad04a99e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5cfb0c082eb272eba0c1782c2d88426ad04a99e0/cmd.py |
print "<empty>" | self.stdout.write("<empty>\n") | def columnize(self, list, displaywidth=80): """Display a list of strings as a compact set of columns. | 5cfb0c082eb272eba0c1782c2d88426ad04a99e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5cfb0c082eb272eba0c1782c2d88426ad04a99e0/cmd.py |
print list[0] | self.stdout.write('%s\n'%str(list[0])) | def columnize(self, list, displaywidth=80): """Display a list of strings as a compact set of columns. | 5cfb0c082eb272eba0c1782c2d88426ad04a99e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5cfb0c082eb272eba0c1782c2d88426ad04a99e0/cmd.py |
print " ".join(texts) | self.stdout.write("%s\n"%str(" ".join(texts))) | def columnize(self, list, displaywidth=80): """Display a list of strings as a compact set of columns. | 5cfb0c082eb272eba0c1782c2d88426ad04a99e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5cfb0c082eb272eba0c1782c2d88426ad04a99e0/cmd.py |
def search_function(encoding): # Cache lookup entry = _cache.get(encoding,_unknown) if entry is not _unknown: return entry # Import the module modname = encoding.replace('-', '_') modname = aliases.aliases.get(modname,modname) try: mod = __import__(modname,globals(),locals(),'*') except ImportError,why: _cache[encoding] = None return None # Now ask the module for the registry entry try: entry = tuple(mod.getregentry()) except AttributeError: entry = () if len(entry) != 4: raise SystemError,\ 'module "%s.%s" failed to register' % \ (__name__,modname) for obj in entry: if not callable(obj): raise SystemError,\ 'incompatible codecs in module "%s.%s"' % \ (__name__,modname) # Cache the encoding and its aliases _cache[encoding] = entry try: codecaliases = mod.getaliases() except AttributeError: pass else: for alias in codecaliases: _cache[alias] = entry return entry | 317c8803ab350aa0393542d622f6f31a09110230 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/317c8803ab350aa0393542d622f6f31a09110230/__init__.py |
||
_cache[alias] = entry | if not aliases.aliases.has_key(alias): aliases.aliases[alias] = modname | def search_function(encoding): # Cache lookup entry = _cache.get(encoding,_unknown) if entry is not _unknown: return entry # Import the module modname = encoding.replace('-', '_') modname = aliases.aliases.get(modname,modname) try: mod = __import__(modname,globals(),locals(),'*') except ImportError,why: _cache[encoding] = None return None # Now ask the module for the registry entry try: entry = tuple(mod.getregentry()) except AttributeError: entry = () if len(entry) != 4: raise SystemError,\ 'module "%s.%s" failed to register' % \ (__name__,modname) for obj in entry: if not callable(obj): raise SystemError,\ 'incompatible codecs in module "%s.%s"' % \ (__name__,modname) # Cache the encoding and its aliases _cache[encoding] = entry try: codecaliases = mod.getaliases() except AttributeError: pass else: for alias in codecaliases: _cache[alias] = entry return entry | 317c8803ab350aa0393542d622f6f31a09110230 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/317c8803ab350aa0393542d622f6f31a09110230/__init__.py |
self.addheaders = [('User-agent', server_version)] | self.addheaders = [('User-Agent', server_version)] | def __init__(self): server_version = "Python-urllib/%s" % __version__ self.addheaders = [('User-agent', server_version)] # manage the individual handlers self.handlers = [] self.handle_open = {} self.handle_error = {} | edb1ba0d80cc59bbc7f2b07f4cecdc5ecfc43f6d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/edb1ba0d80cc59bbc7f2b07f4cecdc5ecfc43f6d/urllib2.py |
h.putheader(*args) | if name not in req.headers: h.putheader(*args) | def do_open(self, http_class, req): host = req.get_host() if not host: raise URLError('no host given') | edb1ba0d80cc59bbc7f2b07f4cecdc5ecfc43f6d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/edb1ba0d80cc59bbc7f2b07f4cecdc5ecfc43f6d/urllib2.py |
self.__buf = self.__buf + \ (chr(int(x>>24 & 0xff)) + chr(int(x>>16 & 0xff)) + \ chr(int(x>>8 & 0xff)) + chr(int(x & 0xff))) if _USE_MACHINE_REP: def pack_uint(self, x): if type(x) == LongType: x = int((x + 0x80000000L) % 0x100000000L - 0x80000000L) self.__buf = self.__buf + struct.pack('l', x) | self.__buf = self.__buf + struct.pack('>L', x) | def pack_uint(self, x): | 2872566e68635b18cf8277829ca192eaee5921be /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2872566e68635b18cf8277829ca192eaee5921be/xdrlib.py |
raise ConversionError('Not supported') | try: self.__buf = self.__buf + struct.pack('>f', x) except struct.error, msg: raise ConversionError(msg) | def pack_float(self, x): | 2872566e68635b18cf8277829ca192eaee5921be /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2872566e68635b18cf8277829ca192eaee5921be/xdrlib.py |
raise ConversionError('Not supported') if _xdr: def pack_float(self, x): try: self.__buf = self.__buf + _xdr.pack_float(x) except _xdr.error, msg: raise ConversionError(msg) def pack_double(self, x): try: self.__buf = self.__buf + _xdr.pack_double(x) except _xdr.error, msg: raise ConversionError(msg) | try: self.__buf = self.__buf + struct.pack('>d', x) except struct.error, msg: raise ConversionError(msg) | def pack_double(self, x): | 2872566e68635b18cf8277829ca192eaee5921be /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2872566e68635b18cf8277829ca192eaee5921be/xdrlib.py |
x = long(ord(data[0]))<<24 | ord(data[1])<<16 | \ ord(data[2])<<8 | ord(data[3]) if x < 0x80000000L: x = int(x) return x if _USE_MACHINE_REP: def unpack_uint(self): i = self.__pos self.__pos = j = i+4 data = self.__buf[i:j] if len(data) < 4: raise EOFError return struct.unpack('l', data)[0] | x = struct.unpack('>L', data)[0] try: return int(x) except OverflowError: return x | def unpack_uint(self): | 2872566e68635b18cf8277829ca192eaee5921be /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2872566e68635b18cf8277829ca192eaee5921be/xdrlib.py |
x = self.unpack_uint() if x >= 0x80000000L: x = x - 0x100000000L return int(x) | i = self.__pos self.__pos = j = i+4 data = self.__buf[i:j] if len(data) < 4: raise EOFError return struct.unpack('>l', data)[0] | def unpack_int(self): | 2872566e68635b18cf8277829ca192eaee5921be /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2872566e68635b18cf8277829ca192eaee5921be/xdrlib.py |
raise ConversionError('Not supported') | i = self.__pos self.__pos = j = i+4 data = self.__buf[i:j] if len(data) < 4: raise EOFError return struct.unpack('>f', data)[0] | def unpack_float(self): | 2872566e68635b18cf8277829ca192eaee5921be /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2872566e68635b18cf8277829ca192eaee5921be/xdrlib.py |
raise ConversionError('Not supported') if _xdr: def unpack_float(self): i = self.__pos self.__pos = j = i+4 data = self.__buf[i:j] if len(data) < 4: raise EOFError try: return _xdr.unpack_float(data) except _xdr.error, msg: raise ConversionError(msg) def unpack_double(self): i = self.__pos self.__pos = j = i+8 data = self.__buf[i:j] if len(data) < 8: raise EOFError try: return _xdr.unpack_double(data) except _xdr.error, msg: raise ConversionError(msg) | i = self.__pos self.__pos = j = i+8 data = self.__buf[i:j] if len(data) < 8: raise EOFError return struct.unpack('>d', data)[0] | def unpack_double(self): | 2872566e68635b18cf8277829ca192eaee5921be /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2872566e68635b18cf8277829ca192eaee5921be/xdrlib.py |
def testboth(formatstr, *args): testformat(formatstr, *args) if have_unicode: testformat(unicode(formatstr), *args) | 5910653d2ed56d64ff29162ef905344317163ef5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5910653d2ed56d64ff29162ef905344317163ef5/test_format.py |
||
def testboth(formatstr, *args): testformat(formatstr, *args) if have_unicode: testformat(unicode(formatstr), *args) | 5910653d2ed56d64ff29162ef905344317163ef5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5910653d2ed56d64ff29162ef905344317163ef5/test_format.py |
||
n[i] = n[i].split(os.sep) if os.altsep and len(n[i]) == 1: n[i] = n[i].split(os.altsep) | n[i] = n[i].split("/") | def commonprefix(m): "Given a list of pathnames, returns the longest common leading component" if not m: return '' n = m[:] for i in range(len(n)): n[i] = n[i].split(os.sep) # if os.sep didn't have any effect, try os.altsep if os.altsep and len(n[i]) == 1: n[i] = n[i].split(os.altsep) prefix = n[0] for item in n: for i in range(len(prefix)): if prefix[:i+1] <> item[:i+1]: prefix = prefix[:i] if i == 0: return '' break return os.sep.join(prefix) | 32a917b45870b1ac7b5158870d1464f9a2994533 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/32a917b45870b1ac7b5158870d1464f9a2994533/posixpath.py |
return os.sep.join(prefix) | return "/".join(prefix) | def commonprefix(m): "Given a list of pathnames, returns the longest common leading component" if not m: return '' n = m[:] for i in range(len(n)): n[i] = n[i].split(os.sep) # if os.sep didn't have any effect, try os.altsep if os.altsep and len(n[i]) == 1: n[i] = n[i].split(os.altsep) prefix = n[0] for item in n: for i in range(len(prefix)): if prefix[:i+1] <> item[:i+1]: prefix = prefix[:i] if i == 0: return '' break return os.sep.join(prefix) | 32a917b45870b1ac7b5158870d1464f9a2994533 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/32a917b45870b1ac7b5158870d1464f9a2994533/posixpath.py |
elif usage.startswith("usage: "): | elif usage.lower().startswith("usage: "): | def set_usage (self, usage): if usage is None: self.usage = "%prog [options]" elif usage is SUPPRESS_USAGE: self.usage = None elif usage.startswith("usage: "): # for backwards compatibility with Optik 1.3 and earlier self.usage = usage[7:] else: self.usage = usage | 8bfcc472a239359744909bb242eeb8f10c680917 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8bfcc472a239359744909bb242eeb8f10c680917/optparse.py |
data = convert_path(f[1]) | data = convert_path(data) | def run (self): self.mkpath(self.install_dir) for f in self.data_files: if type(f) == StringType: # it's a simple file, so copy it f = convert_path(f) if self.warn_dir: self.warn("setup script did not provide a directory for " "'%s' -- installing right in '%s'" % (f, self.install_dir)) (out, _) = self.copy_file(f, self.install_dir) self.outfiles.append(out) else: # it's a tuple with path to install to and a list of files dir = convert_path(f[0]) if not os.path.isabs(dir): dir = os.path.join(self.install_dir, dir) elif self.root: dir = change_root(self.root, dir) self.mkpath(dir) for data in f[1]: data = convert_path(f[1]) (out, _) = self.copy_file(data, dir) self.outfiles.append(out) | c2679318d21980573d4b82d2ce90df890e2767e4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c2679318d21980573d4b82d2ce90df890e2767e4/install_data.py |
filename = words[-1] infostuff = words[-5:-1] | filename = string.join(words[8:]) infostuff = words[5:] | def mirrorsubdir(f, localdir): pwd = f.pwd() if localdir and not os.path.isdir(localdir): if verbose: print 'Creating local directory', localdir try: makedir(localdir) except os.error, msg: print "Failed to establish local directory", localdir return infofilename = os.path.join(localdir, '.mirrorinfo') try: text = open(infofilename, 'r').read() except IOError, msg: text = '{}' try: info = eval(text) except (SyntaxError, NameError): print 'Bad mirror info in %s' % infofilename info = {} subdirs = [] listing = [] if verbose: print 'Listing remote directory %s...' % pwd f.retrlines('LIST', listing.append) filesfound = [] for line in listing: if verbose > 1: print '-->', `line` if mac: # Mac listing has just filenames; # trailing / means subdirectory filename = string.strip(line) mode = '-' if filename[-1:] == '/': filename = filename[:-1] mode = 'd' infostuff = '' else: # Parse, assuming a UNIX listing words = string.split(line) if len(words) < 6: if verbose > 1: print 'Skipping short line' continue if words[-2] == '->': if verbose > 1: print 'Skipping symbolic link %s -> %s' % \ (words[-3], words[-1]) continue filename = words[-1] infostuff = words[-5:-1] mode = words[0] skip = 0 for pat in skippats: if fnmatch(filename, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', filename skip = 1 break if skip: continue if mode[0] == 'd': if verbose > 1: print 'Remembering subdirectory', filename subdirs.append(filename) continue filesfound.append(filename) if info.has_key(filename) and info[filename] == infostuff: if verbose > 1: print 'Already have this version of', filename continue fullname = os.path.join(localdir, filename) tempname = os.path.join(localdir, '@'+filename) if interactive: doit = askabout('file', filename, pwd) if not doit: if not info.has_key(filename): info[filename] = 'Not retrieved' continue try: os.unlink(tempname) except os.error: pass try: fp = open(tempname, 'wb') except IOError, msg: print "Can't create %s: %s" % (tempname, str(msg)) continue if verbose: print 'Retrieving %s from %s as %s...' % \ (filename, pwd, fullname) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout) else: fp1 = fp t0 = time.time() try: f.retrbinary('RETR ' + filename, fp1.write, 8*1024) except ftplib.error_perm, msg: print msg t1 = time.time() bytes = fp.tell() fp.close() if fp1 != fp: fp1.close() try: os.unlink(fullname) except os.error: pass # Ignore the error try: os.rename(tempname, fullname) except os.error, msg: print "Can't rename %s to %s: %s" % (tempname, fullname, str(msg)) continue info[filename] = infostuff writedict(info, infofilename) if verbose: dt = t1 - t0 kbytes = bytes / 1024.0 print int(round(kbytes)), print 'Kbytes in', print int(round(dt)), print 'seconds', if t1 > t0: print '(~%d Kbytes/sec)' % \ int(round(kbytes/dt),) print # # Remove files from info that are no longer remote deletions = 0 for filename in info.keys(): if filename not in filesfound: if verbose: print "Removing obsolete info entry for", print filename, "in", localdir or "." del info[filename] deletions = deletions + 1 if deletions: writedict(info, infofilename) # # Remove local files that are no longer in the remote directory try: if not localdir: names = os.listdir(os.curdir) else: names = os.listdir(localdir) except os.error: names = [] for name in names: if name[0] == '.' or info.has_key(name) or name in subdirs: continue skip = 0 for pat in skippats: if fnmatch(name, pat): if verbose > 1: print 'Skip pattern', pat, print 'matches', name skip = 1 break if skip: continue fullname = os.path.join(localdir, name) if not rmok: if verbose: print 'Local file', fullname, print 'is no longer pertinent' continue if verbose: print 'Removing local file/dir', fullname remove(fullname) # # Recursively mirror subdirectories for subdir in subdirs: if interactive: doit = askabout('subdirectory', subdir, pwd) if not doit: continue if verbose: print 'Processing subdirectory', subdir localsubdir = os.path.join(localdir, subdir) pwd = f.pwd() if verbose > 1: print 'Remote directory now:', pwd print 'Remote cwd', subdir try: f.cwd(subdir) except ftplib.error_perm, msg: print "Can't chdir to", subdir, ":", msg else: if verbose: print 'Mirroring as', localsubdir mirrorsubdir(f, localsubdir) if verbose > 1: print 'Remote cwd ..' f.cwd('..') newpwd = f.pwd() if newpwd != pwd: print 'Ended up in wrong directory after cd + cd ..' print 'Giving up now.' break else: if verbose > 1: print 'OK.' | b14f39a09df1d0e0a2bc906153e21625ee610c83 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b14f39a09df1d0e0a2bc906153e21625ee610c83/ftpmirror.py |
del _active[_get_ident()] | if _sys.modules.has_key('dummy_threading'): try: del _active[_get_ident()] except KeyError: pass else: del _active[_get_ident()] | def __delete(self): _active_limbo_lock.acquire() del _active[_get_ident()] _active_limbo_lock.release() | af5950f0a4c93d272979064de4989be5532c8022 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/af5950f0a4c93d272979064de4989be5532c8022/threading.py |
'Library', 'Python', sys.version[:3], 'site-packages') | 'Library', 'Python', sys.version[:3], 'site-packages') | def _init(): import macresource import sys, os macresource.need('DITL', 468, "PythonIDE.rsrc") widgetrespathsegs = [sys.exec_prefix, "Mac", "Tools", "IDE", "Widgets.rsrc"] widgetresfile = os.path.join(*widgetrespathsegs) if not os.path.exists(widgetresfile): widgetrespathsegs = [os.pardir, "Tools", "IDE", "Widgets.rsrc"] widgetresfile = os.path.join(*widgetrespathsegs) refno = macresource.need('CURS', 468, widgetresfile) if os.environ.has_key('PYTHONIDEPATH'): # For development set this environment variable ide_path = os.environ['PYTHONIDEPATH'] elif refno: # We're not a fullblown application idepathsegs = [sys.exec_prefix, "Mac", "Tools", "IDE"] ide_path = os.path.join(*idepathsegs) if not os.path.exists(ide_path): idepathsegs = [os.pardir, "Tools", "IDE"] for p in sys.path: ide_path = os.path.join(*([p]+idepathsegs)) if os.path.exists(ide_path): break else: # We are a fully frozen application ide_path = sys.argv[0] if ide_path not in sys.path: sys.path.insert(0, ide_path) | d0421802b28eb8d1cf616b78a4ea48a02fa6fa17 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d0421802b28eb8d1cf616b78a4ea48a02fa6fa17/PackageManager.py |
rv = 0 | rv = 0 | def _quit(self): | d0421802b28eb8d1cf616b78a4ea48a02fa6fa17 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d0421802b28eb8d1cf616b78a4ea48a02fa6fa17/PackageManager.py |
self.packages = self.pimpdb.list() | packages = self.pimpdb.list() if show_hidden: self.packages = packages else: self.packages = [] for pkg in packages: name = pkg.fullname() if name[0] == '(' and name[-1] == ')' and not show_hidden: continue self.packages.append(pkg) | def getbrowserdata(self, show_hidden=1): self.packages = self.pimpdb.list() rv = [] for pkg in self.packages: name = pkg.fullname() if name[0] == '(' and name[-1] == ')' and not show_hidden: continue status, _ = pkg.installed() description = pkg.description() rv.append((status, name, description)) return rv | d0421802b28eb8d1cf616b78a4ea48a02fa6fa17 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d0421802b28eb8d1cf616b78a4ea48a02fa6fa17/PackageManager.py |
if name[0] == '(' and name[-1] == ')' and not show_hidden: continue | def getbrowserdata(self, show_hidden=1): self.packages = self.pimpdb.list() rv = [] for pkg in self.packages: name = pkg.fullname() if name[0] == '(' and name[-1] == ')' and not show_hidden: continue status, _ = pkg.installed() description = pkg.description() rv.append((status, name, description)) return rv | d0421802b28eb8d1cf616b78a4ea48a02fa6fa17 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d0421802b28eb8d1cf616b78a4ea48a02fa6fa17/PackageManager.py |
|
result = f % val fields = string.split(result, ".") | result = f % abs(val) fields = result.split(".") | def format(f,val,grouping=0): """Formats a value in the same way that the % formatting would use, but takes the current locale into account. Grouping is applied if the third parameter is true.""" result = f % val fields = string.split(result, ".") if grouping: fields[0]=_group(fields[0]) if len(fields)==2: return fields[0]+localeconv()['decimal_point']+fields[1] elif len(fields)==1: return fields[0] else: raise Error, "Too many decimal points in result string" | 0d4d81590f82ee1ba817c28f0a091353a2e69b59 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0d4d81590f82ee1ba817c28f0a091353a2e69b59/locale.py |
return fields[0]+localeconv()['decimal_point']+fields[1] | res = fields[0]+localeconv()['decimal_point']+fields[1] | def format(f,val,grouping=0): """Formats a value in the same way that the % formatting would use, but takes the current locale into account. Grouping is applied if the third parameter is true.""" result = f % val fields = string.split(result, ".") if grouping: fields[0]=_group(fields[0]) if len(fields)==2: return fields[0]+localeconv()['decimal_point']+fields[1] elif len(fields)==1: return fields[0] else: raise Error, "Too many decimal points in result string" | 0d4d81590f82ee1ba817c28f0a091353a2e69b59 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0d4d81590f82ee1ba817c28f0a091353a2e69b59/locale.py |
return fields[0] | res = fields[0] | def format(f,val,grouping=0): """Formats a value in the same way that the % formatting would use, but takes the current locale into account. Grouping is applied if the third parameter is true.""" result = f % val fields = string.split(result, ".") if grouping: fields[0]=_group(fields[0]) if len(fields)==2: return fields[0]+localeconv()['decimal_point']+fields[1] elif len(fields)==1: return fields[0] else: raise Error, "Too many decimal points in result string" | 0d4d81590f82ee1ba817c28f0a091353a2e69b59 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0d4d81590f82ee1ba817c28f0a091353a2e69b59/locale.py |
_nmtoken_rx = re.compile("[a-z][-._a-z0-9]*", re.IGNORECASE) | _nmtoken_rx = re.compile("[a-z][-._a-z0-9]*$", re.IGNORECASE) | def format_attrs(attrs, xml=0): attrs = attrs.items() attrs.sort() s = '' for name, value in attrs: if xml: s = '%s %s="%s"' % (s, name, escape(value)) else: # this is a little bogus, but should do for now if name == value and isnmtoken(value): s = "%s %s" % (s, value) elif istoken(value): s = "%s %s=%s" % (s, name, value) else: s = '%s %s="%s"' % (s, name, escape(value)) return s | bb8f94c6f346fecdf3230a57d410b799ddf05642 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/bb8f94c6f346fecdf3230a57d410b799ddf05642/esis2sgml.py |
_token_rx = re.compile("[a-z0-9][-._a-z0-9]*", re.IGNORECASE) | _token_rx = re.compile("[a-z0-9][-._a-z0-9]*$", re.IGNORECASE) | def isnmtoken(s): return _nmtoken_rx.match(s) is not None | bb8f94c6f346fecdf3230a57d410b799ddf05642 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/bb8f94c6f346fecdf3230a57d410b799ddf05642/esis2sgml.py |
output_dir=None): | output_dir=None, debug=0): | def link_static_lib (self, objects, output_libname, output_dir=None): | 1a1611dd2a217ae6813b1293cb7f52a70463ba56 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a1611dd2a217ae6813b1293cb7f52a70463ba56/unixccompiler.py |
['response', ['mesg_num octets', ...]]. | ['response', ['mesg_num octets', ...], octets]. | def list(self, which=None): """Request listing, return result. | 2b315792cca6fea1ab84344227f59d2bb272647e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2b315792cca6fea1ab84344227f59d2bb272647e/poplib.py |
frozendllmain_c, extensions_c] + files | frozendllmain_c, os.path.basename(extensions_c)] + files | def main(): # overridable context prefix = None # settable with -p option exec_prefix = None # settable with -P option extensions = [] exclude = [] # settable with -x option addn_link = [] # settable with -l, but only honored under Windows. path = sys.path[:] modargs = 0 debug = 1 odir = '' win = sys.platform[:3] == 'win' # default the exclude list for each platform if win: exclude = exclude + [ 'dos', 'dospath', 'mac', 'macpath', 'macfs', 'MACFS', 'posix', 'os2'] # modules that are imported by the Python runtime implicits = ["site", "exceptions"] # output files frozen_c = 'frozen.c' config_c = 'config.c' target = 'a.out' # normally derived from script name makefile = 'Makefile' subsystem = 'console' # parse command line by first replacing any "-i" options with the file contents. pos = 1 while pos < len(sys.argv)-1: # last option can not be "-i", so this ensures "pos+1" is in range! if sys.argv[pos] == '-i': try: options = string.split(open(sys.argv[pos+1]).read()) except IOError, why: usage("File name '%s' specified with the -i option can not be read - %s" % (sys.argv[pos+1], why) ) # Replace the '-i' and the filename with the read params. sys.argv[pos:pos+2] = options pos = pos + len(options) - 1 # Skip the name and the included args. pos = pos + 1 # Now parse the command line with the extras inserted. try: opts, args = getopt.getopt(sys.argv[1:], 'a:de:hmo:p:P:qs:wx:l:') except getopt.error, msg: usage('getopt error: ' + str(msg)) # proces option arguments for o, a in opts: if o == '-h': print __doc__ return if o == '-d': debug = debug + 1 if o == '-e': extensions.append(a) if o == '-m': modargs = 1 if o == '-o': odir = a if o == '-p': prefix = a if o == '-P': exec_prefix = a if o == '-q': debug = 0 if o == '-w': win = not win if o == '-s': if not win: usage("-s subsystem option only on Windows") subsystem = a if o == '-x': exclude.append(a) if o == '-l': addn_link.append(a) if o == '-a': apply(modulefinder.AddPackagePath, tuple(string.split(a,"=", 2))) # default prefix and exec_prefix if not exec_prefix: if prefix: exec_prefix = prefix else: exec_prefix = sys.exec_prefix if not prefix: prefix = sys.prefix # determine whether -p points to the Python source tree ishome = os.path.exists(os.path.join(prefix, 'Python', 'ceval.c')) # locations derived from options version = sys.version[:3] if win: extensions_c = 'frozen_extensions.c' if ishome: print "(Using Python source directory)" binlib = exec_prefix incldir = os.path.join(prefix, 'Include') config_h_dir = exec_prefix config_c_in = os.path.join(prefix, 'Modules', 'config.c.in') frozenmain_c = os.path.join(prefix, 'Python', 'frozenmain.c') makefile_in = os.path.join(exec_prefix, 'Modules', 'Makefile') if win: frozendllmain_c = os.path.join(exec_prefix, 'Pc\\frozen_dllmain.c') else: binlib = os.path.join(exec_prefix, 'lib', 'python%s' % version, 'config') incldir = os.path.join(prefix, 'include', 'python%s' % version) config_h_dir = os.path.join(exec_prefix, 'include', 'python%s' % version) config_c_in = os.path.join(binlib, 'config.c.in') frozenmain_c = os.path.join(binlib, 'frozenmain.c') makefile_in = os.path.join(binlib, 'Makefile') frozendllmain_c = os.path.join(binlib, 'frozen_dllmain.c') supp_sources = [] defines = [] includes = ['-I' + incldir, '-I' + config_h_dir] # sanity check of directories and files check_dirs = [prefix, exec_prefix, binlib, incldir] if not win: check_dirs = check_dirs + extensions # These are not directories on Windows. for dir in check_dirs: if not os.path.exists(dir): usage('needed directory %s not found' % dir) if not os.path.isdir(dir): usage('%s: not a directory' % dir) if win: files = supp_sources + extensions # extensions are files on Windows. else: files = [config_c_in, makefile_in] + supp_sources for file in supp_sources: if not os.path.exists(file): usage('needed file %s not found' % file) if not os.path.isfile(file): usage('%s: not a plain file' % file) if not win: for dir in extensions: setup = os.path.join(dir, 'Setup') if not os.path.exists(setup): usage('needed file %s not found' % setup) if not os.path.isfile(setup): usage('%s: not a plain file' % setup) # check that enough arguments are passed if not args: usage('at least one filename argument required') # check that file arguments exist for arg in args: if arg == '-m': break # if user specified -m on the command line before _any_ # file names, then nothing should be checked (as the # very first file should be a module name) if modargs: break if not os.path.exists(arg): usage('argument %s not found' % arg) if not os.path.isfile(arg): usage('%s: not a plain file' % arg) # process non-option arguments scriptfile = args[0] modules = args[1:] # derive target name from script name base = os.path.basename(scriptfile) base, ext = os.path.splitext(base) if base: if base != scriptfile: target = base else: target = base + '.bin' # handle -o option base_frozen_c = frozen_c base_config_c = config_c base_target = target if odir and not os.path.isdir(odir): try: os.mkdir(odir) print "Created output directory", odir except os.error, msg: usage('%s: mkdir failed (%s)' % (odir, str(msg))) base = '' if odir: base = os.path.join(odir, '') frozen_c = os.path.join(odir, frozen_c) config_c = os.path.join(odir, config_c) target = os.path.join(odir, target) makefile = os.path.join(odir, makefile) if win: extensions_c = os.path.join(odir, extensions_c) # Handle special entry point requirements # (on Windows, some frozen programs do not use __main__, but # import the module directly. Eg, DLLs, Services, etc custom_entry_point = None # Currently only used on Windows python_entry_is_main = 1 # Is the entry point called __main__? # handle -s option on Windows if win: import winmakemakefile try: custom_entry_point, python_entry_is_main = \ winmakemakefile.get_custom_entry_point(subsystem) except ValueError, why: usage(why) # Actual work starts here... # collect all modules of the program dir = os.path.dirname(scriptfile) path[0] = dir mf = modulefinder.ModuleFinder(path, debug, exclude) if win and subsystem=='service': # If a Windows service, then add the "built-in" module. mod = mf.add_module("servicemanager") mod.__file__="dummy.pyd" # really built-in to the resulting EXE for mod in implicits: mf.import_hook(mod) for mod in modules: if mod == '-m': modargs = 1 continue if modargs: if mod[-2:] == '.*': mf.import_hook(mod[:-2], None, ["*"]) else: mf.import_hook(mod) else: mf.load_file(mod) # Add the main script as either __main__, or the actual module name. if python_entry_is_main: mf.run_script(scriptfile) else: if modargs: mf.import_hook(scriptfile) else: mf.load_file(scriptfile) if debug > 0: mf.report() print dict = mf.modules # generate output for frozen modules files = makefreeze.makefreeze(base, dict, debug, custom_entry_point) # look for unfrozen modules (builtin and of unknown origin) builtins = [] unknown = [] mods = dict.keys() mods.sort() for mod in mods: if dict[mod].__code__: continue if not dict[mod].__file__: builtins.append(mod) else: unknown.append(mod) # search for unknown modules in extensions directories (not on Windows) addfiles = [] frozen_extensions = [] # Windows list of modules. if unknown or (not win and builtins): if not win: addfiles, addmods = \ checkextensions.checkextensions(unknown+builtins, extensions) for mod in addmods: if mod in unknown: unknown.remove(mod) builtins.append(mod) else: # Do the windows thang... import checkextensions_win32 # Get a list of CExtension instances, each describing a module # (including its source files) frozen_extensions = checkextensions_win32.checkextensions( unknown, extensions) for mod in frozen_extensions: unknown.remove(mod.name) # report unknown modules if unknown: sys.stderr.write('Warning: unknown modules remain: %s\n' % string.join(unknown)) # windows gets different treatment if win: # Taking a shortcut here... import winmakemakefile, checkextensions_win32 checkextensions_win32.write_extension_table(extensions_c, frozen_extensions) # Create a module definition for the bootstrap C code. xtras = [frozenmain_c, os.path.basename(frozen_c), frozendllmain_c, extensions_c] + files maindefn = checkextensions_win32.CExtension( '__main__', xtras ) frozen_extensions.append( maindefn ) outfp = open(makefile, 'w') try: winmakemakefile.makemakefile(outfp, locals(), frozen_extensions, os.path.basename(target)) finally: outfp.close() return # generate config.c and Makefile builtins.sort() infp = open(config_c_in) outfp = bkfile.open(config_c, 'w') try: makeconfig.makeconfig(infp, outfp, builtins) finally: outfp.close() infp.close() cflags = defines + includes + ['$(OPT)'] libs = [os.path.join(binlib, 'libpython$(VERSION).a')] somevars = {} if os.path.exists(makefile_in): makevars = parsesetup.getmakevars(makefile_in) for key in makevars.keys(): somevars[key] = makevars[key] somevars['CFLAGS'] = string.join(cflags) # override files = ['$(OPT)', '$(LDFLAGS)', base_config_c, base_frozen_c] + \ files + supp_sources + addfiles + libs + \ ['$(MODLIBS)', '$(LIBS)', '$(SYSLIBS)'] outfp = bkfile.open(makefile, 'w') try: makemakefile.makemakefile(outfp, somevars, files, base_target) finally: outfp.close() # Done! if odir: print 'Now run "make" in', odir, print 'to build the target:', base_target else: print 'Now run "make" to build the target:', base_target | 94f9614360fc8ebe4364718f3af599c648d629f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/94f9614360fc8ebe4364718f3af599c648d629f7/freeze.py |
if s[0] in ('-', '+'): | if s[:1] in ('-', '+'): | def zfill(x, width): """zfill(x, width) -> string Pad a numeric string x with zeros on the left, to fill a field of the specified width. The string x is never truncated. """ if type(x) == type(''): s = x else: s = `x` n = len(s) if n >= width: return s sign = '' if s[0] in ('-', '+'): sign, s = s[0], s[1:] return sign + '0'*(width-n) + s | c9bd845ea6af67fca6027db65a3b5e44322d616c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c9bd845ea6af67fca6027db65a3b5e44322d616c/string.py |
elif sys.platform.startswith("netbsd"): | elif sys.platform.startswith("netbsd") or sys.platform.startswith("openbsd"): | def test_load(self): if os.name == "nt": name = "msvcrt" elif os.name == "ce": name = "coredll" elif sys.platform == "darwin": name = "libc.dylib" elif sys.platform.startswith("freebsd"): name = "libc.so" elif sys.platform == "sunos5": name = "libc.so" elif sys.platform.startswith("netbsd"): name = "libc.so" else: name = "libc.so.6" | 65f353dd849c255b0e0b60b9d69ec330df1182ec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/65f353dd849c255b0e0b60b9d69ec330df1182ec/test_loading.py |
If the population has repeated elements, then each occurence is | If the population has repeated elements, then each occurrence is | def sample(self, population, k, random=None, int=int): """Chooses k unique random elements from a population sequence. | 6f68c25d5262d7494b811f26217f67f8c4d621c3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6f68c25d5262d7494b811f26217f67f8c4d621c3/random.py |
if os.name == 'mac': def getproxies(): | if sys.platform == 'darwin': def getproxies_internetconfig(): | def getproxies_environment(): """Return a dictionary of scheme -> proxy server URL mappings. Scan the environment for variables named <scheme>_proxy; this seems to be the standard convention. If you need a different way, you can pass a proxies dictionary to the [Fancy]URLopener constructor. """ proxies = {} for name, value in os.environ.items(): name = name.lower() if value and name[-6:] == '_proxy': proxies[name[:-6]] = value return proxies | 79fa06313b55f6f7edeeccd22bad17eec6fc2e1e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/79fa06313b55f6f7edeeccd22bad17eec6fc2e1e/urllib.py |
def translate(self, table, deletechars=""): return self.__class__(self.data.translate(table, deletechars)) | def translate(self, *args): return self.__class__(self.data.translate(*args)) | def translate(self, table, deletechars=""): return self.__class__(self.data.translate(table, deletechars)) | 3b9d868dca7ac679ae8c3812a9a5450c94e22b66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3b9d868dca7ac679ae8c3812a9a5450c94e22b66/UserString.py |
if re.match(e[1], result): continue | if re.match(escapestr(e[1], ampm), result): continue | def strftest(now): if verbose: print "strftime test for", time.ctime(now) nowsecs = str(long(now))[:-1] gmt = time.gmtime(now) now = time.localtime(now) if now[3] < 12: ampm='(AM|am)' else: ampm='(PM|pm)' jan1 = time.localtime(time.mktime((now[0], 1, 1, 0, 0, 0, 0, 1, 0))) try: if now[8]: tz = time.tzname[1] else: tz = time.tzname[0] except AttributeError: tz = '' if now[3] > 12: clock12 = now[3] - 12 elif now[3] > 0: clock12 = now[3] else: clock12 = 12 expectations = ( ('%a', calendar.day_abbr[now[6]], 'abbreviated weekday name'), ('%A', calendar.day_name[now[6]], 'full weekday name'), ('%b', calendar.month_abbr[now[1]], 'abbreviated month name'), ('%B', calendar.month_name[now[1]], 'full month name'), # %c see below ('%d', '%02d' % now[2], 'day of month as number (00-31)'), ('%H', '%02d' % now[3], 'hour (00-23)'), ('%I', '%02d' % clock12, 'hour (01-12)'), ('%j', '%03d' % now[7], 'julian day (001-366)'), ('%m', '%02d' % now[1], 'month as number (01-12)'), ('%M', '%02d' % now[4], 'minute, (00-59)'), ('%p', ampm, 'AM or PM as appropriate'), ('%S', '%02d' % now[5], 'seconds of current time (00-60)'), ('%U', '%02d' % ((now[7] + jan1[6])//7), 'week number of the year (Sun 1st)'), ('%w', '0?%d' % ((1+now[6]) % 7), 'weekday as a number (Sun 1st)'), ('%W', '%02d' % ((now[7] + (jan1[6] - 1)%7)//7), 'week number of the year (Mon 1st)'), # %x see below ('%X', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'), ('%y', '%02d' % (now[0]%100), 'year without century'), ('%Y', '%d' % now[0], 'year with century'), # %Z see below ('%%', '%', 'single percent sign'), ) nonstandard_expectations = ( # These are standard but don't have predictable output ('%c', fixasctime(time.asctime(now)), 'near-asctime() format'), ('%x', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)), '%m/%d/%y %H:%M:%S'), ('%Z', '%s' % tz, 'time zone name'), # These are some platform specific extensions ('%D', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)), 'mm/dd/yy'), ('%e', '%2d' % now[2], 'day of month as number, blank padded ( 0-31)'), ('%h', calendar.month_abbr[now[1]], 'abbreviated month name'), ('%k', '%2d' % now[3], 'hour, blank padded ( 0-23)'), ('%n', '\n', 'newline character'), ('%r', '%02d:%02d:%02d %s' % (clock12, now[4], now[5], ampm), '%I:%M:%S %p'), ('%R', '%02d:%02d' % (now[3], now[4]), '%H:%M'), ('%s', nowsecs, 'seconds since the Epoch in UCT'), ('%t', '\t', 'tab character'), ('%T', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'), ('%3y', '%03d' % (now[0]%100), 'year without century rendered using fieldwidth'), ) if verbose: print "Strftime test, platform: %s, Python version: %s" % \ (sys.platform, sys.version.split()[0]) for e in expectations: try: result = time.strftime(e[0], now) except ValueError, error: print "Standard '%s' format gave error:" % e[0], error continue if re.match(e[1], result): continue if not result or result[0] == '%': print "Does not support standard '%s' format (%s)" % (e[0], e[2]) else: print "Conflict for %s (%s):" % (e[0], e[2]) print " Expected %s, but got %s" % (e[1], result) for e in nonstandard_expectations: try: result = time.strftime(e[0], now) except ValueError, result: if verbose: print "Error for nonstandard '%s' format (%s): %s" % \ (e[0], e[2], str(result)) continue if re.match(e[1], result): if verbose: print "Supports nonstandard '%s' format (%s)" % (e[0], e[2]) elif not result or result[0] == '%': if verbose: print "Does not appear to support '%s' format (%s)" % (e[0], e[2]) else: if verbose: print "Conflict for nonstandard '%s' format (%s):" % (e[0], e[2]) print " Expected %s, but got %s" % (e[1], result) | 14862d75c75ae24480c1ab96017a87014f7c45c4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/14862d75c75ae24480c1ab96017a87014f7c45c4/test_strftime.py |
if re.match(e[1], result): | if re.match(escapestr(e[1], ampm), result): | def strftest(now): if verbose: print "strftime test for", time.ctime(now) nowsecs = str(long(now))[:-1] gmt = time.gmtime(now) now = time.localtime(now) if now[3] < 12: ampm='(AM|am)' else: ampm='(PM|pm)' jan1 = time.localtime(time.mktime((now[0], 1, 1, 0, 0, 0, 0, 1, 0))) try: if now[8]: tz = time.tzname[1] else: tz = time.tzname[0] except AttributeError: tz = '' if now[3] > 12: clock12 = now[3] - 12 elif now[3] > 0: clock12 = now[3] else: clock12 = 12 expectations = ( ('%a', calendar.day_abbr[now[6]], 'abbreviated weekday name'), ('%A', calendar.day_name[now[6]], 'full weekday name'), ('%b', calendar.month_abbr[now[1]], 'abbreviated month name'), ('%B', calendar.month_name[now[1]], 'full month name'), # %c see below ('%d', '%02d' % now[2], 'day of month as number (00-31)'), ('%H', '%02d' % now[3], 'hour (00-23)'), ('%I', '%02d' % clock12, 'hour (01-12)'), ('%j', '%03d' % now[7], 'julian day (001-366)'), ('%m', '%02d' % now[1], 'month as number (01-12)'), ('%M', '%02d' % now[4], 'minute, (00-59)'), ('%p', ampm, 'AM or PM as appropriate'), ('%S', '%02d' % now[5], 'seconds of current time (00-60)'), ('%U', '%02d' % ((now[7] + jan1[6])//7), 'week number of the year (Sun 1st)'), ('%w', '0?%d' % ((1+now[6]) % 7), 'weekday as a number (Sun 1st)'), ('%W', '%02d' % ((now[7] + (jan1[6] - 1)%7)//7), 'week number of the year (Mon 1st)'), # %x see below ('%X', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'), ('%y', '%02d' % (now[0]%100), 'year without century'), ('%Y', '%d' % now[0], 'year with century'), # %Z see below ('%%', '%', 'single percent sign'), ) nonstandard_expectations = ( # These are standard but don't have predictable output ('%c', fixasctime(time.asctime(now)), 'near-asctime() format'), ('%x', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)), '%m/%d/%y %H:%M:%S'), ('%Z', '%s' % tz, 'time zone name'), # These are some platform specific extensions ('%D', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)), 'mm/dd/yy'), ('%e', '%2d' % now[2], 'day of month as number, blank padded ( 0-31)'), ('%h', calendar.month_abbr[now[1]], 'abbreviated month name'), ('%k', '%2d' % now[3], 'hour, blank padded ( 0-23)'), ('%n', '\n', 'newline character'), ('%r', '%02d:%02d:%02d %s' % (clock12, now[4], now[5], ampm), '%I:%M:%S %p'), ('%R', '%02d:%02d' % (now[3], now[4]), '%H:%M'), ('%s', nowsecs, 'seconds since the Epoch in UCT'), ('%t', '\t', 'tab character'), ('%T', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'), ('%3y', '%03d' % (now[0]%100), 'year without century rendered using fieldwidth'), ) if verbose: print "Strftime test, platform: %s, Python version: %s" % \ (sys.platform, sys.version.split()[0]) for e in expectations: try: result = time.strftime(e[0], now) except ValueError, error: print "Standard '%s' format gave error:" % e[0], error continue if re.match(e[1], result): continue if not result or result[0] == '%': print "Does not support standard '%s' format (%s)" % (e[0], e[2]) else: print "Conflict for %s (%s):" % (e[0], e[2]) print " Expected %s, but got %s" % (e[1], result) for e in nonstandard_expectations: try: result = time.strftime(e[0], now) except ValueError, result: if verbose: print "Error for nonstandard '%s' format (%s): %s" % \ (e[0], e[2], str(result)) continue if re.match(e[1], result): if verbose: print "Supports nonstandard '%s' format (%s)" % (e[0], e[2]) elif not result or result[0] == '%': if verbose: print "Does not appear to support '%s' format (%s)" % (e[0], e[2]) else: if verbose: print "Conflict for nonstandard '%s' format (%s):" % (e[0], e[2]) print " Expected %s, but got %s" % (e[1], result) | 14862d75c75ae24480c1ab96017a87014f7c45c4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/14862d75c75ae24480c1ab96017a87014f7c45c4/test_strftime.py |
directory already exists, return silently. Raise DistutilsFileError if unable to create some directory along the way (eg. some sub-path exists, but is a file rather than a directory). If 'verbose' is true, print a one-line summary of each mkdir to stdout.""" | directory already exists (or if 'name' is the empty string, which means the current directory, which of course exists), then do nothing. Raise DistutilsFileError if unable to create some directory along the way (eg. some sub-path exists, but is a file rather than a directory). If 'verbose' is true, print a one-line summary of each mkdir to stdout. Return the list of directories actually created.""" | def mkpath (name, mode=0777, verbose=0, dry_run=0): """Create a directory and any missing ancestor directories. If the directory already exists, return silently. Raise DistutilsFileError if unable to create some directory along the way (eg. some sub-path exists, but is a file rather than a directory). If 'verbose' is true, print a one-line summary of each mkdir to stdout.""" global PATH_CREATED # XXX what's the better way to handle verbosity? print as we create # each directory in the path (the current behaviour), or only announce # the creation of the whole path? (quite easy to do the latter since # we're not using a recursive algorithm) name = os.path.normpath (name) created_dirs = [] if os.path.isdir (name) or name == '': return created_dirs if PATH_CREATED.get (name): return created_dirs (head, tail) = os.path.split (name) tails = [tail] # stack of lone dirs to create while head and tail and not os.path.isdir (head): #print "splitting '%s': " % head, (head, tail) = os.path.split (head) #print "to ('%s','%s')" % (head, tail) tails.insert (0, tail) # push next higher dir onto stack #print "stack of tails:", tails # now 'head' contains the deepest directory that already exists # (that is, the child of 'head' in 'name' is the highest directory # that does *not* exist) for d in tails: #print "head = %s, d = %s: " % (head, d), head = os.path.join (head, d) if PATH_CREATED.get (head): continue if verbose: print "creating", head if not dry_run: try: os.mkdir (head) created_dirs.append(head) except os.error, (errno, errstr): raise DistutilsFileError, \ "could not create '%s': %s" % (head, errstr) PATH_CREATED[head] = 1 return created_dirs | 870a5dc523dc3eec775d824b702988101d6a75bc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/870a5dc523dc3eec775d824b702988101d6a75bc/util.py |
except os.error, (errno, errstr): | except OSError, exc: | def mkpath (name, mode=0777, verbose=0, dry_run=0): """Create a directory and any missing ancestor directories. If the directory already exists, return silently. Raise DistutilsFileError if unable to create some directory along the way (eg. some sub-path exists, but is a file rather than a directory). If 'verbose' is true, print a one-line summary of each mkdir to stdout.""" global PATH_CREATED # XXX what's the better way to handle verbosity? print as we create # each directory in the path (the current behaviour), or only announce # the creation of the whole path? (quite easy to do the latter since # we're not using a recursive algorithm) name = os.path.normpath (name) created_dirs = [] if os.path.isdir (name) or name == '': return created_dirs if PATH_CREATED.get (name): return created_dirs (head, tail) = os.path.split (name) tails = [tail] # stack of lone dirs to create while head and tail and not os.path.isdir (head): #print "splitting '%s': " % head, (head, tail) = os.path.split (head) #print "to ('%s','%s')" % (head, tail) tails.insert (0, tail) # push next higher dir onto stack #print "stack of tails:", tails # now 'head' contains the deepest directory that already exists # (that is, the child of 'head' in 'name' is the highest directory # that does *not* exist) for d in tails: #print "head = %s, d = %s: " % (head, d), head = os.path.join (head, d) if PATH_CREATED.get (head): continue if verbose: print "creating", head if not dry_run: try: os.mkdir (head) created_dirs.append(head) except os.error, (errno, errstr): raise DistutilsFileError, \ "could not create '%s': %s" % (head, errstr) PATH_CREATED[head] = 1 return created_dirs | 870a5dc523dc3eec775d824b702988101d6a75bc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/870a5dc523dc3eec775d824b702988101d6a75bc/util.py |
"could not create '%s': %s" % (head, errstr) | "could not create '%s': %s" % (head, exc[-1]) | def mkpath (name, mode=0777, verbose=0, dry_run=0): """Create a directory and any missing ancestor directories. If the directory already exists, return silently. Raise DistutilsFileError if unable to create some directory along the way (eg. some sub-path exists, but is a file rather than a directory). If 'verbose' is true, print a one-line summary of each mkdir to stdout.""" global PATH_CREATED # XXX what's the better way to handle verbosity? print as we create # each directory in the path (the current behaviour), or only announce # the creation of the whole path? (quite easy to do the latter since # we're not using a recursive algorithm) name = os.path.normpath (name) created_dirs = [] if os.path.isdir (name) or name == '': return created_dirs if PATH_CREATED.get (name): return created_dirs (head, tail) = os.path.split (name) tails = [tail] # stack of lone dirs to create while head and tail and not os.path.isdir (head): #print "splitting '%s': " % head, (head, tail) = os.path.split (head) #print "to ('%s','%s')" % (head, tail) tails.insert (0, tail) # push next higher dir onto stack #print "stack of tails:", tails # now 'head' contains the deepest directory that already exists # (that is, the child of 'head' in 'name' is the highest directory # that does *not* exist) for d in tails: #print "head = %s, d = %s: " % (head, d), head = os.path.join (head, d) if PATH_CREATED.get (head): continue if verbose: print "creating", head if not dry_run: try: os.mkdir (head) created_dirs.append(head) except os.error, (errno, errstr): raise DistutilsFileError, \ "could not create '%s': %s" % (head, errstr) PATH_CREATED[head] = 1 return created_dirs | 870a5dc523dc3eec775d824b702988101d6a75bc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/870a5dc523dc3eec775d824b702988101d6a75bc/util.py |
archive_basename = "%s.win32" % self.distribution.get_fullname() | fullname = self.distribution.get_fullname() archive_basename = os.path.join(self.bdist_dir, "%s.win32" % fullname) | def run (self): | d632280482e5e5e66cebc993062f0fd1e60755b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d632280482e5e5e66cebc993062f0fd1e60755b5/bdist_wininst.py |
self.create_exe (arcname) | self.create_exe (arcname, fullname) | def run (self): | d632280482e5e5e66cebc993062f0fd1e60755b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d632280482e5e5e66cebc993062f0fd1e60755b5/bdist_wininst.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.