rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
import string | def __init__(self, dirname): import string self.dirname = dirname | |
import string | def _test(): import time import sys import string import os args = sys.argv[1:] if not args: for key in 'MAILDIR', 'MAIL', 'LOGNAME', 'USER': if os.environ.has_key(key): mbox = os.environ[key] break else: print "$MAIL, $LOGNAME nor $USER set -- who are you?" return else: mbox = args[0] if mbox[:1] == '+': mbox = os.en... | |
num = string.atoi(args[1]) | num = int(args[1]) | def _test(): import time import sys import string import os args = sys.argv[1:] if not args: for key in 'MAILDIR', 'MAIL', 'LOGNAME', 'USER': if os.environ.has_key(key): mbox = os.environ[key] break else: print "$MAIL, $LOGNAME nor $USER set -- who are you?" return else: mbox = args[0] if mbox[:1] == '+': mbox = os.en... |
self.literal = message | self.literal = MapCRLF.sub(CRLF, message) | def append(self, mailbox, flags, date_time, message): """Append message to named mailbox. |
test_mesg = 'From: %(user)s@localhost%(lf)sSubject: IMAP4 test%(lf)s%(lf)sdata...%(lf)s' % {'user':USER, 'lf':CRLF} | test_mesg = 'From: %(user)s@localhost%(lf)sSubject: IMAP4 test%(lf)s%(lf)sdata...%(lf)s' % {'user':USER, 'lf':'\n'} | def Time2Internaldate(date_time): """Convert 'date_time' to IMAP4 INTERNALDATE representation. Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"' """ if isinstance(date_time, (int, float)): tt = time.localtime(date_time) elif isinstance(date_time, (tuple, time.struct_time)): tt = date_time elif isinstance(date_ti... |
class IEEEOperationsTestCase(unittest.TestCase): if float.__getformat__("double").startswith("IEEE"): def test_double_infinity(self): big = 4.8e159 pro = big*big self.assertEquals(repr(pro), 'inf') sqr = big**2 self.assertEquals(repr(sqr), 'inf') | def test_float_specials_do_unpack(self): for fmt, data in [('>f', BE_FLOAT_INF), ('>f', BE_FLOAT_NAN), ('<f', LE_FLOAT_INF), ('<f', LE_FLOAT_NAN)]: struct.unpack(fmt, data) | |
IEEEFormatTestCase, IEEEOperationsTestCase, ) | IEEEFormatTestCase) | def test_main(): test_support.run_unittest( FormatFunctionsTestCase, UnknownFormatTestCase, IEEEFormatTestCase, IEEEOperationsTestCase, ) |
index = terminator.find (self.ac_in_buffer) | index = ac_in_buffer.find (self.terminator) | def handle_read (self): |
capability_name = _capability_names[ch] | capability_name = _capability_names.get(ch) if capability_name is None: return 0 | def has_key(ch): if type(ch) == type( '' ): ch = ord(ch) # Figure out the correct capability name for the keycode. capability_name = _capability_names[ch] #Check the current terminal description for that capability; #if present, return true, else return false. if _curses.tigetstr( capability_name ): return 1 else: re... |
if lastcs is not None: if nextcs is None or nextcs == 'us-ascii': | if lastcs not in (None, 'us-ascii'): if nextcs in (None, 'us-ascii'): | def __unicode__(self): """Helper for the built-in unicode function.""" uchunks = [] lastcs = None for s, charset in self._chunks: # We must preserve spaces between encoded and non-encoded word # boundaries, which means for us we need to add a space when we go # from a charset to None/us-ascii, or from None/us-ascii to ... |
elif nextcs is not None and nextcs <> 'us-ascii': | elif nextcs not in (None, 'us-ascii'): | def __unicode__(self): """Helper for the built-in unicode function.""" uchunks = [] lastcs = None for s, charset in self._chunks: # We must preserve spaces between encoded and non-encoded word # boundaries, which means for us we need to add a space when we go # from a charset to None/us-ascii, or from None/us-ascii to ... |
readermode=None): | readermode=None, usenetrc=True): | def __init__(self, host, port=NNTP_PORT, user=None, password=None, readermode=None): """Initialize an instance. Arguments: - host: hostname to connect to - port: port to connect to (default the standard NNTP port) - user: username to authenticate with - password: password to use with username - readermode: if true, se... |
if not user: | if usenetrc and not user: | def __init__(self, host, port=NNTP_PORT, user=None, password=None, readermode=None): """Initialize an instance. Arguments: - host: hostname to connect to - port: port to connect to (default the standard NNTP port) - user: username to authenticate with - password: password to use with username - readermode: if true, se... |
all, scheme, rfc, selfdot, name = match.groups() | all, scheme, rfc, pep, selfdot, name = match.groups() | def markup(self, text, escape=None, funcs={}, classes={}, methods={}): """Mark up some plain text, given a context of symbols to look for. Each context dictionary maps object names to anchor names.""" escape = escape or self.escape results = [] here = 0 pattern = re.compile(r'\b((http|ftp)://\S+[\w/]|' r'RFC[- ]?(\d+)|... |
url = 'http://www.rfc-editor.org/rfc/rfc%s.txt' % rfc | url = 'http://www.rfc-editor.org/rfc/rfc%d.txt' % int(rfc) results.append('<a href="%s">%s</a>' % (url, escape(all))) elif pep: url = 'http://www.python.org/peps/pep-%04d.html' % int(pep) | def markup(self, text, escape=None, funcs={}, classes={}, methods={}): """Mark up some plain text, given a context of symbols to look for. Each context dictionary maps object names to anchor names.""" escape = escape or self.escape results = [] here = 0 pattern = re.compile(r'\b((http|ftp)://\S+[\w/]|' r'RFC[- ]?(\d+)|... |
if cache.has_key(path) and cache[path] != info: module = reload(module) | if cache.get(path) == info: continue module = reload(module) | def freshimport(name, cache={}): """Import a module, reloading it if the source file has changed.""" topmodule = __import__(name) module = None for component in split(name, '.'): if module == None: module = topmodule path = split(name, '.')[0] else: module = getattr(module, component) path = path + '.' + component if h... |
return '''To get help on a Python object, call help(object). | return '''Welcome to Python %s! To get help on a Python object, call help(object). | def __repr__(self): return '''To get help on a Python object, call help(object). |
help(module) or call help('modulename').''' | help(module) or call help('modulename').''' % sys.version[:3] | def __repr__(self): return '''To get help on a Python object, call help(object). |
(typ, [data]) = <instance>.create(mailbox, who, what) | (typ, [data]) = <instance>.setacl(mailbox, who, what) | def setacl(self, mailbox, who, what): """Set a mailbox acl. |
simple_err(struct.pack, "Q", -1) | any_err(struct.pack, "Q", -1) | def simple_err(func, *args): try: apply(func, args) except struct.error: pass else: raise TestFailed, "%s%s did not raise struct.error" % ( func.__name__, args) |
chars = list(value) chars.reverse() return "".join(chars) if has_native_qQ: | else: return string_reverse(value) def test_native_qQ(): | def bigendian_to_native(value): if isbigendian: return value chars = list(value) chars.reverse() return "".join(chars) |
print "before _get_package_data():" print "vendor =", self.vendor print "packager =", self.packager print "doc_files =", self.doc_files print "changelog =", self.changelog | if DEBUG: print "before _get_package_data():" print "vendor =", self.vendor print "packager =", self.packager print "doc_files =", self.doc_files print "changelog =", self.changelog | def run (self): |
if line == '\037\014\n': | if line == '\037\014\n' or line == '\037': | def _search_end(self): while 1: pos = self.fp.tell() line = self.fp.readline() if not line: return if line == '\037\014\n': self.fp.seek(pos) return |
args = ('wm', 'colormapwindows', self._w) + _flatten(wlist) | if len(wlist) > 1: wlist = (wlist,) args = ('wm', 'colormapwindows', self._w) + wlist | def wm_colormapwindows(self, *wlist): args = ('wm', 'colormapwindows', self._w) + _flatten(wlist) return map(self._nametowidget, self.tk.call(args)) |
env['CONTENT_TYPE'] = self.headers.type | if self.headers.typeheader is None: env['CONTENT_TYPE'] = self.headers.type else: env['CONTENT_TYPE'] = self.headers.typeheader | def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = string.rfind(rest, '?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = string.find(rest, '/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.tran... |
if self.debuglevel > 0: print 'connect:', (host, port) | if self.debuglevel > 0: print>>stderr, 'connect:', (host, port) | def connect(self, host='localhost', port = 0): """Connect to a host on a given port. |
if self.debuglevel > 0: print 'connect fail:', (host, port) | if self.debuglevel > 0: print>>stderr, 'connect fail:', (host, port) | def connect(self, host='localhost', port = 0): """Connect to a host on a given port. |
if self.debuglevel > 0: print "connect:", msg | if self.debuglevel > 0: print>>stderr, "connect:", msg | def connect(self, host='localhost', port = 0): """Connect to a host on a given port. |
if self.debuglevel > 0: print 'send:', repr(str) | if self.debuglevel > 0: print>>stderr, 'send:', repr(str) | def send(self, str): """Send `str' to the server.""" if self.debuglevel > 0: print 'send:', repr(str) if self.sock: try: self.sock.sendall(str) except socket.error: self.close() raise SMTPServerDisconnected('Server not connected') else: raise SMTPServerDisconnected('please run connect() first') |
if self.debuglevel > 0: print 'reply:', repr(line) | if self.debuglevel > 0: print>>stderr, 'reply:', repr(line) | def getreply(self): """Get a reply from the server. |
print 'reply: retcode (%s); Msg: %s' % (errcode,errmsg) | print>>stderr, 'reply: retcode (%s); Msg: %s' % (errcode,errmsg) | def getreply(self): """Get a reply from the server. |
if self.debuglevel >0 : print "data:", (code,repl) | if self.debuglevel >0 : print>>stderr, "data:", (code,repl) | def data(self,msg): """SMTP 'DATA' command -- sends message data to server. |
if self.debuglevel >0 : print "data:", (code,msg) | if self.debuglevel >0 : print>>stderr, "data:", (code,msg) | def data(self,msg): """SMTP 'DATA' command -- sends message data to server. |
... def f(): | ... def _f(): | ... def f(): |
>>> d = {"_f": m1.f, "g": m1.g, "h": m1.H, ... "f2": m2.f, "g2": m2.g, "h2": m2.H} | ... def bar(self): | |
>>> t.rundict(d, "rundict_test", m1) | >>> t.rundict(m1.__dict__, "rundict_test", m1) | ... def bar(self): |
>>> t.rundict(d, "rundict_test_pvt", m1) | >>> t.rundict(m1.__dict__, "rundict_test_pvt", m1) | ... def bar(self): |
>>> t.rundict(d, "rundict_test_pvt") | >>> t.rundict(m1.__dict__, "rundict_test_pvt") | ... def bar(self): |
f, t = tester.rundict(m.__dict__, name) | f, t = tester.rundict(m.__dict__, name, m) | def testmod(m, name=None, globs=None, verbose=None, isprivate=None, report=1): """m, name=None, globs=None, verbose=None, isprivate=None, report=1 Test examples in docstrings in functions and classes reachable from module m, starting with m.__doc__. Private names are skipped. Also test examples reachable from dict m... |
[("MyInBuffer", 'inDataPtr', "InMode")]) | [("MyInBuffer", 'inDataPtr', "InMode")]), ([("Boolean", 'ioWasInRgn', "OutMode")], [("Boolean", 'ioWasInRgn', "InOutMode")]), | def makerepairinstructions(self): return [ ([("UInt32", 'inSize', "InMode"), ("void_ptr", 'inDataPtr', "InMode")], [("MyInBuffer", 'inDataPtr', "InMode")]) ] |
print ("bdist.run: format=%s, command=%s, rest=%s" % (self.formats[i], cmd_name, commands[i+1:])) | def run (self): | |
os.fsync(f.fileno()) | if hasattr(os, 'fsync'): os.fsync(f.fileno()) | def _sync_flush(f): """Ensure changes to file f are physically on disk.""" f.flush() os.fsync(f.fileno()) |
self.dict[headerseen] = string.strip(line[len(headerseen)+2:]) | self.dict[headerseen] = string.strip(line[len(headerseen)+1:]) | def readheaders(self): """Read header lines. Read header lines up to the entirely blank line that terminates them. The (normally blank) line that ends the headers is skipped, but not included in the returned list. If a non-header line ends the headers, (which is an error), an attempt is made to backspace over it; it ... |
"""Signals the start of an element. | def endElement(self, name): """Signals the end of an element in non-namespace mode. The name parameter contains the name of the element type, just as with the startElement event.""" def startElementNS(self, name, qname, attrs): """Signals the start of an element in namespace mode. | def startElement(self, name, attrs): """Signals the start of an element. |
def endElement(self, name ): """Signals the end of an element. | def endElementNS(self, name, qname): """Signals the end of an element in namespace mode. | def endElement(self, name ): """Signals the end of an element. |
as with the startElement event.""" | as with the startElementNS event.""" | def endElement(self, name ): """Signals the end of an element. |
{'code': code, 'message': message, 'explain': explain}) | {'code': code, 'message': _quote_html(message), 'explain': explain}) | def send_error(self, code, message=None): """Send and log an error reply. |
child.id = None | child.my_id = None | def my_ringer(child): child.id = None stdwin.fleep() |
WindowSched.enter(child.my_number*1000, 0, my_ringer, child) | WindowSched.enter(child.my_number*1000, 0, my_ringer, (child,)) | def my_hook(child): # schedule for the bell to ring in N seconds; cancel previous if child.my_id: WindowSched.cancel(child.my_id) child.my_id = \ WindowSched.enter(child.my_number*1000, 0, my_ringer, child) |
self._parseheaders(root, fp) | firstbodyline = self._parseheaders(root, fp) | def parse(self, fp, headersonly=False): """Create a message structure from the data in a file. |
self._parsebody(root, fp) | self._parsebody(root, fp, firstbodyline) | def parse(self, fp, headersonly=False): """Create a message structure from the data in a file. |
raise Errors.HeaderParseError( "Not a header, not a continuation: ``%s''"%line) | firstbodyline = line break | def _parseheaders(self, container, fp): # Parse the headers, returning a list of header/value pairs. None as # the header means the Unix-From header. lastheader = '' lastvalue = [] lineno = 0 while True: # Don't strip the line before we test for the end condition, # because whitespace-only header lines are RFC complia... |
def _parsebody(self, container, fp): | return firstbodyline def _parsebody(self, container, fp, firstbodyline=None): | def _parseheaders(self, container, fp): # Parse the headers, returning a list of header/value pairs. None as # the header means the Unix-From header. lastheader = '' lastvalue = [] lineno = 0 while True: # Don't strip the line before we test for the end condition, # because whitespace-only header lines are RFC complia... |
container.set_payload(fp.read()) | text = fp.read() if firstbodyline is not None: text = firstbodyline + '\n' + text container.set_payload(text) | def _parsebody(self, container, fp): # Parse the body, but first split the payload on the content-type # boundary if present. boundary = container.get_boundary() isdigest = (container.get_content_type() == 'multipart/digest') # If there's a boundary, split the payload text into its constituent # parts and parse each se... |
def __init__(self, root, flist, stack=None): self.top = top = ListedToplevel(root) top.protocol("WM_DELETE_WINDOW", self.close) top.bind("<Key-Escape>", self.close) top.wm_title("Stack viewer") top.wm_iconname("Stack") self.helplabel = Label(top, text="Click once to view variables; twice for source", borderwidth=2, re... | def __init__(self, flist=None): self.flist = flist self.stack = get_stack() self.text = get_exception() | def __init__(self, root, flist, stack=None): self.top = top = ListedToplevel(root) top.protocol("WM_DELETE_WINDOW", self.close) top.bind("<Key-Escape>", self.close) top.wm_title("Stack viewer") top.wm_iconname("Stack") # Create help label self.helplabel = Label(top, text="Click once to view variables; twice for source"... |
def close(self, event=None): self.top.destroy() | def GetText(self): return self.text | def close(self, event=None): self.top.destroy() |
localsframe = None localsviewer = None localsdict = None globalsframe = None globalsviewer = None globalsdict = None curframe = None | def GetSubList(self): sublist = [] for info in self.stack: item = FrameTreeItem(info, self.flist) sublist.append(item) return sublist | def close(self, event=None): self.top.destroy() |
def show_frame(self, (frame, lineno)): if frame is self.curframe: return self.curframe = None if frame.f_globals is not self.globalsdict: self.show_globals(frame) self.show_locals(frame) self.curframe = frame | class FrameTreeItem(TreeItem): | def show_frame(self, (frame, lineno)): if frame is self.curframe: return self.curframe = None if frame.f_globals is not self.globalsdict: self.show_globals(frame) self.show_locals(frame) self.curframe = frame |
def show_globals(self, frame): title = "Global Variables" if frame.f_globals.has_key("__name__"): try: name = str(frame.f_globals["__name__"]) + "" except: name = "" if name: title = title + " in module " + name self.globalsdict = None if self.globalsviewer: self.globalsviewer.close() self.globalsviewer = None if not s... | def __init__(self, info, flist): self.info = info self.flist = flist | def show_globals(self, frame): title = "Global Variables" if frame.f_globals.has_key("__name__"): try: name = str(frame.f_globals["__name__"]) + "" except: name = "" if name: title = title + " in module " + name self.globalsdict = None if self.globalsviewer: self.globalsviewer.close() self.globalsviewer = None if not s... |
def show_locals(self, frame): self.localsdict = None if self.localsviewer: self.localsviewer.close() self.localsviewer = None if frame.f_locals is not frame.f_globals: title = "Local Variables" code = frame.f_code funcname = code.co_name if funcname not in ("?", "", None): title = title + " in " + funcname if not self.... | def GetText(self): frame, lineno = self.info try: modname = frame.f_globals["__name__"] except: modname = "?" | def show_locals(self, frame): self.localsdict = None if self.localsviewer: self.localsviewer.close() self.localsviewer = None if frame.f_locals is not frame.f_globals: title = "Local Variables" code = frame.f_code funcname = code.co_name if funcname not in ("?", "", None): title = title + " in " + funcname if not self.... |
if os.path.isfile(filename): | funcname = code.co_name sourceline = linecache.getline(filename, lineno) sourceline = string.strip(sourceline) if funcname in ("?", "", None): item = "%s, line %d: %s" % (modname, lineno, sourceline) else: item = "%s.%s(...), line %d: %s" % (modname, funcname, lineno, sourceline) return item def GetSubList(self): fr... | def show_source(self, index): if not (0 <= index < len(self.stack)): return frame, lineno = self.stack[index] code = frame.f_code filename = code.co_filename if os.path.isfile(filename): edit = self.flist.open(filename) if edit: edit.gotoline(lineno) |
if edit: edit.gotoline(lineno) | edit.gotoline(lineno) | def show_source(self, index): if not (0 <= index < len(self.stack)): return frame, lineno = self.stack[index] code = frame.f_code filename = code.co_filename if os.path.isfile(filename): edit = self.flist.open(filename) if edit: edit.gotoline(lineno) |
def getexception(type=None, value=None): | def get_exception(type=None, value=None): | def get_stack(t=None, f=None): if t is None: t = sys.last_traceback stack = [] if t and t.tb_frame is f: t = t.tb_next while f is not None: stack.append((f, f.f_lineno)) if f is self.botframe: break f = f.f_back stack.reverse() while t is not None: stack.append((t.tb_frame, t.tb_lineno)) t = t.tb_next return stack |
class NamespaceViewer: def __init__(self, master, title, dict=None): width = 0 height = 40 if dict: height = 20*len(dict) self.master = master self.title = title self.repr = Repr() self.repr.maxstring = 60 self.repr.maxother = 60 self.frame = frame = Frame(master) self.frame.pack(expand=1, fill="both") self.label = La... | if __name__ == "__main__": root = Tk() root.withdraw() StackBrowser(root) | def getexception(type=None, value=None): if type is None: type = sys.last_type value = sys.last_value if hasattr(type, "__name__"): type = type.__name__ s = str(type) if value is not None: s = s + ": " + str(value) return s |
Aassumes that the line does *not* end with \r\n. | Assumes that the line does *not* end with \\r\\n. | def _output(self, s): """Add a line of output to the current request buffer. Aassumes that the line does *not* end with \r\n. """ self._buffer.append(s) |
Appends an extra \r\n to the buffer. | Appends an extra \\r\\n to the buffer. | def _send_output(self): """Send the currently buffered request and clear the buffer. |
self.compiler = new_compiler (verbose=self.verbose, | self.compiler = new_compiler (compiler=self.compiler, verbose=self.verbose, | def run (self): |
while 1: | while formlength > 0: | def initfp(self, file): self._file = file self._version = 0 self._decomp = None self._markers = [] self._soundpos = 0 form = self._file.read(4) if form != 'FORM': raise Error, 'file does not start with FORM id' formlength = _read_long(self._file) if formlength <= 0: raise Error, 'invalid FORM chunk data size' formdata ... |
try: chunk = Chunk().init(self._file) except EOFError: raise Error, 'COMM chunk and/or SSND chunk missing' | chunk = Chunk().init(self._file) | def initfp(self, file): self._file = file self._version = 0 self._decomp = None self._markers = [] self._soundpos = 0 form = self._file.read(4) if form != 'FORM': raise Error, 'file does not start with FORM id' formlength = _read_long(self._file) if formlength <= 0: raise Error, 'invalid FORM chunk data size' formdata ... |
if formlength <= 0: if not self._comm_chunk_read: raise Error, 'COMM chunk missing' break | def initfp(self, file): self._file = file self._version = 0 self._decomp = None self._markers = [] self._soundpos = 0 form = self._file.read(4) if form != 'FORM': raise Error, 'file does not start with FORM id' formlength = _read_long(self._file) if formlength <= 0: raise Error, 'invalid FORM chunk data size' formdata ... | |
def setmark(self, (id, pos, name)): | def setmark(self, id, pos, name): | def setmark(self, (id, pos, name)): if id <= 0: raise Error, 'marker ID must be > 0' if pos < 0: raise Error, 'marker position must be >= 0' if type(name) != type(''): raise Error, 'marker name must be a string' for i in range(len(self._markers)): if id == self._markers[i][0]: self._markers[i] = id, pos, name return se... |
self._nframes == self._nframeswritten: | self._nframes == self._nframeswritten and \ self._marklength == 0: | def _patchheader(self): curpos = self._file.tell() if self._datawritten & 1: datalength = self._datawritten + 1 self._file.write(chr(0)) else: datalength = self._datawritten if datalength == self._datalength and \ self._nframes == self._nframeswritten: self._file.seek(curpos, 0) return self._file.seek(self._form_length... |
_write_short(len(self._file, markers)) | _write_short(self._file, len(self._markers)) | def _writemarkers(self): if len(self._markers) == 0: return self._file.write('MARK') length = 2 for marker in self._markers: id, pos, name = marker length = length + len(name) + 1 + 6 if len(name) & 1 == 0: length = length + 1 _write_long(self._file, length) self._marklength = length + 8 _write_short(len(self._file, ma... |
context = context.copy() | context = copy.deepcopy(context) context.clear_flags() | def setcontext(context): """Set this thread's context to context.""" if context in (DefaultContext, BasicContext, ExtendedContext): context = context.copy() threading.currentThread().__decimal_context__ = context |
context = context.copy() | context = copy.deepcopy(context) context.clear_flags() | def setcontext(context, _local=local): """Set this thread's context to context.""" if context in (DefaultContext, BasicContext, ExtendedContext): context = context.copy() _local.__decimal_context__ = context |
if self._int[prec-1] %2 == 0: | if self._int[prec-1] & 1 == 0: | def _round_half_even(self, prec, expdiff, context): """Round 5 to even, rest to nearest.""" |
if tmp._exp % 2 == 1: | if tmp._exp & 1: | def sqrt(self, context=None): """Return the square root of self. |
if tmp.adjusted() % 2 == 0: | if tmp.adjusted() & 1 == 0: | def sqrt(self, context=None): """Return the square root of self. |
return self._int[-1+self._exp] % 2 == 0 | return self._int[-1+self._exp] & 1 == 0 | def _iseven(self): """Returns 1 if self is even. Assumes self is an integer.""" if self._exp > 0: return 1 return self._int[-1+self._exp] % 2 == 0 |
zinfo.flag_bits = 0x08 | zinfo.flag_bits = 0x00 | def write(self, filename, arcname=None, compress_type=None): """Put the bytes from filename into the archive under the name arcname.""" st = os.stat(filename) mtime = time.localtime(st[8]) date_time = mtime[0:6] # Create ZipInfo instance to store file information if arcname is None: zinfo = ZipInfo(filename, date_time)... |
CRC = 0 compress_size = 0 file_size = 0 | def write(self, filename, arcname=None, compress_type=None): """Put the bytes from filename into the archive under the name arcname.""" st = os.stat(filename) mtime = time.localtime(st[8]) date_time = mtime[0:6] # Create ZipInfo instance to store file information if arcname is None: zinfo = ZipInfo(filename, date_time)... | |
position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) | def write(self, filename, arcname=None, compress_type=None): """Put the bytes from filename into the archive under the name arcname.""" st = os.stat(filename) mtime = time.localtime(st[8]) date_time = mtime[0:6] # Create ZipInfo instance to store file information if arcname is None: zinfo = ZipInfo(filename, date_time)... | |
'euc-jp': 'japanese.euc-jp', 'iso-2022-jp': 'japanese.iso-2022-jp', 'shift_jis': 'japanese.shift_jis', 'euc-kr': 'korean.euc-kr', 'ks_c_5601-1987': 'korean.cp949', 'iso-2022-kr': 'korean.iso-2022-kr', 'johab': 'korean.johab', 'gb2132': 'eucgb2312_cn', | 'gb2312': 'eucgb2312_cn', | def _isunicode(s): return isinstance(s, UnicodeType) |
'utf-8': 'utf-8', | def _isunicode(s): return isinstance(s, UnicodeType) | |
self.input_codec) | self.output_charset) | def __init__(self, input_charset=DEFAULT_CHARSET): # RFC 2046, $4.1.2 says charsets are not case sensitive input_charset = input_charset.lower() # Set the input charset after filtering through the aliases self.input_charset = ALIASES.get(input_charset, input_charset) # We can try to guess which encoding and conversion ... |
e.set_lk_detect(db.DB_LOCK_DEFAULT) | def _openDBEnv(cachesize): e = db.DBEnv() if cachesize is not None: if cachesize >= 20480: e.set_cachesize(0, cachesize) else: raise error, "cachesize must be >= 20480" e.open('.', db.DB_PRIVATE | db.DB_CREATE | db.DB_THREAD | db.DB_INIT_LOCK | db.DB_INIT_MPOOL) e.set_lk_detect(db.DB_LOCK_DEFAULT) return e | |
import sys | def test_main(verbose=None): import sys from test import test_sets test_classes = ( TestSet, TestSetSubclass, TestFrozenSet, TestFrozenSetSubclass, TestSetOfSets, TestExceptionPropagation, TestBasicOpsEmpty, TestBasicOpsSingleton, TestBasicOpsTuple, TestBasicOpsTriple, TestBinaryOps, TestUpdateOps, TestMutate, TestSubs... | |
if ((template_exists and template_newer) or self.force_manifest or self.manifest_only): | if ((template_exists and (template_newer or setup_newer)) or self.force_manifest or self.manifest_only): | def get_file_list (self): """Figure out the list of files to include in the source distribution, and put it in 'self.files'. This might involve reading the manifest template (and writing the manifest), or just reading the manifest, or just using the default file set -- it all depends on the user's options and the stat... |
print>>sys.__stderr__, "** __file__: ", __file__ | def view_readme(self, event=None): print>>sys.__stderr__, "** __file__: ", __file__ fn=os.path.join(os.path.abspath(os.path.dirname(__file__)),'README.txt') textView.TextViewer(self.top,'IDLEfork - README',fn) | |
if kind[0] == 'f' and not re.search('\$IN\b', cmd): | if kind[0] == 'f' and not re.search(r'\$IN\b', cmd): | def append(self, cmd, kind): """t.append(cmd, kind) adds a new step at the end.""" if type(cmd) is not type(''): raise TypeError, \ 'Template.append: cmd must be a string' if kind not in stepkinds: raise ValueError, \ 'Template.append: bad kind ' + `kind` if kind == SOURCE: raise ValueError, \ 'Template.append: SOURCE ... |
if kind[1] == 'f' and not re.search('\$OUT\b', cmd): | if kind[1] == 'f' and not re.search(r'\$OUT\b', cmd): | def append(self, cmd, kind): """t.append(cmd, kind) adds a new step at the end.""" if type(cmd) is not type(''): raise TypeError, \ 'Template.append: cmd must be a string' if kind not in stepkinds: raise ValueError, \ 'Template.append: bad kind ' + `kind` if kind == SOURCE: raise ValueError, \ 'Template.append: SOURCE ... |
if kind[0] == 'f' and not re.search('\$IN\b', cmd): | if kind[0] == 'f' and not re.search(r'\$IN\b', cmd): | def prepend(self, cmd, kind): """t.prepend(cmd, kind) adds a new step at the front.""" if type(cmd) is not type(''): raise TypeError, \ 'Template.prepend: cmd must be a string' if kind not in stepkinds: raise ValueError, \ 'Template.prepend: bad kind ' + `kind` if kind == SINK: raise ValueError, \ 'Template.prepend: SI... |
if kind[1] == 'f' and not re.search('\$OUT\b', cmd): | if kind[1] == 'f' and not re.search(r'\$OUT\b', cmd): | def prepend(self, cmd, kind): """t.prepend(cmd, kind) adds a new step at the front.""" if type(cmd) is not type(''): raise TypeError, \ 'Template.prepend: cmd must be a string' if kind not in stepkinds: raise ValueError, \ 'Template.prepend: bad kind ' + `kind` if kind == SINK: raise ValueError, \ 'Template.prepend: SI... |
version_number = float(version.split('/', 1)[1]) except ValueError: | base_version_number = version.split('/', 1)[1] version_number = base_version_number.split(".") if len(version_number) != 2: raise ValueError version_number = int(version_number[0]), int(version_number[1]) except (ValueError, IndexError): | def parse_request(self): """Parse a request (internal). |
if version_number >= 1.1 and self.protocol_version >= "HTTP/1.1": | if version_number >= (1, 1) and self.protocol_version >= "HTTP/1.1": | def parse_request(self): """Parse a request (internal). |
if version_number >= 2.0: | if version_number >= (2, 0): | def parse_request(self): """Parse a request (internal). |
"Invalid HTTP Version (%f)" % version_number) | "Invalid HTTP Version (%s)" % base_version_number) | def parse_request(self): """Parse a request (internal). |
else: | elif (i + 1) < n: | def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: match = self.interesting.search(rawdata, i) # < or & if match: j = match.start() else: j = n if i < j: self.handle_data(rawdata[i:j]) i = self.updatepos(i, j) if i == n: break if rawdata[i] == '<': if starttagopen.match(rawdata, i): # < ... |
elif rawdata[i] == '&': | elif rawdata[i:i+2] == "& | def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: match = self.interesting.search(rawdata, i) # < or & if match: j = match.start() else: j = n if i < j: self.handle_data(rawdata[i:j]) i = self.updatepos(i, j) if i == n: break if rawdata[i] == '<': if starttagopen.match(rawdata, i): # < ... |
if end and rest != "&" and match.group() == rest: | if end and match.group() == rest: | def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: match = self.interesting.search(rawdata, i) # < or & if match: j = match.start() else: j = n if i < j: self.handle_data(rawdata[i:j]) i = self.updatepos(i, j) if i == n: break if rawdata[i] == '<': if starttagopen.match(rawdata, i): # < ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.