rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
return string.join(res, '') | return ''.join(res) | def quote(s, safe = '/'): """quote('abc def') -> 'abc%20def' Each part of a URL, e.g. the path info, the query, etc., has a different set of reserved characters that must be quoted. RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax lists the following reserved characters. reserved = ";" | "/" | "?" | ":... |
l = string.split(s, ' ') | l = s.split(' ') | def quote_plus(s, safe = ''): """Quote the query fragment of a URL; replacing ' ' with '+'""" if ' ' in s: l = string.split(s, ' ') for i in range(len(l)): l[i] = quote(l[i], safe) return string.join(l, '+') else: return quote(s, safe) |
return string.join(l, '+') | return '+'.join(l) | def quote_plus(s, safe = ''): """Quote the query fragment of a URL; replacing ' ' with '+'""" if ' ' in s: l = string.split(s, ' ') for i in range(len(l)): l[i] = quote(l[i], safe) return string.join(l, '+') else: return quote(s, safe) |
return string.join(l, '&') | return '&'.join(l) | def urlencode(dict): """Encode a dictionary of form entries into a URL query string.""" l = [] for k, v in dict.items(): k = quote_plus(str(k)) v = quote_plus(str(v)) l.append(k + '=' + v) return string.join(l, '&') |
name = string.lower(name) | name = name.lower() | def getproxies_environment(): """Return a dictionary of scheme -> proxy server URL mappings. Scan the environment for variables named <scheme>_proxy; this seems to be the standard convention. If you need a different way, you can pass a proxies dictionary to the [Fancy]URLopener constructor. """ proxies = {} for name... |
print fn, h | print fn | def test(args=[]): if not args: args = [ '/etc/passwd', 'file:/etc/passwd', 'file://localhost/etc/passwd', 'ftp://ftp.python.org/etc/passwd', |
data = string.translate(data, table, "\r") | data = data.translate(table, "\r") | def test(args=[]): if not args: args = [ '/etc/passwd', 'file:/etc/passwd', 'file://localhost/etc/passwd', 'ftp://ftp.python.org/etc/passwd', |
print (garbage, path) | def retrieve(self, url, filename=None): url = unwrap(url) if self.tempcache and self.tempcache.has_key(url): return self.tempcache[url] type, url1 = splittype(url) if not filename and (not type or type == 'file'): try: fp = self.open_local_file(url1) hdrs = fp.info() del fp return url2pathname(splithost(url1)[1]), hdrs... | |
print (path, garbage) | def retrieve(self, url, filename=None): url = unwrap(url) if self.tempcache and self.tempcache.has_key(url): return self.tempcache[url] type, url1 = splittype(url) if not filename and (not type or type == 'file'): try: fp = self.open_local_file(url1) hdrs = fp.info() del fp return url2pathname(splithost(url1)[1]), hdrs... | |
tests.remove("test_file") tests.insert(tests.index("test_optparse"), "test_file") | def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False, exclude=False, single=False, randomize=False, fromfile=None, findleaks=False, use_resources=None, trace=False, coverdir='coverage', runleaks=False, huntrleaks=False, verbose2=False): """Execute a test suite. This also parses command-line option... | |
no elements are considered to be junk. For examples, pass | no elements are considered to be junk. For example, pass | def __init__(self, isjunk=None, a='', b=''): """Construct a SequenceMatcher. |
default, an empty string. The elements of a must be hashable. See | default, an empty string. The elements of b must be hashable. See | def __init__(self, isjunk=None, a='', b=''): """Construct a SequenceMatcher. |
raise ValueError("n must be > 0: %s" % `n`) | raise ValueError("n must be > 0: " + `n`) | def get_close_matches(word, possibilities, n=3, cutoff=0.6): """Use SequenceMatcher to return list of the best "good enough" matches. word is a sequence for which close matches are desired (typically a string). possibilities is a list of sequences against which to match word (typically a list of strings). Optional a... |
raise ValueError("cutoff must be in [0.0, 1.0]: %s" % `cutoff`) | raise ValueError("cutoff must be in [0.0, 1.0]: " + `cutoff`) | def get_close_matches(word, possibilities, n=3, cutoff=0.6): """Use SequenceMatcher to return list of the best "good enough" matches. word is a sequence for which close matches are desired (typically a string). possibilities is a list of sequences against which to match word (typically a list of strings). Optional a... |
if terminator is None or terminator == '': | if not terminator: | def handle_read (self): |
elif isinstance(terminator, int): | elif isinstance(terminator, int) or isinstance(terminator, long): | def handle_read (self): |
veris(x, None) vereq((spam.spamlist,) + a, a1) | veris(x, spam.spamlist) vereq(a, a1) | def classmethods_in_c(): if verbose: print "Testing C-based class methods..." import xxsubtype as spam a = (1, 2, 3) d = {'abc': 123} x, a1, d1 = spam.spamlist.classmeth(*a, **d) veris(x, None) vereq((spam.spamlist,) + a, a1) vereq(d, d1) x, a1, d1 = spam.spamlist().classmeth(*a, **d) veris(x, None) vereq((spam.spamlis... |
self.membernames = [] | def __init__(self, name=None, mode="r", fileobj=None): """Open an (uncompressed) tar archive `name'. `mode' is either 'r' to read from an existing archive, 'a' to append data to an existing file or 'w' to create a new file overwriting an existing one. `mode' defaults to 'r'. If `fileobj' is given, it is used for readin... | |
self._check() if name not in self.membernames and not self._loaded: self._load() if name not in self.membernames: | tarinfo = self._getmember(name) if tarinfo is None: | def getmember(self, name): """Return a TarInfo object for member `name'. If `name' can not be found in the archive, KeyError is raised. If a member occurs more than once in the archive, its last occurence is assumed to be the most up-to-date version. """ self._check() if name not in self.membernames and not self._loade... |
return self._getmember(name) | return tarinfo | def getmember(self, name): """Return a TarInfo object for member `name'. If `name' can not be found in the archive, KeyError is raised. If a member occurs more than once in the archive, its last occurence is assumed to be the most up-to-date version. """ self._check() if name not in self.membernames and not self._loade... |
self._check() if not self._loaded: self._load() return self.membernames | return [tarinfo.name for tarinfo in self.getmembers()] | def getnames(self): """Return the members of the archive as a list of their names. It has the same order as the list returned by getmembers(). """ self._check() if not self._loaded: self._load() return self.membernames |
self._record_member(tarinfo) | self.members.append(tarinfo) | def addfile(self, tarinfo, fileobj=None): """Add the TarInfo object `tarinfo' to the archive. If `fileobj' is given, tarinfo.size bytes are read from it and added to the archive. You can create TarInfo objects using gettarinfo(). On Windows platforms, `fileobj' should always be opened with mode 'rb' to avoid irritation... |
self._record_member(tarinfo) | self.members.append(tarinfo) | def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m |
self._record_member(tarinfo) | self.members.append(tarinfo) | def proc_sparse(self, tarinfo): """Analyze a GNU sparse header plus extra headers. """ buf = tarinfo.tobuf() sp = _ringbuffer() pos = 386 lastpos = 0L realpos = 0L # There are 4 possible sparse structs in the # first header. for i in xrange(4): try: offset = int(buf[pos:pos + 12], 8) numbytes = int(buf[pos + 12:pos + 2... |
end = len(self.members) else: end = self.members.index(tarinfo) | end = len(members) else: end = members.index(tarinfo) | def _getmember(self, name, tarinfo=None): """Find an archive member by name from bottom to top. If tarinfo is given, it is used as the starting point. """ if tarinfo is None: end = len(self.members) else: end = self.members.index(tarinfo) |
if name == self.membernames[i]: return self.members[i] def _record_member(self, tarinfo): """Record a tarinfo object in the internal datastructures. """ self.members.append(tarinfo) self.membernames.append(tarinfo.name) | if name == members[i].name: return members[i] | def _getmember(self, name, tarinfo=None): """Find an archive member by name from bottom to top. If tarinfo is given, it is used as the starting point. """ if tarinfo is None: end = len(self.members) else: end = self.members.index(tarinfo) |
(objects, output_dir) = self._fix_link_args (objects, output_dir, takes_libs=0) | (objects, output_dir) = self._fix_object_args (objects, output_dir) | def create_static_lib (self, objects, output_libname, output_dir=None, debug=0): |
(objects, output_dir, libraries, library_dirs) = \ self._fix_link_args (objects, output_dir, takes_libs=1, libraries=libraries, library_dirs=library_dirs) | (objects, output_dir) = self._fix_object_args (objects, output_dir) (libraries, library_dirs, runtime_library_dirs) = \ self._fix_lib_args (libraries, library_dirs, runtime_library_dirs) | def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, debug=0, extra_preargs=None, extra_postargs=None): |
library_dirs, self.runtime_library_dirs, | library_dirs, runtime_library_dirs, | def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, debug=0, extra_preargs=None, extra_postargs=None): |
(objects, output_dir, libraries, library_dirs) = \ self._fix_link_args (objects, output_dir, takes_libs=1, libraries=libraries, library_dirs=library_dirs) | (objects, output_dir) = self._fix_object_args (objects, output_dir) (libraries, library_dirs, runtime_library_dirs) = \ self._fix_lib_args (libraries, library_dirs, runtime_library_dirs) | def link_executable (self, objects, output_progname, output_dir=None, libraries=None, library_dirs=None, debug=0, extra_preargs=None, extra_postargs=None): (objects, output_dir, libraries, library_dirs) = \ self._fix_link_args (objects, output_dir, takes_libs=1, libraries=libraries, library_dirs=library_dirs) |
library_dirs, self.runtime_library_dirs, | library_dirs, runtime_library_dirs, | def link_executable (self, objects, output_progname, output_dir=None, libraries=None, library_dirs=None, debug=0, extra_preargs=None, extra_postargs=None): (objects, output_dir, libraries, library_dirs) = \ self._fix_link_args (objects, output_dir, takes_libs=1, libraries=libraries, library_dirs=library_dirs) |
'nooutput', | >>> def f(x): | |
runner.run(self._dt_test, out=nooutput) | runner.run(self._dt_test) | def debug(self): r"""Run the test case without results and without catching exceptions |
def nooutput(*args): pass | def shortDescription(self): return "Doctest: " + self._dt_test.name | |
srcfss = macfs.FSSpec(src) dstfss = macfs.FSSpec(dst) | def copy(src, dst, createpath=0, copydates=1, forcetype=None): """Copy a file, including finder info, resource fork, etc""" if createpath: mkdirs(os.path.split(dst)[0]) srcfss = macfs.FSSpec(src) dstfss = macfs.FSSpec(dst) ifp = open(srcfss.as_pathname(), 'rb') ofp = open(dstfss.as_pathname(), 'wb') d = ifp.read(BUFSI... | |
ifp = open(srcfss.as_pathname(), 'rb') ofp = open(dstfss.as_pathname(), 'wb') | ifp = open(src, 'rb') ofp = open(dst, 'wb') | def copy(src, dst, createpath=0, copydates=1, forcetype=None): """Copy a file, including finder info, resource fork, etc""" if createpath: mkdirs(os.path.split(dst)[0]) srcfss = macfs.FSSpec(src) dstfss = macfs.FSSpec(dst) ifp = open(srcfss.as_pathname(), 'rb') ofp = open(dstfss.as_pathname(), 'wb') d = ifp.read(BUFSI... |
ifp = openrf(srcfss.as_pathname(), '*rb') ofp = openrf(dstfss.as_pathname(), '*wb') | ifp = openrf(src, '*rb') ofp = openrf(dst, '*wb') | def copy(src, dst, createpath=0, copydates=1, forcetype=None): """Copy a file, including finder info, resource fork, etc""" if createpath: mkdirs(os.path.split(dst)[0]) srcfss = macfs.FSSpec(src) dstfss = macfs.FSSpec(dst) ifp = open(srcfss.as_pathname(), 'rb') ofp = open(dstfss.as_pathname(), 'wb') d = ifp.read(BUFSI... |
"contact_email", "licence") | "contact_email", "licence", "classifiers") | def is_pure (self): return (self.has_pure_modules() and not self.has_ext_modules() and not self.has_c_libraries()) |
run_unittest(StatAttributeTests) | def test_main(): run_unittest(TemporaryFileTests) | |
raise DistutilsSetupError, \ "invalid distribution option '%s'" % key | msg = "Unknown distribution option: %s" % repr(key) if warnings is not None: warnings.warn(msg) else: sys.stderr.write(msg + "\n") | def __init__ (self, attrs=None): """Construct a new Distribution instance: initialize all the attributes of a Distribution, and then use 'attrs' (a dictionary mapping attribute names to values) to assign some of those attributes their "real" values. (Any attributes not mentioned in 'attrs' will be assigned to some nul... |
def _buffer_decode(self, input, errors, final): return mbcs_decode(input,self.errors,final) | _buffer_decode = mbcs_decode | def _buffer_decode(self, input, errors, final): return mbcs_decode(input,self.errors,final) |
class StreamWriter(Codec,codecs.StreamWriter): pass | class StreamWriter(codecs.StreamWriter): encode = mbcs_encode | def _buffer_decode(self, input, errors, final): return mbcs_decode(input,self.errors,final) |
class StreamReader(Codec,codecs.StreamReader): pass class StreamConverter(StreamWriter,StreamReader): encode = codecs.mbcs_decode decode = codecs.mbcs_encode | class StreamReader(codecs.StreamReader): decode = mbcs_decode | def _buffer_decode(self, input, errors, final): return mbcs_decode(input,self.errors,final) |
filename = fp.read(centdir[12]) | filename = fp.read(centdir[_CD_FILENAME_LENGTH]) | def _GetContents(self): """Read in the table of contents for the ZIP file.""" fp = self.fp fp.seek(-22, 2) # Start of end-of-archive record filesize = fp.tell() + 22 # Get file size endrec = fp.read(22) # Archive must not end with a comment! if endrec[0:4] != stringEndArchive or endrec[-2:] != "\000\00... |
x.extra = fp.read(centdir[13]) x.comment = fp.read(centdir[14]) total = total + centdir[12] + centdir[13] + centdir[14] x.header_offset = centdir[18] + concat x.file_offset = x.header_offset + 30 + centdir[12] + centdir[13] | x.extra = fp.read(centdir[_CD_EXTRA_FIELD_LENGTH]) x.comment = fp.read(centdir[_CD_COMMENT_LENGTH]) total = (total + centdir[_CD_FILENAME_LENGTH] + centdir[_CD_EXTRA_FIELD_LENGTH] + centdir[_CD_COMMENT_LENGTH]) x.header_offset = centdir[_CD_LOCAL_HEADER_OFFSET] + concat | def _GetContents(self): """Read in the table of contents for the ZIP file.""" fp = self.fp fp.seek(-22, 2) # Start of end-of-archive record filesize = fp.tell() + 22 # Get file size endrec = fp.read(22) # Archive must not end with a comment! if endrec[0:4] != stringEndArchive or endrec[-2:] != "\000\00... |
fname = fp.read(fheader[10]) | data.file_offset = (data.header_offset + 30 + fheader[_FH_FILENAME_LENGTH] + fheader[_FH_EXTRA_FIELD_LENGTH]) fname = fp.read(fheader[_FH_FILENAME_LENGTH]) | def _GetContents(self): """Read in the table of contents for the ZIP file.""" fp = self.fp fp.seek(-22, 2) # Start of end-of-archive record filesize = fp.tell() + 22 # Get file size endrec = fp.read(22) # Archive must not end with a comment! if endrec[0:4] != stringEndArchive or endrec[-2:] != "\000\00... |
raise RuntimeError, "UserList.__cmp__() is obsolete" | return cmp(self.data, self.__cast(other)) | def __cmp__(self, other): raise RuntimeError, "UserList.__cmp__() is obsolete" |
fp = MyURLopener().open(url).fp | fp = urllib2.urlopen(url).fp | def appendURL(self, url, included=0): """Append packages from the database with the given URL. Only the first database should specify included=0, so the global information (maintainer, description) get stored.""" if url in self._urllist: return self._urllist.append(url) fp = MyURLopener().open(url).fp dict = plistlib.... |
exts.append( Extension('cmath', ['cmathmodule.c'], libraries=['m']) ) | exts.append( Extension('cmath', ['cmathmodule.c'], libraries=math_libs) ) | def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' ) |
exts.append( Extension('math', ['mathmodule.c'], libraries=['m']) ) | exts.append( Extension('math', ['mathmodule.c'], libraries=math_libs) ) | def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' ) |
exts.append( Extension('time', ['timemodule.c'], libraries=['m']) ) | exts.append( Extension('time', ['timemodule.c'], libraries=math_libs) ) | def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' ) |
print | def basic(src): print print "Testing basic accessors..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) L = cf.sections() L.sort() print L for s in L: print "%s: %s" % (s, cf.options(s)) # The use of spaces in the section names serves as a regression test for # SourceForge bug #115357. # ... | |
print L for s in L: print "%s: %s" % (s, cf.options(s)) | verify(L == ['Commented Bar', 'Foo Bar', 'Internationalized Stuff', 'Spacey Bar'], "unexpected list of section names") | def basic(src): print print "Testing basic accessors..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) L = cf.sections() L.sort() print L for s in L: print "%s: %s" % (s, cf.options(s)) # The use of spaces in the section names serves as a regression test for # SourceForge bug #115357. # ... |
print `cf.get('Foo Bar', 'foo', raw=1)` print `cf.get('Spacey Bar', 'foo', raw=1)` print `cf.get('Commented Bar', 'foo', raw=1)` | verify(cf.get('Foo Bar', 'foo', raw=1) == 'bar') verify(cf.get('Spacey Bar', 'foo', raw=1) == 'bar') verify(cf.get('Commented Bar', 'foo', raw=1) == 'bar') | def basic(src): print print "Testing basic accessors..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) L = cf.sections() L.sort() print L for s in L: print "%s: %s" % (s, cf.options(s)) # The use of spaces in the section names serves as a regression test for # SourceForge bug #115357. # ... |
if '__name__' in cf.options("Foo Bar"): print '__name__ "option" should not be exposed by the API!' else: print '__name__ "option" properly hidden by the API.' | verify('__name__' not in cf.options("Foo Bar"), '__name__ "option" should not be exposed by the API!') | def basic(src): print print "Testing basic accessors..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) L = cf.sections() L.sort() print L for s in L: print "%s: %s" % (s, cf.options(s)) # The use of spaces in the section names serves as a regression test for # SourceForge bug #115357. # ... |
if not cf.remove_option('Foo Bar', 'foo'): raise TestFailed( "remove_option() failed to report existance of option") if cf.has_option('Foo Bar', 'foo'): raise TestFailed("remove_option() failed to remove option") if cf.remove_option('Foo Bar', 'foo'): raise TestFailed( "remove_option() failed to report non-existance of... | verify(cf.remove_option('Foo Bar', 'foo'), "remove_option() failed to report existance of option") verify(not cf.has_option('Foo Bar', 'foo'), "remove_option() failed to remove option") verify(not cf.remove_option('Foo Bar', 'foo'), "remove_option() failed to report non-existance of option" " that was removed") | def basic(src): print print "Testing basic accessors..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) L = cf.sections() L.sort() print L for s in L: print "%s: %s" % (s, cf.options(s)) # The use of spaces in the section names serves as a regression test for # SourceForge bug #115357. # ... |
print | def interpolation(src): print print "Testing value interpolation..." cf = ConfigParser.ConfigParser({"getname": "%(__name__)s"}) sio = StringIO.StringIO(src) cf.readfp(sio) print `cf.get("Foo", "getname")` print `cf.get("Foo", "bar")` print `cf.get("Foo", "bar9")` print `cf.get("Foo", "bar10")` expect_get_error(cf, Con... | |
print `cf.get("Foo", "getname")` print `cf.get("Foo", "bar")` print `cf.get("Foo", "bar9")` print `cf.get("Foo", "bar10")` | verify(cf.get("Foo", "getname") == "Foo") verify(cf.get("Foo", "bar") == "something with interpolation (1 step)") verify(cf.get("Foo", "bar9") == "something with lots of interpolation (9 steps)") verify(cf.get("Foo", "bar10") == "something with lots of interpolation (10 steps)") | def interpolation(src): print print "Testing value interpolation..." cf = ConfigParser.ConfigParser({"getname": "%(__name__)s"}) sio = StringIO.StringIO(src) cf.readfp(sio) print `cf.get("Foo", "getname")` print `cf.get("Foo", "bar")` print `cf.get("Foo", "bar9")` print `cf.get("Foo", "bar10")` expect_get_error(cf, Con... |
print print "Testing for parsing errors..." | print "Testing parse errors..." | def parse_errors(): print print "Testing for parsing errors..." expect_parse_error(ConfigParser.ParsingError, """[Foo]\n extra-spaces: splat\n""") expect_parse_error(ConfigParser.ParsingError, """[Foo]\n extra-spaces= splat\n""") expect_parse_error(ConfigParser.ParsingError, """[Foo]\noption-without-value\n""") expec... |
print | def query_errors(): print print "Testing query interface..." cf = ConfigParser.ConfigParser() print cf.sections() print "Has section 'Foo'?", cf.has_section("Foo") try: cf.options("Foo") except ConfigParser.NoSectionError, e: print "Caught expected NoSectionError:", e else: print "Failed to catch expected NoSectionErro... | |
print cf.sections() print "Has section 'Foo'?", cf.has_section("Foo") | verify(cf.sections() == [], "new ConfigParser should have no defined sections") verify(not cf.has_section("Foo"), "new ConfigParser should have no acknowledged sections") | def query_errors(): print print "Testing query interface..." cf = ConfigParser.ConfigParser() print cf.sections() print "Has section 'Foo'?", cf.has_section("Foo") try: cf.options("Foo") except ConfigParser.NoSectionError, e: print "Caught expected NoSectionError:", e else: print "Failed to catch expected NoSectionErro... |
print "Caught expected NoSectionError:", e | pass | def query_errors(): print print "Testing query interface..." cf = ConfigParser.ConfigParser() print cf.sections() print "Has section 'Foo'?", cf.has_section("Foo") try: cf.options("Foo") except ConfigParser.NoSectionError, e: print "Caught expected NoSectionError:", e else: print "Failed to catch expected NoSectionErro... |
print "Failed to catch expected NoSectionError from options()" | raise TestFailed( "Failed to catch expected NoSectionError from options()") | def query_errors(): print print "Testing query interface..." cf = ConfigParser.ConfigParser() print cf.sections() print "Has section 'Foo'?", cf.has_section("Foo") try: cf.options("Foo") except ConfigParser.NoSectionError, e: print "Caught expected NoSectionError:", e else: print "Failed to catch expected NoSectionErro... |
print "Failed to catch expected NoSectionError from set()" | raise TestFailed("Failed to catch expected NoSectionError from set()") | def query_errors(): print print "Testing query interface..." cf = ConfigParser.ConfigParser() print cf.sections() print "Has section 'Foo'?", cf.has_section("Foo") try: cf.options("Foo") except ConfigParser.NoSectionError, e: print "Caught expected NoSectionError:", e else: print "Failed to catch expected NoSectionErro... |
print | def weird_errors(): print print "Testing miscellaneous error conditions..." cf = ConfigParser.ConfigParser() cf.add_section("Foo") try: cf.add_section("Foo") except ConfigParser.DuplicateSectionError, e: print "Caught expected DuplicateSectionError:", e else: print "Failed to catch expected DuplicateSectionError" | |
print "Caught expected DuplicateSectionError:", e | pass | def weird_errors(): print print "Testing miscellaneous error conditions..." cf = ConfigParser.ConfigParser() cf.add_section("Foo") try: cf.add_section("Foo") except ConfigParser.DuplicateSectionError, e: print "Caught expected DuplicateSectionError:", e else: print "Failed to catch expected DuplicateSectionError" |
print "Failed to catch expected DuplicateSectionError" | raise TestFailed("Failed to catch expected DuplicateSectionError") | def weird_errors(): print print "Testing miscellaneous error conditions..." cf = ConfigParser.ConfigParser() cf.add_section("Foo") try: cf.add_section("Foo") except ConfigParser.DuplicateSectionError, e: print "Caught expected DuplicateSectionError:", e else: print "Failed to catch expected DuplicateSectionError" |
print "Caught expected", exctype.__name__, ":" print e | pass | def expect_get_error(cf, exctype, section, option, raw=0): try: cf.get(section, option, raw=raw) except exctype, e: print "Caught expected", exctype.__name__, ":" print e else: print "Failed to catch expected", exctype.__name__ |
print "Failed to catch expected", exctype.__name__ | raise TestFailed("Failed to catch expected " + exctype.__name__) | def expect_get_error(cf, exctype, section, option, raw=0): try: cf.get(section, option, raw=raw) except exctype, e: print "Caught expected", exctype.__name__, ":" print e else: print "Failed to catch expected", exctype.__name__ |
print "Caught expected exception:", e | pass | def expect_parse_error(exctype, src): cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) try: cf.readfp(sio) except exctype, e: print "Caught expected exception:", e else: print "Failed to catch expected", exctype.__name__ |
print "Failed to catch expected", exctype.__name__ | raise TestFailed("Failed to catch expected " + exctype.__name__) | def expect_parse_error(exctype, src): cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) try: cf.readfp(sio) except exctype, e: print "Caught expected exception:", e else: print "Failed to catch expected", exctype.__name__ |
default_startupinfo = STARTUPINFO() | def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite): """Execute program (MS Windows version)""" | |
startupinfo = default_startupinfo if not None in (p2cread, c2pwrite, errwrite): | startupinfo = STARTUPINFO() if None not in (p2cread, c2pwrite, errwrite): | def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite): """Execute program (MS Windows version)""" |
default_startupinfo.dwFlags |= STARTF_USESHOWWINDOW default_startupinfo.wShowWindow = SW_HIDE | startupinfo.dwFlags |= STARTF_USESHOWWINDOW startupinfo.wShowWindow = SW_HIDE | def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite): """Execute program (MS Windows version)""" |
def __init__(self): | def __init__(self, verbose=0): self.verbose = verbose | def __init__(self): self.reset() |
if j == n: break | if j == n or rawdata[i:i+2] == '<!': break | def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: if self.nomoretags: self.handle_data(rawdata[i:n]) i = n break j = incomplete.search(rawdata, i) if j < 0: j = n if i < j: self.handle_data(rawdata[i:j]) i = j if i == n: break if rawdata[i] == '<': if starttagopen.match(rawdata, i) >= 0... |
print '*** Unbalanced </' + tag + '>' print '*** Stack:', self.stack | if self.verbose: print '*** Unbalanced </' + tag + '>' print '*** Stack:', self.stack | def report_unbalanced(self, tag): print '*** Unbalanced </' + tag + '>' print '*** Stack:', self.stack |
name = string.lower(name) | def handle_entityref(self, name): table = self.entitydefs name = string.lower(name) if table.has_key(name): self.handle_data(table[name]) else: self.unknown_entityref(name) return | |
w.ide_radio = W.RadioButton((8, 22, 160, 18), "This application", radiobuttons, self.ide_hit) w.interp_radio = W.RadioButton((8, 42, 160, 18), "MacPython Interpreter", radiobuttons, self.interp_hit) w.interpx_radio = W.RadioButton((8, 62, 160, 18), "OSX PythonW Interpreter", radiobuttons, self.interpx_hit) | w.ide_radio = W.RadioButton((8, 22, 160, 18), "PythonIDE", radiobuttons, self.ide_hit) w.interp_radio = W.RadioButton((8, 42, 160, 18), "MacPython-OS9 Interpreter", radiobuttons, self.interp_hit) w.interpx_radio = W.RadioButton((8, 62, 160, 18), "PythonLauncher", radiobuttons, self.interpx_hit) | def __init__(self, creator, eoln): self.rv = None self.eoln = eoln self.w = w = W.ModalDialog((260, 160), 'Save options') radiobuttons = [] w.label = W.TextBox((8, 8, 80, 18), "File creator:") w.ide_radio = W.RadioButton((8, 22, 160, 18), "This application", radiobuttons, self.ide_hit) w.interp_radio = W.RadioButton((8... |
if not code1 and err1 == err2: | try: e1 = err1.__dict__ except AttributeError: e1 = err1 try: e2 = err2.__dict__ except AttributeError: e2 = err2 if not code1 and e1 == e2: | def compile_command(source, filename="<input>", symbol="single"): r"""Compile a command and determine whether it is incomplete. Arguments: source -- the source string; may contain \n characters filename -- optional filename from which source was read; default "<input>" symbol -- optional grammar start symbol; "single... |
if type(name) is not StringType: | if not isinstance(name, StringTypes): | def mkpath (name, mode=0777, verbose=0, dry_run=0): """Create a directory and any missing ancestor directories. If the directory already exists (or if 'name' is the empty string, which means the current directory, which of course exists), then do nothing. Raise DistutilsFileError if unable to create some directory al... |
if nodelist[2] != ':': | if len(nodelist) == 1 or nodelist[1] != ':': | def com_dictsetmaker(self, nodelist): # dictsetmaker: (test ':' test (',' test ':' value)* [',']) | (test (',' test)* [',']) items = [] if nodelist[2] != ':': # it's a set for i in range(1, len(nodelist), 2): items.append(self.com_node(nodelist[i])) return Set(items, lineno=items[0].lineno) else: # it's a dict for i in... |
self.atcr = False | def __init__(self, stream, errors='strict'): | |
if self.atcr and data.startswith(u"\n"): data = data[1:] | def readline(self, size=None, keepends=True): | |
self.atcr = data.endswith(u"\r") if self.atcr and size is None: | if data.endswith(u"\r"): | def readline(self, size=None, keepends=True): |
self.atcr = data.endswith(u"\r") | def readline(self, size=None, keepends=True): | |
self.atcr = False | def reset(self): | |
negative_opts = {'use-defaults': 'no-defaults'} | negative_opt = {'no-defaults': 'use-defaults', 'no-prune': 'prune' } | def show_formats (): """Print all possible values for the 'formats' option (used by the "--help-formats" command-line option). """ from distutils.fancy_getopt import FancyGetopt from distutils.archive_util import ARCHIVE_FORMATS formats=[] for format in ARCHIVE_FORMATS.keys(): formats.append(("formats=" + format, None,... |
self.prune_file_list() | if self.prune: self.prune_file_list() | def get_file_list (self): """Figure out the list of files to include in the source distribution, and put it in 'self.files'. This might involve reading the manifest template (and writing the manifest), or just reading the manifest, or just using the default file set -- it all depends on the user's options and the stat... |
by 'read_template()', but really don't belong there: specifically, the build tree (typically "build") and the release tree itself (only an issue if we ran "sdist" previously with --keep-tree, or it aborted). | 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-tree, or it aborted) * any RCS or CVS directories | 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: specifically, the build tree (typically "build") and the release tree itself (only an issue if we ran "sdist" previously with --keep-tree, or it aborted). """ build = self... |
def select_pattern (self, files, pattern, anchor=1, prefix=None): | self.exclude_pattern (self.files, r'/(RCS|CVS)/.*', is_regex=1) def select_pattern (self, files, pattern, anchor=1, prefix=None, is_regex=0): | 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: specifically, the build tree (typically "build") and the release tree itself (only an issue if we ran "sdist" previously with --keep-tree, or it aborted). """ build = self... |
pattern_re = translate_pattern (pattern, anchor, prefix) | pattern_re = translate_pattern (pattern, anchor, prefix, is_regex) | def select_pattern (self, files, pattern, anchor=1, prefix=None): """Select strings (presumably filenames) from 'files' that match 'pattern', a Unix-style wildcard (glob) pattern. Patterns are not quite the same as implemented by the 'fnmatch' module: '*' and '?' match non-special characters, where "special" is platfo... |
def exclude_pattern (self, files, pattern, anchor=1, prefix=None): | def exclude_pattern (self, files, pattern, anchor=1, prefix=None, is_regex=0): | def exclude_pattern (self, files, pattern, anchor=1, prefix=None): """Remove strings (presumably filenames) from 'files' that match 'pattern'. 'pattern', 'anchor', 'and 'prefix' are the same as for 'select_pattern()', above. The list 'files' is modified in place. """ pattern_re = translate_pattern (pattern, anchor, p... |
'pattern'. 'pattern', 'anchor', 'and 'prefix' are the same as for 'select_pattern()', above. The list 'files' is modified in place. """ pattern_re = translate_pattern (pattern, anchor, prefix) | 'pattern'. Other parameters are the same as for 'select_pattern()', above. The list 'files' is modified in place. """ pattern_re = translate_pattern (pattern, anchor, prefix, is_regex) | def exclude_pattern (self, files, pattern, anchor=1, prefix=None): """Remove strings (presumably filenames) from 'files' that match 'pattern'. 'pattern', 'anchor', 'and 'prefix' are the same as for 'select_pattern()', above. The list 'files' is modified in place. """ pattern_re = translate_pattern (pattern, anchor, p... |
list.append (fullname) if os.path.isdir (fullname) and not os.path.islink(fullname): | stat = os.stat(fullname) mode = stat[ST_MODE] if S_ISREG(mode): list.append (fullname) elif S_ISDIR(mode) and not S_ISLNK(mode): | def findall (dir = os.curdir): """Find all files under 'dir' and return the list of full filenames (relative to 'dir'). """ list = [] stack = [dir] pop = stack.pop push = stack.append while stack: dir = pop() names = os.listdir (dir) for name in names: if dir != os.curdir: # avoid the dreaded "./" syndrome ful... |
while f and f is not self.botframe: | while f is not None: | def setup(self, f, t): self.lineno = None self.stack = [] if t and t.tb_frame is f: t = t.tb_next while f and f is not self.botframe: self.stack.append((f, f.f_lineno)) f = f.f_back self.stack.reverse() self.curindex = max(0, len(self.stack) - 1) while t: self.stack.append((t.tb_frame, t.tb_lineno)) t = t.tb_next if 0 ... |
while t: | while t is not None: | def setup(self, f, t): self.lineno = None self.stack = [] if t and t.tb_frame is f: t = t.tb_next while f and f is not self.botframe: self.stack.append((f, f.f_lineno)) f = f.f_back self.stack.reverse() self.curindex = max(0, len(self.stack) - 1) while t: self.stack.append((t.tb_frame, t.tb_lineno)) t = t.tb_next if 0 ... |
if 0 <= self.curindex < len(self.stack): self.curframe = self.stack[self.curindex][0] else: self.curframe = None | self.curframe = self.stack[self.curindex][0] | def setup(self, f, t): self.lineno = None self.stack = [] if t and t.tb_frame is f: t = t.tb_next while f and f is not self.botframe: self.stack.append((f, f.f_lineno)) f = f.f_back self.stack.reverse() self.curindex = max(0, len(self.stack) - 1) while t: self.stack.append((t.tb_frame, t.tb_lineno)) t = t.tb_next if 0 ... |
pass | return | def runctx(self, cmd, globals, locals): self.reset() sys.trace = self.dispatch try: exec(cmd + '\n', globals, locals) except PdbQuit: pass except: print '***', sys.exc_type + ':', `sys.exc_value` print '*** Post Mortem Debugging:' sys.trace = None del sys.trace try: self.ask_user(None, sys.exc_traceback) except PdbQuit... |
print '*** Post Mortem Debugging:' sys.trace = None del sys.trace try: self.ask_user(None, sys.exc_traceback) except PdbQuit: pass | t = sys.exc_traceback | def runctx(self, cmd, globals, locals): self.reset() sys.trace = self.dispatch try: exec(cmd + '\n', globals, locals) except PdbQuit: pass except: print '***', sys.exc_type + ':', `sys.exc_value` print '*** Post Mortem Debugging:' sys.trace = None del sys.trace try: self.ask_user(None, sys.exc_traceback) except PdbQuit... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.