rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
return EditorWindow.close(self) | self.closing = True self.text.after(2 * self.pollinterval, self.close2) def close2(self): return EditorWindow.close(self) | def close(self): "Extend EditorWindow.close()" if self.executing: response = tkMessageBox.askokcancel( "Kill?", "The program is still running!\n Do you want to kill it?", default="ok", parent=self.text) if response == False: return "cancel" # interrupt the subprocess self.canceled = True if use_subprocess: self.interp.... |
buildno = int(buildno) | def _sys_version(): """ Returns a parsed version of Python's sys.version as tuple (version, buildno, builddate, compiler) referring to the Python version, build number, build date/time as string and the compiler identification string. Note that unlike the Python sys.version, the returned value for the Python version ... | |
if self.distribution.has_ext_modules(): | if not self.skip_build and self.distribution.has_ext_modules(): | def finalize_options (self): if self.bdist_dir is None: bdist_base = self.get_finalized_command('bdist').bdist_base self.bdist_dir = os.path.join(bdist_base, 'wininst') if not self.target_version: self.target_version = "" if self.distribution.has_ext_modules(): short_version = get_python_version() if self.target_versio... |
"target version can only be" + short_version | "target version can only be %s, or the '--skip_build'" \ " option must be specified" % (short_version,) | def finalize_options (self): if self.bdist_dir is None: bdist_base = self.get_finalized_command('bdist').bdist_base self.bdist_dir = os.path.join(bdist_base, 'wininst') if not self.target_version: self.target_version = "" if self.distribution.has_ext_modules(): short_version = get_python_version() if self.target_versio... |
build_info = "Build %s with distutils-%s" % \ | build_info = "Built %s with distutils-%s" % \ | def get_inidata (self): # Return data describing the installation. |
`fileName`+' .') | `fn`+' .', parent=self) | def ViewFile(self, viewTitle, viewFile, encoding=None): fn = os.path.join(os.path.abspath(os.path.dirname(__file__)), viewFile) if encoding: import codecs try: textFile = codecs.open(fn, 'r') except IOError: tkMessageBox.showerror(title='File Load Error', message='Unable to load file '+ `fileName`+' .') return else: da... |
topdir = os.getcwd() + 'build/rpm' | def run (self): | |
'_topdir ' + os.getcwd() + '/build/rpm',]) | '_topdir %s/%s' % (os.getcwd(), rpm_base),]) | def run (self): |
chars = self.text.get("1.0", "end-1c") | chars = str(self.text.get("1.0", "end-1c")) | def writefile(self, filename): self.fixlastline() try: f = open(filename, "w") chars = self.text.get("1.0", "end-1c") f.write(chars) f.close() ## print "saved to", `filename` return 1 except IOError, msg: tkMessageBox.showerror("I/O Error", str(msg), master=self.text) return 0 |
def __init__(self, get, set=None): | def __init__(self, get, set=None, delete=None): | def __init__(self, get, set=None): self.__get = get self.__set = set |
x = computed_attribute(__get_x, __set_x) | def __delete_x(self): del self.__x x = computed_attribute(__get_x, __set_x, __delete_x) | def __set_x(self, x): self.__x = x |
C.x.__delete__(a) verify(not hasattr(a, "x")) | def delx(self): del self.__x | |
__call__ = run | def __call__(self, *args, **kwds): return self.run(*args, **kwds) | def run(self, result=None): if result is None: result = self.defaultTestResult() result.startTest(self) testMethod = getattr(self, self.__testMethodName) try: try: self.setUp() except KeyboardInterrupt: raise except: result.addError(self, self.__exc_info()) return |
return self(result) def __call__(self, result): | def run(self, result): return self(result) | |
print "usage:", sys.argv[0], "file ..." | print "usage:", sys.argv[0], "[-t tabwidth] file ..." | def main(): tabsize = 8 try: opts, args = getopt.getopt(sys.argv[1:], "t:") if not args: raise getopt.error, "At least one file argument required" except getopt.error, msg: print msg print "usage:", sys.argv[0], "file ..." return for file in args: process(file, tabsize) |
vout.setpf(1, -2)) | vout.setpf((1, -2)) | def record(v, info, filename, audiofilename, mono, grey, greybits, \ monotreshold, fields, preallocspace): import thread format, x, y, qsize, rate = info fps = 59.64 # Fields per second # XXX (Strange: need fps of Indigo monitor, not of PAL or NTSC!) tpf = 1000.0 / fps # Time per field in msec if filename: vout = VFile... |
pdict: dictionary containing other parameters of conten-type header | pdict: dictionary containing other parameters of content-type header | def parse_multipart(fp, pdict): """Parse multipart input. Arguments: fp : input file pdict: dictionary containing other parameters of conten-type header Returns a dictionary just like parse_qs(): keys are the field names, each value is a list of values for that field. This is easy to use but not much good if you a... |
headers = mimetools.Message(fp) | headers = _header_parser.parse(fp) | def parse_multipart(fp, pdict): """Parse multipart input. Arguments: fp : input file pdict: dictionary containing other parameters of conten-type header Returns a dictionary just like parse_qs(): keys are the field names, each value is a list of values for that field. This is easy to use but not much good if you a... |
headers: a dictionary(-like) object (sometimes rfc822.Message or a subclass thereof) containing *all* headers | headers: a dictionary(-like) object (sometimes email.Message.Message or a subclass thereof) containing *all* headers | def __repr__(self): """Return printable representation.""" return "MiniFieldStorage(%r, %r)" % (self.name, self.value) |
headers = rfc822.Message(self.fp) | headers = _header_parser.parse(self.fp) | def read_multi(self, environ, keep_blank_values, strict_parsing): """Internal: read a part that is itself multipart.""" ib = self.innerboundary if not valid_boundary(ib): raise ValueError, 'Invalid boundary in multipart form: %r' % (ib,) self.list = [] klass = self.FieldStorageClass or self.__class__ part = klass(self.... |
if type(f) == type(''): | if isinstance(f, basestring): | def __init__(self, f): self._i_opened_the_file = None if type(f) == type(''): f = __builtin__.open(f, 'rb') self._i_opened_the_file = f # else, assume it is an open file object already self.initfp(f) |
if type(f) == type(''): | if isinstance(f, basestring): | def __init__(self, f): self._i_opened_the_file = None if type(f) == type(''): f = __builtin__.open(f, 'wb') self._i_opened_the_file = f self.initfp(f) |
else: MacOS.HandleEvent(event) | return MacOS.HandleEvent(event) | def lowlevelhandler(self, event): what, message, when, where, modifiers = event h, v = where if what == kHighLevelEvent: msg = "High Level Event: %s %s" % \ (`code(message)`, `code(h | (v<<16))`) try: AE.AEProcessAppleEvent(event) except AE.Error, err: print 'AE error: ', err print 'in', msg traceback.print_exc() retur... |
in setRollover(). | in doRollover(). | def emit(self, record): """ Emit a record. |
value = _EmptyClass() value.__class__ = klass else: | try: value = _EmptyClass() value.__class__ = klass except RuntimeError: pass if not instantiated: | def load_inst(self): k = self.marker() args = tuple(self.stack[k+1:]) del self.stack[k:] module = self.readline()[:-1] name = self.readline()[:-1] klass = self.find_class(module, name) |
value = _EmptyClass() value.__class__ = klass else: | try: value = _EmptyClass() value.__class__ = klass instantiated = 1 except RuntimeError: pass if not instantiated: | def load_obj(self): stack = self.stack k = self.marker() klass = stack[k + 1] del stack[k + 1] args = tuple(stack[k + 1:]) del stack[k:] |
inst.__dict__.update(value) | try: inst.__dict__.update(value) except RuntimeError: for k, v in value.items(): setattr(inst, k, v) | def load_build(self): stack = self.stack value = stack[-1] del stack[-1] inst = stack[-1] try: setstate = inst.__setstate__ except AttributeError: inst.__dict__.update(value) else: setstate(value) |
__starttag_text = None | def parse_pi(self, i): rawdata = self.rawdata if rawdata[i:i+2] != '<?': self.error('unexpected call to parse_pi()') match = piclose.search(rawdata, i+2) if not match: return -1 j = match.start(0) self.handle_pi(rawdata[i+2: j]) j = match.end(0) return j-i | |
def __delitem__(self, key): del self.data[key.upper()] | try: unsetenv except NameError: def __delitem__(self, key): del self.data[key.upper()] else: def __delitem__(self, key): unsetenv(key) del self.data[key.upper()] | def __delitem__(self, key): del self.data[key.upper()] |
st2 = parser.sequence2ast(t) | try: st2 = parser.sequence2ast(t) except parser.ParserError: print "Failing syntax tree:" pprint.pprint(t) raise | def roundtrip(f, s): st1 = f(s) t = st1.totuple() st2 = parser.sequence2ast(t) |
buffering. Sublcasses should however, if possible, try to | buffering. Subclasses should however, if possible, try to | def readline(self, size=None): |
the file. | file. | def open(filename, mode='rb', encoding=None, errors='strict', buffering=1): """ Open an encoded file using the given mode and return a wrapped version providing transparent encoding/decoding. Note: The wrapped version will only accept the object format defined by the codecs, i.e. Unicode objects for most builtin code... |
If a target mapping in the decoding map occurrs multiple | If a target mapping in the decoding map occurs multiple | def make_encoding_map(decoding_map): """ Creates an encoding map from a decoding map. If a target mapping in the decoding map occurrs multiple times, then that target is mapped to None (undefined mapping), causing an exception when encountered by the charmap codec during translation. One example where this happens i... |
FileHandler.names = (socket.gethostbyname('localhost'), socket.gethostbyname(socket.gethostname())) | try: FileHandler.names = (socket.gethostbyname('localhost'), socket.gethostbyname(socket.gethostname())) except socket.gaierror: FileHandler.names = (socket.gethostbyname('localhost'),) | def get_names(self): if FileHandler.names is None: FileHandler.names = (socket.gethostbyname('localhost'), socket.gethostbyname(socket.gethostname())) return FileHandler.names |
data = s[:n] | def pack_fstring(self, n, s): if n < 0: raise ValueError, 'fstring size must be nonnegative' n = ((n+3)/4)*4 data = s[:n] data = data + (n - len(data)) * '\0' self.__buf.write(data) | |
if e.errno == errno.EAGAIN: | if e.errno in (errno.EAGAIN, errno.EACCES): | def _lock_file(f, dotlock=True): """Lock file f using lockf and dot locking.""" dotlock_done = False try: if fcntl: try: fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError, e: if e.errno == errno.EAGAIN: raise ExternalClashError('lockf: lock unavailable: %s' % f.name) else: raise if dotlock: try: pre_lock = _... |
if os.name == "posix": check_environ() sys_dir = os.path.dirname(sys.modules['distutils'].__file__) sys_file = os.path.join(sys_dir, "pydistutils.cfg") if os.path.isfile(sys_file): files.append(sys_file) user_file = os.path.join(os.environ.get('HOME'), ".pydistutils.cfg") | check_environ() if os.name=='posix': sys_dir = os.path.dirname(sys.modules['distutils'].__file__) user_filename = ".pydistutils.cfg" else: sys_dir = sysconfig.PREFIX user_filename = "pydistutils.cfg" sys_file = os.path.join(sys_dir, "pydistutils.cfg") if os.path.isfile(sys_file): files.append(sys_file) if os.environ... | def find_config_files (self): """Find as many configuration files as should be processed for this platform, and return a list of filenames in the order in which they should be parsed. The filenames returned are guaranteed to exist (modulo nasty race conditions). |
else: sys_file = os.path.join (sysconfig.PREFIX, "pydistutils.cfg") if os.path.isfile(sys_file): files.append(sys_file) | def find_config_files (self): """Find as many configuration files as should be processed for this platform, and return a list of filenames in the order in which they should be parsed. The filenames returned are guaranteed to exist (modulo nasty race conditions). | |
self.assertRaises(AttributeError, f, LenOnly(), 10) | self.assertRaises(TypeError, f, LenOnly(), 10) | def test_len_only(self): for f in (bisect_left, bisect_right, insort_left, insort_right): self.assertRaises(AttributeError, f, LenOnly(), 10) |
self.assertRaises(AttributeError, f, GetOnly(), 10) | self.assertRaises(TypeError, f, GetOnly(), 10) | def test_get_only(self): for f in (bisect_left, bisect_right, insort_left, insort_right): self.assertRaises(AttributeError, f, GetOnly(), 10) |
data = self.sslobj.read(size) while len(data) < size: data += self.sslobj.read(size-len(data)) return data | chunks = [] read = 0 while read < size: data = self.sslobj.read(size-read) read += len(data) chunks.append(size) return ''.join(chunks) | def read(self, size): """Read 'size' bytes from remote.""" # sslobj.read() sometimes returns < size bytes data = self.sslobj.read(size) while len(data) < size: data += self.sslobj.read(size-len(data)) |
line = "" | line = [] | def readline(self): """Read line from remote.""" # NB: socket.ssl needs a "readline" method, or perhaps a "makefile" method. line = "" while 1: char = self.sslobj.read(1) line += char if char == "\n": return line |
line += char if char == "\n": return line | line.append(char) if char == "\n": return ''.join(line) | def readline(self): """Read line from remote.""" # NB: socket.ssl needs a "readline" method, or perhaps a "makefile" method. line = "" while 1: char = self.sslobj.read(1) line += char if char == "\n": return line |
if not host: return addinfo(open(file, 'r'), noheaders()) | if not host: return addinfo(open(_fixpath(file), 'r'), noheaders()) | def open_local_file(self, url): host, file = splithost(url) if not host: return addinfo(open(file, 'r'), noheaders()) host, port = splitport(host) if not port and socket.gethostbyname(host) in ( localhost(), thishost()): file = unquote(file) return addinfo(open(file, 'r'), noheaders()) raise IOError, ('local file error... |
return addinfo(open(file, 'r'), noheaders()) | return addinfo(open(_fixpath(file), 'r'), noheaders()) | def open_local_file(self, url): host, file = splithost(url) if not host: return addinfo(open(file, 'r'), noheaders()) host, port = splitport(host) if not port and socket.gethostbyname(host) in ( localhost(), thishost()): file = unquote(file) return addinfo(open(file, 'r'), noheaders()) raise IOError, ('local file error... |
self.implib_dir = self.build_temp | def finalize_options (self): from distutils import sysconfig | |
def get_ext_libname (self, ext_name): ext_path = string.split (ext_name, '.') if os.name == 'nt' and self.debug: return apply (os.path.join, ext_path) + '_d.lib' return apply (os.path.join, ext_path) + '.lib' | def get_ext_libname (self, ext_name): # create a filename for the (unneeded) lib-file. # extensions in debug_mode are named 'module_d.pyd' under windows ext_path = string.split (ext_name, '.') if os.name == 'nt' and self.debug: return apply (os.path.join, ext_path) + '_d.lib' return apply (os.path.join, ext_path) + '.l... | |
if sys.platform == "win32": pythonlib = ("python%d%d" % (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff)) | from distutils.msvccompiler import MSVCCompiler if sys.platform == "win32" and \ not isinstance(self.compiler, MSVCCompiler): template = "python%d%d" if self.debug: template = template + '_d' pythonlib = (template % (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff)) | def get_libraries (self, ext): """Return the list of libraries to link against when building a shared extension. On most platforms, this is just 'ext.libraries'; on Windows, we add the Python library (eg. python20.dll). """ # The python library is always needed on Windows. For MSVC, this # is redundant, since the lib... |
self.spawn (["zip", "-r", base_dir, base_dir]) | self.spawn (["zip", "-r", base_dir + ".zip", base_dir]) | def make_zipfile (self, base_dir): |
filename = sys.argv[0] | try: filename = sys.argv[0] except AttributeError: filename = '__main__' | def warn(message, category=None, stacklevel=1): """Issue a warning, or maybe ignore it or raise an exception.""" # Check if message is already a Warning object if isinstance(message, Warning): category = message.__class__ # Check category argument if category is None: category = UserWarning assert issubclass(category, ... |
The walk is performed in breadth-first order. This method is a | The walk is performed in depth-first order. This method is a | def walk(self): """Walk over the message tree, yielding each subpart. |
if not self.stack and not space.match(data): | if not self.stack and space.match(data) is None: | def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: if i > 0: self.__at_start = 0 if self.nomoretags: data = rawdata[i:n] self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = n break res = interesting.search(rawdata, i) if res: j = res.start(0) else: j = n if i ... |
if not res: | if res is None: | def parse_comment(self, i): rawdata = self.rawdata if rawdata[i:i+4] <> '<!--': raise RuntimeError, 'unexpected call to handle_comment' res = commentclose.search(rawdata, i+4) if not res: return -1 if doubledash.search(rawdata, i+4, res.start(0)): self.syntax_error("`--' inside comment") if rawdata[res.start(0)-1] == '... |
if not res: | if res is None: | def parse_doctype(self, res): rawdata = self.rawdata n = len(rawdata) name = res.group('name') pubid, syslit = res.group('pubid', 'syslit') if pubid is not None: pubid = pubid[1:-1] # remove quotes pubid = string.join(string.split(pubid)) # normalize if syslit is not None: syslit = syslit[1:-1] # remove quotes ... |
res = endbracket.search(rawdata, k) if not res: | res = endbracketfind.match(rawdata, k) if res is None: | def parse_doctype(self, res): rawdata = self.rawdata n = len(rawdata) name = res.group('name') pubid, syslit = res.group('pubid', 'syslit') if pubid is not None: pubid = pubid[1:-1] # remove quotes pubid = string.join(string.split(pubid)) # normalize if syslit is not None: syslit = syslit[1:-1] # remove quotes ... |
if res.start(0) != k: | if endbracket.match(rawdata, k) is None: | def parse_doctype(self, res): rawdata = self.rawdata n = len(rawdata) name = res.group('name') pubid, syslit = res.group('pubid', 'syslit') if pubid is not None: pubid = pubid[1:-1] # remove quotes pubid = string.join(string.split(pubid)) # normalize if syslit is not None: syslit = syslit[1:-1] # remove quotes ... |
if not res: | if res is None: | def parse_cdata(self, i): rawdata = self.rawdata if rawdata[i:i+9] <> '<![CDATA[': raise RuntimeError, 'unexpected call to parse_cdata' res = cdataclose.search(rawdata, i+9) if not res: return -1 if illegal.search(rawdata, i+9, res.start(0)): self.syntax_error('illegal character in CDATA') if not self.stack: self.synta... |
if not end: | if end is None: | def parse_proc(self, i): rawdata = self.rawdata end = procclose.search(rawdata, i) if not end: return -1 j = end.start(0) if illegal.search(rawdata, i+2, j): self.syntax_error('illegal character in processing instruction') res = tagfind.match(rawdata, i+2) if not res: raise RuntimeError, 'unexpected call to parse_proc'... |
if not res: | if res is None: | def parse_proc(self, i): rawdata = self.rawdata end = procclose.search(rawdata, i) if not end: return -1 j = end.start(0) if illegal.search(rawdata, i+2, j): self.syntax_error('illegal character in processing instruction') res = tagfind.match(rawdata, i+2) if not res: raise RuntimeError, 'unexpected call to parse_proc'... |
def parse_attributes(self, tag, k, j, attributes = None): | def parse_attributes(self, tag, i, j, attributes = None): | def parse_attributes(self, tag, k, j, attributes = None): rawdata = self.rawdata # Now parse the data between k and j into a tag and attrs attrdict = {} try: # convert attributes list to dictionary d = {} for a in attributes: d[a] = None attributes = d except TypeError: pass while k < j: res = attrfind.match(rawdata, k... |
while k < j: res = attrfind.match(rawdata, k) if not res: break | while i < j: res = attrfind.match(rawdata, i) if res is None: break | def parse_attributes(self, tag, k, j, attributes = None): rawdata = self.rawdata # Now parse the data between k and j into a tag and attrs attrdict = {} try: # convert attributes list to dictionary d = {} for a in attributes: d[a] = None attributes = d except TypeError: pass while k < j: res = attrfind.match(rawdata, k... |
self.syntax_error('no attribute value specified') | self.syntax_error("no value specified for attribute `%s'" % attrname) | def parse_attributes(self, tag, k, j, attributes = None): rawdata = self.rawdata # Now parse the data between k and j into a tag and attrs attrdict = {} try: # convert attributes list to dictionary d = {} for a in attributes: d[a] = None attributes = d except TypeError: pass while k < j: res = attrfind.match(rawdata, k... |
self.syntax_error('attribute value not quoted') | self.syntax_error("attribute `%s' value not quoted" % attrname) if '<' in attrvalue: self.syntax_error("`<' illegal in attribute value") | def parse_attributes(self, tag, k, j, attributes = None): rawdata = self.rawdata # Now parse the data between k and j into a tag and attrs attrdict = {} try: # convert attributes list to dictionary d = {} for a in attributes: d[a] = None attributes = d except TypeError: pass while k < j: res = attrfind.match(rawdata, k... |
self.syntax_error('unknown attribute %s of element %s' % | self.syntax_error("unknown attribute `%s' of element `%s'" % | def parse_attributes(self, tag, k, j, attributes = None): rawdata = self.rawdata # Now parse the data between k and j into a tag and attrs attrdict = {} try: # convert attributes list to dictionary d = {} for a in attributes: d[a] = None attributes = d except TypeError: pass while k < j: res = attrfind.match(rawdata, k... |
self.syntax_error('attribute specified twice') | self.syntax_error("attribute `%s' specified twice" % attrname) | def parse_attributes(self, tag, k, j, attributes = None): rawdata = self.rawdata # Now parse the data between k and j into a tag and attrs attrdict = {} try: # convert attributes list to dictionary d = {} for a in attributes: d[a] = None attributes = d except TypeError: pass while k < j: res = attrfind.match(rawdata, k... |
k = res.end(0) | i = res.end(0) | def parse_attributes(self, tag, k, j, attributes = None): rawdata = self.rawdata # Now parse the data between k and j into a tag and attrs attrdict = {} try: # convert attributes list to dictionary d = {} for a in attributes: d[a] = None attributes = d except TypeError: pass while k < j: res = attrfind.match(rawdata, k... |
return attrdict, k | return attrdict, i | def parse_attributes(self, tag, k, j, attributes = None): rawdata = self.rawdata # Now parse the data between k and j into a tag and attrs attrdict = {} try: # convert attributes list to dictionary d = {} for a in attributes: d[a] = None attributes = d except TypeError: pass while k < j: res = attrfind.match(rawdata, k... |
end = endbracket.search(rawdata, i+1) if not end: | end = endbracketfind.match(rawdata, i+1) if end is None: | def parse_starttag(self, i): rawdata = self.rawdata # i points to start of tag end = endbracket.search(rawdata, i+1) if not end: return -1 j = end.start(0) res = tagfind.match(rawdata, i+1) if not res: raise RuntimeError, 'unexpected call to parse_starttag' k = res.end(0) tag = res.group(0) if not self.__seen_starttag ... |
j = end.start(0) res = tagfind.match(rawdata, i+1) if not res: raise RuntimeError, 'unexpected call to parse_starttag' k = res.end(0) tag = res.group(0) if not self.__seen_starttag and self.__seen_doctype: if tag != self.__seen_doctype: self.syntax_error('starttag does not match DOCTYPE') | tag = starttagmatch.match(rawdata, i) if tag is None or tag.end(0) != end.end(0): self.syntax_error('garbage in starttag') return end.end(0) tagname = tag.group('tagname') if not self.__seen_starttag and self.__seen_doctype and \ tagname != self.__seen_doctype: self.syntax_error('starttag does not match DOCTYPE') | def parse_starttag(self, i): rawdata = self.rawdata # i points to start of tag end = endbracket.search(rawdata, i+1) if not end: return -1 j = end.start(0) res = tagfind.match(rawdata, i+1) if not res: raise RuntimeError, 'unexpected call to parse_starttag' k = res.end(0) tag = res.group(0) if not self.__seen_starttag ... |
if hasattr(self, tag + '_attributes'): attributes = getattr(self, tag + '_attributes') | if hasattr(self, tagname + '_attributes'): attributes = getattr(self, tagname + '_attributes') | def parse_starttag(self, i): rawdata = self.rawdata # i points to start of tag end = endbracket.search(rawdata, i+1) if not end: return -1 j = end.start(0) res = tagfind.match(rawdata, i+1) if not res: raise RuntimeError, 'unexpected call to parse_starttag' k = res.end(0) tag = res.group(0) if not self.__seen_starttag ... |
attrdict, k = self.parse_attributes(tag, k, j, attributes) res = starttagend.match(rawdata, k) if not res: self.syntax_error('garbage in start tag') self.finish_starttag(tag, attrdict) if res and res.group('slash') == '/': self.finish_endtag(tag) return end.end(0) | k, j = tag.span('attrs') attrdict, k = self.parse_attributes(tagname, k, j, attributes) self.finish_starttag(tagname, attrdict) if tag.group('slash') == '/': self.finish_endtag(tagname) return tag.end(0) | def parse_starttag(self, i): rawdata = self.rawdata # i points to start of tag end = endbracket.search(rawdata, i+1) if not end: return -1 j = end.start(0) res = tagfind.match(rawdata, i+1) if not res: raise RuntimeError, 'unexpected call to parse_starttag' k = res.end(0) tag = res.group(0) if not self.__seen_starttag ... |
end = endbracket.search(rawdata, i+1) if not end: | end = endbracketfind.match(rawdata, i+1) if end is None: | def parse_endtag(self, i): rawdata = self.rawdata end = endbracket.search(rawdata, i+1) if not end: return -1 res = tagfind.match(rawdata, i+2) if not res: self.syntax_error('no name specified in end tag') tag = '' k = i+2 else: tag = res.group(0) k = res.end(0) if k != end.start(0): self.syntax_error('garbage in end t... |
if not res: | if res is None: | def parse_endtag(self, i): rawdata = self.rawdata end = endbracket.search(rawdata, i+1) if not end: return -1 res = tagfind.match(rawdata, i+2) if not res: self.syntax_error('no name specified in end tag') tag = '' k = i+2 else: tag = res.group(0) k = res.end(0) if k != end.start(0): self.syntax_error('garbage in end t... |
if k != end.start(0): | if endbracket.match(rawdata, k) is None: | def parse_endtag(self, i): rawdata = self.rawdata end = endbracket.search(rawdata, i+1) if not end: return -1 res = tagfind.match(rawdata, i+2) if not res: self.syntax_error('no name specified in end tag') tag = '' k = i+2 else: tag = res.group(0) k = res.end(0) if k != end.start(0): self.syntax_error('garbage in end t... |
class C: | class Boom: | def test_trashcan(): # "trashcan" is a hack to prevent stack overflow when deallocating # very deeply nested tuples etc. It works in part by abusing the # type pointer and refcount fields, and that can yield horrible # problems when gc tries to traverse the structures. # If this test fails (as it does in 2.0, 2.1 and ... |
a = C() b = C() | a = Boom() b = Boom() | def test_boom(): a = C() b = C() a.attr = b b.attr = a gc.collect() garbagelen = len(gc.garbage) del a, b # a<->b are in a trash cycle now. Collection will invoke C.__getattr__ # (to see whether a and b have __del__ methods), and __getattr__ deletes # the internal "attr" attributes as a side effect. That causes the ... |
self._read_test(['a,\\b,c'], [['a', '\\b', 'c']], escapechar='\\') | self._read_test(['a,\\b,c'], [['a', 'b', 'c']], escapechar='\\') | def test_read_escape(self): self._read_test(['a,\\b,c'], [['a', '\\b', 'c']], escapechar='\\') self._read_test(['a,b\\,c'], [['a', 'b,c']], escapechar='\\') self._read_test(['a,"b\\,c"'], [['a', 'b,c']], escapechar='\\') self._read_test(['a,"b,\\c"'], [['a', 'b,\\c']], escapechar='\\') self._read_test(['a,"b,c\\""'], [... |
self._read_test(['a,"b,\\c"'], [['a', 'b,\\c']], escapechar='\\') | self._read_test(['a,"b,\\c"'], [['a', 'b,c']], escapechar='\\') | def test_read_escape(self): self._read_test(['a,\\b,c'], [['a', '\\b', 'c']], escapechar='\\') self._read_test(['a,b\\,c'], [['a', 'b,c']], escapechar='\\') self._read_test(['a,"b\\,c"'], [['a', 'b,c']], escapechar='\\') self._read_test(['a,"b,\\c"'], [['a', 'b,\\c']], escapechar='\\') self._read_test(['a,"b,c\\""'], [... |
host, port = self.socket.getsockname() | host, port = self.socket.getsockname()[:2] | def server_bind(self): """Override server_bind to store the server name.""" SocketServer.TCPServer.server_bind(self) host, port = self.socket.getsockname() self.server_name = socket.getfqdn(host) self.server_port = port |
host, port = self.client_address | host, port = self.client_address[:2] | def address_string(self): """Return the client address formatted for logging. |
"exclude=", "include=", "package=", "strip", "iconfile=") | "exclude=", "include=", "package=", "strip", "iconfile=", "lib=") | def main(builder=None): if builder is None: builder = AppBuilder(verbosity=1) shortopts = "b:n:r:f:e:m:c:p:lx:i:hvqa" longopts = ("builddir=", "name=", "resource=", "file=", "executable=", "mainprogram=", "creator=", "nib=", "plist=", "link", "link-exec", "help", "verbose", "quiet", "argv", "standalone", "exclude=", "... |
def fileConfig(fname): | def fileConfig(fname, defaults=None): | def fileConfig(fname): """ Read the logging configuration from a ConfigParser-format file. This can be called several times from an application, allowing an end user the ability to select from various pre-canned configurations (if the developer provides a mechanism to present the choices and load the chosen configurat... |
cp = ConfigParser.ConfigParser() | cp = ConfigParser.ConfigParser(defaults) | def fileConfig(fname): """ Read the logging configuration from a ConfigParser-format file. This can be called several times from an application, allowing an end user the ability to select from various pre-canned configurations (if the developer provides a mechanism to present the choices and load the chosen configurat... |
Output("PyObject_HEAD_INIT(&PyType_Type)") | Output("PyObject_HEAD_INIT(NULL)") | def outputTypeObject(self): sf = self.static and "staticforward " Output() Output("%sPyTypeObject %s = {", sf, self.typename) IndentLevel() Output("PyObject_HEAD_INIT(&PyType_Type)") Output("0, /*ob_size*/") Output("\"%s\", /*tp_name*/", self.name) Output("sizeof(%s), /*tp_basicsize*/", self.objecttype) Output("0, /*tp... |
__slots__ = ['_hash'] | __slots__ = ['_hashcode'] | def _compute_hash(self): # Calculate hash code for a set by xor'ing the hash codes of # the elements. This algorithm ensures that the hash code # does not depend on the order in which elements are added to # the code. This is not called __hash__ because a BaseSet # should not be hashable; only an ImmutableSet is hash... |
TixWidget.__init__(self, master, 'tixDirList', ['options'], cnf, kw) self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') self.subwidget_list['shlist'] = _dummyScrolledHList(self, 'vsb') | TixWidget.__init__(self, master, 'tixListNoteBook', ['options'], cnf, kw) self.subwidget_list['pane'] = _dummyPanedWindow(self, 'pane', destroy_physically=0) self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') self.subwidget_list['shlist'] = _dummyScrolledHList(self, 'vsb') | def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixDirList', ['options'], cnf, kw) self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') self.subwidget_list['shlist'] = _dummyScrolledHList(self, 'vsb') |
'UNICODE': ('ref/unicode', 'encodings unicode TYPES STRING'), | 'UNICODE': ('ref/strings', 'encodings unicode TYPES STRING'), | def writedocs(dir, pkgpath='', done=None): """Write out HTML documentation for all modules in a directory tree.""" if done is None: done = {} for file in os.listdir(dir): path = os.path.join(dir, file) if ispackage(path): writedocs(path, pkgpath + file + '.', done) elif os.path.isfile(path): modname = inspect.getmodule... |
'BOOLEAN': ('ref/lambda', 'EXPRESSIONS TRUTHVALUE'), | 'BOOLEAN': ('ref/Booleans', 'EXPRESSIONS TRUTHVALUE'), | 'METHODS': ('lib/typesmethods', 'class def CLASSES TYPES'), |
"""Tix maintains a list of directory under which which | """Tix maintains a list of directories under which | def tix_addbitmapdir(self, directory): """Tix maintains a list of directory under which which the tix_getimage and tix_getbitmap commands will search for image files. The standard bitmap direc tory is $TIX_LIBRARY/bitmaps. The addbitmapdir com mand adds directory into this list. By using this command, the image ... |
"""Query or modify the configuration options of the Tix application context. If no option is specified, returns a list describing all of the available options (see Tk_ConfigureInfo for information on the format of this list). If option is specified with no value, then the command returns a list describin... | """Query or modify the configuration options of the Tix application context. If no option is specified, returns a dictionary all of the available options. If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of t... | def tix_configure(self, cnf=None, **kw): """Query or modify the configuration options of the Tix application context. If no option is specified, returns a list describing all of the available options (see Tk_ConfigureInfo for information on the format of this list). If option is specified with no value, th... |
return apply(self.tk.call, ('tix', configure) + self._options(cnf,kw) ) | if kw: cnf = _cnfmerge((cnf, kw)) elif cnf: cnf = _cnfmerge(cnf) if cnf is None: cnf = {} for x in self.tk.split(self.tk.call('tix', 'configure')): cnf[x[0][1:]] = (x[0][1:],) + x[1:] return cnf if isinstance(cnf, StringType): x = self.tk.split(self.tk.call('tix', 'configure', '-'+cnf)) return (x[0][1:],) + x[1:] retur... | def tix_configure(self, cnf=None, **kw): """Query or modify the configuration options of the Tix application context. If no option is specified, returns a list describing all of the available options (see Tk_ConfigureInfo for information on the format of this list). If option is specified with no value, th... |
"""Returns the file selection dialog that may be shared among different modules of this application. This command will create a file selection dialog widget when it is called the first time. This dialog will be returned by all subsequent calls to tix filedialog. An optional dlgclass parameter can be passe... | """Returns the file selection dialog that may be shared among different calls from this application. This command will create a file selection dialog widget when it is called the first time. This dialog will be returned by all subsequent calls to tix_filedialog. An optional dlgclass parameter can be passed to specifie... | def tix_filedialog(self, dlgclass=None): """Returns the file selection dialog that may be shared among different modules of this application. This command will create a file selection dialog widget when it is called the first time. This dialog will be returned by all subsequent calls to tix filedialog. An op... |
"""Locates a bitmap file of the name name.xpm or name in one of the bitmap directories (self, see the tix_addbitmapdir command above). By using tix_getbitmap, you can advoid hard coding the pathnames of the bitmap files in your application. When successful, it returns the complete pathname of the bitmap f... | """Locates a bitmap file of the name name.xpm or name in one of the bitmap directories (see the tix_addbitmapdir command above). By using tix_getbitmap, you can avoid hard coding the pathnames of the bitmap files in your application. When successful, it returns the complete pathname of the bitmap file, prefixed with t... | def tix_getbitmap(self, name): """Locates a bitmap file of the name name.xpm or name in one of the bitmap directories (self, see the tix_addbitmapdir command above). By using tix_getbitmap, you can advoid hard coding the pathnames of the bitmap files in your application. When successful, it returns the co... |
"""Locates an image file of the name name.xpm, name.xbm or name.ppm in one of the bitmap directo ries (see the addbitmapdir command above). If more than one file with the same name (but different extensions) exist, then the image type is chosen according to the depth of the X display: xbm images are chose... | """Locates an image file of the name name.xpm, name.xbm or name.ppm in one of the bitmap directories (see the addbitmapdir command above). If more than one file with the same name (but different extensions) exist, then the image type is chosen according to the depth of the X display: xbm images are chosen on monochrome... | def tix_getimage(self, name): """Locates an image file of the name name.xpm, name.xbm or name.ppm in one of the bitmap directo ries (see the addbitmapdir command above). If more than one file with the same name (but different extensions) exist, then the image type is chosen according to the depth of the X ... |
scheme mechanism. Available options are: | scheme mechanism. Available options include: | def tix_option_get(self, name): """Gets the options manitained by the Tix scheme mechanism. Available options are: |
"""Resets the scheme and fontset of the Tix application to newScheme and newFontSet, respectively. This affects only those widgets created after this call. Therefore, it is best to call the resetop tions command before the creation of any widgets in a Tix application. The optional parameter newScmPrio can be... | """Resets the scheme and fontset of the Tix application to newScheme and newFontSet, respectively. This affects only those widgets created after this call. Therefore, it is best to call the resetoptions command before the creation of any widgets in a Tix application. The optional parameter newScmPrio can be given to ... | def tix_resetoptions(self, newScheme, newFontSet, newScmPrio=None): """Resets the scheme and fontset of the Tix application to newScheme and newFontSet, respectively. This affects only those widgets created after this call. Therefore, it is best to call the resetop tions command before the creation of any wid... |
elif type(option) != type(''): | elif not isinstance(option, StringType): | def config_all(self, option, value): """Set configuration options for all subwidgets (and self).""" if option == '': return elif type(option) != type(''): option = `option` if type(value) != type(''): value = `value` names = self._subwidget_names() for name in names: self.tk.call(name, 'configure', '-' + option, value) |
if type(value) != type(''): | if not isinstance(value, StringType): | def config_all(self, option, value): """Set configuration options for all subwidgets (and self).""" if option == '': return elif type(option) != type(''): option = `option` if type(value) != type(''): value = `value` names = self._subwidget_names() for name in names: self.tk.call(name, 'configure', '-' + option, value) |
"lib", "python" + sys.version[:3]) | "lib", "python" + get_python_version()) | def get_python_lib(plat_specific=0, standard_lib=0, prefix=None): """Return the directory containing the Python library (standard or site additions). If 'plat_specific' is true, return the directory containing platform-specific modules, i.e. any module from a non-pure-Python module distribution; otherwise, return the ... |
db.DB_INIT_LOCK | db.DB_THREAD) | db.DB_INIT_LOCK | db.DB_THREAD | self.envFlags) | def setUp(self): self.filename = self.__class__.__name__ + '.db' homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home') self.homeDir = homeDir try: os.mkdir(homeDir) except os.error: pass self.env = db.DBEnv() self.env.open(homeDir, db.DB_CREATE | db.DB_INIT_MPOOL | db.DB_INIT_LOCK | db.DB_THREAD) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.