rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
blocknum = blocknum + 1 | read += len(block) blocknum += 1 | def retrieve(self, url, filename=None, reporthook=None, data=None): """retrieve(url) returns (filename, headers) for a local object or (tempfilename, headers) for a remote object.""" url = unwrap(toBytes(url)) if self.tempcache and url in self.tempcache: return self.tempcache[url] type, url1 = splittype(url) if filenam... |
def putrequest(self, method, url): | def putrequest(self, method, url, skip_host=0): | def putrequest(self, method, url): """Send a request to the server. |
if url.startswith('http:'): nil, netloc, nil, nil, nil = urlsplit(url) self.putheader('Host', netloc) elif self.port == HTTP_PORT: self.putheader('Host', netloc) else: self.putheader('Host', "%s:%s" % (self.host, self.port)) | if not skip_host: netloc = '' if url.startswith('http'): nil, netloc, nil, nil, nil = urlsplit(url) if netloc: self.putheader('Host', netloc) elif self.port == HTTP_PORT: self.putheader('Host', self.host) else: self.putheader('Host', "%s:%s" % (self.host, self.port)) | def putrequest(self, method, url): """Send a request to the server. |
self.putrequest(method, url) | if (headers.has_key('Host') or [k for k in headers.iterkeys() if k.lower() == "host"]): self.putrequest(method, url, skip_host=1) else: self.putrequest(method, url) | def _send_request(self, method, url, body, headers): self.putrequest(method, url) |
self.format_all(map(lambda (mtime, file): file, list)) | self.format_all(map(lambda (mtime, file): file, list), headers=0) | def do_recent(self): |
while 1: | depth = 0 while depth < 10: depth = depth + 1 | def get(self, section, option, raw=0, vars=None): """Get an option value for a given section. |
release = '98' | release = 'postMe' | def win32_ver(release='',version='',csd='',ptype=''): """ Get additional version information from the Windows Registry and return a tuple (version,csd,ptype) referring to version number, CSD level and OS type (multi/single processor). As a hint: ptype returns 'Uniprocessor Free' on single processor NT machines and 'M... |
release = '2000' | if min == 0: release = '2000' elif min == 1: release = 'XP' elif min == 2: release = '2003Server' else: release = 'post2003' | def win32_ver(release='',version='',csd='',ptype=''): """ Get additional version information from the Windows Registry and return a tuple (version,csd,ptype) referring to version number, CSD level and OS type (multi/single processor). As a hint: ptype returns 'Uniprocessor Free' on single processor NT machines and 'M... |
_platform_cache_terse = None _platform_cache_not_terse = None _platform_aliased_cache_terse = None _platform_aliased_cache_not_terse = None | _platform_cache = {} | def python_compiler(): """ Returns a string identifying the compiler used for compiling Python. """ return _sys_version()[3] |
global _platform_cache_terse, _platform_cache_not_terse global _platform_aliased_cache_terse, _platform_aliased_cache_not_terse if not aliased and terse and (_platform_cache_terse is not None): return _platform_cache_terse elif not aliased and not terse and (_platform_cache_not_terse is not None): return _platform_cac... | result = _platform_cache.get((aliased, terse), None) if result is not None: return result | def platform(aliased=0, terse=0): """ Returns a single string identifying the underlying platform with as much useful information as possible (but no more :). The output is intended to be human readable rather than machine parseable. It may look different on different platforms and this is intended. If "aliased" is ... |
if aliased and terse: _platform_aliased_cache_terse = platform elif aliased and not terse: _platform_aliased_cache_not_terse = platform elif terse: pass else: if terse: _platform_cache_terse = platform else: _platform_cache_not_terse = platform | _platform_cache[(aliased, terse)] = platform | def platform(aliased=0, terse=0): """ Returns a single string identifying the underlying platform with as much useful information as possible (but no more :). The output is intended to be human readable rather than machine parseable. It may look different on different platforms and this is intended. If "aliased" is ... |
body = "HTTP/1.1 200 Ok\r\n\r\nText" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock, 1) resp.begin() print resp.read() resp.close() | import sys | def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': raise httplib.UnimplementedFileMode() return StringIO.StringIO(self.text) |
body = "HTTP/1.1 400.100 Not Ok\r\n\r\nText" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock, 1) try: | def test(): buf = StringIO.StringIO() _stdout = sys.stdout try: sys.stdout = buf _test() finally: sys.stdout = _stdout s = buf.getvalue() for line in s.split("\n"): print line.strip() def _test(): body = "HTTP/1.1 200 Ok\r\n\r\nText" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock, 1) | def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': raise httplib.UnimplementedFileMode() return StringIO.StringIO(self.text) |
except httplib.BadStatusLine: print "BadStatusLine raised as expected" else: print "Expect BadStatusLine" | print resp.read() resp.close() | def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': raise httplib.UnimplementedFileMode() return StringIO.StringIO(self.text) |
body = "HTTP/1.1 400.100 Not Ok\r\n\r\nText" sock = FakeSocket(body) resp = httplib.HTTPResponse(sock, 1) try: resp.begin() except httplib.BadStatusLine: print "BadStatusLine raised as expected" else: print "Expect BadStatusLine" | def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': raise httplib.UnimplementedFileMode() return StringIO.StringIO(self.text) | |
for hp in ("www.python.org:abc", "www.python.org:"): try: h = httplib.HTTP(hp) except httplib.InvalidURL: print "InvalidURL raised as expected" else: print "Expect InvalidURL" | def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': raise httplib.UnimplementedFileMode() return StringIO.StringIO(self.text) | |
text = ('HTTP/1.1 200 OK\r\n' 'Set-Cookie: Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"\r\n' 'Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1";' ' Path="/acme"\r\n' '\r\n' 'No body\r\n') hdr = ('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"' ', ' 'Part_Number="Rocket_Launcher_0001"; Version="1";... | for hp in ("www.python.org:abc", "www.python.org:"): try: h = httplib.HTTP(hp) except httplib.InvalidURL: print "InvalidURL raised as expected" else: print "Expect InvalidURL" text = ('HTTP/1.1 200 OK\r\n' 'Set-Cookie: Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"\r\n' 'Set-Cookie: Part_Number="Rocket_Launcher_... | def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': raise httplib.UnimplementedFileMode() return StringIO.StringIO(self.text) |
def register(name, klass, instance=None): | def register(name, klass, instance=None, update_tryorder=1): | def register(name, klass, instance=None): """Register a browser connector and, optionally, connection.""" _browsers[name.lower()] = [klass, instance] |
if command[1] is None: | if command[1] is not None: return command[1] elif command[0] is not None: | def get(using=None): """Return a browser launcher instance appropriate for the environment.""" if using is not None: alternatives = [using] else: alternatives = _tryorder for browser in alternatives: if '%s' in browser: # User gave us a command line, don't mess with it. return GenericBrowser(browser) else: # User gave ... |
else: return command[1] | def get(using=None): """Return a browser launcher instance appropriate for the environment.""" if using is not None: alternatives = [using] else: alternatives = _tryorder for browser in alternatives: if '%s' in browser: # User gave us a command line, don't mess with it. return GenericBrowser(browser) else: # User gave ... | |
get().open(url, new, autoraise) | for name in _tryorder: browser = get(name) if browser.open(url, new, autoraise): return True return False | def open(url, new=0, autoraise=1): get().open(url, new, autoraise) |
get().open(url, 1) def _synthesize(browser): | return open(url, 1) def open_new_tab(url): return open(url, 2) def _synthesize(browser, update_tryorder=1): | def open_new(url): get().open(url, 1) |
if not os.path.exists(browser): | cmd = browser.split()[0] if not _iscommand(cmd): | def _synthesize(browser): """Attempt to synthesize a controller base on existing controllers. This is useful to create a controller when a user specifies a path to an entry in the BROWSER environment variable -- we can copy a general controller to operate using a specific installation of the desired browser in this wa... |
name = os.path.basename(browser) | name = os.path.basename(cmd) | def _synthesize(browser): """Attempt to synthesize a controller base on existing controllers. This is useful to create a controller when a user specifies a path to an entry in the BROWSER environment variable -- we can copy a general controller to operate using a specific installation of the desired browser in this wa... |
register(browser, None, controller) | register(browser, None, controller, update_tryorder) | def _synthesize(browser): """Attempt to synthesize a controller base on existing controllers. This is useful to create a controller when a user specifies a path to an entry in the BROWSER environment variable -- we can copy a general controller to operate using a specific installation of the desired browser in this wa... |
if _isexecutable(cmd): return True | def _iscommand(cmd): """Return True if cmd can be found on the executable search path.""" path = os.environ.get("PATH") if not path: return False for d in path.split(os.pathsep): exe = os.path.join(d, cmd) if os.path.isfile(exe): return True return False | |
if os.path.isfile(exe): | if _isexecutable(exe): | def _iscommand(cmd): """Return True if cmd can be found on the executable search path.""" path = os.environ.get("PATH") if not path: return False for d in path.split(os.pathsep): exe = os.path.join(d, cmd) if os.path.isfile(exe): return True return False |
PROCESS_CREATION_DELAY = 4 class GenericBrowser: | class BaseBrowser(object): """Parent class for all browsers.""" def __init__(self, name=""): self.name = name def open_new(self, url): return self.open(url, 1) def open_new_tab(self, url): return self.open(url, 2) class GenericBrowser(BaseBrowser): """Class for all browsers started with a command and without remot... | def _iscommand(cmd): """Return True if cmd can be found on the executable search path.""" path = os.environ.get("PATH") if not path: return False for d in path.split(os.pathsep): exe = os.path.join(d, cmd) if os.path.isfile(exe): return True return False |
self.basename = os.path.basename(self.name) | def __init__(self, cmd): self.name, self.args = cmd.split(None, 1) self.basename = os.path.basename(self.name) | |
os.system(command % url) def open_new(self, url): self.open(url) class Netscape: "Launcher class for Netscape browsers." def __init__(self, name): self.name = name self.basename = os.path.basename(name) def _remote(self, action, autoraise): raise_opt = ("-noraise", "-raise")[autoraise] cmd = "%s %s -remote '%s' >/d... | rc = os.system(command % url) return not rc class UnixBrowser(BaseBrowser): """Parent class for all Unix browsers with remote functionality.""" raise_opts = None remote_cmd = '' remote_action = None remote_action_newwin = None remote_action_newtab = None remote_background = False def _remote(self, url, action, aut... | def open(self, url, new=0, autoraise=1): assert "'" not in url command = "%s %s" % (self.name, self.args) os.system(command % url) |
import time os.system("%s &" % self.name) time.sleep(PROCESS_CREATION_DELAY) rc = os.system(cmd) | rc = os.system("%s %s" % (self.name, url)) | def _remote(self, action, autoraise): raise_opt = ("-noraise", "-raise")[autoraise] cmd = "%s %s -remote '%s' >/dev/null 2>&1" % (self.name, raise_opt, action) rc = os.system(cmd) if rc: import time os.system("%s &" % self.name) time.sleep(PROCESS_CREATION_DELAY) rc = os.system(cmd) return not rc |
if new: self._remote("openURL(%s, new-window)"%url, autoraise) | assert "'" not in url if new == 0: action = self.remote_action elif new == 1: action = self.remote_action_newwin elif new == 2: if self.remote_action_newtab is None: action = self.remote_action_newwin else: action = self.remote_action_newtab | def open(self, url, new=0, autoraise=1): if new: self._remote("openURL(%s, new-window)"%url, autoraise) else: self._remote("openURL(%s)" % url, autoraise) |
self._remote("openURL(%s)" % url, autoraise) def open_new(self, url): self.open(url, 1) class Galeon: """Launcher class for Galeon browsers.""" def __init__(self, name): self.name = name self.basename = os.path.basename(name) def _remote(self, action, autoraise): raise_opt = ("--noraise", "")[autoraise] cmd = "%s %... | raise Error("Bad 'new' parameter to open(); expected 0, 1, or 2, got %s" % new) return self._remote(url, action % url, autoraise) class Mozilla(UnixBrowser): """Launcher class for Mozilla/Netscape browsers.""" raise_opts = ("-noraise", "-raise") remote_cmd = '-remote' remote_action = "openURL(%s)" remote_action_new... | def open(self, url, new=0, autoraise=1): if new: self._remote("openURL(%s, new-window)"%url, autoraise) else: self._remote("openURL(%s)" % url, autoraise) |
def __init__(self): if _iscommand("konqueror"): self.name = self.basename = "konqueror" else: self.name = self.basename = "kfm" def _remote(self, action): | def _remote(self, url, action): | def __init__(self): if _iscommand("konqueror"): self.name = self.basename = "konqueror" else: self.name = self.basename = "kfm" |
import time if self.basename == "konqueror": os.system(self.name + " --silent &") else: os.system(self.name + " -d &") time.sleep(PROCESS_CREATION_DELAY) rc = os.system(cmd) | if _iscommand("konqueror"): rc = os.system(self.name + " --silent '%s' &" % url) elif _iscommand("kfm"): rc = os.system(self.name + " -d '%s'" % url) | def _remote(self, action): cmd = "kfmclient %s >/dev/null 2>&1" % action rc = os.system(cmd) if rc: import time if self.basename == "konqueror": os.system(self.name + " --silent &") else: os.system(self.name + " -d &") time.sleep(PROCESS_CREATION_DELAY) rc = os.system(cmd) return not rc |
def open(self, url, new=1, autoraise=1): | def open(self, url, new=0, autoraise=1): | def open(self, url, new=1, autoraise=1): # XXX Currently I know no way to prevent KFM from # opening a new win. assert "'" not in url self._remote("openURL '%s'" % url) |
self._remote("openURL '%s'" % url) open_new = open class Grail: | if new == 2: action = "newTab '%s'" % url else: action = "openURL '%s'" % url ok = self._remote(url, action) return ok class Opera(UnixBrowser): "Launcher class for Opera browser." raise_opts = ("", "-raise") remote_cmd = '-remote' remote_action = "openURL(%s)" remote_action_newwin = "openURL(%s,new-window)" remote... | def open(self, url, new=1, autoraise=1): # XXX Currently I know no way to prevent KFM from # opening a new win. assert "'" not in url self._remote("openURL '%s'" % url) |
self._remote("LOADNEW " + url) | ok = self._remote("LOADNEW " + url) | def open(self, url, new=0, autoraise=1): if new: self._remote("LOADNEW " + url) else: self._remote("LOAD " + url) |
self._remote("LOAD " + url) def open_new(self, url): self.open(url, 1) class WindowsDefault: def open(self, url, new=0, autoraise=1): os.startfile(url) def open_new(self, url): self.open(url) | ok = self._remote("LOAD " + url) return ok | def open(self, url, new=0, autoraise=1): if new: self._remote("LOADNEW " + url) else: self._remote("LOAD " + url) |
if os.environ.get("TERM") or os.environ.get("DISPLAY"): _tryorder = ["links", "lynx", "w3m"] if os.environ.get("TERM"): if _iscommand("links"): register("links", None, GenericBrowser("links '%s'")) if _iscommand("lynx"): register("lynx", None, GenericBrowser("lynx '%s'")) if _iscommand("w3m"): register("w3m", None... | if os.environ.get("DISPLAY"): for browser in ("mozilla-firefox", "firefox", "mozilla-firebird", "firebird", "mozilla", "netscape"): if _iscommand(browser): register(browser, None, Mozilla(browser)) if _iscommand("gconftool-2"): gc = 'gconftool-2 -g /desktop/gnome/url-handlers/http/command' out = os.popen(gc) commd... | def open_new(self, url): self.open(url) |
_tryorder = ["netscape", "windows-default"] | class WindowsDefault(BaseBrowser): def open(self, url, new=0, autoraise=1): os.startfile(url) return True _tryorder = [] _browsers = {} for browser in ("firefox", "firebird", "mozilla", "netscape", "opera"): if _iscommand(browser): register(browser, None, GenericBrowser(browser + ' %s')) | def open_new(self, url): self.open(url) |
_tryorder = ["internet-config"] register("internet-config", InternetConfig) | class InternetConfig(BaseBrowser): def open(self, url, new=0, autoraise=1): ic.launchurl(url) return True register("internet-config", InternetConfig, update_tryorder=-1) if sys.platform == 'darwin': class MacOSX(BaseBrowser): """Launcher class for Aqua browsers on Mac OS X Optionally specify a browser name on insta... | def open_new(self, url): self.open(url) |
if sys.platform[:3] == "os2" and _iscommand("netscape.exe"): _tryorder = ["os2netscape"] | if sys.platform[:3] == "os2" and _iscommand("netscape"): _tryorder = [] _browsers = {} | def open_new(self, url): self.open(url) |
GenericBrowser("start netscape.exe %s")) | GenericBrowser("start netscape %s"), -1) | def open_new(self, url): self.open(url) |
_tryorder = os.environ["BROWSER"].split(os.pathsep) for cmd in _tryorder: if not cmd.lower() in _browsers: if _iscommand(cmd.lower()): register(cmd.lower(), None, GenericBrowser( "%s '%%s'" % cmd.lower())) cmd = None del cmd _tryorder = filter(lambda x: x.lower() in _browsers or x.find("%s") > -1, _tryorder) | _userchoices = os.environ["BROWSER"].split(os.pathsep) _userchoices.reverse() for cmdline in _userchoices: if cmdline != '': _synthesize(cmdline, -1) cmdline = None del cmdline del _userchoices | def open_new(self, url): self.open(url) |
s.bind('', self.port) | s.bind(('', self.port)) | def __init__(self, port=None, connection_hook=None): self.connections = [] self.port = port or self.default_port self.connection_hook = connection_hook |
except BClass, v: raise TestFailed except AClass, v: | except BClass, v: | def __init__(self, ignore): |
else: raise TestFailed | def __init__(self, ignore): | |
last = last + 1 | last = min(self.maxx, last+1) | def _end_of_line(self, y): "Go to the location of the first blank on the given line." last = self.maxx while 1: if ascii.ascii(self.win.inch(y, last)) != ascii.SP: last = last + 1 break elif last == 0: break last = last - 1 return last |
parts = ctype.split('/') if len(parts) > 0: return ctype.split('/')[0] return failobj | if ctype.count('/') <> 1: return failobj return ctype.split('/')[0] | def get_main_type(self, failobj=None): """Return the message's main content type if present.""" missing = [] ctype = self.get_type(missing) if ctype is missing: return failobj parts = ctype.split('/') if len(parts) > 0: return ctype.split('/')[0] return failobj |
parts = ctype.split('/') if len(parts) > 1: return ctype.split('/')[1] return failobj | if ctype.count('/') <> 1: return failobj return ctype.split('/')[1] def get_content_type(self): """Returns the message's content type. The returned string is coerced to lowercase and returned as a ingle string of the form `maintype/subtype'. If there was no Content-Type: header in the message, the default type a... | def get_subtype(self, failobj=None): """Return the message's content subtype if present.""" missing = [] ctype = self.get_type(missing) if ctype is missing: return failobj parts = ctype.split('/') if len(parts) > 1: return ctype.split('/')[1] return failobj |
ctype must be either "text/plain" or "message/rfc822". The default content type is not stored in the Content-Type: header. """ if ctype not in ('text/plain', 'message/rfc822'): raise ValueError( 'first arg must be either "text/plain" or "message/rfc822"') | ctype should be either "text/plain" or "message/rfc822", although this is not enforced. The default content type is not stored in the Content-Type: header. """ | def set_default_type(self, ctype): """Set the `default' content type. |
import regex prefix_cache = {} def prefix_regex (needle): if prefix_cache.has_key (needle): return prefix_cache[needle] else: reg = needle[-1] for i in range(1,len(needle)): reg = '%c\(%s\)?' % (needle[-(i+1)], reg) reg = regex.compile (reg+'$') prefix_cache[needle] = reg, len(needle) return reg, len(needle) | def pop (self): if self.list: result = self.list[0] del self.list[0] return (1, result) else: return (0, None) | |
setattr (self, 'install_' + key, scheme[key]) | attrname = 'install_' + key if getattr(self, attrname) is None: setattr(self, attrname, scheme[key]) | def select_scheme (self, name): # it's the caller's problem if they supply a bad name! scheme = INSTALL_SCHEMES[name] for key in ('purelib', 'platlib', 'scripts', 'data'): setattr (self, 'install_' + key, scheme[key]) |
assert isinstance(req, Request) | def open(self, fullurl, data=None): # accept a URL or a Request object if isinstance(fullurl, basestring): req = Request(fullurl, data) else: req = fullurl if data is not None: req.add_data(data) assert isinstance(req, Request) # really only care about interface | |
def findall(pattern, string, maxsplit=0): | def findall(pattern, string): | def findall(pattern, string, maxsplit=0): """Return a list of all non-overlapping matches in the string. If one or more groups are present in the pattern, return a list of groups; this will be a list of tuples if the pattern has more than one group. Empty matches are included in the result.""" return _compile(pattern... |
return _compile(pattern, 0).findall(string, maxsplit) | return _compile(pattern, 0).findall(string) | def findall(pattern, string, maxsplit=0): """Return a list of all non-overlapping matches in the string. If one or more groups are present in the pattern, return a list of groups; this will be a list of tuples if the pattern has more than one group. Empty matches are included in the result.""" return _compile(pattern... |
"n" * newtabwith) | "n" * newtabwidth) | def set_tabwidth(self, newtabwidth): text = self.text if self.get_tabwidth() != newtabwidth: pixels = text.tk.call("font", "measure", text["font"], "-displayof", text.master, "n" * newtabwith) text.configure(tabs=pixels) |
if not callback: callback = print_line | if not callable(callback): callback = print_line | def retrlines(self, cmd, callback = None): '''Retrieve data in line mode. The argument is a RETR or LIST command. The callback function (2nd argument) is called for each line, with trailing CRLF stripped. This creates a new port for you. print_line() is the default callback.''' if not callback: callback = print_line r... |
exc_type, exc_val, exc_tb = sys.exc_info() | exc_type, exc_val = sys.exc_info()[:2] | def _run_examples_inner(out, fakeout, examples, globs, verbose, name): import sys, traceback OK, BOOM, FAIL = range(3) NADA = "nothing" stderr = _SpoofOut() failures = 0 for source, want, lineno in examples: if verbose: _tag_out(out, ("Trying", source), ("Expecting", want or NADA)) fakeout.clear() try: exec compile(sou... |
if isinstance(s, StringType): unicode(s, charset.get_output_charset()) elif isinstance(s, UnicodeType): for charset in USASCII, charset, UTF8: try: s = s.encode(charset.get_output_charset()) break except UnicodeError: pass else: assert False, 'Could not encode to utf-8' | if charset <> '8bit': if isinstance(s, StringType): incodec = charset.input_codec or 'us-ascii' ustr = unicode(s, incodec) outcodec = charset.output_codec or 'us-ascii' ustr.encode(outcodec) elif isinstance(s, UnicodeType): for charset in USASCII, charset, UTF8: try: outcodec = charset.output_codec or 'us-as... | def append(self, s, charset=None): """Append a string to the MIME header. |
typ, dat = self._simple_command('GETQUOTA', mailbox) | typ, dat = self._simple_command('GETQUOTAROOT', mailbox) | def getquotaroot(self, mailbox): """Get the list of quota roots for the named mailbox. |
""" | Mandated responses are ('FLAGS', 'EXISTS', 'RECENT', 'UIDVALIDITY'), so other responses should be obtained via <instance>.response('FLAGS') etc. """ | def select(self, mailbox='INBOX', readonly=None): """Select a mailbox. |
try: ignore = posix.fdopen except: raise AttributeError, 'dup() method unavailable' | if not hasattr(posix, 'fdopen'): raise AttributeError, 'dup() method unavailable' | def dup(self): import posix |
try: ignore = posix.fdopen except: raise AttributeError, 'dup() method unavailable' | if not hasattr(posix, 'fdopen'): raise AttributeError, 'dup() method unavailable' | def dup2(self, fd): import posix |
fn = os.path.join(fn, os.pardir, os.pardir, "Doc", "index.html") | fn = os.path.join(fn, os.pardir, os.pardir, "pythlp.chm") | def help_dialog(self, event=None): fn=os.path.join(os.path.abspath(os.path.dirname(__file__)),'help.txt') textView.TextViewer(self.top,'Help',fn) |
def python_docs(self, event=None): self.display_docs(self.help_url) | def python_docs(self, event=None): os.startfile(self.help_url) else: def python_docs(self, event=None): self.display_docs(self.help_url) | def help_dialog(self, event=None): fn=os.path.join(os.path.abspath(os.path.dirname(__file__)),'help.txt') textView.TextViewer(self.top,'Help',fn) |
self.baseFilename = filename | self.baseFilename = os.path.abspath(filename) | def __init__(self, filename, mode="a"): """ Open the specified file and use it as the stream for logging. """ StreamHandler.__init__(self, open(filename, mode)) self.baseFilename = filename self.mode = mode |
return Utils.collapse_rfc2231_value(boundary).strip() | return Utils.collapse_rfc2231_value(boundary).rstrip() | def get_boundary(self, failobj=None): """Return the boundary associated with the payload if present. |
'recv', 'recvfrom', 'send', 'sendall', 'sendto', 'setblocking', | 'sendall', 'setblocking', | def getfqdn(name=''): """Get fully qualified domain name from name. An empty argument is interpreted as meaning the local host. First the hostname returned by gethostbyaddr() is checked, then possibly existing aliases. In case no FQDN is available, hostname is returned. """ name = name.strip() if not name or name == ... |
def __getattr__(self, name): | def _dummy(*args): | def __getattr__(self, name): raise error(9, 'Bad file descriptor') |
__slots__ = ["_sock"] | __slots__ = ["_sock", "send", "recv", "sendto", "recvfrom"] | def __getattr__(self, name): raise error(9, 'Bad file descriptor') |
return self.dict.len() | return len(self.dict) | def __len__(self): return self.dict.len() |
if sys.platform == "darwin": supports_unicode_filenames = True else: supports_unicode_filenames = False | supports_unicode_filenames = False | def realpath(filename): """Return the canonical path of the specified filename, eliminating any |
def_op('RAISE_VARARGS', 130) def_op('CALL_FUNCTION', 131) def_op('MAKE_FUNCTION', 132) def_op('BUILD_SLICE', 133) | def_op('RAISE_VARARGS', 130) def_op('CALL_FUNCTION', 131) def_op('MAKE_FUNCTION', 132) def_op('BUILD_SLICE', 133) def_op('CALL_FUNCTION_VAR', 140) def_op('CALL_FUNCTION_KW', 141) def_op('CALL_FUNCTION_VAR_KW', 142) | def jabs_op(name, op): opname[op] = name hasjabs.append(op) |
self.fp.write("\n%s = %s\n"%(pname, othername)) | self.fp.write("\n_Prop_%s = _Prop_%s\n"%(pname, othername)) | def compileproperty(self, prop): [name, code, what] = prop if code == 'c@#!': # Something silly with plurals. Skip it. return pname = identify(name) if self.namemappers[0].hascode('property', code): # plural forms and such othername, dummy, dummy = self.namemappers[0].findcodename('property', code) if pname == othernam... |
self.fp.write("class %s(aetools.NProperty):\n" % pname) | self.fp.write("class _Prop_%s(aetools.NProperty):\n" % pname) | def compileproperty(self, prop): [name, code, what] = prop if code == 'c@#!': # Something silly with plurals. Skip it. return pname = identify(name) if self.namemappers[0].hascode('property', code): # plural forms and such othername, dummy, dummy = self.namemappers[0].findcodename('property', code) if pname == othernam... |
self.fp.write("\t'%s' : %s,\n"%(n, n)) | self.fp.write("\t'%s' : _Prop_%s,\n"%(n, n)) | def fillclasspropsandelems(self, cls): [name, code, desc, properties, elements] = cls cname = identify(name) if self.namemappers[0].hascode('class', code) and \ self.namemappers[0].findcodename('class', code)[0] != cname: # This is an other name (plural or so) for something else. Skip. if self.fp and (elements or len(p... |
self.fp.write("\n_propdeclarations = {\n") proplist = self.namemappers[0].getall('property') proplist.sort() for k, v in proplist: self.fp.write("\t%s : %s,\n" % (`k`, v)) self.fp.write("}\n") self.fp.write("\n_compdeclarations = {\n") complist = self.namemappers[0].getall('comparison') complist.sort() for k, v in com... | def dumpindex(self): if not self.fp: return self.fp.write("\n#\n# Indices of types declared in this module\n#\n") self.fp.write("_classdeclarations = {\n") classlist = self.namemappers[0].getall('class') classlist.sort() for k, v in classlist: self.fp.write("\t%s : %s,\n" % (`k`, v)) self.fp.write("}\n") self.fp.writ... | |
Pack the values v2, v2, ... according to fmt, write | Pack the values v1, v2, ... according to fmt, write | def pack_into(fmt, buf, offset, *args): """ Pack the values v2, v2, ... according to fmt, write the packed bytes into the writable buffer buf starting at offset. See struct.__doc__ for more on format strings. """ try: o = _cache[fmt] except KeyError: o = _compile(fmt) return o.pack_into(buf, offset, *args) |
langdict = {} | nelangs = [] | def find(domain, localedir=None, languages=None): # Get some reasonable defaults for arguments that were not supplied if localedir is None: localedir = _default_localedir if languages is None: languages = [] for envar in ('LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG'): val = os.environ.get(envar) if val: languages = val.... |
langdict[nelang] = nelang languages = langdict.keys() | if nelang not in nelangs: nelangs.append(nelang) | def find(domain, localedir=None, languages=None): # Get some reasonable defaults for arguments that were not supplied if localedir is None: localedir = _default_localedir if languages is None: languages = [] for envar in ('LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG'): val = os.environ.get(envar) if val: languages = val.... |
for lang in languages: | for lang in nelangs: | def find(domain, localedir=None, languages=None): # Get some reasonable defaults for arguments that were not supplied if localedir is None: localedir = _default_localedir if languages is None: languages = [] for envar in ('LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG'): val = os.environ.get(envar) if val: languages = val.... |
This (mostly) supports the API for Cryptographic Hash Functions (PEP 247). | This supports the API for Cryptographic Hash Functions (PEP 247). | def _strxor(s1, s2): """Utility method. XOR the two strings s1 and s2 (must have same length). """ return "".join(map(lambda x, y: chr(ord(x) ^ ord(y)), s1, s2)) |
self.digest_size = digestmod.digest_size | def __init__(self, key, msg = None, digestmod = None): """Create a new HMAC object. | |
return HMAC(self) | other = HMAC("") other.digestmod = self.digestmod other.inner = self.inner.copy() other.outer = self.outer.copy() return other | def copy(self): """Return a separate copy of this hashing object. |
def test(): def md5test(key, data, digest): h = HMAC(key, data) assert(h.hexdigest().upper() == digest.upper()) md5test(chr(0x0b) * 16, "Hi There", "9294727A3638BB1C13F48EF8158BFC9D") md5test("Jefe", "what do ya want for nothing?", "750c783e6ab0b503eaa86e310a5db738") md5test(chr(0xAA)*16, chr(0xDD)*50, "56be34521d1... | def test(): def md5test(key, data, digest): h = HMAC(key, data) assert(h.hexdigest().upper() == digest.upper()) # Test vectors from the RFC md5test(chr(0x0b) * 16, "Hi There", "9294727A3638BB1C13F48EF8158BFC9D") md5test("Jefe", "what do ya want for nothing?", "750c783e6ab0b503eaa86e310a5db738") md5test(chr(0xAA)*16,... | |
if not self._dict['MD5Sum']: | if not self._dict.get('MD5Sum'): | def _archiveOK(self): """Test an archive. It should exist and the MD5 checksum should be correct.""" if not os.path.exists(self.archiveFilename): return 0 if not self._dict['MD5Sum']: sys.stderr.write("Warning: no MD5Sum for %s\n" % self.fullname()) return 1 data = open(self.archiveFilename, 'rb').read() checksum = md... |
def configure(self, cnf=None, **kw): """Configure resources of a widget. The values for resources are specified as keyword arguments. To get an overview about the allowed keyword arguments call the method keys. """ | def _configure(self, cmd, cnf, kw): """Internal function.""" | def _report_exception(self): """Internal function.""" import sys exc, val, tb = sys.exc_type, sys.exc_value, sys.exc_traceback root = self._root() root.report_callback_exception(exc, val, tb) |
self.tk.call(self._w, 'configure')): | self.tk.call(_flatten((self._w, cmd)))): | def configure(self, cnf=None, **kw): """Configure resources of a widget. |
x = self.tk.split(self.tk.call( self._w, 'configure', '-'+cnf)) | x = self.tk.split( self.tk.call(_flatten((self._w, cmd, '-'+cnf)))) | def configure(self, cnf=None, **kw): """Configure resources of a widget. |
self.tk.call((self._w, 'configure') + self._options(cnf)) | self.tk.call(_flatten((self._w, cmd)) + self._options(cnf)) def configure(self, cnf=None, **kw): """Configure resources of a widget. The values for resources are specified as keyword arguments. To get an overview about the allowed keyword arguments call the method keys. """ return self._configure('configure', cnf, kw... | def configure(self, cnf=None, **kw): """Configure resources of a widget. |
if cnf is None and not kw: cnf = {} for x in self.tk.split( self.tk.call(self._w, 'itemconfigure', tagOrId)): cnf[x[0][1:]] = (x[0][1:],) + x[1:] return cnf if type(cnf) == StringType and not kw: x = self.tk.split(self.tk.call( self._w, 'itemconfigure', tagOrId, '-'+cnf)) return (x[0][1:],) + x[1:] self.tk.call((self._... | return self._configure(('itemconfigure', tagOrId), cnf, kw) | def itemconfigure(self, tagOrId, cnf=None, **kw): """Configure resources of an item TAGORID. |
if cnf is None and not kw: cnf = {} for x in self.tk.split( self.tk.call(self._w, 'itemconfigure', index)): cnf[x[0][1:]] = (x[0][1:],) + x[1:] return cnf if type(cnf) == StringType and not kw: x = self.tk.split(self.tk.call( self._w, 'itemconfigure', index, '-'+cnf)) return (x[0][1:],) + x[1:] self.tk.call((self._w, '... | return self._configure(('itemconfigure', index), cnf, kw) | def itemconfigure(self, index, cnf=None, **kw): """Configure resources of an ITEM. |
if cnf is None and not kw: cnf = {} for x in self.tk.split(self.tk.call( (self._w, 'entryconfigure', index))): cnf[x[0][1:]] = (x[0][1:],) + x[1:] return cnf if type(cnf) == StringType and not kw: x = self.tk.split(self.tk.call( (self._w, 'entryconfigure', index, '-'+cnf))) return (x[0][1:],) + x[1:] self.tk.call((self... | return self._configure(('entryconfigure', index), cnf, kw) | def entryconfigure(self, index, cnf=None, **kw): """Configure a menu item at INDEX.""" if cnf is None and not kw: cnf = {} for x in self.tk.split(self.tk.call( (self._w, 'entryconfigure', index))): cnf[x[0][1:]] = (x[0][1:],) + x[1:] return cnf if type(cnf) == StringType and not kw: x = self.tk.split(self.tk.call( (sel... |
def image_configure(self, index, cnf={}, **kw): | def image_configure(self, index, cnf=None, **kw): | def image_configure(self, index, cnf={}, **kw): """Configure an embedded image at INDEX.""" if not cnf and not kw: cnf = {} for x in self.tk.split( self.tk.call( self._w, "image", "configure", index)): cnf[x[0][1:]] = (x[0][1:],) + x[1:] return cnf apply(self.tk.call, (self._w, "image", "configure", index) + self._opti... |
if not cnf and not kw: cnf = {} for x in self.tk.split( self.tk.call( self._w, "image", "configure", index)): cnf[x[0][1:]] = (x[0][1:],) + x[1:] return cnf apply(self.tk.call, (self._w, "image", "configure", index) + self._options(cnf, kw)) | return self._configure(('image', 'configure', index), cnf, kw) | def image_configure(self, index, cnf={}, **kw): """Configure an embedded image at INDEX.""" if not cnf and not kw: cnf = {} for x in self.tk.split( self.tk.call( self._w, "image", "configure", index)): cnf[x[0][1:]] = (x[0][1:],) + x[1:] return cnf apply(self.tk.call, (self._w, "image", "configure", index) + self._opti... |
def tag_configure(self, tagName, cnf={}, **kw): | def tag_configure(self, tagName, cnf=None, **kw): | def tag_configure(self, tagName, cnf={}, **kw): """Configure a tag TAGNAME.""" if type(cnf) == StringType: x = self.tk.split(self.tk.call( self._w, 'tag', 'configure', tagName, '-'+cnf)) return (x[0][1:],) + x[1:] self.tk.call( (self._w, 'tag', 'configure', tagName) + self._options(cnf, kw)) |
if type(cnf) == StringType: x = self.tk.split(self.tk.call( self._w, 'tag', 'configure', tagName, '-'+cnf)) return (x[0][1:],) + x[1:] self.tk.call( (self._w, 'tag', 'configure', tagName) + self._options(cnf, kw)) | return self._configure(('tag', 'configure', tagName), cnf, kw) | def tag_configure(self, tagName, cnf={}, **kw): """Configure a tag TAGNAME.""" if type(cnf) == StringType: x = self.tk.split(self.tk.call( self._w, 'tag', 'configure', tagName, '-'+cnf)) return (x[0][1:],) + x[1:] self.tk.call( (self._w, 'tag', 'configure', tagName) + self._options(cnf, kw)) |
def window_configure(self, index, cnf={}, **kw): | def window_configure(self, index, cnf=None, **kw): | def window_configure(self, index, cnf={}, **kw): """Configure an embedded window at INDEX.""" if type(cnf) == StringType: x = self.tk.split(self.tk.call( self._w, 'window', 'configure', index, '-'+cnf)) return (x[0][1:],) + x[1:] self.tk.call( (self._w, 'window', 'configure', index) + self._options(cnf, kw)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.