code
stringlengths
1
1.72M
language
stringclasses
1 value
"""Find modules used by a script, using introspection.""" # This module should be kept compatible with Python 2.2, see PEP 291. import dis import imp import marshal import os import sys import new if hasattr(sys.__stdout__, "newlines"): READ_MODE = "U" # universal line endings else: # remain compatible with...
Python
"""optparse - a powerful, extensible, and easy-to-use option parser. By Greg Ward <gward@python.net> Originally distributed as Optik; see http://optik.sourceforge.net/ . If you have problems with this module, please do not file bugs, patches, or feature requests with Python; instead, use Optik's SourceForge project ...
Python
"""Execute shell commands via os.popen() and return status, output. Interface summary: import commands outtext = commands.getoutput(cmd) (exitstatus, outtext) = commands.getstatusoutput(cmd) outtext = commands.getstatus(file) # returns output of "ls -ld file" A trailing newline is remov...
Python
"""Create portable serialized representations of Python objects. See module cPickle for a (much) faster implementation. See module copy_reg for a mechanism for registering custom picklers. See module pickletools source for extensive comments. Classes: Pickler Unpickler Functions: dump(object, file) ...
Python
#! /usr/bin/env python """ Module difflib -- helpers for computing deltas between objects. Function get_close_matches(word, possibilities, n=3, cutoff=0.6): Use SequenceMatcher to return list of the best "good enough" matches. Function context_diff(a, b): For two lists of strings, return a delta in context d...
Python
"""A POP3 client class. Based on the J. Myers POP3 draft, Jan. 96 """ # Author: David Ascher <david_ascher@brown.edu> # [heavily stealing from nntplib.py] # Updated: Piers Lauder <piers@cs.su.oz.au> [Jul '97] # String method conversion and test jig improvements by ESR, February 2001. # Added the POP3_SSL clas...
Python
"""Convert a NT pathname to a file URL and vice versa.""" def url2pathname(url): r"""Convert a URL to a DOS path. ///C|/foo/bar/spam.foo becomes C:\foo\bar\spam.foo """ import string, urllib if not '|' in url: # No drive specifier, just convert sla...
Python
# # Emulation of has_key() function for platforms that don't use ncurses # import _curses # Table mapping curses keys to the terminfo capability name _capability_names = { _curses.KEY_A1: 'ka1', _curses.KEY_A3: 'ka3', _curses.KEY_B2: 'kb2', _curses.KEY_BACKSPACE: 'kbs', _curses.KEY_BEG: 'kbeg', ...
Python
"""Simple textbox editing widget with Emacs-like keybindings.""" import curses, ascii def rectangle(win, uly, ulx, lry, lrx): """Draw a rectangle with corners at the provided upper-left and lower-right coordinates. """ win.vline(uly+1, ulx, curses.ACS_VLINE, lry - uly - 1) win.hline(uly, ulx+1, cu...
Python
"""Constants and membership tests for ASCII characters""" NUL = 0x00 # ^@ SOH = 0x01 # ^A STX = 0x02 # ^B ETX = 0x03 # ^C EOT = 0x04 # ^D ENQ = 0x05 # ^E ACK = 0x06 # ^F BEL = 0x07 # ^G BS = 0x08 # ^H TAB = 0x09 # ^I HT = 0x09 # ^I LF = 0x0a # ^J NL =...
Python
"""curses.wrapper Contains one function, wrapper(), which runs another function which should be the rest of your curses-based application. If the application raises an exception, wrapper() will restore the terminal to a sane state so you can read the resulting traceback. """ import sys, curses def wrapper(func, *a...
Python
"""curses.panel Module for using panels with curses. """ __revision__ = "$Id: panel.py,v 1.2 2004/07/18 06:14:41 tim_one Exp $" from _curses_panel import *
Python
"""curses The main package for curses support for Python. Normally used by importing the package, and perhaps a particular module inside it. import curses from curses import textpad curses.initwin() ... """ __revision__ = "$Id: __init__.py,v 1.5 2004/07/18 06:14:41 tim_one Exp $" from _curses import *...
Python
"""Helper to provide extensibility for pickle/cPickle. This is only useful to add pickle support for extension types defined in C, not for instances of user-defined classes. """ from types import ClassType as _ClassType __all__ = ["pickle", "constructor", "add_extension", "remove_extension", "clear_extens...
Python
r"""OS routines for Mac, DOS, NT, or Posix depending on what system we're on. This exports: - all functions from posix, nt, os2, mac, or ce, e.g. unlink, stat, etc. - os.path is one of the modules posixpath, ntpath, or macpath - os.name is 'posix', 'nt', 'os2', 'mac', 'ce' or 'riscos' - os.curdir is a string r...
Python
#! /usr/bin/env python """Classes to handle Unix style, MMDF style, and MH style mailboxes.""" import rfc822 import os __all__ = ["UnixMailbox","MmdfMailbox","MHMailbox","Maildir","BabylMailbox", "PortableUnixMailbox"] class _Mailbox: def __init__(self, fp, factory=rfc822.Message): self.fp ...
Python
"""Pseudo terminal utilities.""" # Bugs: No signal handling. Doesn't set slave termios and window size. # Only tested on Linux. # See: W. Richard Stevens. 1992. Advanced Programming in the # UNIX Environment. Chapter 19. # Author: Steen Lumholt -- with additions by Guido. from select import select imp...
Python
# # Secret Labs' Regular Expression Engine # # convert re-style regular expression to sre pattern # # Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved. # # See the sre.py file for information on usage and redistribution. # """Internal support module for sre""" # XXX: show string offset and offending ch...
Python
"""Utilities needed to emulate Python's interactive interpreter. """ # Inspired by similar code by Jeff Epler and Fredrik Lundh. import sys import traceback from codeop import CommandCompiler, compile_command __all__ = ["InteractiveInterpreter", "InteractiveConsole", "interact", "compile_command"] def ...
Python
# Copyright (c) 2004 Python Software Foundation. # All rights reserved. # Written by Eric Price <eprice at tjhsst.edu> # and Facundo Batista <facundo at taniquetil.com.ar> # and Raymond Hettinger <python at rcn.com> # and Aahz <aahz at pobox.com> # and Tim Peters # This module is currently Py2.3 compatibl...
Python
#! /usr/bin/env python """An RFC 2821 smtp proxy. Usage: %(program)s [options] [localhost:localport [remotehost:remoteport]] Options: --nosetuid -n This program generally tries to setuid `nobody', unless this flag is set. The setuid call will fail if this program is not run as root (in ...
Python
"""Debugger basics""" import sys import os import types __all__ = ["BdbQuit","Bdb","Breakpoint"] class BdbQuit(Exception): """Exception to give up completely""" class Bdb: """Generic Python debugger base class. This class takes care of details of the trace facility; a derived class should impleme...
Python
"""Simple XML-RPC Server. This module can be used to create simple XML-RPC servers by creating a server and either installing functions, a class instance, or by extending the SimpleXMLRPCServer class. It can also be used to handle XML-RPC requests in a CGI environment using CGIXMLRPCRequestHandler. A list of possibl...
Python
#! /usr/bin/env python """Non-terminal symbols of Python grammar (from "graminit.h").""" # This file is automatically generated; please don't muck it up! # # To update the symbols in this file, 'cd' to the top directory of # the python source tree after building the interpreter and run: # # python Lib/symbol.py...
Python
"""Text wrapping and filling. """ # Copyright (C) 1999-2001 Gregory P. Ward. # Copyright (C) 2002, 2003 Python Software Foundation. # Written by Greg Ward <gward@python.net> __revision__ = "$Id: textwrap.py,v 1.35.4.1 2005/03/05 02:38:32 gward Exp $" import string, re # Do the right thing with boolean values for al...
Python
"""Shared support for scanning document type declarations in HTML and XHTML.""" import re _declname_match = re.compile(r'[a-zA-Z][-_.a-zA-Z0-9]*\s*').match _declstringlit_match = re.compile(r'(\'[^\']*\'|"[^"]*")\s*').match _commentclose = re.compile(r'--\s*>') _markedsectionclose = re.compile(r']\s*]\s*>') # An ana...
Python
# -*- Mode: Python -*- # Id: asyncore.py,v 2.51 2000/09/07 22:29:26 rushing Exp # Author: Sam Rushing <rushing@nightmare.com> # ====================================================================== # Copyright 1996 by Sam Rushing # # All Rights Reserved # # Permission to use, copy, modify,...
Python
""" Import utilities Exported classes: ImportManager Manage the import process Importer Base class for replacing standard import functions BuiltinImporter Emulate the import mechanism for builtin and frozen modules DynLoadSuffixImporter """ # note: avoid importing non-builtin modules import...
Python
#!/usr/bin/env python ''' Python unit testing framework, based on Erich Gamma's JUnit and Kent Beck's Smalltalk testing framework. This module contains the core framework classes that form the basis of specific test cases and suites (TestCase, TestSuite etc.), and also a text-based utility class for running the tests ...
Python
"""Mutual exclusion -- for use with module sched A mutex has two pieces of state -- a 'locked' bit and a queue. When the mutex is not locked, the queue is empty. Otherwise, the queue contains 0 or more (function, argument) pairs representing functions (or methods) waiting to acquire the lock. When the mutex is unlocke...
Python
"""Conversion functions between RGB and other color systems. This modules provides two functions for each color system ABC: rgb_to_abc(r, g, b) --> a, b, c abc_to_rgb(a, b, c) --> r, g, b All inputs and outputs are triples of floats in the range [0.0...1.0]. Inputs outside this range may cause exceptions or inva...
Python
"""Utilities for comparing files and directories. Classes: dircmp Functions: cmp(f1, f2, shallow=1) -> int cmpfiles(a, b, common) -> ([], [], []) """ import os import stat import warnings from itertools import ifilter, ifilterfalse, imap, izip __all__ = ["cmp","dircmp","cmpfiles"] _cache = {} BUFSIZE=...
Python
#! /usr/bin/env python """RFC 3548: Base16, Base32, Base64 Data Encodings""" # Modified 04-Oct-1995 by Jack Jansen to use binascii module # Modified 30-Dec-2003 by Barry Warsaw to add full RFC 3548 support import re import struct import binascii __all__ = [ # Legacy interface exports traditional RFC 1521 Base6...
Python
"""Random variable generators. integers -------- uniform within range sequences --------- pick random element pick random sample generate random permutation distributions on the real line: ------------------------------ uniform ...
Python
"""HTTP/1.1 client library <intro stuff goes here> <other stuff, too> HTTPConnection go through a number of "states", which defines when a client may legally make another request or fetch the response for a particular request. This diagram details these state transitions: (null) | | HTTPConnection() ...
Python
"""Provide a (g)dbm-compatible interface to bsddb.hashopen.""" import sys try: import bsddb except ImportError: # prevent a second import of this module from spuriously succeeding del sys.modules[__name__] raise __all__ = ["error","open"] error = bsddb.error # Exported for anydbm ...
Python
"""RFC 2822 message manipulation. Note: This is only a very rough sketch of a full RFC-822 parser; in particular the tokenizing of addresses does not adhere to all the quoting rules. Note: RFC 2822 is a long awaited update to RFC 822. This module should conform to RFC 2822, and is thus mis-named (it's not worth rena...
Python
"""Read and cache directory listings. The listdir() routine returns a sorted list of the files in a directory, using a cache to avoid reading the directory more often than necessary. The annotate() routine appends slashes to directories.""" import os __all__ = ["listdir", "opendir", "annotate", "reset"] cache = {} ...
Python
"""An object-oriented interface to .netrc files.""" # Module and documentation by Eric S. Raymond, 21 Dec 1998 import os, shlex __all__ = ["netrc", "NetrcParseError"] class NetrcParseError(Exception): """Exception raised on syntax errors in the .netrc file.""" def __init__(self, msg, filename=None, lineno=...
Python
"""Extract, format and print information about Python stack traces.""" import linecache import sys import types __all__ = ['extract_stack', 'extract_tb', 'format_exception', 'format_exception_only', 'format_list', 'format_stack', 'format_tb', 'print_exc', 'format_exc', 'print_exception', ...
Python
"""Generic MIME writer. This module defines the class MimeWriter. The MimeWriter class implements a basic formatter for creating MIME multi-part files. It doesn't seek around the output file nor does it use large amounts of buffer space. You must write the parts out in the order that they should occur in the final f...
Python
"""Macintosh binhex compression/decompression. easy interface: binhex(inputfilename, outputfilename) hexbin(inputfilename, outputfilename) """ # # Jack Jansen, CWI, August 1995. # # The module is supposed to be as compatible as possible. Especially the # easy interface should work "as expected" on any platform. # XXX...
Python
""" atexit.py - allow programmer to define multiple exit functions to be executed upon normal program termination. One public function, register, is defined. """ __all__ = ["register"] import sys _exithandlers = [] def _run_exitfuncs(): """run any registered exit functions _exithandlers is traversed in rev...
Python
"""Guess the MIME type of a file. This module defines two useful functions: guess_type(url, strict=1) -- guess the MIME type and encoding of a URL. guess_extension(type, strict=1) -- guess the extension for a given MIME type. It also contains the following, for tuning the behavior: Data: knownfiles -- list of fil...
Python
"""Parse (absolute and relative) URLs. See RFC 1808: "Relative Uniform Resource Locators", by R. Fielding, UC Irvine, June 1995. """ __all__ = ["urlparse", "urlunparse", "urljoin", "urldefrag", "urlsplit", "urlunsplit"] # A classification of schemes ('' means apply by default) uses_relative = ['ftp', 'htt...
Python
#------------------------------------------------------------------------ # # Copyright (C) 2000 Autonomous Zone Industries # # License: This is free software. You may use this software for any # purpose including modification/redistribution, so long as # this header remains intact and...
Python
#!/bin/env python #------------------------------------------------------------------------ # Copyright (c) 1997-2001 by Total Control Software # All Rights Reserved #------------------------------------------------------------------------ # # Module Name: dbShelve.py # # Description:...
Python
#---------------------------------------------------------------------- # Copyright (c) 1999-2001, Digital Creations, Fredericksburg, VA, USA # and Andrew Kuchling. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following c...
Python
#------------------------------------------------------------------------- # This file contains real Python object wrappers for DB and DBEnv # C "objects" that can be usefully subclassed. The previous SWIG # based interface allowed this thanks to SWIG's shadow classes. # -- Gregory P. Smith #--------------------...
Python
""" File-like objects that read from or write to a bsddb record. This implements (nearly) all stdio methods. f = DBRecIO(db, key, txn=None) f.close() # explicitly release resources held flag = f.isatty() # always false pos = f.tell() # get current position f.seek(pos) # set current position ...
Python
#!/bin/env python #------------------------------------------------------------------------ # Copyright (c) 1997-2001 by Total Control Software # All Rights Reserved #------------------------------------------------------------------------ # # Module Name: dbShelve.py # # Description:...
Python
#---------------------------------------------------------------------- # Copyright (c) 1999-2001, Digital Creations, Fredericksburg, VA, USA # and Andrew Kuchling. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following c...
Python
#----------------------------------------------------------------------- # # Copyright (C) 2000, 2001 by Autonomous Zone Industries # Copyright (C) 2002 Gregory P. Smith # # License: This is free software. You may use this software for any # purpose including modification/redistribution, so long as ...
Python
#!/usr/bin/env python # #----------------------------------------------------------------------- # A test suite for the table interface built on bsddb.db #----------------------------------------------------------------------- # # Copyright (C) 2000, 2001 by Autonomous Zone Industries # Copyright (C) 2002 Gregory P. Sm...
Python
#! /usr/bin/env python # # Class for profiling python code. rev 1.0 6/2/94 # # Based on prior profile module by Sjoerd Mullender... # which was hacked somewhat by: Guido van Rossum # # See profile.doc for more information """Class for profiling Python code.""" # Copyright 1994, by InfoSeek Corporation, all rights ...
Python
"""Weak reference support for Python. This module is an implementation of PEP 205: http://python.sourceforge.net/peps/pep-0205.html """ # Naming convention: Variables named "wr" are weak reference objects; # they are called this instead of "ref" to avoid name collisions with # the module-global ref() function import...
Python
# Symbols from <gl/get.h> BCKBUFFER = 0x1 FRNTBUFFER = 0x2 DRAWZBUFFER = 0x4 DMRGB = 0 DMSINGLE = 1 DMDOUBLE = 2 DMRGBDOUBLE = 5 HZ30 = 0 HZ60 = 1 NTSC = 2 HDTV = 3 VGA = 4 IRIS3K = 5 PR60 = 6 PAL = 9 HZ30_SG = 11 A343 = 14 STR_RECT = 15 VOF0 = 16 VOF1 = 17 VOF2 = 18 VOF3 = 19 SGI0 = 20 SGI1 = 21 SGI2 = 22 HZ72 = 23 G...
Python
# Implement 'jpeg' interface using SGI's compression library # XXX Options 'smooth' and 'optimize' are ignored. # XXX It appears that compressing grayscale images doesn't work right; # XXX the resulting file causes weirdness. class error(Exception): pass options = {'quality': 75, 'optimize': 0, 'smooth': 0, 'fo...
Python
# This file implements a class which forms an interface to the .cdplayerrc # file that is maintained by SGI's cdplayer program. # # Usage is as follows: # # import readcd # r = readcd.Readcd() # c = Cdplayer(r.gettrackinfo()) # # Now you can use c.artist, c.title and c.track[trackno] (where trackno # starts at 1). Whe...
Python
# # flp - Module to load fl forms from fd files # # Jack Jansen, December 1991 # import os import sys import FL SPLITLINE = '--------------------' FORMLINE = '=============== FORM ===============' ENDLINE = '==============================' class error(Exception): pass ############################################...
Python
NOERROR = 0 NOCONTEXT = -1 NODISPLAY = -2 NOWINDOW = -3 NOGRAPHICS = -4 NOTTOP = -5 NOVISUAL = -6 BUFSIZE = -7 BADWINDOW = -8 ALREADYBOUND = -100 BINDFAILED = -101 SETFAILED = -102
Python
# Convert "arbitrary" image files to rgb files (SGI's image format). # Input may be compressed. # The uncompressed file type may be PBM, PGM, PPM, GIF, TIFF, or Sun raster. # An exception is raised if the file is not of a recognized type. # Returned filename is either the input filename or a temporary filename; # in th...
Python
# Backward compatible module CL. # All relevant symbols are now defined in the module cl. try: from cl import * except ImportError: from CL_old import * else: del CompressImage del DecompressImage del GetAlgorithmName del OpenCompressor del OpenDecompressor del QueryAlgorithms del Qu...
Python
# Constants used by the FORMS library (module fl). # This corresponds to "forms.h". # Recommended use: import FL; ... FL.NORMAL_BOX ... etc. # Alternate use: from FL import *; ... NORMAL_BOX ... etc. _v20 = 1 _v21 = 1 ##import fl ##try: ## _v20 = (fl.get_rgbmode is not None) ##except: ## _v20 = 0 ##del fl N...
Python
ERROR = 0 NODISC = 1 READY = 2 PLAYING = 3 PAUSED = 4 STILL = 5 AUDIO = 0 PNUM = 1 INDEX = 2 PTIME = 3 ATIME = 4 CATALOG = 5 IDENT = 6 CONTROL = 7 CDDA_DATASIZE = 2352 ##CDDA_SUBCODE...
Python
# This file implements a class which forms an interface to the .cddb # directory that is maintained by SGI's cdman program. # # Usage is as follows: # # import readcd # r = readcd.Readcd() # c = Cddb(r.gettrackinfo()) # # Now you can use c.artist, c.title and c.track[trackno] (where trackno # starts at 1). When the CD...
Python
NULL = 0 FALSE = 0 TRUE = 1 ATTRIBSTACKDEPTH = 10 VPSTACKDEPTH = 8 MATRIXSTACKDEPTH = 32 NAMESTACKDEPTH = 1025 STARTTAG = -2 ENDTAG = -3 BLACK = 0 RED = 1 GREEN = 2 YELLOW = 3 BLUE = 4 MAGENTA = 5 CYAN = 6 WHITE = 7 PUP_CLEAR = 0 PUP_COLOR = 1 PUP_BLACK = 2 PUP_WHITE = 3 NORMALDRAW = 0x010 PUPDRAW = 0x020 OVERDRAW = 0x...
Python
NTSC_XMAX = 640 NTSC_YMAX = 480 PAL_XMAX = 768 PAL_YMAX = 576 BLANKING_BUFFER_SIZE = 2 MAX_SOURCES = 2 # mode parameter for Bind calls IN_OFF = 0 # No Video IN_OVER = 1 # Video over graphics IN_UNDER = 2 # Video under graphics IN_REPL...
Python
# Class interface to the CD module. import cd, CD class Error(Exception): pass class _Stop(Exception): pass def _doatime(self, cb_type, data): if ((data[0] * 60) + data[1]) * 75 + data[2] > self.end: ## print 'done with list entry', repr(self.listindex) raise _Stop func, arg = se...
Python
# Module 'panel' # # Support for the Panel library. # Uses built-in module 'pnl'. # Applications should use 'panel.function' instead of 'pnl.function'; # most 'pnl' functions are transparently exported by 'panel', # but dopanel() is overridden and you have to use this version # if you want to use callbacks. import pn...
Python
NULLDEV = 0 BUTOFFSET = 1 VALOFFSET = 256 PSEUDOFFSET = 512 BUT2OFFSET = 3840 TIMOFFSET = 515 XKBDOFFSET = 143 BUTCOUNT = 255 VALCOUNT = 256 TIMCOUNT = 4 XKBDCOUNT = 28 USERBUTOFFSET = 4096 USERVALOFFSET = 12288 USERPSEUDOFFSET = 16384 BUT0 = 1 BUT1 = 2 BUT2 = 3 BUT3 = 4 BUT4 = 5 BUT5 = 6 BUT6 = 7 BUT7 = 8 BUT8 = 9 BUT...
Python
RATE_48000 = 48000 RATE_44100 = 44100 RATE_32000 = 32000 RATE_22050 = 22050 RATE_16000 = 16000 RATE_11025 = 11025 RATE_8000 = 8000 SAMPFMT_TWOSCOMP= 1 SAMPFMT_FLOAT = 32 SAMPFMT_DOUBLE = 64 SAMPLE_8 = 1 SAMPLE_16 = 2 # SAMPLE_24 is the low 24 bits of a long,...
Python
# Module 'parser' # # Parse S-expressions output by the Panel Editor # (which is written in Scheme so it can't help writing S-expressions). # # See notes at end of file. whitespace = ' \t\n' operators = '()\'' separators = operators + whitespace + ';' + '"' # Tokenize a string. # Return a list of tokens (strings). ...
Python
"""Mailcap file handling. See RFC 1524.""" import os __all__ = ["getcaps","findmatch"] # Part 1: top-level interface. def getcaps(): """Return a dictionary containing the mailcap database. The dictionary maps a MIME type (in all lowercase, e.g. 'text/plain') to a list of dictionaries corresponding to ...
Python
"""Tokenization help for Python programs. generate_tokens(readline) is a generator that breaks a stream of text into Python tokens. It accepts a readline-like method which is called repeatedly to get the next line of input (or "" for EOF). It generates 5-tuples with these members: the token type (see token.py) ...
Python
#! /usr/local/bin/python # NOTE: the above "/usr/local/bin/python" is NOT a mistake. It is # intentionally NOT "/usr/bin/env python". On many systems # (e.g. Solaris), /usr/local/bin is not in $PATH as passed to CGI # scripts, and /usr/local/bin is the default directory where Python is # installed, so /usr/bin/env w...
Python
"""Classes to represent arbitrary sets (including sets of sets). This module implements sets using dictionaries whose values are ignored. The usual operations (union, intersection, deletion, etc.) are provided as both methods and operators. Important: sets are not sequences! While they support 'x in s', 'len(s)', a...
Python
"""A generic class to build line-oriented command interpreters. Interpreters constructed with this class obey the following conventions: 1. End of file on input is processed as the command 'EOF'. 2. A command is parsed out of each line by collecting the prefix composed of characters in the identchars member. 3. A ...
Python
"""Routines to help recognizing sound files. Function whathdr() recognizes various types of sound file headers. It understands almost all headers that SOX can decode. The return tuple contains the following items, in this order: - file type (as SOX understands it) - sampling rate (0 if unknown or hard to decode) - nu...
Python
# Symbolic constants for use with sunaudiodev module # The names are the same as in audioio.h with the leading AUDIO_ # removed. # Not all values are supported on all releases of SunOS. # Encoding types, for fields i_encoding and o_encoding ENCODING_NONE = 0 # no encoding assigned ENCODING_ULAW...
Python
"""Manage shelves of pickled objects. A "shelf" is a persistent, dictionary-like object. The difference with dbm databases is that the values (not the keys!) in a shelf can be essentially arbitrary Python objects -- anything that the "pickle" module can handle. This includes most class instances, recursive data type...
Python
r"""File-like objects that read from or write to a string buffer. This implements (nearly) all stdio methods. f = StringIO() # ready for writing f = StringIO(buf) # ready for reading f.close() # explicitly release resources held flag = f.isatty() # always false pos = f.tell() # get current pos...
Python
# Copyright (C) 2001-2004 Python Software Foundation # Author: Barry Warsaw # Contact: email-sig@python.org """Base class for MIME specializations.""" from email import Message class MIMEBase(Message.Message): """Base class for MIME specializations.""" def __init__(self, _maintype, _subtype, **_params): ...
Python
# Copyright (C) 2001-2004 Python Software Foundation # Author: Barry Warsaw # Contact: email-sig@python.org """email package exception classes.""" class MessageError(Exception): """Base class for errors in the email package.""" class MessageParseError(MessageError): """Base class for message parsing erro...
Python
# Copyright (C) 2001-2004 Python Software Foundation # Author: Ben Gertzfield, Barry Warsaw # Contact: email-sig@python.org import email.base64MIME import email.quopriMIME from email.Encoders import encode_7or8bit # Flags for types of header encodings QP = 1 # Quoted-Printable BASE64 = 2 # Base64 SHO...
Python
# Copyright (C) 2002-2004 Python Software Foundation # Author: Ben Gertzfield # Contact: email-sig@python.org """Base64 content transfer encoding per RFCs 2045-2047. This module handles the content transfer encoding method defined in RFC 2045 to encode arbitrary 8-bit data using the three 8-bit bytes in four 7-bit ch...
Python
# Copyright (C) 2001-2004 Python Software Foundation # Author: Ben Gertzfield # Contact: email-sig@python.org """Quoted-printable content transfer encoding per RFCs 2045-2047. This module handles the content transfer encoding method defined in RFC 2045 to encode US ASCII-like 8-bit data called `quoted-printable'. It...
Python
# Copyright (C) 2002-2004 Python Software Foundation # Author: Ben Gertzfield, Barry Warsaw # Contact: email-sig@python.org """Header encoding and decoding functionality.""" import re import binascii import email.quopriMIME import email.base64MIME from email.Errors import HeaderParseError from email.Charset import C...
Python
# Copyright (C) 2001-2004 Python Software Foundation # Author: Barry Warsaw # Contact: email-sig@python.org """Class representing image/* type MIME documents.""" import imghdr from email import Errors from email import Encoders from email.MIMENonMultipart import MIMENonMultipart class MIMEImage(MIMENonMultipart)...
Python
# Copyright (C) 2001-2004 Python Software Foundation # Author: Barry Warsaw, Thomas Wouters, Anthony Baxter # Contact: email-sig@python.org """A parser of RFC 2822 and MIME email messages.""" import warnings from cStringIO import StringIO from email.FeedParser import FeedParser from email.Message import Message c...
Python
# Copyright (C) 2001-2004 Python Software Foundation # Author: Barry Warsaw # Contact: email-sig@python.org """Miscellaneous utilities.""" import os import re import time import base64 import random import socket import warnings from cStringIO import StringIO from email._parseaddr import quote from email._parseaddr ...
Python
# Copyright (C) 2001-2004 Python Software Foundation # Author: Anthony Baxter # Contact: email-sig@python.org """Class representing audio/* type MIME documents.""" import sndhdr from cStringIO import StringIO from email import Errors from email import Encoders from email.MIMENonMultipart import MIMENonMultipart ...
Python
# Copyright (C) 2004 Python Software Foundation # Authors: Baxter, Wouters and Warsaw # Contact: email-sig@python.org """FeedParser - An email feed parser. The feed parser implements an interface for incrementally parsing an email message, line by line. This has advantages for certain applications, such as those rea...
Python
# Copyright (C) 2002-2004 Python Software Foundation # Author: Barry Warsaw # Contact: email-sig@python.org """Base class for MIME type messages that are not multipart.""" from email import Errors from email import MIMEBase class MIMENonMultipart(MIMEBase.MIMEBase): """Base class for MIME multipart/* type mes...
Python
# Copyright (C) 2001-2004 Python Software Foundation # Author: Barry Warsaw # Contact: email-sig@python.org """Basic message object for the email package object model.""" import re import uu import binascii import warnings from cStringIO import StringIO # Intrapackage imports from email import Utils from email impor...
Python
# Copyright (C) 2001-2004 Python Software Foundation # Author: Barry Warsaw # Contact: email-sig@python.org """Encodings and related functions.""" import base64 from quopri import encodestring as _encodestring def _qencode(s): enc = _encodestring(s, quotetabs=True) # Must encode spaces, which quopri.encodest...
Python
# Copyright (C) 2001-2004 Python Software Foundation # Author: Barry Warsaw # Contact: email-sig@python.org """A package for parsing, handling, and generating email messages.""" __version__ = '3.0+' __all__ = [ 'base64MIME', 'Charset', 'Encoders', 'Errors', 'Generator', 'Header', 'Iterato...
Python
# Copyright (C) 2001-2004 Python Software Foundation # Author: Barry Warsaw # Contact: email-sig@python.org """Classes to generate plain text from a message object tree.""" import re import sys import time import random import warnings from cStringIO import StringIO from email.Header import Header UNDERSCORE = '_' ...
Python
# Copyright (C) 2001-2004 Python Software Foundation # Author: Barry Warsaw # Contact: email-sig@python.org """Class representing text/* type MIME documents.""" from email.MIMENonMultipart import MIMENonMultipart from email.Encoders import encode_7or8bit class MIMEText(MIMENonMultipart): """Class for generati...
Python
# Copyright (C) 2002-2004 Python Software Foundation # Author: Barry Warsaw # Contact: email-sig@python.org """Base class for MIME multipart/* type messages.""" from email import MIMEBase class MIMEMultipart(MIMEBase.MIMEBase): """Base class for MIME multipart/* type messages.""" def __init__(self, _subt...
Python