rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
pass class IllegalKeywordArgument(HTTPException): | def __init__(self, version): self.version = version | |
if line == '' or line == '\n' and self.skip_blanks: | if (line == '' or line == '\n') and self.skip_blanks: | def readline (self): """Read and return a single logical line from the current file (or from an internal buffer if lines have previously been "unread" with 'unreadline()'). If the 'join_lines' option is true, this may involve reading multiple physical lines concatenated into a single string. Updates the current line ... |
except NameError: pass import pickle, random | except NameError: pass | def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e |
new = pickle.loads(pickle.dumps(e, random.randint(0, 2))) for checkArgName in expected: self.assertEquals(repr(getattr(e, checkArgName)), repr(expected[checkArgName]), 'pickled exception "%s", attribute "%s' % (repr(e), checkArgName)) | for p in pickle, cPickle: for protocol in range(p.HIGHEST_PROTOCOL + 1): new = p.loads(p.dumps(e, protocol)) for checkArgName in expected: got = repr(getattr(new, checkArgName)) want = repr(expected[checkArgName]) self.assertEquals(got, want, 'pickled "%r", attribute "%s' % (e, checkArgName)) | def testAttributes(self): # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e |
'File name in Central Directory "%s" and File Header "%s" differ.' % ( data.filename, fname) | 'File name in directory "%s" and header "%s" differ.' % ( data.filename, fname) | 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\000": raise BadZipfile,... |
raise xml.sax.SAXParseException(expat.ErrorString(error_code), None, self) | raise SAXParseException(expat.ErrorString(error_code), None, self) | def parse(self, stream_or_string): "Parse an XML document from a URL." if type(stream_or_string) is type(""): stream = open(stream_or_string) else: stream = stream_or_string |
"Looks up and returns the state of a SAX2 feature." | if name == feature_namespaces: return self._namespaces | def getFeature(self, name): "Looks up and returns the state of a SAX2 feature." raise SAXNotRecognizedException("Feature '%s' not recognized" % name) |
"Sets the state of a SAX2 feature." raise SAXNotRecognizedException("Feature '%s' not recognized" % name) | if self._parsing: raise SAXNotSupportedException("Cannot set features while parsing") if name == feature_namespaces: self._namespaces = state else: raise SAXNotRecognizedException("Feature '%s' not recognized" % name) | def setFeature(self, name, state): "Sets the state of a SAX2 feature." raise SAXNotRecognizedException("Feature '%s' not recognized" % name) |
"Looks up and returns the value of a SAX2 property." | def getProperty(self, name): "Looks up and returns the value of a SAX2 property." raise SAXNotRecognizedException("Property '%s' not recognized" % name) | |
"Sets the value of a SAX2 property." | def setProperty(self, name, value): "Sets the value of a SAX2 property." raise SAXNotRecognizedException("Property '%s' not recognized" % name) | |
self._parser.Parse(data, 0) | if not self._parser.Parse(data, 0): msg = pyexpat.ErrorString(self._parser.ErrorCode) raise SAXParseException(msg, None, self) | def feed(self, data): if not self._parsing: self._parsing = 1 self.reset() self._cont_handler.startDocument() # FIXME: error checking and endDocument() self._parser.Parse(data, 0) |
self._cont_handler.startElement(name, name, xmlreader.AttributesImpl(attrs, attrs)) | self._cont_handler.startElement(name, self._attrs) | def start_element(self, name, attrs): self._cont_handler.startElement(name, name, xmlreader.AttributesImpl(attrs, attrs)) |
self._cont_handler.endElement(name, name) | self._cont_handler.endElement(name) | def end_element(self, name): self._cont_handler.endElement(name, name) |
tup = (None, name) else: tup = pair | pair = (None, name) | def start_element_ns(self, name, attrs): pair = name.split() if len(pair) == 1: tup = (None, name) else: tup = pair |
self._cont_handler.startElement(tup, None, xmlreader.AttributesImpl(attrs, None)) | self._cont_handler.startElementNS(pair, None, self._attrs) | def start_element_ns(self, name, attrs): pair = name.split() if len(pair) == 1: tup = (None, name) else: tup = pair |
name = (None, name, None) else: name = pair + [None] | name = (None, name) | def end_element_ns(self, name): pair = name.split() if len(pair) == 1: name = (None, name, None) else: name = pair + [None] # prefix is not implemented yet! self._cont_handler.endElement(name, None) |
self._cont_handler.endElement(name, None) | self._cont_handler.endElementNS(pair, None) | def end_element_ns(self, name): pair = name.split() if len(pair) == 1: name = (None, name, None) else: name = pair + [None] # prefix is not implemented yet! self._cont_handler.endElement(name, None) |
assert 0 | raise NotImplementedError() | def external_entity_ref(self, context, base, sysid, pubid): assert 0 # not implemented source = self._ent_handler.resolveEntity(pubid, sysid) source = saxutils.prepare_input_source(source) # FIXME: create new parser, stack self._source and self._parser # FIXME: reuse code from self.parse(...) return 1 |
ctype = msg.get_type() if ctype is None: ctype = msg.get_default_type() assert ctype in ('text/plain', 'message/rfc822') | ctype = msg.get_content_type() | def _dispatch(self, msg): # Get the Content-Type: for the message, then try to dispatch to # self._handle_<maintype>_<subtype>(). If there's no handler for the # full MIME type, then dispatch to self._handle_<maintype>(). If # that's missing too, then dispatch to self._writeBody(). ctype = msg.get_type() if ctype is ... |
if DEBUG: sys.stderr.write("%s<%s> at %s\n" % (" "*depth, name, point)) | dbgmsg("%s<%s> at %s" % (" "*depth, name, point)) | def pushing(name, point, depth): if DEBUG: sys.stderr.write("%s<%s> at %s\n" % (" "*depth, name, point)) |
if DEBUG: sys.stderr.write("%s</%s> at %s\n" % (" "*depth, name, point)) | dbgmsg("%s</%s> at %s" % (" "*depth, name, point)) | def popping(name, point, depth): if DEBUG: sys.stderr.write("%s</%s> at %s\n" % (" "*depth, name, point)) |
stack = [] line = self.line | def subconvert(self, endchar=None, depth=0): if DEBUG and endchar: self.err_write( "subconvert(%s)\n line = %s\n" % (`endchar`, `line[:20]`)) stack = [] line = self.line while line: if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line return line m = _c... | |
elif envname == stack[-1]: | elif stack and envname == stack[-1]: | def subconvert(self, endchar=None, depth=0): if DEBUG and endchar: self.err_write( "subconvert(%s)\n line = %s\n" % (`endchar`, `line[:20]`)) stack = [] line = self.line while line: if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line return line m = _c... |
line = subconvert("}", depth + len(stack) + 2) | line = self.subconvert("}", len(stack) + depth + 1)[1:] dbgmsg("subconvert() ==> " + `line[:20]`) | def subconvert(self, endchar=None, depth=0): if DEBUG and endchar: self.err_write( "subconvert(%s)\n line = %s\n" % (`endchar`, `line[:20]`)) stack = [] line = self.line while line: if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line return line m = _c... |
print dom | confirm(isinstance(dom,Document)) | def testParseFromFile(): from StringIO import StringIO dom=parse( StringIO( open( tstfile ).read() ) ) print dom |
print Node.allnodes.items()[0:10] | if verbose: print Node.allnodes.items()[0:10] else: print len(Node.allnodes) | def testClonePIDeep(): pass |
cur = (32767 * viewoffset) / (destheight - viewheight) | cur = (32767L * viewoffset) / (destheight - viewheight) | def vscroll(self, value): lineheight = self.ted.WEGetHeight(0, 1) dr = self.ted.WEGetDestRect() vr = self.ted.WEGetViewRect() destheight = dr[3] - dr[1] viewheight = vr[3] - vr[1] viewoffset = maxdelta = vr[1] - dr[1] mindelta = vr[3] - dr[3] if value == "+": delta = lineheight elif value == "-": delta = - lineheight e... |
def __init__(self, _subtype='mixed', boundary=None, *_subparts, **_params): | def __init__(self, _subtype='mixed', boundary=None, _subparts=None, **_params): | def __init__(self, _subtype='mixed', boundary=None, *_subparts, **_params): """Creates a multipart/* type message. |
must be possible to convert this sequence to a list. You can always | must be an iterable object, such as a list. You can always | def __init__(self, _subtype='mixed', boundary=None, *_subparts, **_params): """Creates a multipart/* type message. |
self.attach(*list(_subparts)) | for p in _subparts: self.attach(p) | def __init__(self, _subtype='mixed', boundary=None, *_subparts, **_params): """Creates a multipart/* type message. |
raise SMTPServerDisconnected | raise SMTPServerDisconnected('Server not connected') | def send(self, str): """Send `str' to the server.""" if self.debuglevel > 0: print 'send:', `str` if self.sock: try: self.sock.send(str) except socket.error: raise SMTPServerDisconnected else: raise SMTPServerDisconnected |
raise SMTPServerDisconnected | raise SMTPServerDisconnected('please run connect() first') | def send(self, str): """Send `str' to the server.""" if self.debuglevel > 0: print 'send:', `str` if self.sock: try: self.sock.send(str) except socket.error: raise SMTPServerDisconnected else: raise SMTPServerDisconnected |
raise SMTPServerDisconnected | raise SMTPServerDisconnected("Server not connected") | def ehlo(self, name=''): """ SMTP 'ehlo' command. Hostname to send for this command defaults to the FQDN of the local host. """ name=string.strip(name) if len(name)==0: name=socket.gethostbyaddr(socket.gethostname())[0] self.putcmd("ehlo",name) (code,msg)=self.getreply() # According to RFC1869 some (badly written) # MT... |
raise SMTPSenderRefused | raise SMTPSenderRefused('%s: %s' % (from_addr, resp)) | def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction. |
raise SMTPRecipientsRefused | raise SMTPRecipientsRefused(string.join( map(lambda x:"%s: %s" % (x[0], x[1][1]), senderrs.items()), '; ')) | def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction. |
raise SMTPDataError | raise SMTPDataError('data transmission error: %s' % code) | def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction. |
self.filename = _normpath(filename) | self.orig_filename = filename null_byte = filename.find(chr(0)) if null_byte >= 0: filename = filename[0:null_byte] print "File name %s contains a suspicious null byte!" % filename if os.sep != "/": filename = filename.replace(os.sep, "/") self.filename = filename | def __init__(self, filename="NoName", date_time=(1980,1,1,0,0,0)): self.filename = _normpath(filename) # Name of the file in the archive self.date_time = date_time # year, month, day, hour, min, sec # Standard values: self.compress_type = ZIP_STORED # Type of compression for the file self.comment = "" ... |
if os.sep != "/": def _normpath(path): return path.replace(os.sep, "/") else: def _normpath(path): return path | def FileHeader(self): """Return the per-file header as a string.""" dt = self.date_time dosdate = (dt[0] - 1980) << 9 | dt[1] << 5 | dt[2] dostime = dt[3] << 11 | dt[4] << 5 | (dt[5] // 2) if self.flag_bits & 0x08: # Set these to zero because we write them after the file data CRC = compress_size = file_size = 0 else: C... | |
if fname != data.filename: | if fname != data.orig_filename: | def _RealGetContents(self): """Read in the table of contents for the ZIP file.""" fp = self.fp endrec = _EndRecData(fp) if not endrec: raise BadZipfile, "File is not a zip file" if self.debug > 1: print endrec size_cd = endrec[5] # bytes in central directory offset_cd = endrec[6] # offset of central direc... |
data.filename, fname) | data.orig_filename, fname) | def _RealGetContents(self): """Read in the table of contents for the ZIP file.""" fp = self.fp endrec = _EndRecData(fp) if not endrec: raise BadZipfile, "File is not a zip file" if self.debug > 1: print endrec size_cd = endrec[5] # bytes in central directory offset_cd = endrec[6] # offset of central direc... |
if hasattr(os, 'chmod') and sys.platform[:6] != 'cygwin': | if (hasattr(os, 'chmod') and sys.platform[:6] != 'cygwin' and os.getenv('USER') != 'root'): | def test_rmtree_errors(self): # filename is guaranteed not to exist filename = tempfile.mktemp() self.assertRaises(OSError, shutil.rmtree, filename) |
self.assertEqual(self.errorState, 2) | self.assertEqual(self.errorState, 2, "Expected call to onerror function did not happen.") | def test_on_error(self): self.errorState = 0 os.mkdir(TESTFN) self.childpath = os.path.join(TESTFN, 'a') f = open(self.childpath, 'w') f.close() old_dir_mode = os.stat(TESTFN).st_mode old_child_mode = os.stat(self.childpath).st_mode # Make unwritable. os.chmod(self.childpath, stat.S_IREAD) os.chmod(TESTFN, stat.S_IREAD... |
lines = linecache.getlines(file, getmodule(object).__dict__) | module = getmodule(object) if module: lines = linecache.getlines(file, module.__dict__) else: lines = linecache.getlines(file) | 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... |
WeakKeyDictionaryTestCase ) | WeakKeyDictionaryTestCase, ) | def test_main(): test_support.run_unittest( ReferencesTestCase, MappingTestCase, WeakValueDictionaryTestCase, WeakKeyDictionaryTestCase ) |
min_db_ver = (3, 2) | min_db_ver = (3, 3) | 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') |
ioloop(s, otheraddr) except KeyboardInterrupt: log('client got intr') except error: log('client got error') | try: ioloop(s, otheraddr) except KeyboardInterrupt: log('client got intr') except error: log('client got error') | def client(hostname): print 'client starting' cmd = 'rsh ' + hostname + ' "cd ' + AUDIODIR cmd = cmd + '; DISPLAY=:0; export DISPLAY' cmd = cmd + '; ' + PYTHON + ' intercom.py -r ' for flag in debug: cmd = cmd + flag + ' ' cmd = cmd + gethostname() cmd = cmd + '"' if debug: print cmd pipe = posix.popen(cmd, 'r') ack = ... |
parser.set_aliases({'license': 'licence'}) | parser.set_aliases({'licence': 'license'}) | def parse_command_line (self): """Parse the setup script's command line, taken from the 'script_args' instance attribute (which defaults to 'sys.argv[1:]' -- see 'setup()' in core.py). This list is first processed for "global options" -- options that set attributes of the Distribution instance. Then, it is alternatel... |
if type(command) is ClassType and issubclass(klass, Command): | if type(command) is ClassType and issubclass(command, Command): | def _show_help (self, parser, global_options=1, display_options=1, commands=[]): """Show help for the setup script command-line in the form of several lists of command-line options. 'parser' should be a FancyGetopt instance; do not expect it to be returned in the same state, as its option table will be reset to make i... |
self.licence = None | self.license = None | def __init__ (self): self.name = None self.version = None self.author = None self.author_email = None self.maintainer = None self.maintainer_email = None self.url = None self.licence = None self.description = None self.long_description = None self.keywords = None self.platforms = None |
pkg_info.write('License: %s\n' % self.get_licence() ) | pkg_info.write('License: %s\n' % self.get_license() ) | def write_pkg_info (self, base_dir): """Write the PKG-INFO file into the release tree. """ |
def get_licence(self): return self.licence or "UNKNOWN" | def get_license(self): return self.license or "UNKNOWN" get_licence = get_license | def get_licence(self): return self.licence or "UNKNOWN" |
'_topdir %s/%s' % (os.getcwd(), self.rpm_base),]) | '_topdir %s' % os.path.abspath(self.rpm_base)]) | def run (self): |
def __imull__(self, n): self.data += n | def __imul__(self, n): self.data *= n | def __imull__(self, n): self.data += n return self |
def valueseq(self, value1, value2): return value1.gr_name==value2.gr_name and \ value1.gr_gid==value2.gr_gid and value1.gr_mem==value2.gr_mem | def valueseq(self, value1, value2): # are two grp tuples equal (don't compare passwords) return value1.gr_name==value2.gr_name and \ value1.gr_gid==value2.gr_gid and value1.gr_mem==value2.gr_mem | |
entriesbygid = {} entriesbyname = {} | def test_values(self): entries = grp.getgrall() entriesbygid = {} entriesbyname = {} | |
entriesbygid.setdefault(e.gr_gid, []).append(e) entriesbyname.setdefault(e.gr_name, []).append(e) | def test_values(self): entries = grp.getgrall() entriesbygid = {} entriesbyname = {} | |
self.assert_(max([self.valueseq(e2, x) \ for x in entriesbygid[e.gr_gid]])) | self.assertEqual(e2.gr_gid, e.gr_gid) | def test_values(self): entries = grp.getgrall() entriesbygid = {} entriesbyname = {} |
self.assert_(max([self.valueseq(e2, x) \ for x in entriesbyname[e.gr_name]])) | self.assertEqual(e2.gr_name, e.gr_name) | def test_values(self): entries = grp.getgrall() entriesbygid = {} entriesbyname = {} |
filename="<testcase>", mode="exec"): | filename="<testcase>", mode="exec", subclass=None): | def _check_error(self, code, errtext, filename="<testcase>", mode="exec"): """Check that compiling code raises SyntaxError with errtext. |
test of the exception raised. | test of the exception raised. If subclass is specified it is the expected subclass of SyntaxError (e.g. IndentationError). | def _check_error(self, code, errtext, filename="<testcase>", mode="exec"): """Check that compiling code raises SyntaxError with errtext. |
Triple = group("'''", '"""', "r'''", 'r"""') | Triple = group("[rR]?'''", '[rR]?"""') | def maybe(*choices): return apply(group, choices) + '?' |
ContStr = group("r?'" + any(r'\\.', r"[^\n'\\]") + group("'", r'\\\r?\n'), 'r?"' + any(r'\\.', r'[^\n"\\]') + group('"', r'\\\r?\n')) | ContStr = group("[rR]?'" + any(r'\\.', r"[^\n'\\]") + group("'", r'\\\r?\n'), '[rR]?"' + any(r'\\.', r'[^\n"\\]') + group('"', r'\\\r?\n')) | def maybe(*choices): return apply(group, choices) + '?' |
endprogs = {"'": re.compile(Single), '"': re.compile(Double), 'r': None, | endprogs = {"'": re.compile(Single), '"': re.compile(Double), | def maybe(*choices): return apply(group, choices) + '?' |
"r'''": single3prog, 'r"""': double3prog} | "r'''": single3prog, 'r"""': double3prog, "R'''": single3prog, 'R"""': double3prog, 'r': None, 'R': None} | def maybe(*choices): return apply(group, choices) + '?' |
elif token in ("'''",'"""',"r'''",'r"""'): | elif token in ("'''", '"""', "r'''", 'r"""', "R'''", 'R"""'): | def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr, needcont = '', 0 indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... |
elif initial in ("'", '"') or token[:2] in ("r'", 'r"'): | elif initial in ("'", '"') or \ token[:2] in ("r'", 'r"', "R'", 'R"'): | def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr, needcont = '', 0 indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... |
self.compiler.find_library_file(lib_dirs, 'panel')): | self.compiler.find_library_file(lib_dirs, panel_library)): | 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') |
libraries = ['panel'] + curses_libs) ) | libraries = [panel_library] + curses_libs) ) | 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') |
def set_proxy(self, proxy): self.__proxy = proxy self.type, self.__r_type = splittype(self.__proxy) self.host, XXX = splithost(self.__r_type) self.host = unquote(self.host) | def set_proxy(self, host, type): self.host, self.type = host, type | def set_proxy(self, proxy): self.__proxy = proxy # XXX this code is based on urllib, but it doesn't seem # correct. specifically, if the proxy has a port number then # splittype will return the hostname as the type and the port # will be include with everything else self.type, self.__r_type = splittype(self.__proxy) s... |
if proto == 'http': dict = self.handle_error[proto] | if proto in ['http', 'https']: dict = self.handle_error['http'] | def error(self, proto, *args): if proto == 'http': # XXX http protocol is special cased dict = self.handle_error[proto] proto = args[2] # YUCK! meth_name = 'http_error_%d' % proto http_err = 1 orig_args = args else: dict = self.handle_error meth_name = proto + '_error' http_err = 0 args = (dict, proto, meth_name) + ar... |
if req.error_302_dict.has_key(newurl): | if len(error_302_dict)>10 or req.error_302_dict.has_key(newurl): | def http_error_302(self, req, fp, code, msg, headers): if headers.has_key('location'): newurl = headers['location'] elif headers.has_key('uri'): newurl = headers['uri'] else: return nil = fp.read() fp.close() |
req.set_proxy(proxy) | type, r_type = splittype(proxy) host, XXX = splithost(r_type) if '@' in host: user_pass, host = host.split('@', 1) user_pass = base64.encode_string(unquote(user_passw)).strip() req.addheader('Proxy-Authorization', user_pass) host = unquote(host) req.set_proxy(host, type) | def proxy_open(self, req, proxy, type): orig_type = req.get_type() req.set_proxy(proxy) if orig_type == type: # let other handlers take care of it # XXX this only makes sense if the proxy is before the # other handlers return None else: # need to start over, because the other handlers don't # grok the proxy's URL type ... |
common = os.path.commonprefix((base[1], test[1])) | common = posixpath.commonprefix((base[1], test[1])) | def is_suburi(self, base, test): """Check if test is below base in a URI tree |
class HTTPBasicAuthHandler(BaseHandler): | class HTTPPasswordMgrWithDefaultRealm(HTTPPasswordMgr): def find_user_password(self, realm, authuri): user, password = HTTPPasswordMgr.find_user_password(self,realm,authuri) if user is not None: return user, password return HTTPPasswordMgr.find_user_password(self, None, authuri) class AbstractBasicAuthHandler: | def is_suburi(self, base, test): """Check if test is below base in a URI tree |
def __init__(self): self.passwd = HTTPPasswordMgr() | def __init__(self, password_mgr=None): if password_mgr is None: password_mgr = HTTPPasswordMgr() self.passwd = password_mgr | def __init__(self): self.passwd = HTTPPasswordMgr() self.add_password = self.passwd.add_password self.__current_realm = None # if __current_realm is not None, then the server must have # refused our name/password and is asking for authorization # again. must be careful to set it to None on successful # return. |
def http_error_401(self, req, fp, code, msg, headers): authreq = headers.get('www-authenticate', None) | def http_error_auth_reqed(self, authreq, host, req, headers): authreq = headers.get(authreq, None) | def http_error_401(self, req, fp, code, msg, headers): # XXX could be mult. headers authreq = headers.get('www-authenticate', None) if authreq: mo = HTTPBasicAuthHandler.rx.match(authreq) if mo: scheme, realm = mo.groups() if scheme.lower() == 'basic': return self.retry_http_basic_auth(req, realm) |
mo = HTTPBasicAuthHandler.rx.match(authreq) | mo = AbstractBasicAuthHandler.rx.match(authreq) | def http_error_401(self, req, fp, code, msg, headers): # XXX could be mult. headers authreq = headers.get('www-authenticate', None) if authreq: mo = HTTPBasicAuthHandler.rx.match(authreq) if mo: scheme, realm = mo.groups() if scheme.lower() == 'basic': return self.retry_http_basic_auth(req, realm) |
return self.retry_http_basic_auth(req, realm) def retry_http_basic_auth(self, req, realm): | return self.retry_http_basic_auth(host, req, realm) def retry_http_basic_auth(self, host, req, realm): | def http_error_401(self, req, fp, code, msg, headers): # XXX could be mult. headers authreq = headers.get('www-authenticate', None) if authreq: mo = HTTPBasicAuthHandler.rx.match(authreq) if mo: scheme, realm = mo.groups() if scheme.lower() == 'basic': return self.retry_http_basic_auth(req, realm) |
host = req.get_host() | def retry_http_basic_auth(self, req, realm): if self.__current_realm is None: self.__current_realm = realm else: self.__current_realm = realm return None # XXX host isn't really the correct URI? host = req.get_host() user,pw = self.passwd.find_user_password(realm, host) if pw: raw = "%s:%s" % (user, pw) auth = base64.e... | |
req.add_header('Authorization', 'Basic %s' % auth) | req.add_header(self.header, 'Basic %s' % auth) | def retry_http_basic_auth(self, req, realm): if self.__current_realm is None: self.__current_realm = realm else: self.__current_realm = realm return None # XXX host isn't really the correct URI? host = req.get_host() user,pw = self.passwd.find_user_password(realm, host) if pw: raw = "%s:%s" % (user, pw) auth = base64.e... |
class HTTPDigestAuthHandler(BaseHandler): """An authentication protocol defined by RFC 2069 Digest authentication improves on basic authentication because it does not transmit passwords in the clear. """ def __init__(self): self.passwd = HTTPPasswordMgr() | class HTTPBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler): header = 'Authorization' def http_error_401(self, req, fp, code, msg, headers): host = urlparse.urlparse(req.get_full_url())[1] return self.http_error_auth_reqed('www-authenticate', host, req, headers) class ProxyBasicAuthHandler(AbstractBasicAuthHa... | def retry_http_basic_auth(self, req, realm): if self.__current_realm is None: self.__current_realm = realm else: self.__current_realm = realm return None # XXX host isn't really the correct URI? host = req.get_host() user,pw = self.passwd.find_user_password(realm, host) if pw: raw = "%s:%s" % (user, pw) auth = base64.e... |
def http_error_401(self, req, fp, code, msg, headers): authreq = headers.get('www-authenticate', None) | def http_error_auth_reqed(self, authreq, host, req, headers): authreq = headers.get(self.header, None) | def http_error_401(self, req, fp, code, msg, headers): # XXX could be mult. headers authreq = headers.get('www-authenticate', None) if authreq: kind = authreq.split()[0] if kind == 'Digest': return self.retry_http_digest_auth(req, authreq) |
req.add_header('Authorization', 'Digest %s' % auth) | req.add_header(self.header, 'Digest %s' % auth) | def retry_http_digest_auth(self, req, auth): token, challenge = auth.split(' ', 1) chal = parse_keqv_list(parse_http_list(challenge)) auth = self.get_authorization(req, chal) if auth: req.add_header('Authorization', 'Digest %s' % auth) resp = self.parent.open(req) self.__current_realm = None return resp |
class HTTPHandler(BaseHandler): def http_open(self, req): | class AbstractHTTPHandler(BaseHandler): def do_open(self, http_class, req): | def encode_digest(digest): hexrep = [] for c in digest: n = (ord(c) >> 4) & 0xf hexrep.append(hex(n)[-1]) n = ord(c) & 0xf hexrep.append(hex(n)[-1]) return ''.join(hexrep) |
h = httplib.HTTP(host) | h = http_class(host) | def http_open(self, req): # XXX devise a new mechanism to specify user/password host = req.get_host() if not host: raise URLError('no host given') |
for version in ['8.4', '8.3', '8.2', '8.1', '8.0']: | for version in ['8.4', '84', '8.3', '83', '8.2', '82', '8.1', '81', '8.0', '80']: | def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. # Assume we haven't found any of the libraries or include files tcllib = tklib = tcl_includes = tk_includes = None for version in ['8.4', '8.3', '8.2', '8.1', '8.0']: tklib = self.compiler.find_library_file(lib_dirs, 'tk' + version ) tcllib = self.co... |
libs.append('X11') | if platform != "cygwin": libs.append('X11') | def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. # Assume we haven't found any of the libraries or include files tcllib = tklib = tcl_includes = tk_includes = None for version in ['8.4', '8.3', '8.2', '8.1', '8.0']: tklib = self.compiler.find_library_file(lib_dirs, 'tk' + version ) tcllib = self.co... |
raise ValueError("truncated header") | raise HeaderError("truncated header") | def frombuf(cls, buf): """Construct a TarInfo object from a 512 byte string buffer. """ if len(buf) != BLOCKSIZE: raise ValueError("truncated header") if buf.count(NUL) == BLOCKSIZE: raise ValueError("empty header") |
raise ValueError("empty header") | raise HeaderError("empty header") try: chksum = nti(buf[148:156]) except ValueError: raise HeaderError("invalid header") if chksum not in calc_chksums(buf): raise HeaderError("bad checksum") | def frombuf(cls, buf): """Construct a TarInfo object from a 512 byte string buffer. """ if len(buf) != BLOCKSIZE: raise ValueError("truncated header") if buf.count(NUL) == BLOCKSIZE: raise ValueError("empty header") |
tarinfo.chksum = nti(buf[148:156]) | tarinfo.chksum = chksum | def frombuf(cls, buf): """Construct a TarInfo object from a 512 byte string buffer. """ if len(buf) != BLOCKSIZE: raise ValueError("truncated header") if buf.count(NUL) == BLOCKSIZE: raise ValueError("empty header") |
if tarinfo.chksum not in calc_chksums(buf): raise ValueError("invalid header") | def frombuf(cls, buf): """Construct a TarInfo object from a 512 byte string buffer. """ if len(buf) != BLOCKSIZE: raise ValueError("truncated header") if buf.count(NUL) == BLOCKSIZE: raise ValueError("empty header") | |
except ValueError, e: | except HeaderError, e: | 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._dbg(2, "0x%X: empty or invalid block: %s" % (self.offset, e)) | self._dbg(2, "0x%X: %s" % (self.offset, e)) | 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 |
raise ReadError("empty, unreadable or compressed " "file: %s" % e) | raise ReadError(str(e)) | 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 |
raise RuntimeError, "no clue how to do this on Mac OS" | if not os.path.isabs(pathname): return os.path.join(new_root, pathname) else: elements = string.split(pathname, ":", 1) pathname = ":" + elements[1] return os.path.join(new_root, pathname) | def change_root (new_root, pathname): """Return 'pathname' with 'new_root' prepended. If 'pathname' is relative, this is equivalent to "os.path.join(new_root,pathname)". Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS. """ if os.name == 'posix': if ... |
version = "HTTP/0.9" | def handle(self): | |
self.send_error(400, "Bad request syntax (%s)" % `command`) | self.send_error(400, "Bad request syntax (%s)" % `requestline`) | def handle(self): |
self.send_error(501, "Unsupported method (%s)" % `command`) | self.send_error(501, "Unsupported method (%s)" % `mname`) | def handle(self): |
slave_fd = _slave_open(slave_name) | slave_fd = slave_open(slave_name) | def openpty(): """openpty() -> (master_fd, slave_fd) Open a pty master/slave pair, using os.openpty() if possible.""" try: return os.openpty() except (AttributeError, OSError): pass master_fd, slave_name = _open_terminal() slave_fd = _slave_open(slave_name) return master_fd, slave_fd |
del ce | del riscos | def _get_exports_list(module): try: return list(module.__all__) except AttributeError: return [n for n in dir(module) if n[0] != '_'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.