bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def can_fetch(self, useragent, url): """using the parsed robots.txt decide if useragent can fetch url""" _debug("Checking robot.txt allowance for:\n user agent: %s\n url: %s" % (useragent, url)) if self.disallow_all: return False if self.allow_all: return True # search for given user agent matches # the first match counts url = urllib.quote(urlparse.urlparse(urllib.unquote(url))[2]) or "/" for entry in self.entries: if entry.applies_to(useragent): return entry.allowance(url) # try the default entry last if self.default_entry: return self.default_entry.allowance(url) # agent not found ==> access granted return True
def can_fetch(self, useragent, url): """using the parsed robots.txt decide if useragent can fetch url""" _debug("Checking robots.txt allowance for:\n user agent: %s\n url: %s" % (useragent, url)) if self.disallow_all: return False if self.allow_all: return True # search for given user agent matches # the first match counts url = urllib.quote(urlparse.urlparse(urllib.unquote(url))[2]) or "/" for entry in self.entries: if entry.applies_to(useragent): return entry.allowance(url) # try the default entry last if self.default_entry: return self.default_entry.allowance(url) # agent not found ==> access granted return True
11,900
def __init__(self, master=None, cnf=None, **kw): if cnf is None: cnf = {} if kw: cnf = _cnfmerge((cnf, kw)) fcnf = {} for k in cnf.keys(): if type(k) == ClassType or k == 'name': fcnf[k] = cnf[k] del cnf[k] self.frame = apply(Frame, (master,), fcnf) self.vbar = Scrollbar(self.frame, name='vbar') self.vbar.pack(side=RIGHT, fill=Y) cnf['name'] = 'text' apply(Text.__init__, (self, self.frame), cnf) self.pack(side=LEFT, fill=BOTH, expand=1) self['yscrollcommand'] = self.vbar.set self.vbar['command'] = self.yview
def __init__(self, master=None, cnf=None, **kw): if cnf is None: cnf = {} if kw: cnf = _cnfmerge((cnf, kw)) fcnf = {} for k in cnf.keys(): if type(k) == ClassType or k == 'name': fcnf[k] = cnf[k] del cnf[k] self.frame = apply(Frame, (master,), fcnf) self.vbar = Scrollbar(self.frame, name='vbar') self.vbar.pack(side=RIGHT, fill=Y) cnf['name'] = 'text' apply(Text.__init__, (self, self.frame), cnf) self.pack(side=LEFT, fill=BOTH, expand=1) self['yscrollcommand'] = self.vbar.set self.vbar['command'] = self.yview
11,901
def __init__(self, versionPredicateStr): """Parse a version predicate string. """ # Fields: # name: package name # pred: list of (comparison string, StrictVersion)
def __init__(self, versionPredicateStr): """Parse a version predicate string. """ # Fields: # name: package name # pred: list of (comparison string, StrictVersion)
11,902
def makeunicodename(unicode, trace): FILE = "Modules/unicodename_db.h" print "--- Preparing", FILE, "..." # collect names names = [None] * len(unicode.chars) for char in unicode.chars: record = unicode.table[char] if record: name = record[1].strip() if name and name[0] != "<": names[char] = name + chr(0) print len(filter(lambda n: n is not None, names)), "distinct names" # collect unique words from names (note that we differ between # words inside a sentence, and words ending a sentence. the # latter includes the trailing null byte. words = {} n = b = 0 for char in unicode.chars: name = names[char] if name: w = name.split() b = b + len(name) n = n + len(w) for w in w: l = words.get(w) if l: l.append(None) else: words[w] = [len(words)] print n, "words in text;", b, "bytes" wordlist = words.items() # sort on falling frequency # XXX: different Python versions produce a different order # for words with equal frequency wordlist.sort(lambda a, b: len(b[1])-len(a[1])) # figure out how many phrasebook escapes we need escapes = 0 while escapes * 256 < len(wordlist): escapes = escapes + 1 print escapes, "escapes" short = 256 - escapes assert short > 0 print short, "short indexes in lexicon" # statistics n = 0 for i in range(short): n = n + len(wordlist[i][1]) print n, "short indexes in phrasebook" # pick the most commonly used words, and sort the rest on falling # length (to maximize overlap) wordlist, wordtail = wordlist[:short], wordlist[short:] wordtail.sort(lambda a, b: len(b[0])-len(a[0])) wordlist.extend(wordtail) # generate lexicon from words lexicon_offset = [0] lexicon = "" words = {} # build a lexicon string offset = 0 for w, x in wordlist: # encoding: bit 7 indicates last character in word (chr(128) # indicates the last character in an entire string) ww = w[:-1] + chr(ord(w[-1])+128) # reuse string tails, when possible o = lexicon.find(ww) if o < 0: o = offset lexicon = lexicon + ww offset = offset + len(w) words[w] = len(lexicon_offset) lexicon_offset.append(o) lexicon = map(ord, lexicon) # generate phrasebook from names and lexicon phrasebook = [0] phrasebook_offset = [0] * len(unicode.chars) for char in unicode.chars: name = names[char] if name: w = name.split() phrasebook_offset[char] = len(phrasebook) for w in w: i = words[w] if i < short: phrasebook.append(i) else: # store as two bytes phrasebook.append((i>>8) + short) phrasebook.append(i&255) assert getsize(phrasebook) == 1 # # unicode name hash table # extract names data = [] for char in unicode.chars: record = unicode.table[char] if record: name = record[1].strip() if name and name[0] != "<": data.append((name, char)) # the magic number 47 was chosen to minimize the number of # collisions on the current data set. if you like, change it # and see what happens... codehash = Hash("code", data, 47) print "--- Writing", FILE, "..." fp = open(FILE, "w") print >>fp, "/* this file was generated by %s %s */" % (SCRIPT, VERSION) print >>fp print >>fp, "#define NAME_MAXLEN", 256 print >>fp print >>fp, "/* lexicon */" Array("lexicon", lexicon).dump(fp, trace) Array("lexicon_offset", lexicon_offset).dump(fp, trace) # split decomposition index table offset1, offset2, shift = splitbins(phrasebook_offset, trace) print >>fp, "/* code->name phrasebook */" print >>fp, "#define phrasebook_shift", shift print >>fp, "#define phrasebook_short", short Array("phrasebook", phrasebook).dump(fp, trace) Array("phrasebook_offset1", offset1).dump(fp, trace) Array("phrasebook_offset2", offset2).dump(fp, trace) print >>fp, "/* name->code dictionary */" codehash.dump(fp, trace) fp.close()
def makeunicodename(unicode, trace): FILE = "Modules/unicodename_db.h" print "--- Preparing", FILE, "..." # collect names names = [None] * len(unicode.chars) for char in unicode.chars: record = unicode.table[char] if record: name = record[1].strip() if name and name[0] != "<": names[char] = name + chr(0) print len(filter(lambda n: n is not None, names)), "distinct names" # collect unique words from names (note that we differ between # words inside a sentence, and words ending a sentence. the # latter includes the trailing null byte. words = {} n = b = 0 for char in unicode.chars: name = names[char] if name: w = name.split() b = b + len(name) n = n + len(w) for w in w: l = words.get(w) if l: l.append(None) else: words[w] = [len(words)] print n, "words in text;", b, "bytes" wordlist = words.items() # sort on falling frequency # XXX: different Python versions produce a different order # for words with equal frequency wordlist.sort(lambda a, b: len(b[1])-len(a[1])) # figure out how many phrasebook escapes we need escapes = 0 while escapes * 256 < len(wordlist): escapes = escapes + 1 print escapes, "escapes" short = 256 - escapes assert short > 0 print short, "short indexes in lexicon" # statistics n = 0 for i in range(short): n = n + len(wordlist[i][1]) print n, "short indexes in phrasebook" # pick the most commonly used words, and sort the rest on falling # length (to maximize overlap) wordlist, wordtail = wordlist[:short], wordlist[short:] wordtail.sort(lambda a, b: len(b[0])-len(a[0])) wordlist.extend(wordtail) # generate lexicon from words lexicon_offset = [0] lexicon = "" words = {} # build a lexicon string offset = 0 for w, x in wordlist: # encoding: bit 7 indicates last character in word (chr(128) # indicates the last character in an entire string) ww = w[:-1] + chr(ord(w[-1])+128) # reuse string tails, when possible o = lexicon.find(ww) if o < 0: o = offset lexicon = lexicon + ww offset = offset + len(w) words[w] = len(lexicon_offset) lexicon_offset.append(o) lexicon = map(ord, lexicon) # generate phrasebook from names and lexicon phrasebook = [0] phrasebook_offset = [0] * len(unicode.chars) for char in unicode.chars: name = names[char] if name: w = name.split() phrasebook_offset[char] = len(phrasebook) for w in w: i = words[w] if i < short: phrasebook.append(i) else: # store as two bytes phrasebook.append((i>>8) + short) phrasebook.append(i&255) assert getsize(phrasebook) == 1 # # unicode name hash table # extract names data = [] for char in unicode.chars: record = unicode.table[char] if record: name = record[1].strip() if name and name[0] != "<": data.append((name, char)) # the magic number 47 was chosen to minimize the number of # collisions on the current data set. if you like, change it # and see what happens... codehash = Hash("code", data, 47) print "--- Writing", FILE, "..." fp = open(FILE, "w") print >>fp, "/* this file was generated by %s %s */" % (SCRIPT, VERSION) print >>fp print >>fp, "#define NAME_MAXLEN", 256 print >>fp print >>fp, "/* lexicon */" Array("lexicon", lexicon).dump(fp, trace) Array("lexicon_offset", lexicon_offset).dump(fp, trace) # split decomposition index table offset1, offset2, shift = splitbins(phrasebook_offset, trace) print >>fp, "/* code->name phrasebook */" print >>fp, "#define phrasebook_shift", shift print >>fp, "#define phrasebook_short", short Array("phrasebook", phrasebook).dump(fp, trace) Array("phrasebook_offset1", offset1).dump(fp, trace) Array("phrasebook_offset2", offset2).dump(fp, trace) print >>fp, "/* name->code dictionary */" codehash.dump(fp, trace) fp.close()
11,903
def __init__(self, filename, exclusions, expand=1): file = open(filename) table = [None] * 0x110000 while 1: s = file.readline() if not s: break s = s.strip().split(";") char = int(s[0], 16) table[char] = s
def __init__(self, filename, exclusions, expand=1): file = open(filename) table = [None] * 0x110000 while 1: s = file.readline() if not s: break s = s.strip().split(";") char = int(s[0], 16) table[char] = s
11,904
def __init__(self, filename, exclusions, expand=1): file = open(filename) table = [None] * 0x110000 while 1: s = file.readline() if not s: break s = s.strip().split(";") char = int(s[0], 16) table[char] = s
def __init__(self, filename, exclusions, expand=1): file = open(filename) table = [None] * 0x110000 while 1: s = file.readline() if not s: break s = s.strip().split(";") char = int(s[0], 16) table[char] = s
11,905
def myhash(s, magic): h = 0 for c in map(ord, s.upper()): h = (h * magic) + c ix = h & 0xff000000 if ix: h = (h ^ ((ix>>24) & 0xff)) & 0x00ffffff return h
def myhash(s, magic): h = 0 for c in map(ord, s.upper()): h = (h * magic) + c ix = h & 0xff000000L if ix: h = (h ^ ((ix>>24) & 0xff)) & 0x00ffffff return h
11,906
def printlist(x, width=70, indent=4): """Print the elements of iterable x to stdout. Optional arg width (default 70) is the maximum line length. Optional arg indent (default 4) is the number of blanks with which to begin each line. """ from textwrap import fill blanks = ' ' * indent print fill(' '.join(map(str, x)), width, initial_indent=blanks, subsequent_indent=blanks)
def printlist(x, width=70, indent=4): """Print the elements of iterable x to stdout. Optional arg width (default 70) is the maximum line length. Optional arg indent (default 4) is the number of blanks with which to begin each line. """ from textwrap import fill blanks = ' ' * indent print fill(' '.join(map(str, x)), width, initial_indent=blanks, subsequent_indent=blanks)
11,907
fp.write("def getbaseclasses(v):\n")
fp.write("def getbaseclasses(v):\n")
11,908
fp.write("def getbaseclasses(v):\n")
fp.write("def getbaseclasses(v):\n")
11,909
def _getlang(): # Figure out what the current language is set to. return locale.getlocale(locale.LC_TIME)
def _getlang(): # Figure out what the current language is set to. return locale.getlocale(locale.LC_TIME)
11,910
def _getlang(): # Figure out what the current language is set to. return locale.getlocale(locale.LC_TIME)
def _getlang(): # Figure out what the current language is set to. return locale.getlocale(locale.LC_TIME)
11,911
def prune_file_list (self): """Prune off branches that might slip into the file list as created by 'read_template()', but really don't belong there: * the build tree (typically "build") * the release tree itself (only an issue if we ran "sdist" previously with --keep-temp, or it aborted) * any RCS or CVS directories """ build = self.get_finalized_command('build') base_dir = self.distribution.get_fullname()
def prune_file_list (self): """Prune off branches that might slip into the file list as created by 'read_template()', but really don't belong there: * the build tree (typically "build") * the release tree itself (only an issue if we ran "sdist" previously with --keep-temp, or it aborted) * any RCS, CVS and .svn directories """ build = self.get_finalized_command('build') base_dir = self.distribution.get_fullname()
11,912
def prune_file_list (self): """Prune off branches that might slip into the file list as created by 'read_template()', but really don't belong there: * the build tree (typically "build") * the release tree itself (only an issue if we ran "sdist" previously with --keep-temp, or it aborted) * any RCS or CVS directories """ build = self.get_finalized_command('build') base_dir = self.distribution.get_fullname()
def prune_file_list (self): """Prune off branches that might slip into the file list as created by 'read_template()', but really don't belong there: * the build tree (typically "build") * the release tree itself (only an issue if we ran "sdist" previously with --keep-temp, or it aborted) * any RCS or CVS directories """ build = self.get_finalized_command('build') base_dir = self.distribution.get_fullname()
11,913
def interact(list, pythondir, options, title): """Let the user interact with the dialog""" opythondir = pythondir try: # Try to go to the "correct" dir for GetDirectory os.chdir(pythondir.as_pathname()) except os.error: pass d = GetNewDialog(DIALOG_ID, -1) tp, h, rect = d.GetDialogItem(TITLE_ITEM) SetDialogItemText(h, title) tp, h, rect = d.GetDialogItem(TEXT_ITEM) SetDialogItemText(h, string.joinfields(list, '\r'))
def interact(list, pythondir, options, title): """Let the user interact with the dialog""" opythondir = pythondir try: # Try to go to the "correct" dir for GetDirectory os.chdir(pythondir.as_pathname()) except os.error: pass d = GetNewDialog(DIALOG_ID, -1) tp, h, rect = d.GetDialogItem(TITLE_ITEM) SetDialogItemText(h, title) tp, h, rect = d.GetDialogItem(TEXT_ITEM) SetDialogItemText(h, string.joinfields(list, '\r'))
11,914
def interact(list, pythondir, options, title): """Let the user interact with the dialog""" opythondir = pythondir try: # Try to go to the "correct" dir for GetDirectory os.chdir(pythondir.as_pathname()) except os.error: pass d = GetNewDialog(DIALOG_ID, -1) tp, h, rect = d.GetDialogItem(TITLE_ITEM) SetDialogItemText(h, title) tp, h, rect = d.GetDialogItem(TEXT_ITEM) SetDialogItemText(h, string.joinfields(list, '\r'))
def interact(list, pythondir, options, title): """Let the user interact with the dialog""" opythondir = pythondir try: # Try to go to the "correct" dir for GetDirectory os.chdir(pythondir.as_pathname()) except os.error: pass d = GetNewDialog(DIALOG_ID, -1) tp, h, rect = d.GetDialogItem(TITLE_ITEM) SetDialogItemText(h, title) tp, h, rect = d.GetDialogItem(TEXT_ITEM) SetDialogItemText(h, string.joinfields(list, '\r'))
11,915
def process(filename): try: vin = VFile.RandomVinFile().init(filename) except IOError, msg: sys.stderr.write(filename + ': I/O error: ' + `msg` + '\n') return 1 except VFile.Error, msg: sys.stderr.write(msg + '\n') return 1 except EOFError: sys.stderr.write(filename + ': EOF in video file\n') return 1 if terse: print string.ljust(filename, maxwidth), kbytes = (VFile.getfilesize(filename) + 1023) / 1024 print string.rjust(`kbytes`, 5) + 'K', print ' ', string.ljust(`vin.version`, 5), print string.ljust(vin.format, 8), print string.rjust(`vin.width`, 4), print string.rjust(`vin.height`, 4), s = string.rjust(`vin.packfactor`, 2) if vin.packfactor and vin.format not in ('rgb', 'jpeg') and \ (vin.width/vin.packfactor) % 4 <> 0: s = s + '!' else: s = s + ' ' print s, sys.stdout.flush() else: vin.printinfo() if quick: if terse: print vin.close() return 0 try: vin.readcache() if not terse: print '[Using cached index]' except VFile.Error: if not terse: print '[Constructing index on the fly]' if not short: if delta: print 'Frame time deltas:', else: print 'Frame times:', n = 0 t = 0 told = 0 datasize = 0 while 1: try: t, ds, cs = vin.getnextframeheader() vin.skipnextframedata(ds, cs) except EOFError: break datasize = datasize + ds if cs: datasize = datasize + cs if not short: if n%8 == 0: sys.stdout.write('\n') if delta: sys.stdout.write('\t' + `t - told`) told = t else: sys.stdout.write('\t' + `t`) n = n+1 if not short: print if terse: print string.rjust(`n`, 6), print string.rjust(`int(n*10000.0/t)*0.1`, 5) else: print 'Total', n, 'frames in', t*0.001, 'sec.', if t: print '-- average', int(n*10000.0/t)*0.1, 'frames/sec', print print 'Total data', 0.1 * int(datasize / 102.4), 'Kbytes', if t: print '-- average', print 0.1 * int(datasize / 0.1024 / t), 'Kbytes/sec', print vin.close() return 0
def process(filename): try: vin = VFile.RandomVinFile().init(filename) except IOError, msg: sys.stderr.write(filename + ': I/O error: ' + `msg` + '\n') return 1 except VFile.Error, msg: sys.stderr.write(msg + '\n') return 1 except EOFError: sys.stderr.write(filename + ': EOF in video file\n') return 1 if terse: print string.ljust(filename, maxwidth), kbytes = (VFile.getfilesize(filename) + 1023) / 1024 print string.rjust(`kbytes`, 5) + 'K', print ' ', string.ljust(`vin.version`, 5), print string.ljust(vin.format, 8), print string.rjust(`vin.width`, 4), print string.rjust(`vin.height`, 4), if type(vin.packfactor) == type(()): xpf, ypf = vin.packfactor s = string.rjust(`xpf`, 2) + ',' + \ string.rjust(`ypf`, 2) else: s = s + ' ' print s, sys.stdout.flush() else: vin.printinfo() if quick: if terse: print vin.close() return 0 try: vin.readcache() if not terse: print '[Using cached index]' except VFile.Error: if not terse: print '[Constructing index on the fly]' if not short: if delta: print 'Frame time deltas:', else: print 'Frame times:', n = 0 t = 0 told = 0 datasize = 0 while 1: try: t, ds, cs = vin.getnextframeheader() vin.skipnextframedata(ds, cs) except EOFError: break datasize = datasize + ds if cs: datasize = datasize + cs if not short: if n%8 == 0: sys.stdout.write('\n') if delta: sys.stdout.write('\t' + `t - told`) told = t else: sys.stdout.write('\t' + `t`) n = n+1 if not short: print if terse: print string.rjust(`n`, 6), print string.rjust(`int(n*10000.0/t)*0.1`, 5) else: print 'Total', n, 'frames in', t*0.001, 'sec.', if t: print '-- average', int(n*10000.0/t)*0.1, 'frames/sec', print print 'Total data', 0.1 * int(datasize / 102.4), 'Kbytes', if t: print '-- average', print 0.1 * int(datasize / 0.1024 / t), 'Kbytes/sec', print vin.close() return 0
11,916
def process(filename): try: vin = VFile.RandomVinFile().init(filename) except IOError, msg: sys.stderr.write(filename + ': I/O error: ' + `msg` + '\n') return 1 except VFile.Error, msg: sys.stderr.write(msg + '\n') return 1 except EOFError: sys.stderr.write(filename + ': EOF in video file\n') return 1 if terse: print string.ljust(filename, maxwidth), kbytes = (VFile.getfilesize(filename) + 1023) / 1024 print string.rjust(`kbytes`, 5) + 'K', print ' ', string.ljust(`vin.version`, 5), print string.ljust(vin.format, 8), print string.rjust(`vin.width`, 4), print string.rjust(`vin.height`, 4), s = string.rjust(`vin.packfactor`, 2) if vin.packfactor and vin.format not in ('rgb', 'jpeg') and \ (vin.width/vin.packfactor) % 4 <> 0: s = s + '!' else: s = s + ' ' print s, sys.stdout.flush() else: vin.printinfo() if quick: if terse: print vin.close() return 0 try: vin.readcache() if not terse: print '[Using cached index]' except VFile.Error: if not terse: print '[Constructing index on the fly]' if not short: if delta: print 'Frame time deltas:', else: print 'Frame times:', n = 0 t = 0 told = 0 datasize = 0 while 1: try: t, ds, cs = vin.getnextframeheader() vin.skipnextframedata(ds, cs) except EOFError: break datasize = datasize + ds if cs: datasize = datasize + cs if not short: if n%8 == 0: sys.stdout.write('\n') if delta: sys.stdout.write('\t' + `t - told`) told = t else: sys.stdout.write('\t' + `t`) n = n+1 if not short: print if terse: print string.rjust(`n`, 6), print string.rjust(`int(n*10000.0/t)*0.1`, 5) else: print 'Total', n, 'frames in', t*0.001, 'sec.', if t: print '-- average', int(n*10000.0/t)*0.1, 'frames/sec', print print 'Total data', 0.1 * int(datasize / 102.4), 'Kbytes', if t: print '-- average', print 0.1 * int(datasize / 0.1024 / t), 'Kbytes/sec', print vin.close() return 0
def process(filename): try: vin = VFile.RandomVinFile().init(filename) except IOError, msg: sys.stderr.write(filename + ': I/O error: ' + `msg` + '\n') return 1 except VFile.Error, msg: sys.stderr.write(msg + '\n') return 1 except EOFError: sys.stderr.write(filename + ': EOF in video file\n') return 1 if terse: print string.ljust(filename, maxwidth), kbytes = (VFile.getfilesize(filename) + 1023) / 1024 print string.rjust(`kbytes`, 5) + 'K', print ' ', string.ljust(`vin.version`, 5), print string.ljust(vin.format, 8), print string.rjust(`vin.width`, 4), print string.rjust(`vin.height`, 4), s = string.rjust(`vin.packfactor`, 2) if vin.packfactor and vin.format not in ('rgb', 'jpeg') and \ (vin.width/vin.packfactor) % 4 <> 0: s = s + '!' else: s = string.rjust(`vin.packfactor`, 2) if type(vin.packfactor) == type(0) and \ vin.format not in ('rgb', 'jpeg') and \ (vin.width/vin.packfactor) % 4 <> 0: s = s + '! ' else: s = s + ' ' print s, sys.stdout.flush() else: vin.printinfo() if quick: if terse: print vin.close() return 0 try: vin.readcache() if not terse: print '[Using cached index]' except VFile.Error: if not terse: print '[Constructing index on the fly]' if not short: if delta: print 'Frame time deltas:', else: print 'Frame times:', n = 0 t = 0 told = 0 datasize = 0 while 1: try: t, ds, cs = vin.getnextframeheader() vin.skipnextframedata(ds, cs) except EOFError: break datasize = datasize + ds if cs: datasize = datasize + cs if not short: if n%8 == 0: sys.stdout.write('\n') if delta: sys.stdout.write('\t' + `t - told`) told = t else: sys.stdout.write('\t' + `t`) n = n+1 if not short: print if terse: print string.rjust(`n`, 6), print string.rjust(`int(n*10000.0/t)*0.1`, 5) else: print 'Total', n, 'frames in', t*0.001, 'sec.', if t: print '-- average', int(n*10000.0/t)*0.1, 'frames/sec', print print 'Total data', 0.1 * int(datasize / 102.4), 'Kbytes', if t: print '-- average', print 0.1 * int(datasize / 0.1024 / t), 'Kbytes/sec', print vin.close() return 0
11,917
def process(filename): try: vin = VFile.RandomVinFile().init(filename) except IOError, msg: sys.stderr.write(filename + ': I/O error: ' + `msg` + '\n') return 1 except VFile.Error, msg: sys.stderr.write(msg + '\n') return 1 except EOFError: sys.stderr.write(filename + ': EOF in video file\n') return 1 if terse: print string.ljust(filename, maxwidth), kbytes = (VFile.getfilesize(filename) + 1023) / 1024 print string.rjust(`kbytes`, 5) + 'K', print ' ', string.ljust(`vin.version`, 5), print string.ljust(vin.format, 8), print string.rjust(`vin.width`, 4), print string.rjust(`vin.height`, 4), s = string.rjust(`vin.packfactor`, 2) if vin.packfactor and vin.format not in ('rgb', 'jpeg') and \ (vin.width/vin.packfactor) % 4 <> 0: s = s + '!' else: s = s + ' ' print s, sys.stdout.flush() else: vin.printinfo() if quick: if terse: print vin.close() return 0 try: vin.readcache() if not terse: print '[Using cached index]' except VFile.Error: if not terse: print '[Constructing index on the fly]' if not short: if delta: print 'Frame time deltas:', else: print 'Frame times:', n = 0 t = 0 told = 0 datasize = 0 while 1: try: t, ds, cs = vin.getnextframeheader() vin.skipnextframedata(ds, cs) except EOFError: break datasize = datasize + ds if cs: datasize = datasize + cs if not short: if n%8 == 0: sys.stdout.write('\n') if delta: sys.stdout.write('\t' + `t - told`) told = t else: sys.stdout.write('\t' + `t`) n = n+1 if not short: print if terse: print string.rjust(`n`, 6), print string.rjust(`int(n*10000.0/t)*0.1`, 5) else: print 'Total', n, 'frames in', t*0.001, 'sec.', if t: print '-- average', int(n*10000.0/t)*0.1, 'frames/sec', print print 'Total data', 0.1 * int(datasize / 102.4), 'Kbytes', if t: print '-- average', print 0.1 * int(datasize / 0.1024 / t), 'Kbytes/sec', print vin.close() return 0
def process(filename): try: vin = VFile.RandomVinFile().init(filename) except IOError, msg: sys.stderr.write(filename + ': I/O error: ' + `msg` + '\n') return 1 except VFile.Error, msg: sys.stderr.write(msg + '\n') return 1 except EOFError: sys.stderr.write(filename + ': EOF in video file\n') return 1 if terse: print string.ljust(filename, maxwidth), kbytes = (VFile.getfilesize(filename) + 1023) / 1024 print string.rjust(`kbytes`, 5) + 'K', print ' ', string.ljust(`vin.version`, 5), print string.ljust(vin.format, 8), print string.rjust(`vin.width`, 4), print string.rjust(`vin.height`, 4), s = string.rjust(`vin.packfactor`, 2) if vin.packfactor and vin.format not in ('rgb', 'jpeg') and \ (vin.width/vin.packfactor) % 4 <> 0: s = s + '!' else: s = s + ' ' print s, sys.stdout.flush() else: vin.printinfo() if quick: if terse: print vin.close() return 0 try: vin.readcache() if not terse: print '[Using cached index]' except VFile.Error: if not terse: print '[Constructing index on the fly]' if not short: if delta: print 'Frame time deltas:', else: print 'Frame times:', n = 0 t = 0 told = 0 datasize = 0 while 1: try: t, ds, cs = vin.getnextframeheader() vin.skipnextframedata(ds, cs) except EOFError: break datasize = datasize + ds if cs: datasize = datasize + cs if not short: if n%8 == 0: sys.stdout.write('\n') if delta: sys.stdout.write('\t' + `t - told`) told = t else: sys.stdout.write('\t' + `t`) n = n+1 if not short: print if terse: print string.rjust(`n`, 6), if t: print string.rjust(`int(n*10000.0/t)*0.1`, 5), print else: print 'Total', n, 'frames in', t*0.001, 'sec.', if t: print '-- average', int(n*10000.0/t)*0.1, 'frames/sec', print print 'Total data', 0.1 * int(datasize / 102.4), 'Kbytes', if t: print '-- average', print 0.1 * int(datasize / 0.1024 / t), 'Kbytes/sec', print vin.close() return 0
11,918
def report(self): # XXX something decent pass
def report(self): # XXX something decent pass
11,919
def report(self): # XXX something decent pass
def report(self): # XXX something decent pass
11,920
def report(self): # XXX something decent pass
def report(self): # XXX something decent pass
11,921
def addPythonModules(self): self.message("Adding Python modules", 1)
def addPythonModules(self): self.message("Adding Python modules", 1)
11,922
def addPythonModules(self): self.message("Adding Python modules", 1)
def addPythonModules(self): self.message("Adding Python modules", 1)
11,923
def findDependencies(self): self.message("Finding module dependencies", 1) import modulefinder mf = modulefinder.ModuleFinder(excludes=self.excludeModules) # manually add our own site.py site = mf.add_module("site") site.__code__ = SITE_CO mf.scan_code(SITE_CO, site)
def findDependencies(self): self.message("Finding module dependencies", 1) import modulefinder mf = modulefinder.ModuleFinder(excludes=self.excludeModules) # manually add our own site.py site = mf.add_module("site") site.__code__ = SITE_CO mf.scan_code(SITE_CO, site)
11,924
def findDependencies(self): self.message("Finding module dependencies", 1) import modulefinder mf = modulefinder.ModuleFinder(excludes=self.excludeModules) # manually add our own site.py site = mf.add_module("site") site.__code__ = SITE_CO mf.scan_code(SITE_CO, site)
def findDependencies(self): self.message("Finding module dependencies", 1) import modulefinder mf = modulefinder.ModuleFinder(excludes=self.excludeModules) # manually add our own site.py site = mf.add_module("site") site.__code__ = SITE_CO mf.scan_code(SITE_CO, site)
11,925
def findDependencies(self): self.message("Finding module dependencies", 1) import modulefinder mf = modulefinder.ModuleFinder(excludes=self.excludeModules) # manually add our own site.py site = mf.add_module("site") site.__code__ = SITE_CO mf.scan_code(SITE_CO, site)
def findDependencies(self): self.message("Finding module dependencies", 1) import modulefinder mf = modulefinder.ModuleFinder(excludes=self.excludeModules) # manually add our own site.py site = mf.add_module("site") site.__code__ = SITE_CO mf.scan_code(SITE_CO, site)
11,926
def writePyc(code, path): f = open(path, "wb") f.write("\0" * 8) # don't bother about a time stamp marshal.dump(code, f) f.seek(0, 0) f.write(MAGIC) f.close()
def writePyc(code, path): f = open(path, "wb") f.write(MAGIC) f.write("\0" * 4) # don't bother about a time stamp marshal.dump(code, f) f.seek(0, 0) f.write(MAGIC) f.close()
11,927
def writePyc(code, path): f = open(path, "wb") f.write("\0" * 8) # don't bother about a time stamp marshal.dump(code, f) f.seek(0, 0) f.write(MAGIC) f.close()
def writePyc(code, path): f = open(path, "wb") f.write("\0" * 8) # don't bother about a time stamp marshal.dump(code, f) f.close()
11,928
def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None):
def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None):
11,929
def testAssert(self): # assert_stmt: 'assert' test [',' test] assert 1 assert 1, 1 assert lambda x:x assert 1, lambda x:x+1 try: assert 0, "msg" except AssertionError, e: self.assertEquals(e.args[0], "msg") # we can not expect an assertion error to be raised # if the tests are run in an optimized python #else: # self.fail("AssertionError not raised by assert 0")
def testAssert(self): # assert_stmt: 'assert' test [',' test] assert 1 assert 1, 1 assert lambda x:x assert 1, lambda x:x+1 try: assert 0, "msg" except AssertionError, e: self.assertEquals(e.args[0], "msg") # we can not expect an assertion error to be raised # if the tests are run in an optimized python #else: #else: if __debug__: self.fail("AssertionError not raised by assert 0") self.fail("AssertionError not raised by assert 0")
11,930
def import_module(self, partname, fqname, parent): self.msgin(3, "import_module", partname, fqname, parent) try: m = self.modules[fqname] except KeyError: pass else: self.msgout(3, "import_module ->", m) return m if self.badmodules.has_key(fqname): self.msgout(3, "import_module -> None") self.badmodules[fqname][parent.__name__] = None return None try: fp, pathname, stuff = self.find_module(partname, parent and parent.__path__) except ImportError: self.msgout(3, "import_module ->", None) return None try: m = self.load_module(fqname, fp, pathname, stuff) finally: if fp: fp.close() if parent: setattr(parent, partname, m) self.msgout(3, "import_module ->", m) return m
def import_module(self, partname, fqname, parent): self.msgin(3, "import_module", partname, fqname, parent) try: m = self.modules[fqname] except KeyError: pass else: self.msgout(3, "import_module ->", m) return m if self.badmodules.has_key(fqname): self.msgout(3, "import_module -> None") if parent: self.badmodules[fqname][parent.__name__] = None return None try: fp, pathname, stuff = self.find_module(partname, parent and parent.__path__) except ImportError: self.msgout(3, "import_module ->", None) return None try: m = self.load_module(fqname, fp, pathname, stuff) finally: if fp: fp.close() if parent: setattr(parent, partname, m) self.msgout(3, "import_module ->", m) return m
11,931
def _update(self, value): maxval = self.maxval if maxval == 0: # XXXX Quick fix. Should probably display an unknown duration value = 0 maxval = 1 if maxval > 32767: value = int(value/(maxval/32767.0)) maxval = 32767 progbar = self.d.GetDialogItemAsControl(3) progbar.SetControlMaximum(maxval) progbar.SetControlValue(value) # Test for cancel button ready, ev = Evt.WaitNextEvent( Events.mDownMask, 1 ) if ready : what,msg,when,where,mod = ev part = Win.FindWindow(where)[0] if Dlg.IsDialogEvent(ev): ds = Dlg.DialogSelect(ev) if ds[0] and ds[1] == self.d and ds[-1] == 1: self.w.HideWindow() self.w = None self.d = None raise KeyboardInterrupt, ev else: if part == 4: # inDrag self.d.DragWindow(where, screenbounds) else: MacOS.HandleEvent(ev)
def _update(self, value): maxval = self.maxval if maxval == 0: # XXXX Quick fix. Should probably display an unknown duration value = 0 maxval = 1 if maxval > 32767: value = int(value/(maxval/32767.0)) maxval = 32767 progbar = self.d.GetDialogItemAsControl(3) progbar.SetControlMaximum(maxval) progbar.SetControlValue(value) # Test for cancel button ready, ev = Evt.WaitNextEvent( Events.mDownMask, 1 ) if ready : what,msg,when,where,mod = ev part = Win.FindWindow(where)[0] if Dlg.IsDialogEvent(ev): ds = Dlg.DialogSelect(ev) if ds[0] and ds[1] == self.d and ds[-1] == 1: self.w.HideWindow() self.w = None self.d = None raise KeyboardInterrupt, ev else: if part == 4: # inDrag self.w.DragWindow(where, screenbounds) else: MacOS.HandleEvent(ev)
11,932
def _write_gzip_header(self): self.fileobj.write('\037\213') # magic header self.fileobj.write('\010') # compression method fname = self.filename[:-3] flags = 0 if fname: flags = FNAME self.fileobj.write(chr(flags)) write32(self.fileobj, int(time.time())) self.fileobj.write('\002') self.fileobj.write('\377') if fname: self.fileobj.write(fname + '\000')
def _write_gzip_header(self): self.fileobj.write('\037\213') # magic header self.fileobj.write('\010') # compression method fname = self.filename[:-3] flags = 0 if fname: flags = FNAME self.fileobj.write(chr(flags)) write32u(self.fileobj, long(time.time())) self.fileobj.write('\002') self.fileobj.write('\377') if fname: self.fileobj.write(fname + '\000')
11,933
def _read_eof(self): # We've read to the end of the file, so we have to rewind in order # to reread the 8 bytes containing the CRC and the file size. # We check the that the computed CRC and size of the # uncompressed data matches the stored values. self.fileobj.seek(-8, 1) crc32 = read32(self.fileobj) isize = read32(self.fileobj) if crc32 != self.crc: raise ValueError, "CRC check failed" elif isize != self.size: raise ValueError, "Incorrect length of data produced"
def _read_eof(self): # We've read to the end of the file, so we have to rewind in order # to reread the 8 bytes containing the CRC and the file size. # We check the that the computed CRC and size of the # uncompressed data matches the stored values. self.fileobj.seek(-8, 1) crc32 = read32(self.fileobj) isize = read32(self.fileobj) if crc32%0x100000000L != self.crc%0x100000000L: raise ValueError, "CRC check failed" elif isize != self.size: raise ValueError, "Incorrect length of data produced"
11,934
def do_event(self, (dev, val)): if dev == DEVICE.REDRAW: if self.vin: self.vin.redraw(val) if self.vout: self.vout.redraw(val)
def do_event(self, dev, val): if dev == DEVICE.REDRAW: if self.vin: self.vin.redraw(val) if self.vout: self.vout.redraw(val)
11,935
def cb_in_new(self, args): self.msg('') hd, tl = os.path.split(self.ifile) filename = fl.file_selector('Input video file', hd, '', tl) if not filename: return self.open_input(filename)
def cb_in_new(self, *args): self.msg('') hd, tl = os.path.split(self.ifile) filename = fl.file_selector('Input video file', hd, '', tl) if not filename: return self.open_input(filename)
11,936
def cb_in_close(self, args): self.msg('') self.close_input()
def cb_in_close(self, *args): self.msg('') self.close_input()
11,937
def cb_in_skip(self, args): if not self.icheck(): return if not self.vin.get(): self.err('End of input file') self.ishow()
def cb_in_skip(self, *args): if not self.icheck(): return if not self.vin.get(): self.err('End of input file') self.ishow()
11,938
def cb_in_back(self, args): if not self.icheck(): return if not self.vin.backup(): self.err('Input buffer exhausted') self.ishow()
def cb_in_back(self, *args): if not self.icheck(): return if not self.vin.backup(): self.err('Input buffer exhausted') self.ishow()
11,939
def cb_in_rewind(self, args): if not self.icheck(): return self.vin.rewind() self.ishow()
def cb_in_rewind(self, *args): if not self.icheck(): return self.vin.rewind() self.ishow()
11,940
def cb_copy(self, args): if not self.iocheck(): return data = self.vin.get() if not data: self.err('End of input file') self.ishow() return if self.vout.getinfo() <> self.vin.getinfo(): print 'Copying info...' self.vout.setinfo(self.vin.getinfo()) self.vout.put(data) self.oshow() self.ishow()
def cb_copy(self, *args): if not self.iocheck(): return data = self.vin.get() if not data: self.err('End of input file') self.ishow() return if self.vout.getinfo() <> self.vin.getinfo(): print 'Copying info...' self.vout.setinfo(self.vin.getinfo()) self.vout.put(data) self.oshow() self.ishow()
11,941
def cb_uncopy(self, args): if not self.iocheck(): return if not self.vout.backup(): self.err('Output buffer exhausted') return self.oshow() if not self.vin.backup(): self.err('Input buffer exhausted') return self.ishow()
def cb_uncopy(self, *args): if not self.iocheck(): return if not self.vout.backup(): self.err('Output buffer exhausted') return self.oshow() if not self.vin.backup(): self.err('Input buffer exhausted') return self.ishow()
11,942
def cb_out_new(self, args): self.msg('') hd, tl = os.path.split(self.ofile) filename = fl.file_selector('Output video file', hd, '', tl) if not filename: return self.open_output(filename)
def cb_out_new(self, *args): self.msg('') hd, tl = os.path.split(self.ofile) filename = fl.file_selector('Output video file', hd, '', tl) if not filename: return self.open_output(filename)
11,943
def cb_out_close(self, args): self.msg('') self.close_output()
def cb_out_close(self, *args): self.msg('') self.close_output()
11,944
def cb_out_skip(self, arg): if not self.ocheck(): return if not self.vout.forward(): self.err('Output buffer exhausted') self.oshow()
def cb_out_skip(self, *args): if not self.ocheck(): return if not self.vout.forward(): self.err('Output buffer exhausted') self.oshow()
11,945
def cb_out_back(self, args): if not self.ocheck(): return if not self.vout.backup(): self.err('Output buffer exhausted') self.oshow()
def cb_out_back(self, *args): if not self.ocheck(): return if not self.vout.backup(): self.err('Output buffer exhausted') self.oshow()
11,946
def cb_out_rewind(self, args): if not self.ocheck(): return self.vout.rewind() self.oshow()
def cb_out_rewind(self, *args): if not self.ocheck(): return self.vout.rewind() self.oshow()
11,947
def cb_quit(self, args): self.close_input() self.close_output() sys.exit(0)
def cb_quit(self, *args): self.close_input() self.close_output() sys.exit(0)
11,948
def addword(self, text, space): if self.nospace and not text: return self.nospace = 0 self.blanklines = 0 if not self.para: self.para = self.newpara() self.para.indent_left = self.leftindent self.para.just = self.just self.nextfont = self.font space = int(space * self.space) self.para.words.append(self.nextfont, text, \ self.d.textwidth(text), space, space, \ self.ascent, self.descent) self.nextfont = None
def addword(self, text, space): if self.nospace and not text: return self.nospace = 0 self.blanklines = 0 if not self.para: self.para = self.newpara() self.para.indent_left = self.leftindent self.para.just = self.just self.nextfont = self.font space = int(space * self.space) self.para.words.append((self.nextfont, text, self.d.textwidth(text), space, space, self.ascent, self.descent)) self.nextfont = None
11,949
def showanchor(self, id): for i in range(len(self.paralist)): p = self.paralist[i] if p.hasanchor(id): long1 = i, 0 long2 = i, len(p.extract()) hit = long1, long2 self.setselection(hit) self.window.show( \ (p.left, p.top), (p.right, p.bottom)) break
def showanchor(self, id): for i in range(len(self.paralist)): p = self.paralist[i] if p.hasanchor(id): long1 = i, 0 long2 = i, len(p.extract()) hit = long1, long2 self.setselection(hit) self.window.show( (p.left, p.top), (p.right, p.bottom)) break
11,950
def test_iterator(self): eq = self.assertEqual unless = self.failUnless it = iter(self._fp) # Does this object support the iteration protocol? unless(hasattr(it, '__iter__')) unless(hasattr(it, 'next')) i = 0 for line in self._fp: eq(line, self._line + '\n') i += 1 eq(i, 5)
def test_iterator(self): eq = self.assertEqual unless = self.failUnless eq(iter(self._fp), self._fp) # Does this object support the iteration protocol? unless(hasattr(it, '__iter__')) unless(hasattr(it, 'next')) i = 0 for line in self._fp: eq(line, self._line + '\n') i += 1 eq(i, 5)
11,951
def test_iterator(self): eq = self.assertEqual unless = self.failUnless it = iter(self._fp) # Does this object support the iteration protocol? unless(hasattr(it, '__iter__')) unless(hasattr(it, 'next')) i = 0 for line in self._fp: eq(line, self._line + '\n') i += 1 eq(i, 5)
def test_iterator(self): eq = self.assertEqual unless = self.failUnless it = iter(self._fp) # Does this object support the iteration protocol? unless(hasattr(self._fp, '__iter__')) unless(hasattr(self._fp, 'next')) i = 0 for line in self._fp: eq(line, self._line + '\n') i += 1 eq(i, 5)
11,952
def startchange(): global hist, out hist.chaptertype = "chapter" hist.inenv = [] hist.nodenames = [] hist.cindex = [] hist.inargs = 0 hist.enumeratenesting, hist.itemizenesting = 0, 0 out.doublenodes = [] out.doublecindeces = []
def startchange(): global hist, out hist.chaptertype = "chapter" hist.inenv = [] hist.nodenames = [] hist.cindex = [] hist.inargs = 0 hist.enumeratenesting, hist.itemizenesting = 0, 0 out.doublenodes = [] out.doublecindeces = []
11,953
def do_funcdesc(length, buf, pp, i, index=1): startpoint = i-1 ch = pp[startpoint] wh = ch.where length, newi = getnextarg(length, buf, pp, i) funcname = chunk(GROUP, wh, pp[i:newi]) del pp[i:newi] length = length - (newi-i) save = hist.inargs hist.inargs = 1 length, newi = getnextarg(length, buf, pp, i) hist.inargs = save del save the_args = [chunk(PLAIN, wh, '()'[0])] + pp[i:newi] + \ [chunk(PLAIN, wh, '()'[1])] del pp[i:newi] length = length - (newi-i) idxsi = hist.indexsubitem # words command = '' cat_class = '' if idxsi and idxsi[-1] in ('method', 'protocol', 'attribute'): command = 'defmethod' cat_class = string.join(idxsi[:-1]) elif len(idxsi) == 2 and idxsi[1] == 'function': command = 'deffn' cat_class = string.join(idxsi) elif len(idxsi) == 3 and idxsi[:2] == ['in', 'module']: command = 'deffn' cat_class = 'function of ' + string.join(idxsi[1:]) elif len(idxsi) > 3 and idxsi[:2] == ['in', 'modules']: command = 'deffn' cat_class = 'function of ' + string.join(idxsi[1:]) if not command: raise error, 'don\'t know what to do with indexsubitem ' + `idxsi` ch.chtype = chunk_type[CSLINE] ch.data = command cslinearg = [chunk(GROUP, wh, [chunk(PLAIN, wh, cat_class)])] cslinearg.append(chunk(PLAIN, wh, ' ')) cslinearg.append(funcname) cslinearg.append(chunk(PLAIN, wh, ' ')) l = len(cslinearg) cslinearg[l:l] = the_args pp.insert(i, chunk(GROUP, wh, cslinearg)) i, length = i+1, length+1 hist.command = command return length, i
def do_funcdesc(length, buf, pp, i, index=1): startpoint = i-1 ch = pp[startpoint] wh = ch.where length, newi = getnextarg(length, buf, pp, i) funcname = chunk(GROUP, wh, pp[i:newi]) del pp[i:newi] length = length - (newi-i) save = hist.inargs hist.inargs = 1 length, newi = getnextarg(length, buf, pp, i) hist.inargs = save del save the_args = [chunk(PLAIN, wh, '()'[0])] + pp[i:newi] + \ [chunk(PLAIN, wh, '()'[1])] del pp[i:newi] length = length - (newi-i) idxsi = hist.indexsubitem # words command = 'deffn' if hist.this_module: cat_class = 'function of ' + hist.this_module else: cat_class = 'built-in function' ch.chtype = chunk_type[CSLINE] ch.data = command cslinearg = [chunk(GROUP, wh, [chunk(PLAIN, wh, cat_class)])] cslinearg.append(chunk(PLAIN, wh, ' ')) cslinearg.append(funcname) cslinearg.append(chunk(PLAIN, wh, ' ')) l = len(cslinearg) cslinearg[l:l] = the_args pp.insert(i, chunk(GROUP, wh, cslinearg)) i, length = i+1, length+1 hist.command = command return length, i
11,954
def do_excdesc(length, buf, pp, i): startpoint = i-1 ch = pp[startpoint] wh = ch.where length, newi = getnextarg(length, buf, pp, i) excname = chunk(GROUP, wh, pp[i:newi]) del pp[i:newi] length = length - (newi-i) idxsi = hist.indexsubitem # words command = '' cat_class = '' class_class = '' if len(idxsi) == 2 and idxsi[1] == 'exception': command = 'defvr' cat_class = string.join(idxsi) elif len(idxsi) == 3 and idxsi[:2] == ['in', 'module']: command = 'defcv' cat_class = 'exception' class_class = string.join(idxsi[1:]) elif len(idxsi) == 4 and idxsi[:3] == ['exception', 'in', 'module']: command = 'defcv' cat_class = 'exception' class_class = string.join(idxsi[2:]) elif idxsi == ['built-in', 'exception', 'base', 'class']: command = 'defvr' cat_class = 'exception base class' else: raise error, 'don\'t know what to do with indexsubitem ' + `idxsi` ch.chtype = chunk_type[CSLINE] ch.data = command cslinearg = [chunk(GROUP, wh, [chunk(PLAIN, wh, cat_class)])] cslinearg.append(chunk(PLAIN, wh, ' ')) if class_class: cslinearg.append(chunk(GROUP, wh, [chunk(PLAIN, wh, class_class)])) cslinearg.append(chunk(PLAIN, wh, ' ')) cslinearg.append(excname) pp.insert(i, chunk(GROUP, wh, cslinearg)) i, length = i+1, length+1 hist.command = command return length, i
def do_excdesc(length, buf, pp, i): startpoint = i-1 ch = pp[startpoint] wh = ch.where length, newi = getnextarg(length, buf, pp, i) excname = chunk(GROUP, wh, pp[i:newi]) del pp[i:newi] length = length - (newi-i) idxsi = hist.indexsubitem # words command = '' cat_class = '' class_class = '' if idxsi == ['built-in', 'exception', 'base', 'class']: command = 'defvr' cat_class = 'exception base class' else: raise error, 'don\'t know what to do with indexsubitem ' + `idxsi` ch.chtype = chunk_type[CSLINE] ch.data = command cslinearg = [chunk(GROUP, wh, [chunk(PLAIN, wh, cat_class)])] cslinearg.append(chunk(PLAIN, wh, ' ')) if class_class: cslinearg.append(chunk(GROUP, wh, [chunk(PLAIN, wh, class_class)])) cslinearg.append(chunk(PLAIN, wh, ' ')) cslinearg.append(excname) pp.insert(i, chunk(GROUP, wh, cslinearg)) i, length = i+1, length+1 hist.command = command return length, i
11,955
def do_excdesc(length, buf, pp, i): startpoint = i-1 ch = pp[startpoint] wh = ch.where length, newi = getnextarg(length, buf, pp, i) excname = chunk(GROUP, wh, pp[i:newi]) del pp[i:newi] length = length - (newi-i) idxsi = hist.indexsubitem # words command = '' cat_class = '' class_class = '' if len(idxsi) == 2 and idxsi[1] == 'exception': command = 'defvr' cat_class = string.join(idxsi) elif len(idxsi) == 3 and idxsi[:2] == ['in', 'module']: command = 'defcv' cat_class = 'exception' class_class = string.join(idxsi[1:]) elif len(idxsi) == 4 and idxsi[:3] == ['exception', 'in', 'module']: command = 'defcv' cat_class = 'exception' class_class = string.join(idxsi[2:]) elif idxsi == ['built-in', 'exception', 'base', 'class']: command = 'defvr' cat_class = 'exception base class' else: raise error, 'don\'t know what to do with indexsubitem ' + `idxsi` ch.chtype = chunk_type[CSLINE] ch.data = command cslinearg = [chunk(GROUP, wh, [chunk(PLAIN, wh, cat_class)])] cslinearg.append(chunk(PLAIN, wh, ' ')) if class_class: cslinearg.append(chunk(GROUP, wh, [chunk(PLAIN, wh, class_class)])) cslinearg.append(chunk(PLAIN, wh, ' ')) cslinearg.append(excname) pp.insert(i, chunk(GROUP, wh, cslinearg)) i, length = i+1, length+1 hist.command = command return length, i
def do_excdesc(length, buf, pp, i): startpoint = i-1 ch = pp[startpoint] wh = ch.where length, newi = getnextarg(length, buf, pp, i) excname = chunk(GROUP, wh, pp[i:newi]) del pp[i:newi] length = length - (newi-i) idxsi = hist.indexsubitem # words command = '' cat_class = '' class_class = '' if len(idxsi) == 2 and idxsi[1] == 'exception': command = 'defvr' cat_class = string.join(idxsi) elif len(idxsi) == 3 and idxsi[:2] == ['in', 'module']: command = 'defcv' cat_class = 'exception' class_class = string.join(idxsi[1:]) elif len(idxsi) == 4 and idxsi[:3] == ['exception', 'in', 'module']: command = 'defcv' cat_class = 'exception' class_class = string.join(idxsi[2:]) elif idxsi == ['built-in', 'exception', 'base', 'class']: command = 'defvr' cat_class = 'exception base class' else: command = 'defcv' cat_class = 'exception' ch.chtype = chunk_type[CSLINE] ch.data = command cslinearg = [chunk(GROUP, wh, [chunk(PLAIN, wh, cat_class)])] cslinearg.append(chunk(PLAIN, wh, ' ')) if class_class: cslinearg.append(chunk(GROUP, wh, [chunk(PLAIN, wh, class_class)])) cslinearg.append(chunk(PLAIN, wh, ' ')) cslinearg.append(excname) pp.insert(i, chunk(GROUP, wh, cslinearg)) i, length = i+1, length+1 hist.command = command return length, i
11,956
def changeit(buf, pp): global onlylatexspecial, hist, out i, length = 0, len(pp) while 1: # sanity check: length should always equal len(pp) if len(pp) != length: print i, pp[i] raise 'FATAL', 'inconsistent length. thought ' + `length` + ', but should really be ' + `len(pp)` if i >= length: break ch = pp[i] i = i + 1 if type(ch) is StringType: #normally, only chunks are present in pp, # but in some cases, some extra info # has been inserted, e.g., the \end{...} clauses raise 'FATAL', 'got string, probably too many ' + `end` if ch.chtype == chunk_type[GROUP]: # check for {\em ...} constructs data = ch.data if data and \ data[0].chtype == chunk_type[CSNAME] and \ fontchanges.has_key(s(buf, data[0].data)): k = s(buf, data[0].data) del data[0] pp.insert(i-1, chunk(CSNAME, ch.where, fontchanges[k])) length, i = length+1, i+1 elif data: if len(data) \ and data[0].chtype == chunk_type[GROUP] \ and len(data[0].data) \ and data[0].data[0].chtype == chunk_type[CSNAME] \ and s(buf, data[0].data[0].data) == 'e': data[0] = data[0].data[0] print "invoking \\e magic group transform..." else:
def changeit(buf, pp): global onlylatexspecial, hist, out i, length = 0, len(pp) while 1: # sanity check: length should always equal len(pp) if len(pp) != length: print i, pp[i] raise 'FATAL', 'inconsistent length. thought ' + `length` + ', but should really be ' + `len(pp)` if i >= length: break ch = pp[i] i = i + 1 if type(ch) is StringType: #normally, only chunks are present in pp, # but in some cases, some extra info # has been inserted, e.g., the \end{...} clauses raise 'FATAL', 'got string, probably too many ' + `end` if ch.chtype == chunk_type[GROUP]: # check for {\em ...} constructs data = ch.data if data and \ data[0].chtype == chunk_type[CSNAME] and \ fontchanges.has_key(s(buf, data[0].data)): k = s(buf, data[0].data) del data[0] pp.insert(i-1, chunk(CSNAME, ch.where, fontchanges[k])) length, i = length+1, i+1 elif data: if len(data) \ and data[0].chtype == chunk_type[GROUP] \ and len(data[0].data) \ and data[0].data[0].chtype == chunk_type[CSNAME] \ and s(buf, data[0].data[0].data) == 'e': data[0] = data[0].data[0] print "invoking \\e magic group transform..." else:
11,957
def changeit(buf, pp): global onlylatexspecial, hist, out i, length = 0, len(pp) while 1: # sanity check: length should always equal len(pp) if len(pp) != length: print i, pp[i] raise 'FATAL', 'inconsistent length. thought ' + `length` + ', but should really be ' + `len(pp)` if i >= length: break ch = pp[i] i = i + 1 if type(ch) is StringType: #normally, only chunks are present in pp, # but in some cases, some extra info # has been inserted, e.g., the \end{...} clauses raise 'FATAL', 'got string, probably too many ' + `end` if ch.chtype == chunk_type[GROUP]: # check for {\em ...} constructs data = ch.data if data and \ data[0].chtype == chunk_type[CSNAME] and \ fontchanges.has_key(s(buf, data[0].data)): k = s(buf, data[0].data) del data[0] pp.insert(i-1, chunk(CSNAME, ch.where, fontchanges[k])) length, i = length+1, i+1 elif data: if len(data) \ and data[0].chtype == chunk_type[GROUP] \ and len(data[0].data) \ and data[0].data[0].chtype == chunk_type[CSNAME] \ and s(buf, data[0].data[0].data) == 'e': data[0] = data[0].data[0] print "invoking \\e magic group transform..." else:
def changeit(buf, pp): global onlylatexspecial, hist, out i, length = 0, len(pp) while 1: # sanity check: length should always equal len(pp) if len(pp) != length: print i, pp[i] raise 'FATAL', 'inconsistent length. thought ' + `length` + ', but should really be ' + `len(pp)` if i >= length: break ch = pp[i] i = i + 1 if type(ch) is StringType: #normally, only chunks are present in pp, # but in some cases, some extra info # has been inserted, e.g., the \end{...} clauses raise 'FATAL', 'got string, probably too many ' + `end` if ch.chtype == chunk_type[GROUP]: # check for {\em ...} constructs data = ch.data if data and \ data[0].chtype == chunk_type[CSNAME] and \ fontchanges.has_key(s(buf, data[0].data)): k = s(buf, data[0].data) del data[0] pp.insert(i-1, chunk(CSNAME, ch.where, fontchanges[k])) length, i = length+1, i+1 elif data: if len(data) \ and data[0].chtype == chunk_type[GROUP] \ and len(data[0].data) \ and data[0].data[0].chtype == chunk_type[CSNAME] \ and s(buf, data[0].data[0].data) == 'e': data[0] = data[0].data[0] print "invoking \\e magic group transform..." else:
11,958
def changeit(buf, pp): global onlylatexspecial, hist, out i, length = 0, len(pp) while 1: # sanity check: length should always equal len(pp) if len(pp) != length: print i, pp[i] raise 'FATAL', 'inconsistent length. thought ' + `length` + ', but should really be ' + `len(pp)` if i >= length: break ch = pp[i] i = i + 1 if type(ch) is StringType: #normally, only chunks are present in pp, # but in some cases, some extra info # has been inserted, e.g., the \end{...} clauses raise 'FATAL', 'got string, probably too many ' + `end` if ch.chtype == chunk_type[GROUP]: # check for {\em ...} constructs data = ch.data if data and \ data[0].chtype == chunk_type[CSNAME] and \ fontchanges.has_key(s(buf, data[0].data)): k = s(buf, data[0].data) del data[0] pp.insert(i-1, chunk(CSNAME, ch.where, fontchanges[k])) length, i = length+1, i+1 elif data: if len(data) \ and data[0].chtype == chunk_type[GROUP] \ and len(data[0].data) \ and data[0].data[0].chtype == chunk_type[CSNAME] \ and s(buf, data[0].data[0].data) == 'e': data[0] = data[0].data[0] print "invoking \\e magic group transform..." else:
def changeit(buf, pp): global onlylatexspecial, hist, out i, length = 0, len(pp) while 1: # sanity check: length should always equal len(pp) if len(pp) != length: print i, pp[i] raise 'FATAL', 'inconsistent length. thought ' + `length` + ', but should really be ' + `len(pp)` if i >= length: break ch = pp[i] i = i + 1 if type(ch) is StringType: #normally, only chunks are present in pp, # but in some cases, some extra info # has been inserted, e.g., the \end{...} clauses raise 'FATAL', 'got string, probably too many ' + `end` if ch.chtype == chunk_type[GROUP]: # check for {\em ...} constructs data = ch.data if data and \ data[0].chtype == chunk_type[CSNAME] and \ fontchanges.has_key(s(buf, data[0].data)): k = s(buf, data[0].data) del data[0] pp.insert(i-1, chunk(CSNAME, ch.where, fontchanges[k])) length, i = length+1, i+1 elif data: if len(data) \ and data[0].chtype == chunk_type[GROUP] \ and len(data[0].data) \ and data[0].data[0].chtype == chunk_type[CSNAME] \ and s(buf, data[0].data[0].data) == 'e': data[0] = data[0].data[0] print "invoking \\e magic group transform..." else:
11,959
def changeit(buf, pp): global onlylatexspecial, hist, out i, length = 0, len(pp) while 1: # sanity check: length should always equal len(pp) if len(pp) != length: print i, pp[i] raise 'FATAL', 'inconsistent length. thought ' + `length` + ', but should really be ' + `len(pp)` if i >= length: break ch = pp[i] i = i + 1 if type(ch) is StringType: #normally, only chunks are present in pp, # but in some cases, some extra info # has been inserted, e.g., the \end{...} clauses raise 'FATAL', 'got string, probably too many ' + `end` if ch.chtype == chunk_type[GROUP]: # check for {\em ...} constructs data = ch.data if data and \ data[0].chtype == chunk_type[CSNAME] and \ fontchanges.has_key(s(buf, data[0].data)): k = s(buf, data[0].data) del data[0] pp.insert(i-1, chunk(CSNAME, ch.where, fontchanges[k])) length, i = length+1, i+1 elif data: if len(data) \ and data[0].chtype == chunk_type[GROUP] \ and len(data[0].data) \ and data[0].data[0].chtype == chunk_type[CSNAME] \ and s(buf, data[0].data[0].data) == 'e': data[0] = data[0].data[0] print "invoking \\e magic group transform..." else:
def changeit(buf, pp): global onlylatexspecial, hist, out i, length = 0, len(pp) while 1: # sanity check: length should always equal len(pp) if len(pp) != length: print i, pp[i] raise 'FATAL', 'inconsistent length. thought ' + `length` + ', but should really be ' + `len(pp)` if i >= length: break ch = pp[i] i = i + 1 if type(ch) is StringType: #normally, only chunks are present in pp, # but in some cases, some extra info # has been inserted, e.g., the \end{...} clauses raise 'FATAL', 'got string, probably too many ' + `end` if ch.chtype == chunk_type[GROUP]: # check for {\em ...} constructs data = ch.data if data and \ data[0].chtype == chunk_type[CSNAME] and \ fontchanges.has_key(s(buf, data[0].data)): k = s(buf, data[0].data) del data[0] pp.insert(i-1, chunk(CSNAME, ch.where, fontchanges[k])) length, i = length+1, i+1 elif data: if len(data) \ and data[0].chtype == chunk_type[GROUP] \ and len(data[0].data) \ and data[0].data[0].chtype == chunk_type[CSNAME] \ and s(buf, data[0].data[0].data) == 'e': data[0] = data[0].data[0] print "invoking \\e magic group transform..." else:
11,960
def changeit(buf, pp): global onlylatexspecial, hist, out i, length = 0, len(pp) while 1: # sanity check: length should always equal len(pp) if len(pp) != length: print i, pp[i] raise 'FATAL', 'inconsistent length. thought ' + `length` + ', but should really be ' + `len(pp)` if i >= length: break ch = pp[i] i = i + 1 if type(ch) is StringType: #normally, only chunks are present in pp, # but in some cases, some extra info # has been inserted, e.g., the \end{...} clauses raise 'FATAL', 'got string, probably too many ' + `end` if ch.chtype == chunk_type[GROUP]: # check for {\em ...} constructs data = ch.data if data and \ data[0].chtype == chunk_type[CSNAME] and \ fontchanges.has_key(s(buf, data[0].data)): k = s(buf, data[0].data) del data[0] pp.insert(i-1, chunk(CSNAME, ch.where, fontchanges[k])) length, i = length+1, i+1 elif data: if len(data) \ and data[0].chtype == chunk_type[GROUP] \ and len(data[0].data) \ and data[0].data[0].chtype == chunk_type[CSNAME] \ and s(buf, data[0].data[0].data) == 'e': data[0] = data[0].data[0] print "invoking \\e magic group transform..." else:
def changeit(buf, pp): global onlylatexspecial, hist, out i, length = 0, len(pp) while 1: # sanity check: length should always equal len(pp) if len(pp) != length: print i, pp[i] raise 'FATAL', 'inconsistent length. thought ' + `length` + ', but should really be ' + `len(pp)` if i >= length: break ch = pp[i] i = i + 1 if type(ch) is StringType: #normally, only chunks are present in pp, # but in some cases, some extra info # has been inserted, e.g., the \end{...} clauses raise 'FATAL', 'got string, probably too many ' + `end` if ch.chtype == chunk_type[GROUP]: # check for {\em ...} constructs data = ch.data if data and \ data[0].chtype == chunk_type[CSNAME] and \ fontchanges.has_key(s(buf, data[0].data)): k = s(buf, data[0].data) del data[0] pp.insert(i-1, chunk(CSNAME, ch.where, fontchanges[k])) length, i = length+1, i+1 elif data: if len(data) \ and data[0].chtype == chunk_type[GROUP] \ and len(data[0].data) \ and data[0].data[0].chtype == chunk_type[CSNAME] \ and s(buf, data[0].data[0].data) == 'e': data[0] = data[0].data[0] print "invoking \\e magic group transform..." else:
11,961
def changeit(buf, pp): global onlylatexspecial, hist, out i, length = 0, len(pp) while 1: # sanity check: length should always equal len(pp) if len(pp) != length: print i, pp[i] raise 'FATAL', 'inconsistent length. thought ' + `length` + ', but should really be ' + `len(pp)` if i >= length: break ch = pp[i] i = i + 1 if type(ch) is StringType: #normally, only chunks are present in pp, # but in some cases, some extra info # has been inserted, e.g., the \end{...} clauses raise 'FATAL', 'got string, probably too many ' + `end` if ch.chtype == chunk_type[GROUP]: # check for {\em ...} constructs data = ch.data if data and \ data[0].chtype == chunk_type[CSNAME] and \ fontchanges.has_key(s(buf, data[0].data)): k = s(buf, data[0].data) del data[0] pp.insert(i-1, chunk(CSNAME, ch.where, fontchanges[k])) length, i = length+1, i+1 elif data: if len(data) \ and data[0].chtype == chunk_type[GROUP] \ and len(data[0].data) \ and data[0].data[0].chtype == chunk_type[CSNAME] \ and s(buf, data[0].data[0].data) == 'e': data[0] = data[0].data[0] print "invoking \\e magic group transform..." else:
def changeit(buf, pp): global onlylatexspecial, hist, out i, length = 0, len(pp) while 1: # sanity check: length should always equal len(pp) if len(pp) != length: print i, pp[i] raise 'FATAL', 'inconsistent length. thought ' + `length` + ', but should really be ' + `len(pp)` if i >= length: break ch = pp[i] i = i + 1 if type(ch) is StringType: #normally, only chunks are present in pp, # but in some cases, some extra info # has been inserted, e.g., the \end{...} clauses raise 'FATAL', 'got string, probably too many ' + `end` if ch.chtype == chunk_type[GROUP]: # check for {\em ...} constructs data = ch.data if data and \ data[0].chtype == chunk_type[CSNAME] and \ fontchanges.has_key(s(buf, data[0].data)): k = s(buf, data[0].data) del data[0] pp.insert(i-1, chunk(CSNAME, ch.where, fontchanges[k])) length, i = length+1, i+1 elif data: if len(data) \ and data[0].chtype == chunk_type[GROUP] \ and len(data[0].data) \ and data[0].data[0].chtype == chunk_type[CSNAME] \ and s(buf, data[0].data[0].data) == 'e': data[0] = data[0].data[0] print "invoking \\e magic group transform..." else:
11,962
def changeit(buf, pp): global onlylatexspecial, hist, out i, length = 0, len(pp) while 1: # sanity check: length should always equal len(pp) if len(pp) != length: print i, pp[i] raise 'FATAL', 'inconsistent length. thought ' + `length` + ', but should really be ' + `len(pp)` if i >= length: break ch = pp[i] i = i + 1 if type(ch) is StringType: #normally, only chunks are present in pp, # but in some cases, some extra info # has been inserted, e.g., the \end{...} clauses raise 'FATAL', 'got string, probably too many ' + `end` if ch.chtype == chunk_type[GROUP]: # check for {\em ...} constructs data = ch.data if data and \ data[0].chtype == chunk_type[CSNAME] and \ fontchanges.has_key(s(buf, data[0].data)): k = s(buf, data[0].data) del data[0] pp.insert(i-1, chunk(CSNAME, ch.where, fontchanges[k])) length, i = length+1, i+1 elif data: if len(data) \ and data[0].chtype == chunk_type[GROUP] \ and len(data[0].data) \ and data[0].data[0].chtype == chunk_type[CSNAME] \ and s(buf, data[0].data[0].data) == 'e': data[0] = data[0].data[0] print "invoking \\e magic group transform..." else:
def changeit(buf, pp): global onlylatexspecial, hist, out i, length = 0, len(pp) while 1: # sanity check: length should always equal len(pp) if len(pp) != length: print i, pp[i] raise 'FATAL', 'inconsistent length. thought ' + `length` + ', but should really be ' + `len(pp)` if i >= length: break ch = pp[i] i = i + 1 if type(ch) is StringType: #normally, only chunks are present in pp, # but in some cases, some extra info # has been inserted, e.g., the \end{...} clauses raise 'FATAL', 'got string, probably too many ' + `end` if ch.chtype == chunk_type[GROUP]: # check for {\em ...} constructs data = ch.data if data and \ data[0].chtype == chunk_type[CSNAME] and \ fontchanges.has_key(s(buf, data[0].data)): k = s(buf, data[0].data) del data[0] pp.insert(i-1, chunk(CSNAME, ch.where, fontchanges[k])) length, i = length+1, i+1 elif data: if len(data) \ and data[0].chtype == chunk_type[GROUP] \ and len(data[0].data) \ and data[0].data[0].chtype == chunk_type[CSNAME] \ and s(buf, data[0].data[0].data) == 'e': data[0] = data[0].data[0] print "invoking \\e magic group transform..." else:
11,963
def changeit(buf, pp): global onlylatexspecial, hist, out i, length = 0, len(pp) while 1: # sanity check: length should always equal len(pp) if len(pp) != length: print i, pp[i] raise 'FATAL', 'inconsistent length. thought ' + `length` + ', but should really be ' + `len(pp)` if i >= length: break ch = pp[i] i = i + 1 if type(ch) is StringType: #normally, only chunks are present in pp, # but in some cases, some extra info # has been inserted, e.g., the \end{...} clauses raise 'FATAL', 'got string, probably too many ' + `end` if ch.chtype == chunk_type[GROUP]: # check for {\em ...} constructs data = ch.data if data and \ data[0].chtype == chunk_type[CSNAME] and \ fontchanges.has_key(s(buf, data[0].data)): k = s(buf, data[0].data) del data[0] pp.insert(i-1, chunk(CSNAME, ch.where, fontchanges[k])) length, i = length+1, i+1 elif data: if len(data) \ and data[0].chtype == chunk_type[GROUP] \ and len(data[0].data) \ and data[0].data[0].chtype == chunk_type[CSNAME] \ and s(buf, data[0].data[0].data) == 'e': data[0] = data[0].data[0] print "invoking \\e magic group transform..." else:
def changeit(buf, pp): global onlylatexspecial, hist, out i, length = 0, len(pp) while 1: # sanity check: length should always equal len(pp) if len(pp) != length: print i, pp[i] raise 'FATAL', 'inconsistent length. thought ' + `length` + ', but should really be ' + `len(pp)` if i >= length: break ch = pp[i] i = i + 1 if type(ch) is StringType: #normally, only chunks are present in pp, # but in some cases, some extra info # has been inserted, e.g., the \end{...} clauses raise 'FATAL', 'got string, probably too many ' + `end` if ch.chtype == chunk_type[GROUP]: # check for {\em ...} constructs data = ch.data if data and \ data[0].chtype == chunk_type[CSNAME] and \ fontchanges.has_key(s(buf, data[0].data)): k = s(buf, data[0].data) del data[0] pp.insert(i-1, chunk(CSNAME, ch.where, fontchanges[k])) length, i = length+1, i+1 elif data: if len(data) \ and data[0].chtype == chunk_type[GROUP] \ and len(data[0].data) \ and data[0].data[0].chtype == chunk_type[CSNAME] \ and s(buf, data[0].data[0].data) == 'e': data[0] = data[0].data[0] print "invoking \\e magic group transform..." else:
11,964
def dumpit(buf, wm, pp): global out i, length = 0, len(pp) addspace = 0 while 1: if len(pp) != length: raise 'FATAL', 'inconsistent length' if i == length: break ch = pp[i] i = i + 1 dospace = addspace addspace = 0 if ch.chtype == chunk_type[CSNAME]: s_buf_data = s(buf, ch.data)
def dumpit(buf, wm, pp): global out i, length = 0, len(pp) addspace = 0 while 1: if len(pp) != length: raise 'FATAL', 'inconsistent length' if i == length: break ch = pp[i] i = i + 1 dospace = addspace addspace = 0 if ch.chtype == chunk_type[CSNAME]: s_buf_data = s(buf, ch.data)
11,965
def test_weakref(self): s = self.thetype('gallahad') p = proxy(s) self.assertEqual(str(p), str(s)) s = None self.assertRaises(ReferenceError, str, p)
def test_weakref(self): s = self.thetype('gallahad') p = proxy(s) self.assertEqual(str(p), str(s)) s = None self.assertRaises(ReferenceError, str, p)
11,966
def open_new(self, url): self.open(url)
def open_new(self, url): self.open(url)
11,967
def Internaldate2tuple(resp): """Convert IMAP4 INTERNALDATE to UT. Returns Python time module tuple. """ mo = InternalDate.match(resp) if not mo: return None mon = Mon2num[mo.group('mon')] zonen = mo.group('zonen') day = int(mo.group(day)) year = int(mo.group(year)) hour = int(mo.group(hour)) min = int(mo.group(min)) sec = int(mo.group(sec)) zoneh = int(mo.group(zoneh)) zonem = int(mo.group(zonem)) # INTERNALDATE timezone must be subtracted to get UT zone = (zoneh*60 + zonem)*60 if zonen == '-': zone = -zone tt = (year, mon, day, hour, min, sec, -1, -1, -1) utc = time.mktime(tt) # Following is necessary because the time module has no 'mkgmtime'. # 'mktime' assumes arg in local timezone, so adds timezone/altzone. lt = time.localtime(utc) if time.daylight and lt[-1]: zone = zone + time.altzone else: zone = zone + time.timezone return time.localtime(utc - zone)
def Internaldate2tuple(resp): """Convert IMAP4 INTERNALDATE to UT. Returns Python time module tuple. """ mo = InternalDate.match(resp) if not mo: return None mon = Mon2num[mo.group('mon')] zonen = mo.group('zonen') day = int(mo.group('day')) year = int(mo.group('year')) hour = int(mo.group('hour')) min = int(mo.group('min')) sec = int(mo.group('sec')) zoneh = int(mo.group('zoneh')) zonem = int(mo.group('zonem')) # INTERNALDATE timezone must be subtracted to get UT zone = (zoneh*60 + zonem)*60 if zonen == '-': zone = -zone tt = (year, mon, day, hour, min, sec, -1, -1, -1) utc = time.mktime(tt) # Following is necessary because the time module has no 'mkgmtime'. # 'mktime' assumes arg in local timezone, so adds timezone/altzone. lt = time.localtime(utc) if time.daylight and lt[-1]: zone = zone + time.altzone else: zone = zone + time.timezone return time.localtime(utc - zone)
11,968
def notify_range(self, index1, index2=None): self.tag_add("TODO", index1, index2) if self.after_id: if __debug__: print "colorizing already scheduled" return if self.colorizing: self.stop_colorizing = 1 if __debug__: print "stop colorizing" if self.allow_colorizing: if __debug__: print "schedule colorizing" self.after_id = self.after(1, self.recolorize)
def notify_range(self, index1, index2=None): self.tag_add("TODO", index1, index2) if self.after_id: if DEBUG: print "colorizing already scheduled" return if self.colorizing: self.stop_colorizing = 1 if __debug__: print "stop colorizing" if self.allow_colorizing: if __debug__: print "schedule colorizing" self.after_id = self.after(1, self.recolorize)
11,969
def notify_range(self, index1, index2=None): self.tag_add("TODO", index1, index2) if self.after_id: if __debug__: print "colorizing already scheduled" return if self.colorizing: self.stop_colorizing = 1 if __debug__: print "stop colorizing" if self.allow_colorizing: if __debug__: print "schedule colorizing" self.after_id = self.after(1, self.recolorize)
def notify_range(self, index1, index2=None): self.tag_add("TODO", index1, index2) if self.after_id: if __debug__: print "colorizing already scheduled" return if self.colorizing: self.stop_colorizing = 1 if DEBUG: print "stop colorizing" if self.allow_colorizing: if __debug__: print "schedule colorizing" self.after_id = self.after(1, self.recolorize)
11,970
def notify_range(self, index1, index2=None): self.tag_add("TODO", index1, index2) if self.after_id: if __debug__: print "colorizing already scheduled" return if self.colorizing: self.stop_colorizing = 1 if __debug__: print "stop colorizing" if self.allow_colorizing: if __debug__: print "schedule colorizing" self.after_id = self.after(1, self.recolorize)
def notify_range(self, index1, index2=None): self.tag_add("TODO", index1, index2) if self.after_id: if __debug__: print "colorizing already scheduled" return if self.colorizing: self.stop_colorizing = 1 if __debug__: print "stop colorizing" if self.allow_colorizing: if DEBUG: print "schedule colorizing" self.after_id = self.after(1, self.recolorize)
11,971
def close(self, close_when_done=None): if self.after_id: after_id = self.after_id self.after_id = None if __debug__: print "cancel scheduled recolorizer" self.after_cancel(after_id) self.allow_colorizing = 0 self.stop_colorizing = 1 if close_when_done: if not self.colorizing: close_when_done.destroy() else: self.close_when_done = close_when_done
def close(self, close_when_done=None): if self.after_id: after_id = self.after_id self.after_id = None if DEBUG: print "cancel scheduled recolorizer" self.after_cancel(after_id) self.allow_colorizing = 0 self.stop_colorizing = 1 if close_when_done: if not self.colorizing: close_when_done.destroy() else: self.close_when_done = close_when_done
11,972
def toggle_colorize_event(self, event): if self.after_id: after_id = self.after_id self.after_id = None if __debug__: print "cancel scheduled recolorizer" self.after_cancel(after_id) if self.allow_colorizing and self.colorizing: if __debug__: print "stop colorizing" self.stop_colorizing = 1 self.allow_colorizing = not self.allow_colorizing if self.allow_colorizing and not self.colorizing: self.after_id = self.after(1, self.recolorize) if __debug__: print "auto colorizing turned", self.allow_colorizing and "on" or "off" return "break"
def toggle_colorize_event(self, event): if self.after_id: after_id = self.after_id self.after_id = None if DEBUG: print "cancel scheduled recolorizer" self.after_cancel(after_id) if self.allow_colorizing and self.colorizing: if __debug__: print "stop colorizing" self.stop_colorizing = 1 self.allow_colorizing = not self.allow_colorizing if self.allow_colorizing and not self.colorizing: self.after_id = self.after(1, self.recolorize) if __debug__: print "auto colorizing turned", self.allow_colorizing and "on" or "off" return "break"
11,973
def toggle_colorize_event(self, event): if self.after_id: after_id = self.after_id self.after_id = None if __debug__: print "cancel scheduled recolorizer" self.after_cancel(after_id) if self.allow_colorizing and self.colorizing: if __debug__: print "stop colorizing" self.stop_colorizing = 1 self.allow_colorizing = not self.allow_colorizing if self.allow_colorizing and not self.colorizing: self.after_id = self.after(1, self.recolorize) if __debug__: print "auto colorizing turned", self.allow_colorizing and "on" or "off" return "break"
def toggle_colorize_event(self, event): if self.after_id: after_id = self.after_id self.after_id = None if __debug__: print "cancel scheduled recolorizer" self.after_cancel(after_id) if self.allow_colorizing and self.colorizing: if DEBUG: print "stop colorizing" self.stop_colorizing = 1 self.allow_colorizing = not self.allow_colorizing if self.allow_colorizing and not self.colorizing: self.after_id = self.after(1, self.recolorize) if __debug__: print "auto colorizing turned", self.allow_colorizing and "on" or "off" return "break"
11,974
def toggle_colorize_event(self, event): if self.after_id: after_id = self.after_id self.after_id = None if __debug__: print "cancel scheduled recolorizer" self.after_cancel(after_id) if self.allow_colorizing and self.colorizing: if __debug__: print "stop colorizing" self.stop_colorizing = 1 self.allow_colorizing = not self.allow_colorizing if self.allow_colorizing and not self.colorizing: self.after_id = self.after(1, self.recolorize) if __debug__: print "auto colorizing turned", self.allow_colorizing and "on" or "off" return "break"
def toggle_colorize_event(self, event): if self.after_id: after_id = self.after_id self.after_id = None if DEBUG: print "cancel scheduled recolorizer" self.after_cancel(after_id) if self.allow_colorizing and self.colorizing: if DEBUG: print "stop colorizing" self.stop_colorizing = 1 self.allow_colorizing = not self.allow_colorizing if self.allow_colorizing and not self.colorizing: self.after_id = self.after(1, self.recolorize) if DEBUG: print "auto colorizing turned", self.allow_colorizing and "on" or "off" return "break"
11,975
def recolorize(self): self.after_id = None if not self.delegate: if __debug__: print "no delegate" return if not self.allow_colorizing: if __debug__: print "auto colorizing is off" return if self.colorizing: if __debug__: print "already colorizing" return try: self.stop_colorizing = 0 self.colorizing = 1 if __debug__: print "colorizing..." t0 = time.clock() self.recolorize_main() t1 = time.clock() if __debug__: print "%.3f seconds" % (t1-t0) finally: self.colorizing = 0 if self.allow_colorizing and self.tag_nextrange("TODO", "1.0"): if __debug__: print "reschedule colorizing" self.after_id = self.after(1, self.recolorize) if self.close_when_done: top = self.close_when_done self.close_when_done = None top.destroy()
def recolorize(self): self.after_id = None if not self.delegate: if DEBUG: print "no delegate" return if not self.allow_colorizing: if __debug__: print "auto colorizing is off" return if self.colorizing: if __debug__: print "already colorizing" return try: self.stop_colorizing = 0 self.colorizing = 1 if __debug__: print "colorizing..." t0 = time.clock() self.recolorize_main() t1 = time.clock() if __debug__: print "%.3f seconds" % (t1-t0) finally: self.colorizing = 0 if self.allow_colorizing and self.tag_nextrange("TODO", "1.0"): if __debug__: print "reschedule colorizing" self.after_id = self.after(1, self.recolorize) if self.close_when_done: top = self.close_when_done self.close_when_done = None top.destroy()
11,976
def recolorize(self): self.after_id = None if not self.delegate: if __debug__: print "no delegate" return if not self.allow_colorizing: if __debug__: print "auto colorizing is off" return if self.colorizing: if __debug__: print "already colorizing" return try: self.stop_colorizing = 0 self.colorizing = 1 if __debug__: print "colorizing..." t0 = time.clock() self.recolorize_main() t1 = time.clock() if __debug__: print "%.3f seconds" % (t1-t0) finally: self.colorizing = 0 if self.allow_colorizing and self.tag_nextrange("TODO", "1.0"): if __debug__: print "reschedule colorizing" self.after_id = self.after(1, self.recolorize) if self.close_when_done: top = self.close_when_done self.close_when_done = None top.destroy()
def recolorize(self): self.after_id = None if not self.delegate: if __debug__: print "no delegate" return if not self.allow_colorizing: if DEBUG: print "auto colorizing is off" return if self.colorizing: if __debug__: print "already colorizing" return try: self.stop_colorizing = 0 self.colorizing = 1 if __debug__: print "colorizing..." t0 = time.clock() self.recolorize_main() t1 = time.clock() if __debug__: print "%.3f seconds" % (t1-t0) finally: self.colorizing = 0 if self.allow_colorizing and self.tag_nextrange("TODO", "1.0"): if __debug__: print "reschedule colorizing" self.after_id = self.after(1, self.recolorize) if self.close_when_done: top = self.close_when_done self.close_when_done = None top.destroy()
11,977
def recolorize(self): self.after_id = None if not self.delegate: if __debug__: print "no delegate" return if not self.allow_colorizing: if __debug__: print "auto colorizing is off" return if self.colorizing: if __debug__: print "already colorizing" return try: self.stop_colorizing = 0 self.colorizing = 1 if __debug__: print "colorizing..." t0 = time.clock() self.recolorize_main() t1 = time.clock() if __debug__: print "%.3f seconds" % (t1-t0) finally: self.colorizing = 0 if self.allow_colorizing and self.tag_nextrange("TODO", "1.0"): if __debug__: print "reschedule colorizing" self.after_id = self.after(1, self.recolorize) if self.close_when_done: top = self.close_when_done self.close_when_done = None top.destroy()
def recolorize(self): self.after_id = None if not self.delegate: if __debug__: print "no delegate" return if not self.allow_colorizing: if __debug__: print "auto colorizing is off" return if self.colorizing: if DEBUG: print "already colorizing" return try: self.stop_colorizing = 0 self.colorizing = 1 if __debug__: print "colorizing..." t0 = time.clock() self.recolorize_main() t1 = time.clock() if __debug__: print "%.3f seconds" % (t1-t0) finally: self.colorizing = 0 if self.allow_colorizing and self.tag_nextrange("TODO", "1.0"): if __debug__: print "reschedule colorizing" self.after_id = self.after(1, self.recolorize) if self.close_when_done: top = self.close_when_done self.close_when_done = None top.destroy()
11,978
def recolorize(self): self.after_id = None if not self.delegate: if __debug__: print "no delegate" return if not self.allow_colorizing: if __debug__: print "auto colorizing is off" return if self.colorizing: if __debug__: print "already colorizing" return try: self.stop_colorizing = 0 self.colorizing = 1 if __debug__: print "colorizing..." t0 = time.clock() self.recolorize_main() t1 = time.clock() if __debug__: print "%.3f seconds" % (t1-t0) finally: self.colorizing = 0 if self.allow_colorizing and self.tag_nextrange("TODO", "1.0"): if __debug__: print "reschedule colorizing" self.after_id = self.after(1, self.recolorize) if self.close_when_done: top = self.close_when_done self.close_when_done = None top.destroy()
def recolorize(self): self.after_id = None if not self.delegate: if __debug__: print "no delegate" return if not self.allow_colorizing: if __debug__: print "auto colorizing is off" return if self.colorizing: if __debug__: print "already colorizing" return try: self.stop_colorizing = 0 self.colorizing = 1 if DEBUG: print "colorizing..." t0 = time.clock() self.recolorize_main() t1 = time.clock() if __debug__: print "%.3f seconds" % (t1-t0) finally: self.colorizing = 0 if self.allow_colorizing and self.tag_nextrange("TODO", "1.0"): if __debug__: print "reschedule colorizing" self.after_id = self.after(1, self.recolorize) if self.close_when_done: top = self.close_when_done self.close_when_done = None top.destroy()
11,979
def recolorize(self): self.after_id = None if not self.delegate: if __debug__: print "no delegate" return if not self.allow_colorizing: if __debug__: print "auto colorizing is off" return if self.colorizing: if __debug__: print "already colorizing" return try: self.stop_colorizing = 0 self.colorizing = 1 if __debug__: print "colorizing..." t0 = time.clock() self.recolorize_main() t1 = time.clock() if __debug__: print "%.3f seconds" % (t1-t0) finally: self.colorizing = 0 if self.allow_colorizing and self.tag_nextrange("TODO", "1.0"): if __debug__: print "reschedule colorizing" self.after_id = self.after(1, self.recolorize) if self.close_when_done: top = self.close_when_done self.close_when_done = None top.destroy()
def recolorize(self): self.after_id = None if not self.delegate: if __debug__: print "no delegate" return if not self.allow_colorizing: if __debug__: print "auto colorizing is off" return if self.colorizing: if __debug__: print "already colorizing" return try: self.stop_colorizing = 0 self.colorizing = 1 if __debug__: print "colorizing..." t0 = time.clock() self.recolorize_main() t1 = time.clock() if DEBUG: print "%.3f seconds" % (t1-t0) finally: self.colorizing = 0 if self.allow_colorizing and self.tag_nextrange("TODO", "1.0"): if __debug__: print "reschedule colorizing" self.after_id = self.after(1, self.recolorize) if self.close_when_done: top = self.close_when_done self.close_when_done = None top.destroy()
11,980
def recolorize(self): self.after_id = None if not self.delegate: if __debug__: print "no delegate" return if not self.allow_colorizing: if __debug__: print "auto colorizing is off" return if self.colorizing: if __debug__: print "already colorizing" return try: self.stop_colorizing = 0 self.colorizing = 1 if __debug__: print "colorizing..." t0 = time.clock() self.recolorize_main() t1 = time.clock() if __debug__: print "%.3f seconds" % (t1-t0) finally: self.colorizing = 0 if self.allow_colorizing and self.tag_nextrange("TODO", "1.0"): if __debug__: print "reschedule colorizing" self.after_id = self.after(1, self.recolorize) if self.close_when_done: top = self.close_when_done self.close_when_done = None top.destroy()
def recolorize(self): self.after_id = None if not self.delegate: if __debug__: print "no delegate" return if not self.allow_colorizing: if __debug__: print "auto colorizing is off" return if self.colorizing: if __debug__: print "already colorizing" return try: self.stop_colorizing = 0 self.colorizing = 1 if __debug__: print "colorizing..." t0 = time.clock() self.recolorize_main() t1 = time.clock() if __debug__: print "%.3f seconds" % (t1-t0) finally: self.colorizing = 0 if self.allow_colorizing and self.tag_nextrange("TODO", "1.0"): if DEBUG: print "reschedule colorizing" self.after_id = self.after(1, self.recolorize) if self.close_when_done: top = self.close_when_done self.close_when_done = None top.destroy()
11,981
def recolorize_main(self): next = "1.0" while 1: item = self.tag_nextrange("TODO", next) if not item: break head, tail = item self.tag_remove("SYNC", head, tail) item = self.tag_prevrange("SYNC", head) if item: head = item[1] else: head = "1.0"
def recolorize_main(self): next = "1.0" while 1: item = self.tag_nextrange("TODO", next) if not item: break head, tail = item self.tag_remove("SYNC", head, tail) item = self.tag_prevrange("SYNC", head) if item: head = item[1] else: head = "1.0"
11,982
def compile_dir(dir, maxlevels=10, ddir=None, force=0, rx=None): """Byte-compile all modules in the given directory tree. Arguments (only dir is required): dir: the directory to byte-compile maxlevels: maximum recursion level (default 10) ddir: if given, purported directory name (this is the directory name that will show up in error messages) force: if 1, force compilation, even if timestamps are up-to-date """ print 'Listing', dir, '...' try: names = os.listdir(dir) except os.error: print "Can't list", dir names = [] names.sort() success = 1 for name in names: fullname = os.path.join(dir, name) if ddir: dfile = os.path.join(ddir, name) else: dfile = None if rx: mo = rx.search(fullname) if mo: continue if os.path.isfile(fullname): head, tail = name[:-3], name[-3:] if tail == '.py': cfile = fullname + (__debug__ and 'c' or 'o') ftime = os.stat(fullname)[stat.ST_MTIME] try: ctime = os.stat(cfile)[stat.ST_MTIME] except os.error: ctime = 0 if (ctime > ftime) and not force: continue print 'Compiling', fullname, '...' try: ok = py_compile.compile(fullname, None, dfile) except KeyboardInterrupt: raise KeyboardInterrupt except: # XXX py_compile catches SyntaxErrors if type(sys.exc_type) == type(''): exc_type_name = sys.exc_type else: exc_type_name = sys.exc_type.__name__ print 'Sorry:', exc_type_name + ':', print sys.exc_value success = 0 else: if ok == 0: success = 0 elif maxlevels > 0 and \ name != os.curdir and name != os.pardir and \ os.path.isdir(fullname) and \ not os.path.islink(fullname): if not compile_dir(fullname, maxlevels - 1, dfile, force, rx): success = 0 return success
def compile_dir(dir, maxlevels=10, ddir=None, force=0, rx=None, quiet=0): """Byte-compile all modules in the given directory tree. Arguments (only dir is required): dir: the directory to byte-compile maxlevels: maximum recursion level (default 10) ddir: if given, purported directory name (this is the directory name that will show up in error messages) force: if 1, force compilation, even if timestamps are up-to-date """ print 'Listing', dir, '...' try: names = os.listdir(dir) except os.error: print "Can't list", dir names = [] names.sort() success = 1 for name in names: fullname = os.path.join(dir, name) if ddir: dfile = os.path.join(ddir, name) else: dfile = None if rx: mo = rx.search(fullname) if mo: continue if os.path.isfile(fullname): head, tail = name[:-3], name[-3:] if tail == '.py': cfile = fullname + (__debug__ and 'c' or 'o') ftime = os.stat(fullname)[stat.ST_MTIME] try: ctime = os.stat(cfile)[stat.ST_MTIME] except os.error: ctime = 0 if (ctime > ftime) and not force: continue print 'Compiling', fullname, '...' try: ok = py_compile.compile(fullname, None, dfile) except KeyboardInterrupt: raise KeyboardInterrupt except: # XXX py_compile catches SyntaxErrors if type(sys.exc_type) == type(''): exc_type_name = sys.exc_type else: exc_type_name = sys.exc_type.__name__ print 'Sorry:', exc_type_name + ':', print sys.exc_value success = 0 else: if ok == 0: success = 0 elif maxlevels > 0 and \ name != os.curdir and name != os.pardir and \ os.path.isdir(fullname) and \ not os.path.islink(fullname): if not compile_dir(fullname, maxlevels - 1, dfile, force, rx): success = 0 return success
11,983
def compile_dir(dir, maxlevels=10, ddir=None, force=0, rx=None): """Byte-compile all modules in the given directory tree. Arguments (only dir is required): dir: the directory to byte-compile maxlevels: maximum recursion level (default 10) ddir: if given, purported directory name (this is the directory name that will show up in error messages) force: if 1, force compilation, even if timestamps are up-to-date """ print 'Listing', dir, '...' try: names = os.listdir(dir) except os.error: print "Can't list", dir names = [] names.sort() success = 1 for name in names: fullname = os.path.join(dir, name) if ddir: dfile = os.path.join(ddir, name) else: dfile = None if rx: mo = rx.search(fullname) if mo: continue if os.path.isfile(fullname): head, tail = name[:-3], name[-3:] if tail == '.py': cfile = fullname + (__debug__ and 'c' or 'o') ftime = os.stat(fullname)[stat.ST_MTIME] try: ctime = os.stat(cfile)[stat.ST_MTIME] except os.error: ctime = 0 if (ctime > ftime) and not force: continue print 'Compiling', fullname, '...' try: ok = py_compile.compile(fullname, None, dfile) except KeyboardInterrupt: raise KeyboardInterrupt except: # XXX py_compile catches SyntaxErrors if type(sys.exc_type) == type(''): exc_type_name = sys.exc_type else: exc_type_name = sys.exc_type.__name__ print 'Sorry:', exc_type_name + ':', print sys.exc_value success = 0 else: if ok == 0: success = 0 elif maxlevels > 0 and \ name != os.curdir and name != os.pardir and \ os.path.isdir(fullname) and \ not os.path.islink(fullname): if not compile_dir(fullname, maxlevels - 1, dfile, force, rx): success = 0 return success
def compile_dir(dir, maxlevels=10, ddir=None, force=0, rx=None): """Byte-compile all modules in the given directory tree. Arguments (only dir is required): dir: the directory to byte-compile maxlevels: maximum recursion level (default 10) ddir: if given, purported directory name (this is the directory name that will show up in error messages) force: if 1, force compilation, even if timestamps are up-to-date """ if not quiet: print 'Listing', dir, '...' try: names = os.listdir(dir) except os.error: print "Can't list", dir names = [] names.sort() success = 1 for name in names: fullname = os.path.join(dir, name) if ddir: dfile = os.path.join(ddir, name) else: dfile = None if rx: mo = rx.search(fullname) if mo: continue if os.path.isfile(fullname): head, tail = name[:-3], name[-3:] if tail == '.py': cfile = fullname + (__debug__ and 'c' or 'o') ftime = os.stat(fullname)[stat.ST_MTIME] try: ctime = os.stat(cfile)[stat.ST_MTIME] except os.error: ctime = 0 if (ctime > ftime) and not force: continue print 'Compiling', fullname, '...' try: ok = py_compile.compile(fullname, None, dfile) except KeyboardInterrupt: raise KeyboardInterrupt except: # XXX py_compile catches SyntaxErrors if type(sys.exc_type) == type(''): exc_type_name = sys.exc_type else: exc_type_name = sys.exc_type.__name__ print 'Sorry:', exc_type_name + ':', print sys.exc_value success = 0 else: if ok == 0: success = 0 elif maxlevels > 0 and \ name != os.curdir and name != os.pardir and \ os.path.isdir(fullname) and \ not os.path.islink(fullname): if not compile_dir(fullname, maxlevels - 1, dfile, force, rx): success = 0 return success
11,984
def compile_dir(dir, maxlevels=10, ddir=None, force=0, rx=None): """Byte-compile all modules in the given directory tree. Arguments (only dir is required): dir: the directory to byte-compile maxlevels: maximum recursion level (default 10) ddir: if given, purported directory name (this is the directory name that will show up in error messages) force: if 1, force compilation, even if timestamps are up-to-date """ print 'Listing', dir, '...' try: names = os.listdir(dir) except os.error: print "Can't list", dir names = [] names.sort() success = 1 for name in names: fullname = os.path.join(dir, name) if ddir: dfile = os.path.join(ddir, name) else: dfile = None if rx: mo = rx.search(fullname) if mo: continue if os.path.isfile(fullname): head, tail = name[:-3], name[-3:] if tail == '.py': cfile = fullname + (__debug__ and 'c' or 'o') ftime = os.stat(fullname)[stat.ST_MTIME] try: ctime = os.stat(cfile)[stat.ST_MTIME] except os.error: ctime = 0 if (ctime > ftime) and not force: continue print 'Compiling', fullname, '...' try: ok = py_compile.compile(fullname, None, dfile) except KeyboardInterrupt: raise KeyboardInterrupt except: # XXX py_compile catches SyntaxErrors if type(sys.exc_type) == type(''): exc_type_name = sys.exc_type else: exc_type_name = sys.exc_type.__name__ print 'Sorry:', exc_type_name + ':', print sys.exc_value success = 0 else: if ok == 0: success = 0 elif maxlevels > 0 and \ name != os.curdir and name != os.pardir and \ os.path.isdir(fullname) and \ not os.path.islink(fullname): if not compile_dir(fullname, maxlevels - 1, dfile, force, rx): success = 0 return success
def compile_dir(dir, maxlevels=10, ddir=None, force=0, rx=None): """Byte-compile all modules in the given directory tree. Arguments (only dir is required): dir: the directory to byte-compile maxlevels: maximum recursion level (default 10) ddir: if given, purported directory name (this is the directory name that will show up in error messages) force: if 1, force compilation, even if timestamps are up-to-date """ print 'Listing', dir, '...' try: names = os.listdir(dir) except os.error: print "Can't list", dir names = [] names.sort() success = 1 for name in names: fullname = os.path.join(dir, name) if ddir: dfile = os.path.join(ddir, name) else: dfile = None if rx: mo = rx.search(fullname) if mo: continue if os.path.isfile(fullname): head, tail = name[:-3], name[-3:] if tail == '.py': cfile = fullname + (__debug__ and 'c' or 'o') ftime = os.stat(fullname)[stat.ST_MTIME] try: ctime = os.stat(cfile)[stat.ST_MTIME] except os.error: ctime = 0 if (ctime > ftime) and not force: continue if not quiet: print 'Compiling', fullname, '...' try: ok = py_compile.compile(fullname, None, dfile) except KeyboardInterrupt: raise KeyboardInterrupt except: # XXX py_compile catches SyntaxErrors if type(sys.exc_type) == type(''): exc_type_name = sys.exc_type else: exc_type_name = sys.exc_type.__name__ print 'Sorry:', exc_type_name + ':', print sys.exc_value success = 0 else: if ok == 0: success = 0 elif maxlevels > 0 and \ name != os.curdir and name != os.pardir and \ os.path.isdir(fullname) and \ not os.path.islink(fullname): if not compile_dir(fullname, maxlevels - 1, dfile, force, rx): success = 0 return success
11,985
def compile_dir(dir, maxlevels=10, ddir=None, force=0, rx=None): """Byte-compile all modules in the given directory tree. Arguments (only dir is required): dir: the directory to byte-compile maxlevels: maximum recursion level (default 10) ddir: if given, purported directory name (this is the directory name that will show up in error messages) force: if 1, force compilation, even if timestamps are up-to-date """ print 'Listing', dir, '...' try: names = os.listdir(dir) except os.error: print "Can't list", dir names = [] names.sort() success = 1 for name in names: fullname = os.path.join(dir, name) if ddir: dfile = os.path.join(ddir, name) else: dfile = None if rx: mo = rx.search(fullname) if mo: continue if os.path.isfile(fullname): head, tail = name[:-3], name[-3:] if tail == '.py': cfile = fullname + (__debug__ and 'c' or 'o') ftime = os.stat(fullname)[stat.ST_MTIME] try: ctime = os.stat(cfile)[stat.ST_MTIME] except os.error: ctime = 0 if (ctime > ftime) and not force: continue print 'Compiling', fullname, '...' try: ok = py_compile.compile(fullname, None, dfile) except KeyboardInterrupt: raise KeyboardInterrupt except: # XXX py_compile catches SyntaxErrors if type(sys.exc_type) == type(''): exc_type_name = sys.exc_type else: exc_type_name = sys.exc_type.__name__ print 'Sorry:', exc_type_name + ':', print sys.exc_value success = 0 else: if ok == 0: success = 0 elif maxlevels > 0 and \ name != os.curdir and name != os.pardir and \ os.path.isdir(fullname) and \ not os.path.islink(fullname): if not compile_dir(fullname, maxlevels - 1, dfile, force, rx): success = 0 return success
def compile_dir(dir, maxlevels=10, ddir=None, force=0, rx=None): """Byte-compile all modules in the given directory tree. Arguments (only dir is required): dir: the directory to byte-compile maxlevels: maximum recursion level (default 10) ddir: if given, purported directory name (this is the directory name that will show up in error messages) force: if 1, force compilation, even if timestamps are up-to-date """ print 'Listing', dir, '...' try: names = os.listdir(dir) except os.error: print "Can't list", dir names = [] names.sort() success = 1 for name in names: fullname = os.path.join(dir, name) if ddir: dfile = os.path.join(ddir, name) else: dfile = None if rx: mo = rx.search(fullname) if mo: continue if os.path.isfile(fullname): head, tail = name[:-3], name[-3:] if tail == '.py': cfile = fullname + (__debug__ and 'c' or 'o') ftime = os.stat(fullname)[stat.ST_MTIME] try: ctime = os.stat(cfile)[stat.ST_MTIME] except os.error: ctime = 0 if (ctime > ftime) and not force: continue print 'Compiling', fullname, '...' try: ok = py_compile.compile(fullname, None, dfile) except KeyboardInterrupt: raise KeyboardInterrupt except: # XXX py_compile catches SyntaxErrors if type(sys.exc_type) == type(''): exc_type_name = sys.exc_type else: exc_type_name = sys.exc_type.__name__ print 'Sorry:', exc_type_name + ':', print sys.exc_value success = 0 else: if ok == 0: success = 0 elif maxlevels > 0 and \ name != os.curdir and name != os.pardir and \ os.path.isdir(fullname) and \ not os.path.islink(fullname): if not compile_dir(fullname, maxlevels - 1, dfile, force, rx, quiet): success = 0 return success
11,986
def compile_path(skip_curdir=1, maxlevels=0, force=0): """Byte-compile all module on sys.path. Arguments (all optional): skip_curdir: if true, skip current directory (default true) maxlevels: max recursion level (default 0) force: as for compile_dir() (default 0) """ success = 1 for dir in sys.path: if (not dir or dir == os.curdir) and skip_curdir: print 'Skipping current directory' else: success = success and compile_dir(dir, maxlevels, None, force) return success
def compile_path(skip_curdir=1, maxlevels=0, force=0, quiet=0): """Byte-compile all module on sys.path. Arguments (all optional): skip_curdir: if true, skip current directory (default true) maxlevels: max recursion level (default 0) force: as for compile_dir() (default 0) """ success = 1 for dir in sys.path: if (not dir or dir == os.curdir) and skip_curdir: print 'Skipping current directory' else: success = success and compile_dir(dir, maxlevels, None, force) return success
11,987
def compile_path(skip_curdir=1, maxlevels=0, force=0): """Byte-compile all module on sys.path. Arguments (all optional): skip_curdir: if true, skip current directory (default true) maxlevels: max recursion level (default 0) force: as for compile_dir() (default 0) """ success = 1 for dir in sys.path: if (not dir or dir == os.curdir) and skip_curdir: print 'Skipping current directory' else: success = success and compile_dir(dir, maxlevels, None, force) return success
def compile_path(skip_curdir=1, maxlevels=0, force=0): """Byte-compile all module on sys.path. Arguments (all optional): skip_curdir: if true, skip current directory (default true) maxlevels: max recursion level (default 0) force: as for compile_dir() (default 0) """ success = 1 for dir in sys.path: if (not dir or dir == os.curdir) and skip_curdir: print 'Skipping current directory' else: success = success and compile_dir(dir, maxlevels, None, force, quiet=quiet) return success
11,988
def main(): """Script main program.""" import getopt try: opts, args = getopt.getopt(sys.argv[1:], 'lfd:x:') except getopt.error, msg: print msg print "usage: python compileall.py [-l] [-f] [-d destdir] " \ "[-s regexp] [directory ...]" print "-l: don't recurse down" print "-f: force rebuild even if timestamps are up-to-date" print "-d destdir: purported directory name for error messages" print " if no directory arguments, -l sys.path is assumed" print "-x regexp: skip files matching the regular expression regexp" print " the regexp is search for in the full path of the file" sys.exit(2) maxlevels = 10 ddir = None force = 0 rx = None for o, a in opts: if o == '-l': maxlevels = 0 if o == '-d': ddir = a if o == '-f': force = 1 if o == '-x': import re rx = re.compile(a) if ddir: if len(args) != 1: print "-d destdir require exactly one directory argument" sys.exit(2) success = 1 try: if args: for dir in args: if not compile_dir(dir, maxlevels, ddir, force, rx): success = 0 else: success = compile_path() except KeyboardInterrupt: print "\n[interrupt]" success = 0 return success
def main(): """Script main program.""" import getopt try: opts, args = getopt.getopt(sys.argv[1:], 'lfqd:x:') except getopt.error, msg: print msg print "usage: python compileall.py [-l] [-f] [-d destdir] " \ "[-s regexp] [directory ...]" print "-l: don't recurse down" print "-f: force rebuild even if timestamps are up-to-date" print "-d destdir: purported directory name for error messages" print " if no directory arguments, -l sys.path is assumed" print "-x regexp: skip files matching the regular expression regexp" print " the regexp is search for in the full path of the file" sys.exit(2) maxlevels = 10 ddir = None force = 0 rx = None for o, a in opts: if o == '-l': maxlevels = 0 if o == '-d': ddir = a if o == '-f': force = 1 if o == '-x': import re rx = re.compile(a) if ddir: if len(args) != 1: print "-d destdir require exactly one directory argument" sys.exit(2) success = 1 try: if args: for dir in args: if not compile_dir(dir, maxlevels, ddir, force, rx): success = 0 else: success = compile_path() except KeyboardInterrupt: print "\n[interrupt]" success = 0 return success
11,989
def main(): """Script main program.""" import getopt try: opts, args = getopt.getopt(sys.argv[1:], 'lfd:x:') except getopt.error, msg: print msg print "usage: python compileall.py [-l] [-f] [-d destdir] " \ "[-s regexp] [directory ...]" print "-l: don't recurse down" print "-f: force rebuild even if timestamps are up-to-date" print "-d destdir: purported directory name for error messages" print " if no directory arguments, -l sys.path is assumed" print "-x regexp: skip files matching the regular expression regexp" print " the regexp is search for in the full path of the file" sys.exit(2) maxlevels = 10 ddir = None force = 0 rx = None for o, a in opts: if o == '-l': maxlevels = 0 if o == '-d': ddir = a if o == '-f': force = 1 if o == '-x': import re rx = re.compile(a) if ddir: if len(args) != 1: print "-d destdir require exactly one directory argument" sys.exit(2) success = 1 try: if args: for dir in args: if not compile_dir(dir, maxlevels, ddir, force, rx): success = 0 else: success = compile_path() except KeyboardInterrupt: print "\n[interrupt]" success = 0 return success
def main(): """Script main program.""" import getopt try: opts, args = getopt.getopt(sys.argv[1:], 'lfd:x:') except getopt.error, msg: print msg print "usage: python compileall.py [-l] [-f] [-q] [-d destdir] " \ "[-s regexp] [directory ...]" print "-l: don't recurse down" print "-f: force rebuild even if timestamps are up-to-date" print "-d destdir: purported directory name for error messages" print " if no directory arguments, -l sys.path is assumed" print "-x regexp: skip files matching the regular expression regexp" print " the regexp is search for in the full path of the file" sys.exit(2) maxlevels = 10 ddir = None force = 0 rx = None for o, a in opts: if o == '-l': maxlevels = 0 if o == '-d': ddir = a if o == '-f': force = 1 if o == '-x': import re rx = re.compile(a) if ddir: if len(args) != 1: print "-d destdir require exactly one directory argument" sys.exit(2) success = 1 try: if args: for dir in args: if not compile_dir(dir, maxlevels, ddir, force, rx): success = 0 else: success = compile_path() except KeyboardInterrupt: print "\n[interrupt]" success = 0 return success
11,990
def main(): """Script main program.""" import getopt try: opts, args = getopt.getopt(sys.argv[1:], 'lfd:x:') except getopt.error, msg: print msg print "usage: python compileall.py [-l] [-f] [-d destdir] " \ "[-s regexp] [directory ...]" print "-l: don't recurse down" print "-f: force rebuild even if timestamps are up-to-date" print "-d destdir: purported directory name for error messages" print " if no directory arguments, -l sys.path is assumed" print "-x regexp: skip files matching the regular expression regexp" print " the regexp is search for in the full path of the file" sys.exit(2) maxlevels = 10 ddir = None force = 0 rx = None for o, a in opts: if o == '-l': maxlevels = 0 if o == '-d': ddir = a if o == '-f': force = 1 if o == '-x': import re rx = re.compile(a) if ddir: if len(args) != 1: print "-d destdir require exactly one directory argument" sys.exit(2) success = 1 try: if args: for dir in args: if not compile_dir(dir, maxlevels, ddir, force, rx): success = 0 else: success = compile_path() except KeyboardInterrupt: print "\n[interrupt]" success = 0 return success
def main(): """Script main program.""" import getopt try: opts, args = getopt.getopt(sys.argv[1:], 'lfd:x:') except getopt.error, msg: print msg print "usage: python compileall.py [-l] [-f] [-d destdir] " \ "[-s regexp] [directory ...]" print "-l: don't recurse down" print "-f: force rebuild even if timestamps are up-to-date" print "-d destdir: purported directory name for error messages" print " if no directory arguments, -l sys.path is assumed" print "-x regexp: skip files matching the regular expression regexp" print " the regexp is search for in the full path of the file" sys.exit(2) maxlevels = 10 ddir = None force = 0 rx = None for o, a in opts: if o == '-l': maxlevels = 0 if o == '-d': ddir = a if o == '-f': force = 1 if o == '-x': import re rx = re.compile(a) if ddir: if len(args) != 1: print "-d destdir require exactly one directory argument" sys.exit(2) success = 1 try: if args: for dir in args: if not compile_dir(dir, maxlevels, ddir, force, rx, quiet): success = 0 else: success = compile_path() except KeyboardInterrupt: print "\n[interrupt]" success = 0 return success
11,991
def check_module (self, module, module_file): if not os.path.isfile (module_file): self.warn ("file %s (for module %s) not found" % module_file, module) return 0 else: return 1
def check_module (self, module, module_file): if not os.path.isfile (module_file): self.warn ("file %s (for module %s) not found" % (module_file, module)) return 0 else: return 1
11,992
def __getitem__(self, i): if 0 <= i < 10: return i raise IndexError
def __getitem__(self, i): if 0 <= i < 10: return i raise IndexError
11,993
def __getitem__(self, i): if 0 <= i < 10: return i raise IndexError
def __getitem__(self, i): if 0 <= i < 10: return i raise IndexError
11,994
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.insert(0, '/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.insert(0, '/usr/local/include' )
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.insert(0, '/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.insert(0, '/usr/local/include' )
11,995
def rfind(s, *args): """rfind(s, sub [,start [,end]]) -> int Return the highest index in s where substring sub is found, such that sub is contained within s[start,end]. Optional arguments start and end are interpreted as in slice notation. Return -1 on failure. """ return s.rfind(*args)
def rfind(s, *args): """rfind(s, sub [,start [,end]]) -> int Return the highest index in s where substring sub is found, such that sub is contained within s[start,end]. Optional arguments start and end are interpreted as in slice notation. Return -1 on failure. """ return s.rfind(*args)
11,996
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
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 not isinstance(x, _StringTypes): x = str(x) n = len(x) if n >= width: return x sign = '' if s[0] in ('-', '+'): sign, s = s[0], s[1:] return sign + '0'*(width-n) + s
11,997
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
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 x[0] in '-+': sign, x = x[0], x[1:] return sign + '0'*(width-n) + x
11,998
def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = string.rfind(rest, '?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = string.find(rest, '/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `scriptname`) return if not executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return nobody = nobody_uid() self.send_response(200, "Script output follows") self.wfile.flush() # Always flush before forking pid = os.fork() if pid != 0: # Parent pid, sts = os.waitpid(pid, 0) if sts: self.log_error("CGI script exit status x%x" % sts) return # Child try: # Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html # XXX Much of the following could be prepared ahead of time! env = {} env['SERVER_SOFTWARE'] = self.version_string() env['SERVER_NAME'] = self.server.server_name env['GATEWAY_INTERFACE'] = 'CGI/1.1' env['SERVER_PROTOCOL'] = self.protocol_version env['SERVER_PORT'] = str(self.server.server_port) env['REQUEST_METHOD'] = self.command uqrest = urllib.unquote(rest) env['PATH_INFO'] = uqrest env['PATH_TRANSLATED'] = self.translate_path(uqrest) env['SCRIPT_NAME'] = scriptname if query: env['QUERY_STRING'] = query host = self.address_string() if host != self.client_address[0]: env['REMOTE_HOST'] = host env['REMOTE_ADDR'] = self.client_address[0] # AUTH_TYPE # REMOTE_USER # REMOTE_IDENT if self.headers.typeheader is None: env['CONTENT_TYPE'] = self.headers.type else: env['CONTENT_TYPE'] = self.headers.typeheader length = self.headers.getheader('content-length') if length: env['CONTENT_LENGTH'] = length accept = [] for line in self.headers.getallmatchingheaders('accept'): if line[:1] in string.whitespace: accept.append(string.strip(line)) else: accept = accept + string.split(line[7:]) env['HTTP_ACCEPT'] = string.joinfields(accept, ',') ua = self.headers.getheader('user-agent') if ua: env['HTTP_USER_AGENT'] = ua # XXX Other HTTP_* headers decoded_query = string.replace(query, '+', ' ') try: os.setuid(nobody) except os.error: pass os.dup2(self.rfile.fileno(), 0) os.dup2(self.wfile.fileno(), 1) print scriptfile, script, decoded_query os.execve(scriptfile, [script, decoded_query], env) except: self.server.handle_error(self.request, self.client_address) os._exit(127)
def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = string.rfind(rest, '?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = string.find(rest, '/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `scriptname`) return if not executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return nobody = nobody_uid() self.send_response(200, "Script output follows") self.wfile.flush() # Always flush before forking pid = os.fork() if pid != 0: # Parent pid, sts = os.waitpid(pid, 0) if sts: self.log_error("CGI script exit status x%x" % sts) return # Child try: # Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html # XXX Much of the following could be prepared ahead of time! env = {} env['SERVER_SOFTWARE'] = self.version_string() env['SERVER_NAME'] = self.server.server_name env['GATEWAY_INTERFACE'] = 'CGI/1.1' env['SERVER_PROTOCOL'] = self.protocol_version env['SERVER_PORT'] = str(self.server.server_port) env['REQUEST_METHOD'] = self.command uqrest = urllib.unquote(rest) env['PATH_INFO'] = uqrest env['PATH_TRANSLATED'] = self.translate_path(uqrest) env['SCRIPT_NAME'] = scriptname if query: env['QUERY_STRING'] = query host = self.address_string() if host != self.client_address[0]: env['REMOTE_HOST'] = host env['REMOTE_ADDR'] = self.client_address[0] # AUTH_TYPE # REMOTE_USER # REMOTE_IDENT if self.headers.typeheader is None: env['CONTENT_TYPE'] = self.headers.type else: env['CONTENT_TYPE'] = self.headers.typeheader length = self.headers.getheader('content-length') if length: env['CONTENT_LENGTH'] = length accept = [] for line in self.headers.getallmatchingheaders('accept'): if line[:1] in string.whitespace: accept.append(string.strip(line)) else: accept = accept + string.split(line[7:], ',') env['HTTP_ACCEPT'] = string.joinfields(accept, ',') ua = self.headers.getheader('user-agent') if ua: env['HTTP_USER_AGENT'] = ua # XXX Other HTTP_* headers decoded_query = string.replace(query, '+', ' ') try: os.setuid(nobody) except os.error: pass os.dup2(self.rfile.fileno(), 0) os.dup2(self.wfile.fileno(), 1) print scriptfile, script, decoded_query os.execve(scriptfile, [script, decoded_query], env) except: self.server.handle_error(self.request, self.client_address) os._exit(127)
11,999