rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
if self.returncode == None: | if self.returncode is None: | def wait(self): """Wait for child process to terminate. Returns returncode attribute.""" if self.returncode == None: obj = WaitForSingleObject(self._handle, INFINITE) self.returncode = GetExitCodeProcess(self._handle) _active.remove(self) return self.returncode |
if input != None: | if input is not None: | def communicate(self, input=None): """Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to terminate. The optional input argument should be a string to be sent to the child process, or None, if no data should be sent to the child. |
if stdout != None: | if stdout is not None: | def communicate(self, input=None): """Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to terminate. The optional input argument should be a string to be sent to the child process, or None, if no data should be sent to the child. |
if stderr != None: | if stderr is not None: | def communicate(self, input=None): """Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to terminate. The optional input argument should be a string to be sent to the child process, or None, if no data should be sent to the child. |
if stdin == None: | if stdin is None: | def _get_handles(self, stdin, stdout, stderr): """Construct and return tupel with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ p2cread, p2cwrite = None, None c2pread, c2pwrite = None, None errread, errwrite = None, None |
elif type(stdin) == int: | elif isinstance(stdin, int): | def _get_handles(self, stdin, stdout, stderr): """Construct and return tupel with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ p2cread, p2cwrite = None, None c2pread, c2pwrite = None, None errread, errwrite = None, None |
if stdout == None: | if stdout is None: | def _get_handles(self, stdin, stdout, stderr): """Construct and return tupel with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ p2cread, p2cwrite = None, None c2pread, c2pwrite = None, None errread, errwrite = None, None |
elif type(stdout) == int: | elif isinstance(stdout, int): | def _get_handles(self, stdin, stdout, stderr): """Construct and return tupel with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ p2cread, p2cwrite = None, None c2pread, c2pwrite = None, None errread, errwrite = None, None |
if stderr == None: | if stderr is None: | def _get_handles(self, stdin, stdout, stderr): """Construct and return tupel with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ p2cread, p2cwrite = None, None c2pread, c2pwrite = None, None errread, errwrite = None, None |
elif type(stderr) == int: | elif isinstance(stderr, int): | def _get_handles(self, stdin, stdout, stderr): """Construct and return tupel with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ p2cread, p2cwrite = None, None c2pread, c2pwrite = None, None errread, errwrite = None, None |
if executable == None: | if executable is None: | 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 (POSIX version)""" |
if cwd != None: | if cwd is not None: | 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 (POSIX version)""" |
if env == None: | if env is None: | 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 (POSIX version)""" |
if self.returncode == None: | if self.returncode is None: | def poll(self): """Check if child process has terminated. Returns returncode attribute.""" if self.returncode == None: try: pid, sts = os.waitpid(self.pid, os.WNOHANG) if pid == self.pid: self._handle_exitstatus(sts) except os.error: pass return self.returncode |
if self.returncode == None: | if self.returncode is None: | def wait(self): """Wait for child process to terminate. Returns returncode attribute.""" if self.returncode == None: pid, sts = os.waitpid(self.pid, 0) self._handle_exitstatus(sts) return self.returncode |
while True: | while self.pos < len(self.field): | def getaddrlist(self): """Parse all addresses. |
break | result.append(('', '')) | def getaddrlist(self): """Parse all addresses. |
exts.append( Extension('gestalt', ['gestaltmodule.c']) ) | exts.append( Extension('gestalt', ['gestaltmodule.c'], extra_link_args=['-framework', 'Carbon']) ) | def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') |
exts.append( Extension('_CF', ['cf/_CFmodule.c']) ) exts.append( Extension('_Res', ['res/_Resmodule.c']) ) | exts.append( Extension('_CF', ['cf/_CFmodule.c'], extra_link_args=['-framework', 'CoreFoundation']) ) exts.append( Extension('_Res', ['res/_Resmodule.c'], extra_link_args=['-framework', 'Carbon']) ) | def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') |
print time.strftime(LAST_CHANGED, time.localtime(now)) | print time.strftime(LAST_CHANGED, time.localtime(latest)) | def last_changed(self, files): |
code, modname = compilesuite(suite, major, minor, language, script, fname, basepackage) if modname: suitelist.append((code, modname)) | code, suite, fss, modname, precompinfo = precompilesuite(suite, basepackage) if not code: continue allprecompinfo = allprecompinfo + precompinfo suiteinfo = suite, fss, modname suitelist.append((code, modname)) allsuites.append(suiteinfo) for suiteinfo in allsuites: compilesuite(suiteinfo, major, minor, language, scrip... | def compileaete(aete, resinfo, fname): """Generate code for a full aete resource. fname passed for doc purposes""" [version, language, script, suites] = aete major, minor = divmod(version, 256) fss = macfs.FSSpec(fname) creatorsignature, dummy = fss.GetCreatorType() packagename = identify(os.path.basename(fname)) if la... |
fp.write("\t'%s' : '%s.%s',\n"%(code, packagename, modname)) | fp.write("\t'%s' : ('%s.%s', '%s'),\n"%(code, packagename, modname, modname)) | def compileaete(aete, resinfo, fname): """Generate code for a full aete resource. fname passed for doc purposes""" [version, language, script, suites] = aete major, minor = divmod(version, 256) fss = macfs.FSSpec(fname) creatorsignature, dummy = fss.GetCreatorType() packagename = identify(os.path.basename(fname)) if la... |
fp.write(",\n\t%s_Events"%modname) fp.write(",\n\taetools.TalkTo):\n") | fp.write(",\n\t\t%s_Events"%modname) fp.write(",\n\t\taetools.TalkTo):\n") | def compileaete(aete, resinfo, fname): """Generate code for a full aete resource. fname passed for doc purposes""" [version, language, script, suites] = aete major, minor = divmod(version, 256) fss = macfs.FSSpec(fname) creatorsignature, dummy = fss.GetCreatorType() packagename = identify(os.path.basename(fname)) if la... |
def compilesuite(suite, major, minor, language, script, fname, basepackage=None): """Generate code for a single suite""" | def precompilesuite(suite, basepackage=None): """Parse a single suite without generating the output. This step is needed so we can resolve recursive references by suites to enums/comps/etc declared in other suites""" | def compileaete(aete, resinfo, fname): """Generate code for a full aete resource. fname passed for doc purposes""" [version, language, script, suites] = aete major, minor = divmod(version, 256) fss = macfs.FSSpec(fname) creatorsignature, dummy = fss.GetCreatorType() packagename = identify(os.path.basename(fname)) if la... |
return None, None | return None, None, None, None, None | def compilesuite(suite, major, minor, language, script, fname, basepackage=None): """Generate code for a single suite""" [name, desc, code, level, version, events, classes, comps, enums] = suite modname = identify(name) if len(modname) > 28: modname = modname[:27] fss, ok = macfs.StandardPutFile('Python output file', ... |
fp = open(fss.as_pathname(), 'w') fss.SetCreatorType('Pyth', 'TEXT') fp.write('"""Suite %s: %s\n' % (name, desc)) fp.write("Level %d, version %d\n\n" % (level, version)) fp.write("Generated from %s\n"%fname) fp.write("AETE/AEUT resource version %d/%d, language %d, script %d\n" % \ (major, minor, language, script)) fp.... | def compilesuite(suite, major, minor, language, script, fname, basepackage=None): """Generate code for a single suite""" [name, desc, code, level, version, events, classes, comps, enums] = suite modname = identify(name) if len(modname) > 28: modname = modname[:27] fss, ok = macfs.StandardPutFile('Python output file', ... | |
fp.write('from %s import *\n'%basepackage._code_to_fullname[code]) | def compilesuite(suite, major, minor, language, script, fname, basepackage=None): """Generate code for a single suite""" [name, desc, code, level, version, events, classes, comps, enums] = suite modname = identify(name) if len(modname) > 28: modname = modname[:27] fss, ok = macfs.StandardPutFile('Python output file', ... | |
compileclassheader(fp, modname, basemodule) | def compilesuite(suite, major, minor, language, script, fname, basepackage=None): """Generate code for a single suite""" [name, desc, code, level, version, events, classes, comps, enums] = suite modname = identify(name) if len(modname) > 28: modname = modname[:27] fss, ok = macfs.StandardPutFile('Python output file', ... | |
if events: for event in events: compileevent(fp, event, enumsneeded) else: fp.write("\tpass\n\n") objc = ObjectCompiler(fp, basemodule) | for event in events: findenumsinevent(event, enumsneeded) objc = ObjectCompiler(None, basemodule) | def compilesuite(suite, major, minor, language, script, fname, basepackage=None): """Generate code for a single suite""" [name, desc, code, level, version, events, classes, comps, enums] = suite modname = identify(name) if len(modname) > 28: modname = modname[:27] fss, ok = macfs.StandardPutFile('Python output file', ... |
if module and hasattr(module, classname): fp.write("class %s(%s):\n\n"%(classname, classname)) | if module: modshortname = string.split(module.__name__, '.')[-1] baseclassname = '%s_Events'%modshortname fp.write("class %s(%s):\n\n"%(classname, baseclassname)) | def compileclassheader(fp, name, module=None): """Generate class boilerplate""" classname = '%s_Events'%name if module and hasattr(module, classname): fp.write("class %s(%s):\n\n"%(classname, classname)) else: fp.write("class %s:\n\n"%classname) |
def __init__(self, fp, basesuite=None): | def __init__(self, fp, basesuite=None, othernamemappers=None): | def __init__(self, fp, basesuite=None): self.fp = fp self.propnames = {} self.classnames = {} self.propcodes = {} self.classcodes = {} self.compcodes = {} self.enumcodes = {} self.othersuites = [] self.basesuite = basesuite |
self.propnames = {} self.classnames = {} self.propcodes = {} self.classcodes = {} self.compcodes = {} self.enumcodes = {} self.othersuites = [] | def __init__(self, fp, basesuite=None): self.fp = fp self.propnames = {} self.classnames = {} self.propcodes = {} self.classcodes = {} self.compcodes = {} self.enumcodes = {} self.othersuites = [] self.basesuite = basesuite | |
if type == 'property': if self.propcodes.has_key(code): return self.propcodes[code], self.propcodes[code], None if self.basesuite and self.basesuite._propdeclarations.has_key(code): name = self.basesuite._propdeclarations[code].__name__ return name, name, None for s in self.othersuites: if s._propdeclarations.has_k... | for mapper in self.namemappers: if mapper.hascode(type, code): return mapper.findcodename(type, code) for mapper in self.othernamemappers: if mapper.hascode(type, code): self.othernamemappers.remove(mapper) self.namemappers.append(mapper) if self.fp: self.fp.write("import %s\n"%mapper.modulename) break else: if self... | def findcodename(self, type, code): while 1: if type == 'property': # First we check whether we ourselves have defined it if self.propcodes.has_key(code): return self.propcodes[code], self.propcodes[code], None # Next we check whether our base suite module has defined it if self.basesuite and self.basesuite._propdeclar... |
if self.classcodes.has_key(code): | if self.namemappers[0].hascode('class', code): | def compileclass(self, cls): [name, code, desc, properties, elements] = cls pname = identify(name) if self.classcodes.has_key(code): # plural forms and such self.fp.write("\n%s = %s\n"%(pname, self.classcodes[code])) self.classnames[pname] = code else: self.fp.write('\nclass %s(aetools.ComponentItem):\n' % pname) self.... |
self.fp.write("\n%s = %s\n"%(pname, self.classcodes[code])) self.classnames[pname] = code | othername, dummy, dummy = self.namemappers[0].findcodename('class', code) if self.fp: self.fp.write("\n%s = %s\n"%(pname, othername)) | def compileclass(self, cls): [name, code, desc, properties, elements] = cls pname = identify(name) if self.classcodes.has_key(code): # plural forms and such self.fp.write("\n%s = %s\n"%(pname, self.classcodes[code])) self.classnames[pname] = code else: self.fp.write('\nclass %s(aetools.ComponentItem):\n' % pname) self.... |
self.fp.write('\nclass %s(aetools.ComponentItem):\n' % pname) self.fp.write('\t"""%s - %s """\n' % (name, desc)) self.fp.write('\twant = %s\n' % `code`) self.classnames[pname] = code self.classcodes[code] = pname | if self.fp: self.fp.write('\nclass %s(aetools.ComponentItem):\n' % pname) self.fp.write('\t"""%s - %s """\n' % (name, desc)) self.fp.write('\twant = %s\n' % `code`) self.namemappers[0].addnamecode('class', pname, code) | def compileclass(self, cls): [name, code, desc, properties, elements] = cls pname = identify(name) if self.classcodes.has_key(code): # plural forms and such self.fp.write("\n%s = %s\n"%(pname, self.classcodes[code])) self.classnames[pname] = code else: self.fp.write('\nclass %s(aetools.ComponentItem):\n' % pname) self.... |
if self.propcodes.has_key(code): self.fp.write(" | if self.namemappers[0].hascode('property', code): if self.fp: self.fp.write(" | def compileproperty(self, prop): [name, code, what] = prop if code == 'c@#!': # Something silly with plurals. Skip it. return pname = identify(name) if self.propcodes.has_key(code): self.fp.write("# repeated property %s %s\n"%(pname, what[1])) else: self.fp.write("class %s(aetools.NProperty):\n" % pname) self.fp.write(... |
self.fp.write("class %s(aetools.NProperty):\n" % pname) self.fp.write('\t"""%s - %s """\n' % (name, what[1])) self.fp.write("\twhich = %s\n" % `code`) self.fp.write("\twant = %s\n" % `what[0]`) self.propnames[pname] = code self.propcodes[code] = pname | if self.fp: self.fp.write("class %s(aetools.NProperty):\n" % pname) self.fp.write('\t"""%s - %s """\n' % (name, what[1])) self.fp.write("\twhich = %s\n" % `code`) self.fp.write("\twant = %s\n" % `what[0]`) self.namemappers[0].addnamecode('property', pname, code) | def compileproperty(self, prop): [name, code, what] = prop if code == 'c@#!': # Something silly with plurals. Skip it. return pname = identify(name) if self.propcodes.has_key(code): self.fp.write("# repeated property %s %s\n"%(pname, what[1])) else: self.fp.write("class %s(aetools.NProperty):\n" % pname) self.fp.write(... |
self.fp.write(" | if self.fp: self.fp.write(" | def compileelement(self, elem): [code, keyform] = elem self.fp.write("# element %s as %s\n" % (`code`, keyform)) |
if self.classcodes[code] != cname: | if self.namemappers[0].hascode('class', code) and \ self.namemappers[0].findcodename('class', code)[0] != cname: | def fillclasspropsandelems(self, cls): [name, code, desc, properties, elements] = cls cname = identify(name) if self.classcodes[code] != cname: # This is an other name (plural or so) for something else. Skip. return plist = [] elist = [] for prop in properties: [pname, pcode, what] = prop if pcode == 'c@#!': continue p... |
self.fp.write(" | if self.fp: self.fp.write(" | def fillclasspropsandelems(self, cls): [name, code, desc, properties, elements] = cls cname = identify(name) if self.classcodes[code] != cname: # This is an other name (plural or so) for something else. Skip. return plist = [] elist = [] for prop in properties: [pname, pcode, what] = prop if pcode == 'c@#!': continue p... |
self.fp.write("%s._propdict = {\n"%cname) for n in plist: self.fp.write("\t'%s' : %s,\n"%(n, n)) self.fp.write("}\n") self.fp.write("%s._elemdict = {\n"%cname) for n, fulln in elist: self.fp.write("\t'%s' : %s,\n"%(n, fulln)) self.fp.write("}\n") | if self.fp: self.fp.write("%s._propdict = {\n"%cname) for n in plist: self.fp.write("\t'%s' : %s,\n"%(n, n)) self.fp.write("}\n") self.fp.write("%s._elemdict = {\n"%cname) for n, fulln in elist: self.fp.write("\t'%s' : %s,\n"%(n, fulln)) self.fp.write("}\n") | def fillclasspropsandelems(self, cls): [name, code, desc, properties, elements] = cls cname = identify(name) if self.classcodes[code] != cname: # This is an other name (plural or so) for something else. Skip. return plist = [] elist = [] for prop in properties: [pname, pcode, what] = prop if pcode == 'c@#!': continue p... |
self.compcodes[code] = iname self.fp.write("class %s(aetools.NComparison):\n" % iname) self.fp.write('\t"""%s - %s """\n' % (name, comment)) | self.namemappers[0].addnamecode('comparison', iname, code) if self.fp: self.fp.write("class %s(aetools.NComparison):\n" % iname) self.fp.write('\t"""%s - %s """\n' % (name, comment)) | def compilecomparison(self, comp): [name, code, comment] = comp iname = identify(name) self.compcodes[code] = iname self.fp.write("class %s(aetools.NComparison):\n" % iname) self.fp.write('\t"""%s - %s """\n' % (name, comment)) |
self.fp.write("%s = {\n" % name) for item in items: self.compileenumerator(item) self.fp.write("}\n\n") self.enumcodes[code] = name | if self.fp: self.fp.write("%s = {\n" % name) for item in items: self.compileenumerator(item) self.fp.write("}\n\n") self.namemappers[0].addnamecode('enum', name, code) | def compileenumeration(self, enum): [code, items] = enum name = "_Enum_%s" % identify(code) self.fp.write("%s = {\n" % name) for item in items: self.compileenumerator(item) self.fp.write("}\n\n") self.enumcodes[code] = name return code |
self.fp.write(" | if self.fp: self.fp.write(" | def checkforenum(self, enum): """This enum code is used by an event. Make sure it's available""" name, fullname, module = self.findcodename('enum', enum) if not name: self.fp.write("# XXXX enum %s not found!!\n"%(enum)) return if module: self.fp.write("from %s import %s\n"%(module, name)) |
self.fp.write("from %s import %s\n"%(module, name)) | if self.fp: self.fp.write("from %s import %s\n"%(module, name)) | def checkforenum(self, enum): """This enum code is used by an event. Make sure it's available""" name, fullname, module = self.findcodename('enum', enum) if not name: self.fp.write("# XXXX enum %s not found!!\n"%(enum)) return if module: self.fp.write("from %s import %s\n"%(module, name)) |
for k in self.classcodes.keys(): self.fp.write("\t%s : %s,\n" % (`k`, self.classcodes[k])) | for k, v in self.namemappers[0].getall('class'): self.fp.write("\t%s : %s,\n" % (`k`, v)) | def dumpindex(self): self.fp.write("\n#\n# Indices of types declared in this module\n#\n") self.fp.write("_classdeclarations = {\n") for k in self.classcodes.keys(): self.fp.write("\t%s : %s,\n" % (`k`, self.classcodes[k])) self.fp.write("}\n") self.fp.write("\n_propdeclarations = {\n") for k in self.propcodes.keys(): ... |
for k in self.propcodes.keys(): self.fp.write("\t%s : %s,\n" % (`k`, self.propcodes[k])) | for k, v in self.namemappers[0].getall('property'): self.fp.write("\t%s : %s,\n" % (`k`, v)) | def dumpindex(self): self.fp.write("\n#\n# Indices of types declared in this module\n#\n") self.fp.write("_classdeclarations = {\n") for k in self.classcodes.keys(): self.fp.write("\t%s : %s,\n" % (`k`, self.classcodes[k])) self.fp.write("}\n") self.fp.write("\n_propdeclarations = {\n") for k in self.propcodes.keys(): ... |
for k in self.compcodes.keys(): self.fp.write("\t%s : %s,\n" % (`k`, self.compcodes[k])) | for k, v in self.namemappers[0].getall('comparison'): self.fp.write("\t%s : %s,\n" % (`k`, v)) | def dumpindex(self): self.fp.write("\n#\n# Indices of types declared in this module\n#\n") self.fp.write("_classdeclarations = {\n") for k in self.classcodes.keys(): self.fp.write("\t%s : %s,\n" % (`k`, self.classcodes[k])) self.fp.write("}\n") self.fp.write("\n_propdeclarations = {\n") for k in self.propcodes.keys(): ... |
for k in self.enumcodes.keys(): self.fp.write("\t%s : %s,\n" % (`k`, self.enumcodes[k])) | for k, v in self.namemappers[0].getall('enum'): self.fp.write("\t%s : %s,\n" % (`k`, v)) | def dumpindex(self): self.fp.write("\n#\n# Indices of types declared in this module\n#\n") self.fp.write("_classdeclarations = {\n") for k in self.classcodes.keys(): self.fp.write("\t%s : %s,\n" % (`k`, self.classcodes[k])) self.fp.write("}\n") self.fp.write("\n_propdeclarations = {\n") for k in self.propcodes.keys(): ... |
if not self.filename and self.get_saved(): | try: interp = self.editwin.interp except: interp = None if not self.filename and self.get_saved() and not interp: | def open(self, event=None, editFile=None): if self.editwin.flist: if not editFile: filename = self.askopenfile() else: filename=editFile if filename: # if the current window has no filename and hasn't been # modified, we replace it's contents (no loss). Otherwise # we open a new window. if not self.filename and se... |
ctype = string.lower(info['content-type']) | ctype = string.lower(cgi.parse_header(info['content-type'])[0]) | def checkforhtml(self, info, url): if info.has_key('content-type'): ctype = string.lower(info['content-type']) else: if url[-1:] == "/": return 1 ctype, encoding = mimetypes.guess_type(url) if ctype == 'text/html': return 1 else: self.note(1, " Not HTML, mime type %s", ctype) return 0 |
print 'builtin theme' | def LoadThemeCfg(self): ##current theme type radiobutton self.themeIsBuiltin.set(idleConf.GetOption('main','Theme','default', type='bool',default=1)) ##currently set theme currentOption=idleConf.CurrentTheme() print 'current option',currentOption ##load available theme option menus if self.themeIsBuiltin.get(): #defaul... | |
print 'builtin items:',itemList | def LoadThemeCfg(self): ##current theme type radiobutton self.themeIsBuiltin.set(idleConf.GetOption('main','Theme','default', type='bool',default=1)) ##currently set theme currentOption=idleConf.CurrentTheme() print 'current option',currentOption ##load available theme option menus if self.themeIsBuiltin.get(): #defaul... | |
print 'user items:',itemList | def LoadThemeCfg(self): ##current theme type radiobutton self.themeIsBuiltin.set(idleConf.GetOption('main','Theme','default', type='bool',default=1)) ##currently set theme currentOption=idleConf.CurrentTheme() print 'current option',currentOption ##load available theme option menus if self.themeIsBuiltin.get(): #defaul... | |
print 'user theme' | def LoadThemeCfg(self): ##current theme type radiobutton self.themeIsBuiltin.set(idleConf.GetOption('main','Theme','default', type='bool',default=1)) ##currently set theme currentOption=idleConf.CurrentTheme() print 'current option',currentOption ##load available theme option menus if self.themeIsBuiltin.get(): #defaul... | |
file = unquote(file) | def open_local_file(self, url): import mimetypes, mimetools, StringIO mtype = mimetypes.guess_type(url)[0] headers = mimetools.Message(StringIO.StringIO( 'Content-Type: %s\n' % (mtype or 'text/plain'))) host, file = splithost(url) if not host: return addinfourl( open(url2pathname(file), 'rb'), headers, 'file:'+file) ho... | |
self.user = unquote(user or '') self.passwd = unquote(passwd or '') | self.user = user self.passwd = passwd | def __init__(self, user, passwd, host, port, dirs): self.user = unquote(user or '') self.passwd = unquote(passwd or '') self.host = host self.port = port self.dirs = [] for dir in dirs: self.dirs.append(unquote(dir)) self.init() |
self.dirs = [] for dir in dirs: self.dirs.append(unquote(dir)) | self.dirs = dirs | def __init__(self, user, passwd, host, port, dirs): self.user = unquote(user or '') self.passwd = unquote(passwd or '') self.host = host self.port = port self.dirs = [] for dir in dirs: self.dirs.append(unquote(dir)) self.init() |
install.select_scheme ('nt') for key in ('purelib', 'platlib', 'headers', 'scripts', 'data'): attrname = 'install_' + key attr = getattr (install, attrname) if attr: attr = string.replace (attr, '\\', os.sep) setattr (install, attrname, attr) | install.prefix = "Python" install.select_scheme('nt') | def run (self): if (sys.platform != "win32" and (self.distribution.has_ext_modules() or self.distribution.has_c_libraries())): raise DistutilsPlatformError \ ("distribution contains extensions and/or C libraries; " "must be compiled on a Windows 32 platform") |
def unix_getpass(prompt='Password: '): | def unix_getpass(prompt='Password: ', stream=None): | def unix_getpass(prompt='Password: '): """Prompt for a password, with echo turned off. Restore terminal settings at end. """ try: fd = sys.stdin.fileno() except: return default_getpass(prompt) old = termios.tcgetattr(fd) # a copy to save new = old[:] new[3] = new[3] & ~termios.ECHO # 3 == 'lflags' try: termios.... |
passwd = _raw_input(prompt) | passwd = _raw_input(prompt, stream) | def unix_getpass(prompt='Password: '): """Prompt for a password, with echo turned off. Restore terminal settings at end. """ try: fd = sys.stdin.fileno() except: return default_getpass(prompt) old = termios.tcgetattr(fd) # a copy to save new = old[:] new[3] = new[3] & ~termios.ECHO # 3 == 'lflags' try: termios.... |
sys.stdout.write('\n') | stream.write('\n') | def unix_getpass(prompt='Password: '): """Prompt for a password, with echo turned off. Restore terminal settings at end. """ try: fd = sys.stdin.fileno() except: return default_getpass(prompt) old = termios.tcgetattr(fd) # a copy to save new = old[:] new[3] = new[3] & ~termios.ECHO # 3 == 'lflags' try: termios.... |
def win_getpass(prompt='Password: '): | def win_getpass(prompt='Password: ', stream=None): | def win_getpass(prompt='Password: '): """Prompt for password with echo off, using Windows getch().""" if sys.stdin is not sys.__stdin__: return default_getpass(prompt) import msvcrt for c in prompt: msvcrt.putch(c) pw = "" while 1: c = msvcrt.getch() if c == '\r' or c == '\n': break if c == '\003': raise KeyboardInterr... |
return default_getpass(prompt) | return default_getpass(prompt, stream) | def win_getpass(prompt='Password: '): """Prompt for password with echo off, using Windows getch().""" if sys.stdin is not sys.__stdin__: return default_getpass(prompt) import msvcrt for c in prompt: msvcrt.putch(c) pw = "" while 1: c = msvcrt.getch() if c == '\r' or c == '\n': break if c == '\003': raise KeyboardInterr... |
def default_getpass(prompt='Password: '): print "Warning: Problem with getpass. Passwords may be echoed." return _raw_input(prompt) | def default_getpass(prompt='Password: ', stream=None): print >>sys.stderr, "Warning: Problem with getpass. Passwords may be echoed." return _raw_input(prompt, stream) | def default_getpass(prompt='Password: '): print "Warning: Problem with getpass. Passwords may be echoed." return _raw_input(prompt) |
def _raw_input(prompt=""): | def _raw_input(prompt="", stream=None): | def _raw_input(prompt=""): # A raw_input() replacement that doesn't save the string in the # GNU readline history. prompt = str(prompt) if prompt: sys.stdout.write(prompt) line = sys.stdin.readline() if not line: raise EOFError if line[-1] == '\n': line = line[:-1] return line |
sys.stdout.write(prompt) | stream.write(prompt) | def _raw_input(prompt=""): # A raw_input() replacement that doesn't save the string in the # GNU readline history. prompt = str(prompt) if prompt: sys.stdout.write(prompt) line = sys.stdin.readline() if not line: raise EOFError if line[-1] == '\n': line = line[:-1] return line |
replacement repl""" | replacement repl. repl can be either a string or a callable; if a callable, it's passed the match object and must return a replacement string to be used.""" | def sub(pattern, repl, string, count=0): """Return the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in string by the replacement repl""" return _compile(pattern, 0).sub(repl, string, count) |
substitutions that were made.""" | substitutions that were made. repl can be either a string or a callable; if a callable, it's passed the match object and must return a replacement string to be used.""" | def subn(pattern, repl, string, count=0): """Return a 2-tuple containing (new_string, number). new_string is the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in the source string by the replacement repl. number is the number of substitutions that were made.""" return _compile(pa... |
cre = re.compile(r'def\s+%s\s*[(]' % funcname) | cre = re.compile(r'def\s+%s\s*[(]' % re.escape(funcname)) | def find_function(funcname, filename): cre = re.compile(r'def\s+%s\s*[(]' % funcname) try: fp = open(filename) except IOError: return None # consumer of this info expects the first line to be 1 lineno = 1 answer = None while 1: line = fp.readline() if line == '': break if cre.match(line): answer = funcname, filename, l... |
p = _cache.get(key) | cachekey = (type(key[0]),) + key p = _cache.get(cachekey) | def _compile(*key): # internal: compile pattern p = _cache.get(key) if p is not None: return p pattern, flags = key if isinstance(pattern, _pattern_type): return pattern if not sre_compile.isstring(pattern): raise TypeError, "first argument must be string or compiled pattern" try: p = sre_compile.compile(pattern, flags... |
_cache[key] = p | _cache[cachekey] = p | def _compile(*key): # internal: compile pattern p = _cache.get(key) if p is not None: return p pattern, flags = key if isinstance(pattern, _pattern_type): return pattern if not sre_compile.isstring(pattern): raise TypeError, "first argument must be string or compiled pattern" try: p = sre_compile.compile(pattern, flags... |
return self.try_cpp(headers=[header], include_dirs=include_dirs) | return self.try_cpp(body="/* No body */", headers=[header], include_dirs=include_dirs) | def check_header (self, header, include_dirs=None, library_dirs=None, lang="c"): """Determine if the system header file named by 'header_file' exists and can be found by the preprocessor; return true if so, false otherwise. """ return self.try_cpp(headers=[header], include_dirs=include_dirs) |
str = '<?xml version="1.0" ?>\n<a b="c"/>' | str = '<?xml version="1.0" ?><a b="c"/>' | def testWriteXML(): str = '<?xml version="1.0" ?>\n<a b="c"/>' dom = parseString(str) domstr = dom.toxml() dom.unlink() confirm(str == domstr) |
confirm(doc.toxml() == u'<?xml version="1.0" ?>\n<foo>\u20ac</foo>' and doc.toxml('utf-8') == '<?xml version="1.0" encoding="utf-8"?>\n<foo>\xe2\x82\xac</foo>' and doc.toxml('iso-8859-15') == '<?xml version="1.0" encoding="iso-8859-15"?>\n<foo>\xa4</foo>', | confirm(doc.toxml() == u'<?xml version="1.0" ?><foo>\u20ac</foo>' and doc.toxml('utf-8') == '<?xml version="1.0" encoding="utf-8"?><foo>\xe2\x82\xac</foo>' and doc.toxml('iso-8859-15') == '<?xml version="1.0" encoding="iso-8859-15"?><foo>\xa4</foo>', | def testEncodings(): doc = parseString('<foo>€</foo>') confirm(doc.toxml() == u'<?xml version="1.0" ?>\n<foo>\u20ac</foo>' and doc.toxml('utf-8') == '<?xml version="1.0" encoding="utf-8"?>\n<foo>\xe2\x82\xac</foo>' and doc.toxml('iso-8859-15') == '<?xml version="1.0" encoding="iso-8859-15"?>\n<foo>\xa4</foo>', "... |
if 0: not sys.platform.startswith('win'): | if 0: | def test_basic(): test_support.requires('network') import urllib socket.RAND_status() try: socket.RAND_egd(1) except TypeError: pass else: print "didn't raise TypeError" socket.RAND_add("this is a random string", 75.0) f = urllib.urlopen('https://sf.net') buf = f.read() f.close() |
expand_tabs if true (default), tabs in input text will be expanded to spaces before further processing. Each tab will become 1 .. 8 spaces, depending on its position in its line. If false, each tab is treated as a single character. replace_whitespace if true (default), all whitespace characters in the input text are r... | expand_tabs (default: true) Expand tabs in input text to spaces before further processing. Each tab will become 1 .. 8 spaces, depending on its position in its line. If false, each tab is treated as a single character. replace_whitespace (default: true) Replace all whitespace characters in the input text by spaces aft... | def islower (c): return c in string.lowercase |
if (chunks[i][-1] == "." and | if (chunks[i][-1] in punct and | def _fix_sentence_endings (self, chunks): """_fix_sentence_endings(chunks : [string]) |
self._fix_sentence_endings(chunks) | if self.fix_sentence_endings: self._fix_sentence_endings(chunks) | def wrap (self, text, width): """wrap(text : string, width : int) -> [string] |
s.stdin = FileWrapper(sys.stdin) s.stdout = FileWrapper(sys.stdout) s.stderr = FileWrapper(sys.stderr) sys.stdin = FileDelegate(s, 'stdin') sys.stdout = FileDelegate(s, 'stdout') sys.stderr = FileDelegate(s, 'stderr') | s.stdin = self.restricted_stdin s.stdout = self.restricted_stdout s.stderr = self.restricted_stdout sys.stdin = self.delegate_stdin sys.stdout = self.delegate_stdout sys.stderr = self.delegate_stderr def reset_files(self): self.restore_files() s = self.modules['sys'] self.restricted_stdin = s.stdin self.restricted_std... | def set_files(self): s = self.modules['sys'] s.stdin = FileWrapper(sys.stdin) s.stdout = FileWrapper(sys.stdout) s.stderr = FileWrapper(sys.stderr) |
def restore_files(files): sys.stdin = self.save_sydin | def restore_files(self): sys.stdin = self.save_stdin | def restore_files(files): |
(ccshared,) = sysconfig.get_config_vars('CCSHARED') args['compiler_so'] = compiler + ' ' + ccshared | (ccshared,opt) = sysconfig.get_config_vars('CCSHARED','OPT') args['compiler_so'] = compiler + ' ' + opt + ' ' + ccshared | def build_extensions(self): |
self.chunksize = struct.unpack(strflag+'l', file.read(4))[0] | self.chunksize = struct.unpack(strflag+'L', file.read(4))[0] | def __init__(self, file, align=True, bigendian=True, inclheader=False): import struct self.closed = False self.align = align # whether to align to word (2-byte) boundaries if bigendian: strflag = '>' else: strflag = '<' self.file = file self.chunkname = file.read(4) if len(self.chunkname) < 4: raise EOFError try: ... |
pat = re.compile(r'^\s*class\s*' + name + r'\b') | pat = re.compile(r'^(\s*)class\s*' + name + r'\b') candidates = [] | def findsource(object): """Return the entire source file and starting line number for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of all the lines in the file and the line number indexes a line in that list. An IOError is r... |
if pat.match(lines[i]): return lines, i | match = pat.match(lines[i]) if match: if lines[i][0] == 'c': return lines, i candidates.append((match.group(1), i)) if candidates: candidates.sort() return lines, candidates[0][1] | def findsource(object): """Return the entire source file and starting line number for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of all the lines in the file and the line number indexes a line in that list. An IOError is r... |
copier = x.__deepcopy__ except AttributeError: | issc = issubclass(type(x), type) except TypeError: issc = 0 if issc: y = _deepcopy_dispatch[type](x, memo) else: | def deepcopy(x, memo = None): """Deep copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ if memo is None: memo = {} d = id(x) if d in memo: return memo[d] try: copierfunction = _deepcopy_dispatch[type(x)] except KeyError: try: copier = x.__deepcopy__ except AttributeError: ... |
reductor = x.__reduce__ | copier = x.__deepcopy__ | def deepcopy(x, memo = None): """Deep copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ if memo is None: memo = {} d = id(x) if d in memo: return memo[d] try: copierfunction = _deepcopy_dispatch[type(x)] except KeyError: try: copier = x.__deepcopy__ except AttributeError: ... |
raise error, \ "un-deep-copyable object of type %s" % type(x) | try: reductor = x.__reduce__ except AttributeError: raise error, \ "un-deep-copyable object of type %s" % type(x) else: y = _reconstruct(x, reductor(), 1, memo) | def deepcopy(x, memo = None): """Deep copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ if memo is None: memo = {} d = id(x) if d in memo: return memo[d] try: copierfunction = _deepcopy_dispatch[type(x)] except KeyError: try: copier = x.__deepcopy__ except AttributeError: ... |
y = _reconstruct(x, reductor(), 1, memo) else: y = copier(memo) | y = copier(memo) | def deepcopy(x, memo = None): """Deep copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ if memo is None: memo = {} d = id(x) if d in memo: return memo[d] try: copierfunction = _deepcopy_dispatch[type(x)] except KeyError: try: copier = x.__deepcopy__ except AttributeError: ... |
To understand what this class does, it helps to have a copy of RFC-822 in front of you. | To understand what this class does, it helps to have a copy of RFC 2822 in front of you. | def quote(str): """Add quotes around a string.""" return str.replace('\\', '\\\\').replace('"', '\\"') |
expectaddrspec = 1 | def getrouteaddr(self): """Parse a route address (Return-path value). | |
while self.pos < len(self.field): if self.field[self.pos] in self.atomends: | if atomends is None: atomends = self.atomends while self.pos < len(self.field): if self.field[self.pos] in atomends: | def getatom(self): """Parse an RFC-822 atom.""" atomlist = [''] |
elif self.field[self.pos] in self.atomends: break else: plist.append(self.getatom()) | elif self.field[self.pos] in self.phraseends: break else: plist.append(self.getatom(self.phraseends)) | def getphraselist(self): """Parse a sequence of RFC-822 phrases. |
def __init__(self, host, port = NNTP_PORT): | def __init__(self, host, port = NNTP_PORT, user=None, password=None): | def __init__(self, host, port = NNTP_PORT): self.host = host self.port = port self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.connect(self.host, self.port) self.file = self.sock.makefile('rb') self.debugging = 0 self.welcome = self.getresp() |
authorization = self.headers.getheader("authorization") if authorization: authorization = authorization.split() if len(authorization) == 2: import base64, binascii env['AUTH_TYPE'] = authorization[0] if authorization[0].lower() == "basic": try: authorization = base64.decodestring(authorization[1]) except binascii.Error... | def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scrip... | |
a_gusi = ResLoader(fss, 'GU\267I', OVERRIDE_GUSI_ID, default=gusi_loader) a_path = StrListLoader(fss, 'STR | a_gusi = GusiLoader( ResLoader(fss, 'GU\267I', OVERRIDE_GUSI_ID, default=gusi_loader)) a_path = StrListLoader( ResLoader(fss, 'STR | def AppletOptions(file): fss = macfs.FSSpec(file) a_popt = PoptLoader(ResLoader(fss, 'Popt', OVERRIDE_POPT_ID, default=popt_loader)) a_dir = ResLoader(fss, 'alis', OVERRIDE_DIR_ID, default=dir) a_gusi = ResLoader(fss, 'GU\267I', OVERRIDE_GUSI_ID, default=gusi_loader) a_path = StrListLoader(fss, 'STR#', OVERRIDE_PATH_ID... |
if msg[0] in (errno.EACCES, errno.ENODEV): | if msg[0] in (errno.EACCES, errno.ENODEV, errno.EBUSY): | def play_sound_file(path): fp = open(path, 'r') size, enc, rate, nchannels, extra = sunaudio.gethdr(fp) data = fp.read() fp.close() if enc != SND_FORMAT_MULAW_8: print "Expect .au file with 8-bit mu-law samples" return try: a = linuxaudiodev.open('w') except linuxaudiodev.error, msg: if msg[0] in (errno.EACCES, errno... |
if not hasattr(socket, "ssl"): raise test_support.TestSkipped("socket module has no ssl support") | def test_basic(): test_support.requires('network') if not hasattr(socket, "ssl"): raise test_support.TestSkipped("socket module has no ssl support") import urllib socket.RAND_status() try: socket.RAND_egd(1) except TypeError: pass else: print "didn't raise TypeError" socket.RAND_add("this is a random string", 75.0) ... | |
self.text.insert(mark, str(s), tags) | self.text.insert(mark, s, tags) | def write(self, s, tags=(), mark="iomark"): self.text.mark_gravity(mark, RIGHT) self.text.insert(mark, str(s), tags) self.text.mark_gravity(mark, LEFT) self.text.see(mark) self.text.update() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.