bugged
stringlengths 4
228k
| fixed
stringlengths 0
96.3M
| __index_level_0__
int64 0
481k
|
|---|---|---|
def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically)
|
def __init__(self, master, name, destroy_physically=1): TixSubWidget.__init__(self, master, name, destroy_physically)
| 13,200
|
def finalize_options (self): from distutils import sysconfig
|
def finalize_options (self): from distutils import sysconfig
| 13,201
|
def run (self):
|
def run (self):
| 13,202
|
def __init__(self, dirname): import string self.dirname = dirname
|
def __init__(self, dirname): self.dirname = dirname
| 13,203
|
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.environ['HOME'] + '/Mail/' + mbox[1:] elif not '/' in mbox: mbox = '/usr/mail/' + mbox if os.path.isdir(mbox): if os.path.isdir(os.path.join(mbox, 'cur')): mb = Maildir(mbox) else: mb = MHMailbox(mbox) else: fp = open(mbox, 'r') mb = UnixMailbox(fp) msgs = [] while 1: msg = mb.next() if msg is None: break msgs.append(msg) if len(args) <= 1: msg.fp = None if len(args) > 1: num = string.atoi(args[1]) print 'Message %d body:'%num msg = msgs[num-1] msg.rewindbody() sys.stdout.write(msg.fp.read()) else: print 'Mailbox',mbox,'has',len(msgs),'messages:' for msg in msgs: f = msg.getheader('from') or "" s = msg.getheader('subject') or "" d = msg.getheader('date') or "" print '-%20.20s %20.20s %-30.30s'%(f, d[5:], s)
|
def _test(): import time import sys 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.environ['HOME'] + '/Mail/' + mbox[1:] elif not '/' in mbox: mbox = '/usr/mail/' + mbox if os.path.isdir(mbox): if os.path.isdir(os.path.join(mbox, 'cur')): mb = Maildir(mbox) else: mb = MHMailbox(mbox) else: fp = open(mbox, 'r') mb = UnixMailbox(fp) msgs = [] while 1: msg = mb.next() if msg is None: break msgs.append(msg) if len(args) <= 1: msg.fp = None if len(args) > 1: num = string.atoi(args[1]) print 'Message %d body:'%num msg = msgs[num-1] msg.rewindbody() sys.stdout.write(msg.fp.read()) else: print 'Mailbox',mbox,'has',len(msgs),'messages:' for msg in msgs: f = msg.getheader('from') or "" s = msg.getheader('subject') or "" d = msg.getheader('date') or "" print '-%20.20s %20.20s %-30.30s'%(f, d[5:], s)
| 13,204
|
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.environ['HOME'] + '/Mail/' + mbox[1:] elif not '/' in mbox: mbox = '/usr/mail/' + mbox if os.path.isdir(mbox): if os.path.isdir(os.path.join(mbox, 'cur')): mb = Maildir(mbox) else: mb = MHMailbox(mbox) else: fp = open(mbox, 'r') mb = UnixMailbox(fp) msgs = [] while 1: msg = mb.next() if msg is None: break msgs.append(msg) if len(args) <= 1: msg.fp = None if len(args) > 1: num = string.atoi(args[1]) print 'Message %d body:'%num msg = msgs[num-1] msg.rewindbody() sys.stdout.write(msg.fp.read()) else: print 'Mailbox',mbox,'has',len(msgs),'messages:' for msg in msgs: f = msg.getheader('from') or "" s = msg.getheader('subject') or "" d = msg.getheader('date') or "" print '-%20.20s %20.20s %-30.30s'%(f, d[5:], s)
|
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.environ['HOME'] + '/Mail/' + mbox[1:] elif not '/' in mbox: mbox = '/usr/mail/' + mbox if os.path.isdir(mbox): if os.path.isdir(os.path.join(mbox, 'cur')): mb = Maildir(mbox) else: mb = MHMailbox(mbox) else: fp = open(mbox, 'r') mb = UnixMailbox(fp) msgs = [] while 1: msg = mb.next() if msg is None: break msgs.append(msg) if len(args) <= 1: msg.fp = None if len(args) > 1: num = int(args[1]) print 'Message %d body:'%num msg = msgs[num-1] msg.rewindbody() sys.stdout.write(msg.fp.read()) else: print 'Mailbox',mbox,'has',len(msgs),'messages:' for msg in msgs: f = msg.getheader('from') or "" s = msg.getheader('subject') or "" d = msg.getheader('date') or "" print '-%20.20s %20.20s %-30.30s'%(f, d[5:], s)
| 13,205
|
def append(self, mailbox, flags, date_time, message): """Append message to named mailbox.
|
def append(self, mailbox, flags, date_time, message): """Append message to named mailbox.
| 13,206
|
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_time, str) and (date_time[0],date_time[-1]) == ('"','"'): return date_time # Assume in correct format else: raise ValueError("date_time not of a known type") dt = time.strftime("%d-%b-%Y %H:%M:%S", tt) if dt[0] == '0': dt = ' ' + dt[1:] if time.daylight and tt[-1]: zone = -time.altzone else: zone = -time.timezone return '"' + dt + " %+03d%02d" % divmod(zone/60, 60) + '"'
|
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_time, str) and (date_time[0],date_time[-1]) == ('"','"'): return date_time # Assume in correct format else: raise ValueError("date_time not of a known type") dt = time.strftime("%d-%b-%Y %H:%M:%S", tt) if dt[0] == '0': dt = ' ' + dt[1:] if time.daylight and tt[-1]: zone = -time.altzone else: zone = -time.timezone return '"' + dt + " %+03d%02d" % divmod(zone/60, 60) + '"'
| 13,207
|
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)
|
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)
| 13,208
|
def test_main(): test_support.run_unittest( FormatFunctionsTestCase, UnknownFormatTestCase, IEEEFormatTestCase, IEEEOperationsTestCase, )
|
def test_main(): test_support.run_unittest( FormatFunctionsTestCase, UnknownFormatTestCase, IEEEFormatTestCase)
| 13,209
|
def handle_read (self):
|
def handle_read (self):
| 13,210
|
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: 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.get(ch) if capability_name is None: return 0 #Check the current terminal description for that capability; #if present, return true, else return false. if _curses.tigetstr( capability_name ): return 1 else: return 0
| 13,211
|
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 a # charset. Only do this for the second and subsequent chunks. nextcs = charset if uchunks: if lastcs is not None: if nextcs is None or nextcs == 'us-ascii': uchunks.append(USPACE) nextcs = None elif nextcs is not None and nextcs <> 'us-ascii': uchunks.append(USPACE) lastcs = nextcs uchunks.append(unicode(s, str(charset))) return UEMPTYSTRING.join(uchunks)
|
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 a # charset. Only do this for the second and subsequent chunks. nextcs = charset if uchunks: if lastcs not in (None, 'us-ascii'): if nextcs in (None, 'us-ascii'): uchunks.append(USPACE) nextcs = None elif nextcs is not None and nextcs <> 'us-ascii': uchunks.append(USPACE) lastcs = nextcs uchunks.append(unicode(s, str(charset))) return UEMPTYSTRING.join(uchunks)
| 13,212
|
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 a # charset. Only do this for the second and subsequent chunks. nextcs = charset if uchunks: if lastcs is not None: if nextcs is None or nextcs == 'us-ascii': uchunks.append(USPACE) nextcs = None elif nextcs is not None and nextcs <> 'us-ascii': uchunks.append(USPACE) lastcs = nextcs uchunks.append(unicode(s, str(charset))) return UEMPTYSTRING.join(uchunks)
|
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 a # charset. Only do this for the second and subsequent chunks. nextcs = charset if uchunks: if lastcs is not None: if nextcs is None or nextcs == 'us-ascii': uchunks.append(USPACE) nextcs = None elif nextcs not in (None, 'us-ascii'): uchunks.append(USPACE) lastcs = nextcs uchunks.append(unicode(s, str(charset))) return UEMPTYSTRING.join(uchunks)
| 13,213
|
def finalize_options (self): from distutils import sysconfig
|
def finalize_options (self): from distutils import sysconfig
| 13,214
|
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, send 'mode reader' command after connecting.
|
def __init__(self, host, port=NNTP_PORT, user=None, password=None, readermode=None, usenetrc=True): """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, send 'mode reader' command after connecting.
| 13,215
|
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, send 'mode reader' command after connecting.
|
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, send 'mode reader' command after connecting.
| 13,216
|
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+)|' r'(self\.)?(\w+))\b') while 1: match = pattern.search(text, here) if not match: break start, end = match.span() results.append(escape(text[here:start]))
|
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+)|' r'(self\.)?(\w+))\b') while 1: match = pattern.search(text, here) if not match: break start, end = match.span() results.append(escape(text[here:start]))
| 13,217
|
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+)|' r'(self\.)?(\w+))\b') while 1: match = pattern.search(text, here) if not match: break start, end = match.span() results.append(escape(text[here:start]))
|
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+)|' r'(self\.)?(\w+))\b') while 1: match = pattern.search(text, here) if not match: break start, end = match.span() results.append(escape(text[here:start]))
| 13,218
|
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 hasattr(module, '__file__'): file = module.__file__ if os.path.exists(file): info = (file, os.path.getmtime(file), os.path.getsize(file)) if cache.has_key(path) and cache[path] != info: module = reload(module) file = module.__file__ if os.path.exists(file): info = (file, os.path.getmtime(file), os.path.getsize(file)) cache[path] = info return 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 hasattr(module, '__file__'): file = module.__file__ if os.path.exists(file): info = (file, os.path.getmtime(file), os.path.getsize(file)) if cache.get(path) == info: continue module = reload(module) file = module.__file__ if os.path.exists(file): info = (file, os.path.getmtime(file), os.path.getsize(file)) cache[path] = info return module
| 13,219
|
def __repr__(self): return '''To get help on a Python object, call help(object).
|
def __repr__(self): return '''To get help on a Python object, call help(object).
| 13,220
|
def __repr__(self): return '''To get help on a Python object, call help(object).
|
def __repr__(self): return '''To get help on a Python object, call help(object).
| 13,221
|
def setacl(self, mailbox, who, what): """Set a mailbox acl.
|
def setacl(self, mailbox, who, what): """Set a mailbox acl.
| 13,222
|
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)
|
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)
| 13,223
|
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)
|
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)
| 13,224
|
def bigendian_to_native(value): if isbigendian: return value chars = list(value) chars.reverse() return "".join(chars)
|
def bigendian_to_native(value): if isbigendian: return value chars = list(value) chars.reverse() return "".join(chars)
| 13,225
|
def run (self):
|
def run (self):
| 13,226
|
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
|
def _search_end(self): while 1: pos = self.fp.tell() line = self.fp.readline() if not line: return if line == '\037\014\n' or line == '\037': self.fp.seek(pos) return
| 13,227
|
def wm_colormapwindows(self, *wlist): args = ('wm', 'colormapwindows', self._w) + _flatten(wlist) return map(self._nametowidget, self.tk.call(args))
|
def wm_colormapwindows(self, *wlist): if len(wlist) > 1: wlist = (wlist,) args = ('wm', 'colormapwindows', self._w) + wlist return map(self._nametowidget, self.tk.call(args))
| 13,228
|
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.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `scriptname`) return if not executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return nobody = nobody_uid() self.send_response(200, "Script output follows") self.wfile.flush() # Always flush before forking pid = os.fork() if pid != 0: # Parent pid, sts = os.waitpid(pid, 0) if sts: self.log_error("CGI script exit status x%x" % sts) return # Child try: # Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html # XXX Much of the following could be prepared ahead of time! env = {} env['SERVER_SOFTWARE'] = self.version_string() env['SERVER_NAME'] = self.server.server_name env['GATEWAY_INTERFACE'] = 'CGI/1.1' env['SERVER_PROTOCOL'] = self.protocol_version env['SERVER_PORT'] = str(self.server.server_port) env['REQUEST_METHOD'] = self.command uqrest = urllib.unquote(rest) env['PATH_INFO'] = uqrest env['PATH_TRANSLATED'] = self.translate_path(uqrest) env['SCRIPT_NAME'] = scriptname if query: env['QUERY_STRING'] = query host = self.address_string() if host != self.client_address[0]: env['REMOTE_HOST'] = host env['REMOTE_ADDR'] = self.client_address[0] # AUTH_TYPE # REMOTE_USER # REMOTE_IDENT env['CONTENT_TYPE'] = self.headers.type length = self.headers.getheader('content-length') if length: env['CONTENT_LENGTH'] = length accept = [] for line in self.headers.getallmatchingheaders('accept'): if line[:1] in string.whitespace: accept.append(string.strip(line)) else: accept = accept + string.split(line[7:]) env['HTTP_ACCEPT'] = string.joinfields(accept, ',') ua = self.headers.getheader('user-agent') if ua: env['HTTP_USER_AGENT'] = ua # XXX Other HTTP_* headers decoded_query = string.replace(query, '+', ' ') try: os.setuid(nobody) except os.error: pass os.dup2(self.rfile.fileno(), 0) os.dup2(self.wfile.fileno(), 1) print scriptfile, script, decoded_query os.execve(scriptfile, [script, decoded_query], env) except: self.server.handle_error(self.request, self.client_address) os._exit(127)
|
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.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `scriptname`) return if not executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return nobody = nobody_uid() self.send_response(200, "Script output follows") self.wfile.flush() # Always flush before forking pid = os.fork() if pid != 0: # Parent pid, sts = os.waitpid(pid, 0) if sts: self.log_error("CGI script exit status x%x" % sts) return # Child try: # Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html # XXX Much of the following could be prepared ahead of time! env = {} env['SERVER_SOFTWARE'] = self.version_string() env['SERVER_NAME'] = self.server.server_name env['GATEWAY_INTERFACE'] = 'CGI/1.1' env['SERVER_PROTOCOL'] = self.protocol_version env['SERVER_PORT'] = str(self.server.server_port) env['REQUEST_METHOD'] = self.command uqrest = urllib.unquote(rest) env['PATH_INFO'] = uqrest env['PATH_TRANSLATED'] = self.translate_path(uqrest) env['SCRIPT_NAME'] = scriptname if query: env['QUERY_STRING'] = query host = self.address_string() if host != self.client_address[0]: env['REMOTE_HOST'] = host env['REMOTE_ADDR'] = self.client_address[0] # AUTH_TYPE # REMOTE_USER # REMOTE_IDENT if self.headers.typeheader is None: env['CONTENT_TYPE'] = self.headers.type else: env['CONTENT_TYPE'] = self.headers.typeheader length = self.headers.getheader('content-length') if length: env['CONTENT_LENGTH'] = length accept = [] for line in self.headers.getallmatchingheaders('accept'): if line[:1] in string.whitespace: accept.append(string.strip(line)) else: accept = accept + string.split(line[7:]) env['HTTP_ACCEPT'] = string.joinfields(accept, ',') ua = self.headers.getheader('user-agent') if ua: env['HTTP_USER_AGENT'] = ua # XXX Other HTTP_* headers decoded_query = string.replace(query, '+', ' ') try: os.setuid(nobody) except os.error: pass os.dup2(self.rfile.fileno(), 0) os.dup2(self.wfile.fileno(), 1) print scriptfile, script, decoded_query os.execve(scriptfile, [script, decoded_query], env) except: self.server.handle_error(self.request, self.client_address) os._exit(127)
| 13,229
|
def connect(self, host='localhost', port = 0): """Connect to a host on a given port.
|
def connect(self, host='localhost', port = 0): """Connect to a host on a given port.
| 13,230
|
def connect(self, host='localhost', port = 0): """Connect to a host on a given port.
|
def connect(self, host='localhost', port = 0): """Connect to a host on a given port.
| 13,231
|
def connect(self, host='localhost', port = 0): """Connect to a host on a given port.
|
def connect(self, host='localhost', port = 0): """Connect to a host on a given port.
| 13,232
|
def connect(self, host='localhost', port = 0): """Connect to a host on a given port.
|
def connect(self, host='localhost', port = 0): """Connect to a host on a given port.
| 13,233
|
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')
|
def send(self, str): """Send `str' to the server.""" if self.debuglevel > 0: print>>stderr, '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')
| 13,234
|
def getreply(self): """Get a reply from the server.
|
def getreply(self): """Get a reply from the server.
| 13,235
|
def getreply(self): """Get a reply from the server.
|
def getreply(self): """Get a reply from the server.
| 13,236
|
def data(self,msg): """SMTP 'DATA' command -- sends message data to server.
|
def data(self,msg): """SMTP 'DATA' command -- sends message data to server.
| 13,237
|
def data(self,msg): """SMTP 'DATA' command -- sends message data to server.
|
def data(self,msg): """SMTP 'DATA' command -- sends message data to server.
| 13,238
|
... def f():
|
... def f():
| 13,239
|
... def bar(self):
|
... def bar(self):
| 13,240
|
... def bar(self):
|
... def bar(self):
| 13,241
|
... def bar(self):
|
... def bar(self):
| 13,242
|
... def bar(self):
|
... def bar(self):
| 13,243
|
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.__test__ if it exists and is not None. m.__dict__ maps names to functions, classes and strings; function and class docstrings are tested even if the name is private; strings are tested directly, as if they were docstrings. Return (#failures, #tests). See doctest.__doc__ for an overview. Optional keyword arg "name" gives the name of the module; by default use m.__name__. Optional keyword arg "globs" gives a dict to be used as the globals when executing examples; by default, use m.__dict__. A copy of this dict is actually used for each docstring, so that each docstring's examples start with a clean slate. Optional keyword arg "verbose" prints lots of stuff if true, prints only failures if false; by default, it's true iff "-v" is in sys.argv. Optional keyword arg "isprivate" specifies a function used to determine whether a name is private. The default function is doctest.is_private; see its docs for details. Optional keyword arg "report" prints a summary at the end when true, else prints nothing at the end. In verbose mode, the summary is detailed, else very brief (in fact, empty if all tests passed). Advanced tomfoolery: testmod runs methods of a local instance of class doctest.Tester, then merges the results into (or creates) global Tester instance doctest.master. Methods of doctest.master can be called directly too, if you want to do something unusual. Passing report=0 to testmod is especially useful then, to delay displaying a summary. Invoke doctest.master.summarize(verbose) when you're done fiddling. """ global master if not _ismodule(m): raise TypeError("testmod: module required; " + `m`) if name is None: name = m.__name__ tester = Tester(m, globs=globs, verbose=verbose, isprivate=isprivate) failures, tries = tester.rundoc(m, name) f, t = tester.rundict(m.__dict__, name) failures = failures + f tries = tries + t if hasattr(m, "__test__"): testdict = m.__test__ if testdict: if not hasattr(testdict, "items"): raise TypeError("testmod: module.__test__ must support " ".items(); " + `testdict`) f, t = tester.run__test__(testdict, name + ".__test__") failures = failures + f tries = tries + t if report: tester.summarize() if master is None: master = tester else: master.merge(tester) return failures, tries
|
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.__test__ if it exists and is not None. m.__dict__ maps names to functions, classes and strings; function and class docstrings are tested even if the name is private; strings are tested directly, as if they were docstrings. Return (#failures, #tests). See doctest.__doc__ for an overview. Optional keyword arg "name" gives the name of the module; by default use m.__name__. Optional keyword arg "globs" gives a dict to be used as the globals when executing examples; by default, use m.__dict__. A copy of this dict is actually used for each docstring, so that each docstring's examples start with a clean slate. Optional keyword arg "verbose" prints lots of stuff if true, prints only failures if false; by default, it's true iff "-v" is in sys.argv. Optional keyword arg "isprivate" specifies a function used to determine whether a name is private. The default function is doctest.is_private; see its docs for details. Optional keyword arg "report" prints a summary at the end when true, else prints nothing at the end. In verbose mode, the summary is detailed, else very brief (in fact, empty if all tests passed). Advanced tomfoolery: testmod runs methods of a local instance of class doctest.Tester, then merges the results into (or creates) global Tester instance doctest.master. Methods of doctest.master can be called directly too, if you want to do something unusual. Passing report=0 to testmod is especially useful then, to delay displaying a summary. Invoke doctest.master.summarize(verbose) when you're done fiddling. """ global master if not _ismodule(m): raise TypeError("testmod: module required; " + `m`) if name is None: name = m.__name__ tester = Tester(m, globs=globs, verbose=verbose, isprivate=isprivate) failures, tries = tester.rundoc(m, name) f, t = tester.rundict(m.__dict__, name, m) failures = failures + f tries = tries + t if hasattr(m, "__test__"): testdict = m.__test__ if testdict: if not hasattr(testdict, "items"): raise TypeError("testmod: module.__test__ must support " ".items(); " + `testdict`) f, t = tester.run__test__(testdict, name + ".__test__") failures = failures + f tries = tries + t if report: tester.summarize() if master is None: master = tester else: master.merge(tester) return failures, tries
| 13,244
|
def makerepairinstructions(self): return [ ([("UInt32", 'inSize', "InMode"), ("void_ptr", 'inDataPtr', "InMode")], [("MyInBuffer", 'inDataPtr', "InMode")]) ]
|
def makerepairinstructions(self): return [ ([("UInt32", 'inSize', "InMode"), ("void_ptr", 'inDataPtr', "InMode")], [("MyInBuffer", 'inDataPtr', "InMode")]), ([("Boolean", 'ioWasInRgn', "OutMode")], [("Boolean", 'ioWasInRgn', "InOutMode")]), ]
| 13,245
|
def makerepairinstructions(self): return [ ([("UInt32", 'inSize', "InMode"), ("void_ptr", 'inDataPtr', "InMode")], [("MyInBuffer", 'inDataPtr', "InMode")]) ]
|
def makerepairinstructions(self): return [ ([("UInt32", 'inSize', "InMode"), ("void_ptr", 'inDataPtr', "InMode")], [("MyInBuffer", 'inDataPtr', "InMode")]) ]
| 13,246
|
def run (self):
|
def run (self):
| 13,247
|
def _sync_flush(f): """Ensure changes to file f are physically on disk.""" f.flush() os.fsync(f.fileno())
|
def _sync_flush(f): """Ensure changes to file f are physically on disk.""" f.flush() if hasattr(os, 'fsync'): os.fsync(f.fileno())
| 13,248
|
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 is never included in the returned list. The variable self.status is set to the empty string if all went well, otherwise it is an error message. The variable self.headers is a completely uninterpreted list of lines contained in the header (so printing them will reproduce the header exactly as it appears in the file). """ self.dict = {} self.unixfrom = '' self.headers = list = [] self.status = '' headerseen = "" firstline = 1 startofline = unread = tell = None if hasattr(self.fp, 'unread'): unread = self.fp.unread elif self.seekable: tell = self.fp.tell while 1: if tell: startofline = tell() line = self.fp.readline() if not line: self.status = 'EOF in headers' break # Skip unix From name time lines if firstline and line[:5] == 'From ': self.unixfrom = self.unixfrom + line continue firstline = 0 if headerseen and line[0] in ' \t': # It's a continuation line. list.append(line) x = (self.dict[headerseen] + "\n " + string.strip(line)) self.dict[headerseen] = string.strip(x) continue elif self.iscomment(line): # It's a comment. Ignore it. continue elif self.islast(line): # Note! No pushback here! The delimiter line gets eaten. break headerseen = self.isheader(line) if headerseen: # It's a legal header line, save it. list.append(line) self.dict[headerseen] = string.strip(line[len(headerseen)+2:]) continue else: # It's not a header line; throw it back and stop here. if not self.dict: self.status = 'No headers' else: self.status = 'Non-header line where header expected' # Try to undo the read. if unread: unread(line) elif tell: self.fp.seek(startofline) else: self.status = self.status + '; bad seek' break
|
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 is never included in the returned list. The variable self.status is set to the empty string if all went well, otherwise it is an error message. The variable self.headers is a completely uninterpreted list of lines contained in the header (so printing them will reproduce the header exactly as it appears in the file). """ self.dict = {} self.unixfrom = '' self.headers = list = [] self.status = '' headerseen = "" firstline = 1 startofline = unread = tell = None if hasattr(self.fp, 'unread'): unread = self.fp.unread elif self.seekable: tell = self.fp.tell while 1: if tell: startofline = tell() line = self.fp.readline() if not line: self.status = 'EOF in headers' break # Skip unix From name time lines if firstline and line[:5] == 'From ': self.unixfrom = self.unixfrom + line continue firstline = 0 if headerseen and line[0] in ' \t': # It's a continuation line. list.append(line) x = (self.dict[headerseen] + "\n " + string.strip(line)) self.dict[headerseen] = string.strip(x) continue elif self.iscomment(line): # It's a comment. Ignore it. continue elif self.islast(line): # Note! No pushback here! The delimiter line gets eaten. break headerseen = self.isheader(line) if headerseen: # It's a legal header line, save it. list.append(line) self.dict[headerseen] = string.strip(line[len(headerseen)+1:]) continue else: # It's not a header line; throw it back and stop here. if not self.dict: self.status = 'No headers' else: self.status = 'Non-header line where header expected' # Try to undo the read. if unread: unread(line) elif tell: self.fp.seek(startofline) else: self.status = self.status + '; bad seek' break
| 13,249
|
def startElement(self, name, attrs): """Signals the start of an element.
|
def startElement(self, name, attrs): """Signals the start of an element.
| 13,250
|
def startElement(self, name, attrs): """Signals the start of an element.
|
def startElement(self, name, attrs): """Signals the start of an element.
| 13,251
|
def endElement(self, name ): """Signals the end of an element.
|
def endElement(self, name ): """Signals the end of an element.
| 13,252
|
def endElement(self, name ): """Signals the end of an element.
|
def endElement(self, name ): """Signals the end of an element.
| 13,253
|
def send_error(self, code, message=None): """Send and log an error reply.
|
def send_error(self, code, message=None): """Send and log an error reply.
| 13,254
|
def test_original_excepthook(self): savestderr = sys.stderr err = cStringIO.StringIO() sys.stderr = err
|
def test_original_excepthook(self): savestderr = sys.stderr err = cStringIO.StringIO() sys.stderr = err
| 13,255
|
def my_ringer(child): child.id = None stdwin.fleep()
|
def my_ringer(child): child.my_id = None stdwin.fleep()
| 13,256
|
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)
|
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,))
| 13,257
|
def _make_spec_file(self): """Generate the text of an RPM spec file and return it as a list of strings (one per line). """ # definitions and headers spec_file = [ '%define name ' + self.distribution.get_name(), '%define version ' + self.distribution.get_version().replace('-','_'), '%define release ' + self.release.replace('-','_'), '', 'Summary: ' + self.distribution.get_description(), ]
|
def _make_spec_file(self): """Generate the text of an RPM spec file and return it as a list of strings (one per line). """ # definitions and headers spec_file = [ '%define name ' + self.distribution.get_name(), '%define version ' + self.distribution.get_version().replace('-','_'), '%define release ' + self.release.replace('-','_'), '', 'Summary: ' + self.distribution.get_description(), ]
| 13,258
|
def _make_spec_file(self): """Generate the text of an RPM spec file and return it as a list of strings (one per line). """ # definitions and headers spec_file = [ '%define name ' + self.distribution.get_name(), '%define version ' + self.distribution.get_version().replace('-','_'), '%define release ' + self.release.replace('-','_'), '', 'Summary: ' + self.distribution.get_description(), ]
|
def _make_spec_file(self): """Generate the text of an RPM spec file and return it as a list of strings (one per line). """ # definitions and headers spec_file = [ '%define name ' + self.distribution.get_name(), '%define version ' + self.distribution.get_version().replace('-','_'), '%define release ' + self.release.replace('-','_'), '', 'Summary: ' + self.distribution.get_description(), ]
| 13,259
|
def _make_spec_file(self): """Generate the text of an RPM spec file and return it as a list of strings (one per line). """ # definitions and headers spec_file = [ '%define name ' + self.distribution.get_name(), '%define version ' + self.distribution.get_version().replace('-','_'), '%define release ' + self.release.replace('-','_'), '', 'Summary: ' + self.distribution.get_description(), ]
|
def _make_spec_file(self): """Generate the text of an RPM spec file and return it as a list of strings (one per line). """ # definitions and headers spec_file = [ '%define name ' + self.distribution.get_name(), '%define version ' + self.distribution.get_version().replace('-','_'), '%define release ' + self.release.replace('-','_'), '', 'Summary: ' + self.distribution.get_description(), ]
| 13,260
|
def parse(self, fp, headersonly=False): """Create a message structure from the data in a file.
|
def parse(self, fp, headersonly=False): """Create a message structure from the data in a file.
| 13,261
|
def parse(self, fp, headersonly=False): """Create a message structure from the data in a file.
|
def parse(self, fp, headersonly=False): """Create a message structure from the data in a file.
| 13,262
|
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 compliant # continuation lines. line = fp.readline() if not line: break line = line.splitlines()[0] if not line: break # Ignore the trailing newline lineno += 1 # Check for initial Unix From_ line if line.startswith('From '): if lineno == 1: container.set_unixfrom(line) continue elif self._strict: raise Errors.HeaderParseError( 'Unix-from in headers after first rfc822 header') else: # ignore the wierdly placed From_ line # XXX: maybe set unixfrom anyway? or only if not already? continue # Header continuation line if line[0] in ' \t': if not lastheader: raise Errors.HeaderParseError( 'Continuation line seen before first header') lastvalue.append(line) continue # Normal, non-continuation header. BAW: this should check to make # sure it's a legal header, e.g. doesn't contain spaces. Also, we # should expose the header matching algorithm in the API, and # allow for a non-strict parsing mode (that ignores the line # instead of raising the exception). i = line.find(':') if i < 0: if self._strict: raise Errors.HeaderParseError( "Not a header, not a continuation: ``%s''"%line) elif lineno == 1 and line.startswith('--'): # allow through duplicate boundary tags. continue else: raise Errors.HeaderParseError( "Not a header, not a continuation: ``%s''"%line) if lastheader: container[lastheader] = NL.join(lastvalue) lastheader = line[:i] lastvalue = [line[i+1:].lstrip()] # Make sure we retain the last header if lastheader: container[lastheader] = NL.join(lastvalue)
|
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 compliant # continuation lines. line = fp.readline() if not line: break line = line.splitlines()[0] if not line: break # Ignore the trailing newline lineno += 1 # Check for initial Unix From_ line if line.startswith('From '): if lineno == 1: container.set_unixfrom(line) continue elif self._strict: raise Errors.HeaderParseError( 'Unix-from in headers after first rfc822 header') else: # ignore the wierdly placed From_ line # XXX: maybe set unixfrom anyway? or only if not already? continue # Header continuation line if line[0] in ' \t': if not lastheader: raise Errors.HeaderParseError( 'Continuation line seen before first header') lastvalue.append(line) continue # Normal, non-continuation header. BAW: this should check to make # sure it's a legal header, e.g. doesn't contain spaces. Also, we # should expose the header matching algorithm in the API, and # allow for a non-strict parsing mode (that ignores the line # instead of raising the exception). i = line.find(':') if i < 0: if self._strict: raise Errors.HeaderParseError( "Not a header, not a continuation: ``%s''" % line) elif lineno == 1 and line.startswith('--'): # allow through duplicate boundary tags. continue else: raise Errors.HeaderParseError( "Not a header, not a continuation: ``%s''" % line) if lastheader: container[lastheader] = NL.join(lastvalue) lastheader = line[:i] lastvalue = [line[i+1:].lstrip()] # Make sure we retain the last header if lastheader: container[lastheader] = NL.join(lastvalue)
| 13,263
|
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 compliant # continuation lines. line = fp.readline() if not line: break line = line.splitlines()[0] if not line: break # Ignore the trailing newline lineno += 1 # Check for initial Unix From_ line if line.startswith('From '): if lineno == 1: container.set_unixfrom(line) continue elif self._strict: raise Errors.HeaderParseError( 'Unix-from in headers after first rfc822 header') else: # ignore the wierdly placed From_ line # XXX: maybe set unixfrom anyway? or only if not already? continue # Header continuation line if line[0] in ' \t': if not lastheader: raise Errors.HeaderParseError( 'Continuation line seen before first header') lastvalue.append(line) continue # Normal, non-continuation header. BAW: this should check to make # sure it's a legal header, e.g. doesn't contain spaces. Also, we # should expose the header matching algorithm in the API, and # allow for a non-strict parsing mode (that ignores the line # instead of raising the exception). i = line.find(':') if i < 0: if self._strict: raise Errors.HeaderParseError( "Not a header, not a continuation: ``%s''"%line) elif lineno == 1 and line.startswith('--'): # allow through duplicate boundary tags. continue else: raise Errors.HeaderParseError( "Not a header, not a continuation: ``%s''"%line) if lastheader: container[lastheader] = NL.join(lastvalue) lastheader = line[:i] lastvalue = [line[i+1:].lstrip()] # Make sure we retain the last header if lastheader: container[lastheader] = NL.join(lastvalue)
|
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 compliant # continuation lines. line = fp.readline() if not line: break line = line.splitlines()[0] if not line: break # Ignore the trailing newline lineno += 1 # Check for initial Unix From_ line if line.startswith('From '): if lineno == 1: container.set_unixfrom(line) continue elif self._strict: raise Errors.HeaderParseError( 'Unix-from in headers after first rfc822 header') else: # ignore the wierdly placed From_ line # XXX: maybe set unixfrom anyway? or only if not already? continue # Header continuation line if line[0] in ' \t': if not lastheader: raise Errors.HeaderParseError( 'Continuation line seen before first header') lastvalue.append(line) continue # Normal, non-continuation header. BAW: this should check to make # sure it's a legal header, e.g. doesn't contain spaces. Also, we # should expose the header matching algorithm in the API, and # allow for a non-strict parsing mode (that ignores the line # instead of raising the exception). i = line.find(':') if i < 0: if self._strict: firstbodyline = line break elif lineno == 1 and line.startswith('--'): # allow through duplicate boundary tags. continue else: firstbodyline = line break if lastheader: container[lastheader] = NL.join(lastvalue) lastheader = line[:i] lastvalue = [line[i+1:].lstrip()] # Make sure we retain the last header if lastheader: container[lastheader] = NL.join(lastvalue)
| 13,264
|
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 compliant # continuation lines. line = fp.readline() if not line: break line = line.splitlines()[0] if not line: break # Ignore the trailing newline lineno += 1 # Check for initial Unix From_ line if line.startswith('From '): if lineno == 1: container.set_unixfrom(line) continue elif self._strict: raise Errors.HeaderParseError( 'Unix-from in headers after first rfc822 header') else: # ignore the wierdly placed From_ line # XXX: maybe set unixfrom anyway? or only if not already? continue # Header continuation line if line[0] in ' \t': if not lastheader: raise Errors.HeaderParseError( 'Continuation line seen before first header') lastvalue.append(line) continue # Normal, non-continuation header. BAW: this should check to make # sure it's a legal header, e.g. doesn't contain spaces. Also, we # should expose the header matching algorithm in the API, and # allow for a non-strict parsing mode (that ignores the line # instead of raising the exception). i = line.find(':') if i < 0: if self._strict: raise Errors.HeaderParseError( "Not a header, not a continuation: ``%s''"%line) elif lineno == 1 and line.startswith('--'): # allow through duplicate boundary tags. continue else: raise Errors.HeaderParseError( "Not a header, not a continuation: ``%s''"%line) if lastheader: container[lastheader] = NL.join(lastvalue) lastheader = line[:i] lastvalue = [line[i+1:].lstrip()] # Make sure we retain the last header if lastheader: container[lastheader] = NL.join(lastvalue)
|
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 compliant # continuation lines. line = fp.readline() if not line: break line = line.splitlines()[0] if not line: break # Ignore the trailing newline lineno += 1 # Check for initial Unix From_ line if line.startswith('From '): if lineno == 1: container.set_unixfrom(line) continue elif self._strict: raise Errors.HeaderParseError( 'Unix-from in headers after first rfc822 header') else: # ignore the wierdly placed From_ line # XXX: maybe set unixfrom anyway? or only if not already? continue # Header continuation line if line[0] in ' \t': if not lastheader: raise Errors.HeaderParseError( 'Continuation line seen before first header') lastvalue.append(line) continue # Normal, non-continuation header. BAW: this should check to make # sure it's a legal header, e.g. doesn't contain spaces. Also, we # should expose the header matching algorithm in the API, and # allow for a non-strict parsing mode (that ignores the line # instead of raising the exception). i = line.find(':') if i < 0: if self._strict: raise Errors.HeaderParseError( "Not a header, not a continuation: ``%s''"%line) elif lineno == 1 and line.startswith('--'): # allow through duplicate boundary tags. continue else: raise Errors.HeaderParseError( "Not a header, not a continuation: ``%s''"%line) if lastheader: container[lastheader] = NL.join(lastvalue) lastheader = line[:i] lastvalue = [line[i+1:].lstrip()] # Make sure we retain the last header if lastheader: container[lastheader] = NL.join(lastvalue)
| 13,265
|
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 separately. Otherwise, just parse the rest of # the body as a single message. Note: any exceptions raised in the # recursive parse need to have their line numbers coerced. if boundary: preamble = epilogue = None # Split into subparts. The first boundary we're looking for won't # always have a leading newline since we're at the start of the # body text, and there's not always a preamble before the first # boundary. separator = '--' + boundary payload = fp.read() # We use an RE here because boundaries can have trailing # whitespace. mo = re.search( r'(?P<sep>' + re.escape(separator) + r')(?P<ws>[ \t]*)', payload) if not mo: if self._strict: raise Errors.BoundaryError( "Couldn't find starting boundary: %s" % boundary) container.set_payload(payload) return start = mo.start() if start > 0: # there's some pre-MIME boundary preamble preamble = payload[0:start] # Find out what kind of line endings we're using start += len(mo.group('sep')) + len(mo.group('ws')) mo = nlcre.search(payload, start) if mo: start += len(mo.group(0)) # We create a compiled regexp first because we need to be able to # specify the start position, and the module function doesn't # support this signature. :( cre = re.compile('(?P<sep>\r\n|\r|\n)' + re.escape(separator) + '--') mo = cre.search(payload, start) if mo: terminator = mo.start() linesep = mo.group('sep') if mo.end() < len(payload): # There's some post-MIME boundary epilogue epilogue = payload[mo.end():] elif self._strict: raise Errors.BoundaryError( "Couldn't find terminating boundary: %s" % boundary) else: # Handle the case of no trailing boundary. Check that it ends # in a blank line. Some cases (spamspamspam) don't even have # that! mo = re.search('(?P<sep>\r\n|\r|\n){2}$', payload) if not mo: mo = re.search('(?P<sep>\r\n|\r|\n)$', payload) if not mo: raise Errors.BoundaryError( 'No terminating boundary and no trailing empty line') linesep = mo.group('sep') terminator = len(payload) # We split the textual payload on the boundary separator, which # includes the trailing newline. If the container is a # multipart/digest then the subparts are by default message/rfc822 # instead of text/plain. In that case, they'll have a optional # block of MIME headers, then an empty line followed by the # message headers. parts = re.split( linesep + re.escape(separator) + r'[ \t]*' + linesep, payload[start:terminator]) for part in parts: if isdigest: if part.startswith(linesep): # There's no header block so create an empty message # object as the container, and lop off the newline so # we can parse the sub-subobject msgobj = self._class() part = part[len(linesep):] else: parthdrs, part = part.split(linesep+linesep, 1) # msgobj in this case is the "message/rfc822" container msgobj = self.parsestr(parthdrs, headersonly=1) # while submsgobj is the message itself msgobj.set_default_type('message/rfc822') maintype = msgobj.get_content_maintype() if maintype in ('message', 'multipart'): submsgobj = self.parsestr(part) msgobj.attach(submsgobj) else: msgobj.set_payload(part) else: msgobj = self.parsestr(part) container.preamble = preamble container.epilogue = epilogue container.attach(msgobj) elif container.get_main_type() == 'multipart': # Very bad. A message is a multipart with no boundary! raise Errors.BoundaryError( 'multipart message with no defined boundary') elif container.get_type() == 'message/delivery-status': # This special kind of type contains blocks of headers separated # by a blank line. We'll represent each header block as a # separate Message object blocks = [] while True: blockmsg = self._class() self._parseheaders(blockmsg, fp) if not len(blockmsg): # No more header blocks left break blocks.append(blockmsg) container.set_payload(blocks) elif container.get_main_type() == 'message': # Create a container for the payload, but watch out for there not # being any headers left try: msg = self.parse(fp) except Errors.HeaderParseError: msg = self._class() self._parsebody(msg, fp) container.attach(msg) else: container.set_payload(fp.read())
|
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 separately. Otherwise, just parse the rest of # the body as a single message. Note: any exceptions raised in the # recursive parse need to have their line numbers coerced. if boundary: preamble = epilogue = None # Split into subparts. The first boundary we're looking for won't # always have a leading newline since we're at the start of the # body text, and there's not always a preamble before the first # boundary. separator = '--' + boundary payload = fp.read() # We use an RE here because boundaries can have trailing # whitespace. mo = re.search( r'(?P<sep>' + re.escape(separator) + r')(?P<ws>[ \t]*)', payload) if not mo: if self._strict: raise Errors.BoundaryError( "Couldn't find starting boundary: %s" % boundary) container.set_payload(payload) return start = mo.start() if start > 0: # there's some pre-MIME boundary preamble preamble = payload[0:start] # Find out what kind of line endings we're using start += len(mo.group('sep')) + len(mo.group('ws')) mo = nlcre.search(payload, start) if mo: start += len(mo.group(0)) # We create a compiled regexp first because we need to be able to # specify the start position, and the module function doesn't # support this signature. :( cre = re.compile('(?P<sep>\r\n|\r|\n)' + re.escape(separator) + '--') mo = cre.search(payload, start) if mo: terminator = mo.start() linesep = mo.group('sep') if mo.end() < len(payload): # There's some post-MIME boundary epilogue epilogue = payload[mo.end():] elif self._strict: raise Errors.BoundaryError( "Couldn't find terminating boundary: %s" % boundary) else: # Handle the case of no trailing boundary. Check that it ends # in a blank line. Some cases (spamspamspam) don't even have # that! mo = re.search('(?P<sep>\r\n|\r|\n){2}$', payload) if not mo: mo = re.search('(?P<sep>\r\n|\r|\n)$', payload) if not mo: raise Errors.BoundaryError( 'No terminating boundary and no trailing empty line') linesep = mo.group('sep') terminator = len(payload) # We split the textual payload on the boundary separator, which # includes the trailing newline. If the container is a # multipart/digest then the subparts are by default message/rfc822 # instead of text/plain. In that case, they'll have a optional # block of MIME headers, then an empty line followed by the # message headers. parts = re.split( linesep + re.escape(separator) + r'[ \t]*' + linesep, payload[start:terminator]) for part in parts: if isdigest: if part.startswith(linesep): # There's no header block so create an empty message # object as the container, and lop off the newline so # we can parse the sub-subobject msgobj = self._class() part = part[len(linesep):] else: parthdrs, part = part.split(linesep+linesep, 1) # msgobj in this case is the "message/rfc822" container msgobj = self.parsestr(parthdrs, headersonly=1) # while submsgobj is the message itself msgobj.set_default_type('message/rfc822') maintype = msgobj.get_content_maintype() if maintype in ('message', 'multipart'): submsgobj = self.parsestr(part) msgobj.attach(submsgobj) else: msgobj.set_payload(part) else: msgobj = self.parsestr(part) container.preamble = preamble container.epilogue = epilogue container.attach(msgobj) elif container.get_main_type() == 'multipart': # Very bad. A message is a multipart with no boundary! raise Errors.BoundaryError( 'multipart message with no defined boundary') elif container.get_type() == 'message/delivery-status': # This special kind of type contains blocks of headers separated # by a blank line. We'll represent each header block as a # separate Message object blocks = [] while True: blockmsg = self._class() self._parseheaders(blockmsg, fp) if not len(blockmsg): # No more header blocks left break blocks.append(blockmsg) container.set_payload(blocks) elif container.get_main_type() == 'message': # Create a container for the payload, but watch out for there not # being any headers left try: msg = self.parse(fp) except Errors.HeaderParseError: msg = self._class() self._parsebody(msg, fp) container.attach(msg) else: container.set_payload(fp.read())
| 13,266
|
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", borderwidth=2, relief="groove") self.helplabel.pack(fill="x") # self.sv = StackViewer(top, flist, self) if stack is None: stack = get_stack() self.sv.load_stack(stack)
|
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", borderwidth=2, relief="groove") self.helplabel.pack(fill="x") # self.sv = StackViewer(top, flist, self) if stack is None: stack = get_stack() self.sv.load_stack(stack)
| 13,267
|
def close(self, event=None): self.top.destroy()
|
def close(self, event=None): self.top.destroy()
| 13,268
|
def close(self, event=None): self.top.destroy()
|
def close(self, event=None): self.top.destroy()
| 13,269
|
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_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
| 13,270
|
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 self.globalsframe: self.globalsframe = Frame(self.top) self.globalsdict = frame.f_globals self.globalsviewer = NamespaceViewer( self.globalsframe, title, self.globalsdict) self.globalsframe.pack(fill="both", side="bottom")
|
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 self.globalsframe: self.globalsframe = Frame(self.top) self.globalsdict = frame.f_globals self.globalsviewer = NamespaceViewer( self.globalsframe, title, self.globalsdict) self.globalsframe.pack(fill="both", side="bottom")
| 13,271
|
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.localsframe: self.localsframe = Frame(self.top) self.localsdict = frame.f_locals self.localsviewer = NamespaceViewer( self.localsframe, title, self.localsdict) self.localsframe.pack(fill="both", side="top") else: if self.localsframe: self.localsframe.forget()
|
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.localsframe: self.localsframe = Frame(self.top) self.localsdict = frame.f_locals self.localsviewer = NamespaceViewer( self.localsframe, title, self.localsdict) self.localsframe.pack(fill="both", side="top") else: if self.localsframe: self.localsframe.forget()
| 13,272
|
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 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 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): frame, lineno = self.info sublist = [] if frame.f_globals is not frame.f_locals: item = VariablesTreeItem("<locals>", frame.f_locals, self.flist) sublist.append(item) item = VariablesTreeItem("<globals>", frame.f_globals, self.flist) sublist.append(item) return sublist def OnDoubleClick(self): if self.flist: frame, lineno = self.info filename = frame.f_code.co_filename edit = self.flist.open(filename) if edit: edit.gotoline(lineno)
| 13,273
|
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 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)
| 13,274
|
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
|
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
| 13,275
|
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
|
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
| 13,276
|
def send(self, str): """Send `str' to the server.""" if self.sock is None: if self.auto_open: self.connect() else: raise NotConnected()
|
def send(self, str): """Send `str' to the server.""" if self.sock is None: if self.auto_open: self.connect() else: raise NotConnected()
| 13,277
|
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)
|
def _output(self, s): """Add a line of output to the current request buffer. Assumes that the line does *not* end with \\r\\n. """ self._buffer.append(s)
| 13,278
|
def _send_output(self): """Send the currently buffered request and clear the buffer.
|
def _send_output(self): """Send the currently buffered request and clear the buffer.
| 13,279
|
def run (self):
|
def run (self):
| 13,280
|
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 = self._file.read(4) formlength = formlength - 4 if formdata == 'AIFF': self._aifc = 0 elif formdata == 'AIFC': self._aifc = 1 else: raise Error, 'not an AIFF or AIFF-C file' self._comm_chunk_read = 0 while 1: self._ssnd_seek_needed = 1 try: chunk = Chunk().init(self._file) except EOFError: raise Error, 'COMM chunk and/or SSND chunk missing' formlength = formlength - 8 - chunk.chunksize if chunk.chunksize & 1: formlength = formlength - 1 if chunk.chunkname == 'COMM': self._read_comm_chunk(chunk) self._comm_chunk_read = 1 elif chunk.chunkname == 'SSND': self._ssnd_chunk = chunk dummy = chunk.read(8) self._ssnd_seek_needed = 0 if formlength <= 0: if not self._comm_chunk_read: raise Error, 'COMM chunk missing' break elif chunk.chunkname == 'FVER': self._version = _read_long(chunk) elif chunk.chunkname == 'MARK': self._readmark(chunk) elif chunk.chunkname in _skiplist: pass else: raise Error, 'unrecognized chunk type '+chunk.chunkname chunk.skip() if self._aifc and self._decomp: params = [CL.ORIGINAL_FORMAT, 0, \ CL.BITS_PER_COMPONENT, 0, \ CL.FRAME_RATE, self._framerate] if self._nchannels == AL.MONO: params[1] = CL.MONO else: params[1] = CL.STEREO_INTERLEAVED if self._sampwidth == AL.SAMPLE_8: params[3] = 8 elif self._sampwidth == AL.SAMPLE_16: params[3] = 16 else: params[3] = 24 self._decomp.SetParams(params) return self
|
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 = self._file.read(4) formlength = formlength - 4 if formdata == 'AIFF': self._aifc = 0 elif formdata == 'AIFC': self._aifc = 1 else: raise Error, 'not an AIFF or AIFF-C file' self._comm_chunk_read = 0 while formlength > 0: self._ssnd_seek_needed = 1 try: chunk = Chunk().init(self._file) except EOFError: raise Error, 'COMM chunk and/or SSND chunk missing' formlength = formlength - 8 - chunk.chunksize if chunk.chunksize & 1: formlength = formlength - 1 if chunk.chunkname == 'COMM': self._read_comm_chunk(chunk) self._comm_chunk_read = 1 elif chunk.chunkname == 'SSND': self._ssnd_chunk = chunk dummy = chunk.read(8) self._ssnd_seek_needed = 0 if formlength <= 0: if not self._comm_chunk_read: raise Error, 'COMM chunk missing' break elif chunk.chunkname == 'FVER': self._version = _read_long(chunk) elif chunk.chunkname == 'MARK': self._readmark(chunk) elif chunk.chunkname in _skiplist: pass else: raise Error, 'unrecognized chunk type '+chunk.chunkname chunk.skip() if self._aifc and self._decomp: params = [CL.ORIGINAL_FORMAT, 0, \ CL.BITS_PER_COMPONENT, 0, \ CL.FRAME_RATE, self._framerate] if self._nchannels == AL.MONO: params[1] = CL.MONO else: params[1] = CL.STEREO_INTERLEAVED if self._sampwidth == AL.SAMPLE_8: params[3] = 8 elif self._sampwidth == AL.SAMPLE_16: params[3] = 16 else: params[3] = 24 self._decomp.SetParams(params) return self
| 13,281
|
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 = self._file.read(4) formlength = formlength - 4 if formdata == 'AIFF': self._aifc = 0 elif formdata == 'AIFC': self._aifc = 1 else: raise Error, 'not an AIFF or AIFF-C file' self._comm_chunk_read = 0 while 1: self._ssnd_seek_needed = 1 try: chunk = Chunk().init(self._file) except EOFError: raise Error, 'COMM chunk and/or SSND chunk missing' formlength = formlength - 8 - chunk.chunksize if chunk.chunksize & 1: formlength = formlength - 1 if chunk.chunkname == 'COMM': self._read_comm_chunk(chunk) self._comm_chunk_read = 1 elif chunk.chunkname == 'SSND': self._ssnd_chunk = chunk dummy = chunk.read(8) self._ssnd_seek_needed = 0 if formlength <= 0: if not self._comm_chunk_read: raise Error, 'COMM chunk missing' break elif chunk.chunkname == 'FVER': self._version = _read_long(chunk) elif chunk.chunkname == 'MARK': self._readmark(chunk) elif chunk.chunkname in _skiplist: pass else: raise Error, 'unrecognized chunk type '+chunk.chunkname chunk.skip() if self._aifc and self._decomp: params = [CL.ORIGINAL_FORMAT, 0, \ CL.BITS_PER_COMPONENT, 0, \ CL.FRAME_RATE, self._framerate] if self._nchannels == AL.MONO: params[1] = CL.MONO else: params[1] = CL.STEREO_INTERLEAVED if self._sampwidth == AL.SAMPLE_8: params[3] = 8 elif self._sampwidth == AL.SAMPLE_16: params[3] = 16 else: params[3] = 24 self._decomp.SetParams(params) return self
|
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 = self._file.read(4) formlength = formlength - 4 if formdata == 'AIFF': self._aifc = 0 elif formdata == 'AIFC': self._aifc = 1 else: raise Error, 'not an AIFF or AIFF-C file' self._comm_chunk_read = 0 while 1: self._ssnd_seek_needed = 1 chunk = Chunk().init(self._file) formlength = formlength - 8 - chunk.chunksize if chunk.chunksize & 1: formlength = formlength - 1 if chunk.chunkname == 'COMM': self._read_comm_chunk(chunk) self._comm_chunk_read = 1 elif chunk.chunkname == 'SSND': self._ssnd_chunk = chunk dummy = chunk.read(8) self._ssnd_seek_needed = 0 if formlength <= 0: if not self._comm_chunk_read: raise Error, 'COMM chunk missing' break elif chunk.chunkname == 'FVER': self._version = _read_long(chunk) elif chunk.chunkname == 'MARK': self._readmark(chunk) elif chunk.chunkname in _skiplist: pass else: raise Error, 'unrecognized chunk type '+chunk.chunkname chunk.skip() if self._aifc and self._decomp: params = [CL.ORIGINAL_FORMAT, 0, \ CL.BITS_PER_COMPONENT, 0, \ CL.FRAME_RATE, self._framerate] if self._nchannels == AL.MONO: params[1] = CL.MONO else: params[1] = CL.STEREO_INTERLEAVED if self._sampwidth == AL.SAMPLE_8: params[3] = 8 elif self._sampwidth == AL.SAMPLE_16: params[3] = 16 else: params[3] = 24 self._decomp.SetParams(params) return self
| 13,282
|
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 = self._file.read(4) formlength = formlength - 4 if formdata == 'AIFF': self._aifc = 0 elif formdata == 'AIFC': self._aifc = 1 else: raise Error, 'not an AIFF or AIFF-C file' self._comm_chunk_read = 0 while 1: self._ssnd_seek_needed = 1 try: chunk = Chunk().init(self._file) except EOFError: raise Error, 'COMM chunk and/or SSND chunk missing' formlength = formlength - 8 - chunk.chunksize if chunk.chunksize & 1: formlength = formlength - 1 if chunk.chunkname == 'COMM': self._read_comm_chunk(chunk) self._comm_chunk_read = 1 elif chunk.chunkname == 'SSND': self._ssnd_chunk = chunk dummy = chunk.read(8) self._ssnd_seek_needed = 0 if formlength <= 0: if not self._comm_chunk_read: raise Error, 'COMM chunk missing' break elif chunk.chunkname == 'FVER': self._version = _read_long(chunk) elif chunk.chunkname == 'MARK': self._readmark(chunk) elif chunk.chunkname in _skiplist: pass else: raise Error, 'unrecognized chunk type '+chunk.chunkname chunk.skip() if self._aifc and self._decomp: params = [CL.ORIGINAL_FORMAT, 0, \ CL.BITS_PER_COMPONENT, 0, \ CL.FRAME_RATE, self._framerate] if self._nchannels == AL.MONO: params[1] = CL.MONO else: params[1] = CL.STEREO_INTERLEAVED if self._sampwidth == AL.SAMPLE_8: params[3] = 8 elif self._sampwidth == AL.SAMPLE_16: params[3] = 16 else: params[3] = 24 self._decomp.SetParams(params) return self
|
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 = self._file.read(4) formlength = formlength - 4 if formdata == 'AIFF': self._aifc = 0 elif formdata == 'AIFC': self._aifc = 1 else: raise Error, 'not an AIFF or AIFF-C file' self._comm_chunk_read = 0 while 1: self._ssnd_seek_needed = 1 try: chunk = Chunk().init(self._file) except EOFError: raise Error, 'COMM chunk and/or SSND chunk missing' formlength = formlength - 8 - chunk.chunksize if chunk.chunksize & 1: formlength = formlength - 1 if chunk.chunkname == 'COMM': self._read_comm_chunk(chunk) self._comm_chunk_read = 1 elif chunk.chunkname == 'SSND': self._ssnd_chunk = chunk dummy = chunk.read(8) self._ssnd_seek_needed = 0 elif chunk.chunkname == 'FVER': self._version = _read_long(chunk) elif chunk.chunkname == 'MARK': self._readmark(chunk) elif chunk.chunkname in _skiplist: pass else: raise Error, 'unrecognized chunk type '+chunk.chunkname chunk.skip() if self._aifc and self._decomp: params = [CL.ORIGINAL_FORMAT, 0, \ CL.BITS_PER_COMPONENT, 0, \ CL.FRAME_RATE, self._framerate] if self._nchannels == AL.MONO: params[1] = CL.MONO else: params[1] = CL.STEREO_INTERLEAVED if self._sampwidth == AL.SAMPLE_8: params[3] = 8 elif self._sampwidth == AL.SAMPLE_16: params[3] = 16 else: params[3] = 24 self._decomp.SetParams(params) return self
| 13,283
|
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 self._markers.append((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 self._markers.append((id, pos, name))
| 13,284
|
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_pos, 0) dummy = self._write_form_length(datalength) self._file.seek(self._nframes_pos, 0) _write_long(self._file, self._nframeswritten) self._file.seek(self._ssnd_length_pos, 0) _write_long(self._file, datalength + 8) self._file.seek(curpos, 0) self._nframes = self._nframeswritten self._datalength = datalength
|
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 and \ self._marklength == 0: self._file.seek(curpos, 0) return self._file.seek(self._form_length_pos, 0) dummy = self._write_form_length(datalength) self._file.seek(self._nframes_pos, 0) _write_long(self._file, self._nframeswritten) self._file.seek(self._ssnd_length_pos, 0) _write_long(self._file, datalength + 8) self._file.seek(curpos, 0) self._nframes = self._nframeswritten self._datalength = datalength
| 13,285
|
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, markers)) for marker in self._markers: id, pos, name = marker _write_short(self._file, id) _write_long(self._file, pos) _write_string(self._file, name)
|
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(self._file, len(self._markers)) for marker in self._markers: id, pos, name = marker _write_short(self._file, id) _write_long(self._file, pos) _write_string(self._file, name)
| 13,286
|
def setcontext(context): """Set this thread's context to context.""" if context in (DefaultContext, BasicContext, ExtendedContext): context = context.copy() threading.currentThread().__decimal_context__ = context
|
def setcontext(context): """Set this thread's context to context.""" if context in (DefaultContext, BasicContext, ExtendedContext): context = copy.deepcopy(context) context.clear_flags() threading.currentThread().__decimal_context__ = context
| 13,287
|
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
|
def setcontext(context, _local=local): """Set this thread's context to context.""" if context in (DefaultContext, BasicContext, ExtendedContext): context = copy.deepcopy(context) context.clear_flags() _local.__decimal_context__ = context
| 13,288
|
def _round_half_even(self, prec, expdiff, context): """Round 5 to even, rest to nearest."""
|
def _round_half_even(self, prec, expdiff, context): """Round 5 to even, rest to nearest."""
| 13,289
|
def sqrt(self, context=None): """Return the square root of self.
|
def sqrt(self, context=None): """Return the square root of self.
| 13,290
|
def sqrt(self, context=None): """Return the square root of self.
|
def sqrt(self, context=None): """Return the square root of self.
| 13,291
|
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
|
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
| 13,292
|
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) else: zinfo = ZipInfo(arcname, date_time) zinfo.external_attr = st[0] << 16 # Unix attributes if compress_type is None: zinfo.compress_type = self.compression else: zinfo.compress_type = compress_type self._writecheck(zinfo) fp = open(filename, "rb") zinfo.flag_bits = 0x08 zinfo.header_offset = self.fp.tell() # Start of header bytes self.fp.write(zinfo.FileHeader()) zinfo.file_offset = self.fp.tell() # Start of file bytes CRC = 0 compress_size = 0 file_size = 0 if zinfo.compress_type == ZIP_DEFLATED: cmpr = zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION, zlib.DEFLATED, -15) else: cmpr = None while 1: buf = fp.read(1024 * 8) if not buf: break file_size = file_size + len(buf) CRC = binascii.crc32(buf, CRC) if cmpr: buf = cmpr.compress(buf) compress_size = compress_size + len(buf) self.fp.write(buf) fp.close() if cmpr: buf = cmpr.flush() compress_size = compress_size + len(buf) self.fp.write(buf) zinfo.compress_size = compress_size else: zinfo.compress_size = file_size zinfo.CRC = CRC zinfo.file_size = file_size # Write CRC and file sizes after the file data self.fp.write(struct.pack("<lll", zinfo.CRC, zinfo.compress_size, zinfo.file_size)) self.filelist.append(zinfo) self.NameToInfo[zinfo.filename] = zinfo
|
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) else: zinfo = ZipInfo(arcname, date_time) zinfo.external_attr = st[0] << 16 # Unix attributes if compress_type is None: zinfo.compress_type = self.compression else: zinfo.compress_type = compress_type self._writecheck(zinfo) fp = open(filename, "rb") zinfo.flag_bits = 0x00 zinfo.header_offset = self.fp.tell() # Start of header bytes self.fp.write(zinfo.FileHeader()) zinfo.file_offset = self.fp.tell() # Start of file bytes CRC = 0 compress_size = 0 file_size = 0 if zinfo.compress_type == ZIP_DEFLATED: cmpr = zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION, zlib.DEFLATED, -15) else: cmpr = None while 1: buf = fp.read(1024 * 8) if not buf: break file_size = file_size + len(buf) CRC = binascii.crc32(buf, CRC) if cmpr: buf = cmpr.compress(buf) compress_size = compress_size + len(buf) self.fp.write(buf) fp.close() if cmpr: buf = cmpr.flush() compress_size = compress_size + len(buf) self.fp.write(buf) zinfo.compress_size = compress_size else: zinfo.compress_size = file_size zinfo.CRC = CRC zinfo.file_size = file_size # Write CRC and file sizes after the file data self.fp.write(struct.pack("<lll", zinfo.CRC, zinfo.compress_size, zinfo.file_size)) self.filelist.append(zinfo) self.NameToInfo[zinfo.filename] = zinfo
| 13,293
|
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) else: zinfo = ZipInfo(arcname, date_time) zinfo.external_attr = st[0] << 16 # Unix attributes if compress_type is None: zinfo.compress_type = self.compression else: zinfo.compress_type = compress_type self._writecheck(zinfo) fp = open(filename, "rb") zinfo.flag_bits = 0x08 zinfo.header_offset = self.fp.tell() # Start of header bytes self.fp.write(zinfo.FileHeader()) zinfo.file_offset = self.fp.tell() # Start of file bytes CRC = 0 compress_size = 0 file_size = 0 if zinfo.compress_type == ZIP_DEFLATED: cmpr = zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION, zlib.DEFLATED, -15) else: cmpr = None while 1: buf = fp.read(1024 * 8) if not buf: break file_size = file_size + len(buf) CRC = binascii.crc32(buf, CRC) if cmpr: buf = cmpr.compress(buf) compress_size = compress_size + len(buf) self.fp.write(buf) fp.close() if cmpr: buf = cmpr.flush() compress_size = compress_size + len(buf) self.fp.write(buf) zinfo.compress_size = compress_size else: zinfo.compress_size = file_size zinfo.CRC = CRC zinfo.file_size = file_size # Write CRC and file sizes after the file data self.fp.write(struct.pack("<lll", zinfo.CRC, zinfo.compress_size, zinfo.file_size)) self.filelist.append(zinfo) self.NameToInfo[zinfo.filename] = zinfo
|
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) else: zinfo = ZipInfo(arcname, date_time) zinfo.external_attr = st[0] << 16 # Unix attributes if compress_type is None: zinfo.compress_type = self.compression else: zinfo.compress_type = compress_type self._writecheck(zinfo) fp = open(filename, "rb") zinfo.flag_bits = 0x08 zinfo.header_offset = self.fp.tell() # Start of header bytes self.fp.write(zinfo.FileHeader()) zinfo.file_offset = self.fp.tell() # Start of file bytes if zinfo.compress_type == ZIP_DEFLATED: cmpr = zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION, zlib.DEFLATED, -15) else: cmpr = None while 1: buf = fp.read(1024 * 8) if not buf: break file_size = file_size + len(buf) CRC = binascii.crc32(buf, CRC) if cmpr: buf = cmpr.compress(buf) compress_size = compress_size + len(buf) self.fp.write(buf) fp.close() if cmpr: buf = cmpr.flush() compress_size = compress_size + len(buf) self.fp.write(buf) zinfo.compress_size = compress_size else: zinfo.compress_size = file_size zinfo.CRC = CRC zinfo.file_size = file_size # Write CRC and file sizes after the file data self.fp.write(struct.pack("<lll", zinfo.CRC, zinfo.compress_size, zinfo.file_size)) self.filelist.append(zinfo) self.NameToInfo[zinfo.filename] = zinfo
| 13,294
|
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) else: zinfo = ZipInfo(arcname, date_time) zinfo.external_attr = st[0] << 16 # Unix attributes if compress_type is None: zinfo.compress_type = self.compression else: zinfo.compress_type = compress_type self._writecheck(zinfo) fp = open(filename, "rb") zinfo.flag_bits = 0x08 zinfo.header_offset = self.fp.tell() # Start of header bytes self.fp.write(zinfo.FileHeader()) zinfo.file_offset = self.fp.tell() # Start of file bytes CRC = 0 compress_size = 0 file_size = 0 if zinfo.compress_type == ZIP_DEFLATED: cmpr = zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION, zlib.DEFLATED, -15) else: cmpr = None while 1: buf = fp.read(1024 * 8) if not buf: break file_size = file_size + len(buf) CRC = binascii.crc32(buf, CRC) if cmpr: buf = cmpr.compress(buf) compress_size = compress_size + len(buf) self.fp.write(buf) fp.close() if cmpr: buf = cmpr.flush() compress_size = compress_size + len(buf) self.fp.write(buf) zinfo.compress_size = compress_size else: zinfo.compress_size = file_size zinfo.CRC = CRC zinfo.file_size = file_size # Write CRC and file sizes after the file data self.fp.write(struct.pack("<lll", zinfo.CRC, zinfo.compress_size, zinfo.file_size)) self.filelist.append(zinfo) self.NameToInfo[zinfo.filename] = zinfo
|
def position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) write(self, position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) filename, position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) arcname=None, position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) compress_type=None): position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) """Put position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) the position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) bytes position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) from position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) filename position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) into position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) the position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) archive position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) under position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) the position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) name position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) arcname.""" position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) st position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) os.stat(filename) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) mtime position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) time.localtime(st[8]) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) date_time position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) mtime[0:6] position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) # position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) Create position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) ZipInfo position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) instance position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) to position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) store position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) file position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) information position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) if position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) arcname position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) is position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) None: position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) zinfo position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) ZipInfo(filename, position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) date_time) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) else: position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) zinfo position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) ZipInfo(arcname, position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) date_time) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) zinfo.external_attr position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) st[0] position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) << position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) 16 position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) # position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) Unix position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) attributes position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) if position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) compress_type position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) is position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) None: position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) zinfo.compress_type position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) self.compression position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) else: position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) zinfo.compress_type position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) compress_type position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) self._writecheck(zinfo) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) fp position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) open(filename, position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) "rb") position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) zinfo.flag_bits position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) 0x08 position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) zinfo.header_offset position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) self.fp.tell() position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) # position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) Start position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) of position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) header position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) bytes position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) self.fp.write(zinfo.FileHeader()) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) zinfo.file_offset position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) self.fp.tell() position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) # position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) Start position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) of position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) file position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) bytes position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) CRC position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) 0 position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) compress_size position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) 0 position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) file_size position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) 0 position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) if position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) zinfo.compress_type position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) == position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) ZIP_DEFLATED: position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) cmpr position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION, position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) zlib.DEFLATED, position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) -15) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) else: position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) cmpr position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) None position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) while position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) 1: position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) buf position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) fp.read(1024 position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) * position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) 8) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) if position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) not position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) buf: position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) break position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) file_size position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) file_size position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) + position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) len(buf) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) CRC position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) binascii.crc32(buf, position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) CRC) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) if position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) cmpr: position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) buf position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) cmpr.compress(buf) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) compress_size position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) compress_size position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) + position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) len(buf) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) self.fp.write(buf) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) fp.close() position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) if position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) cmpr: position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) buf position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) cmpr.flush() position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) compress_size position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) compress_size position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) + position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) len(buf) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) self.fp.write(buf) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) zinfo.compress_size position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) compress_size position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) else: position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) zinfo.compress_size position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) file_size position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) zinfo.CRC position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) CRC position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) zinfo.file_size position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) file_size position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) # position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) Write position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) CRC position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) and position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) file position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) sizes position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) after position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) the position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) file position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) data position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) self.fp.write(struct.pack("<lll", position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) zinfo.CRC, position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) zinfo.compress_size, position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) zinfo.file_size)) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) self.filelist.append(zinfo) position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) self.NameToInfo[zinfo.filename] position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) = position = self.fp.tell() self.fp.seek(zinfo.header_offset + 14, 0) zinfo
| 13,295
|
def _isunicode(s): return isinstance(s, UnicodeType)
|
def _isunicode(s): return isinstance(s, UnicodeType)
| 13,296
|
def _isunicode(s): return isinstance(s, UnicodeType)
|
def _isunicode(s): return isinstance(s, UnicodeType)
| 13,297
|
def _isunicode(s): return isinstance(s, UnicodeType)
|
def _isunicode(s): return isinstance(s, UnicodeType)
| 13,298
|
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 to use by the # charset_map dictionary. Try that first, but let the user override # it. henc, benc, conv = CHARSETS.get(self.input_charset, (SHORTEST, BASE64, None)) # Set the attributes, allowing the arguments to override the default. self.header_encoding = henc self.body_encoding = benc self.output_charset = ALIASES.get(conv, conv) # Now set the codecs. If one isn't defined for input_charset, # guess and try a Unicode codec with the same name as input_codec. self.input_codec = CODEC_MAP.get(self.input_charset, self.input_charset) self.output_codec = CODEC_MAP.get(self.output_charset, self.input_codec)
|
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 to use by the # charset_map dictionary. Try that first, but let the user override # it. henc, benc, conv = CHARSETS.get(self.input_charset, (SHORTEST, BASE64, None)) # Set the attributes, allowing the arguments to override the default. self.header_encoding = henc self.body_encoding = benc self.output_charset = ALIASES.get(conv, conv) # Now set the codecs. If one isn't defined for input_charset, # guess and try a Unicode codec with the same name as input_codec. self.input_codec = CODEC_MAP.get(self.input_charset, self.input_charset) self.output_codec = CODEC_MAP.get(self.output_charset, self.input_codec)
| 13,299
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.