SymbolType-1.0/0000755000000000000000000000000011637401374012165 5ustar rootrootSymbolType-1.0/PKG-INFO0000666000000000000000000000564310435276202013271 0ustar rootrootMetadata-Version: 1.0 Name: SymbolType Version: 1.0 Summary: Simple "symbol" type, useful for enumerations or sentinels Home-page: http://peak.telecommunity.com/DevCenter/SymbolType Author: Phillip J. Eby Author-email: peak@eby-sarna.com License: PSF or ZPL Description: Installing SymbolType (using ``"easy_install SymbolType"`` or ``"setup.py install"``) gives you access to the ``peak.util.symbols`` module, previously available only by installing the full PEAK toolkit. ``peak.util.symbols`` provides a ``Symbol`` type and two built-in symbols that are used by PEAK: ``NOT_FOUND`` and ``NOT_GIVEN``. You can create your own symbol objects using the ``Symbol`` type, by giving it the symbol name and the name of the module where the symbol is being created:: >>> from peak.util.symbols import Symbol >>> AN_EXAMPLE = Symbol('AN_EXAMPLE', __name__) The resulting object's ``repr()`` and ``str()`` forms are the same as the name you passed in:: >>> AN_EXAMPLE AN_EXAMPLE >>> str(AN_EXAMPLE) 'AN_EXAMPLE' But symbols compare equal only to themselves; they are not equal to strings:: >>> AN_EXAMPLE == 'AN_EXAMPLE' False >>> AN_EXAMPLE == AN_EXAMPLE True A symbol's ``__name__`` and ``__module__`` attributes are the original name and module used to create the symbol:: >>> from peak.util.symbols import NOT_FOUND >>> NOT_FOUND.__name__ 'NOT_FOUND' >>> NOT_FOUND.__module__ 'peak.util.symbols' The reason that symbols want to know their defining module is that this allows them to be pickled and unpickled correctly:: >>> import pickle >>> pickle.loads(pickle.dumps(NOT_FOUND)) NOT_FOUND Specifically, it's so that the result of unpickling a symbol is exactly the same object as the original symbol:: >>> pickle.loads(pickle.dumps(NOT_FOUND)) is NOT_FOUND True Note that this means the symbol must be defined at module level within its module, with the same name that's passed in to it, or else ``pickle`` will not be able to find it when unpickling. Last, but not least, symbol objects are immutable and cannot be changed in any way:: >>> AN_EXAMPLE.foo = "bar" Traceback (most recent call last): ... TypeError: Symbols are immutable Mailing List ------------ Please direct questions regarding this package to the PEAK mailing list; see http://www.eby-sarna.com/mailman/listinfo/PEAK/ for details. Platform: UNKNOWN SymbolType-1.0/test_symbols.py0000666000000000000000000000025410435273650015272 0ustar rootrootdef additional_tests(): import doctest return doctest.DocFileSuite( 'README.txt', optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE, ) SymbolType-1.0/SymbolType.egg-info/0000755000000000000000000000000011637401374015766 5ustar rootrootSymbolType-1.0/SymbolType.egg-info/SOURCES.txt0000666000000000000000000000043710435276202017655 0ustar rootrootREADME.txt setup.py test_symbols.py SymbolType.egg-info/PKG-INFO SymbolType.egg-info/SOURCES.txt SymbolType.egg-info/namespace_packages.txt SymbolType.egg-info/top_level.txt ez_setup/README.txt ez_setup/__init__.py peak/__init__.py peak/util/__init__.py peak/util/symbols.py SymbolType-1.0/SymbolType.egg-info/PKG-INFO0000666000000000000000000000564310435276202017072 0ustar rootrootMetadata-Version: 1.0 Name: SymbolType Version: 1.0 Summary: Simple "symbol" type, useful for enumerations or sentinels Home-page: http://peak.telecommunity.com/DevCenter/SymbolType Author: Phillip J. Eby Author-email: peak@eby-sarna.com License: PSF or ZPL Description: Installing SymbolType (using ``"easy_install SymbolType"`` or ``"setup.py install"``) gives you access to the ``peak.util.symbols`` module, previously available only by installing the full PEAK toolkit. ``peak.util.symbols`` provides a ``Symbol`` type and two built-in symbols that are used by PEAK: ``NOT_FOUND`` and ``NOT_GIVEN``. You can create your own symbol objects using the ``Symbol`` type, by giving it the symbol name and the name of the module where the symbol is being created:: >>> from peak.util.symbols import Symbol >>> AN_EXAMPLE = Symbol('AN_EXAMPLE', __name__) The resulting object's ``repr()`` and ``str()`` forms are the same as the name you passed in:: >>> AN_EXAMPLE AN_EXAMPLE >>> str(AN_EXAMPLE) 'AN_EXAMPLE' But symbols compare equal only to themselves; they are not equal to strings:: >>> AN_EXAMPLE == 'AN_EXAMPLE' False >>> AN_EXAMPLE == AN_EXAMPLE True A symbol's ``__name__`` and ``__module__`` attributes are the original name and module used to create the symbol:: >>> from peak.util.symbols import NOT_FOUND >>> NOT_FOUND.__name__ 'NOT_FOUND' >>> NOT_FOUND.__module__ 'peak.util.symbols' The reason that symbols want to know their defining module is that this allows them to be pickled and unpickled correctly:: >>> import pickle >>> pickle.loads(pickle.dumps(NOT_FOUND)) NOT_FOUND Specifically, it's so that the result of unpickling a symbol is exactly the same object as the original symbol:: >>> pickle.loads(pickle.dumps(NOT_FOUND)) is NOT_FOUND True Note that this means the symbol must be defined at module level within its module, with the same name that's passed in to it, or else ``pickle`` will not be able to find it when unpickling. Last, but not least, symbol objects are immutable and cannot be changed in any way:: >>> AN_EXAMPLE.foo = "bar" Traceback (most recent call last): ... TypeError: Symbols are immutable Mailing List ------------ Please direct questions regarding this package to the PEAK mailing list; see http://www.eby-sarna.com/mailman/listinfo/PEAK/ for details. Platform: UNKNOWN SymbolType-1.0/SymbolType.egg-info/top_level.txt0000666000000000000000000000000510435276202020512 0ustar rootrootpeak SymbolType-1.0/SymbolType.egg-info/namespace_packages.txt0000666000000000000000000000001710435276202022316 0ustar rootrootpeak peak.util SymbolType-1.0/setup.py0000666000000000000000000000203110435276114013674 0ustar rootroot#!/usr/bin/env python """Distutils setup file""" import ez_setup ez_setup.use_setuptools() from setuptools import setup # Metadata PACKAGE_NAME = "SymbolType" PACKAGE_VERSION = "1.0" PACKAGES = ['peak', 'peak.util'] def get_description(): # Get our long description from the documentation f = file('README.txt') lines = [] for line in f: if not line.strip(): break # skip to first blank line for line in f: if line.startswith('.. contents::'): break # read to table of contents lines.append(line) f.close() return ''.join(lines) setup( name=PACKAGE_NAME, version=PACKAGE_VERSION, description='Simple "symbol" type, useful for enumerations or sentinels', long_description = get_description(), author="Phillip J. Eby", author_email="peak@eby-sarna.com", license="PSF or ZPL", url="http://peak.telecommunity.com/DevCenter/SymbolType", test_suite = 'test_symbols', packages = PACKAGES, namespace_packages = PACKAGES, ) SymbolType-1.0/README.txt0000666000000000000000000000421410435275742013673 0ustar rootrootSimple "Symbol" Type ==================== Installing SymbolType (using ``"easy_install SymbolType"`` or ``"setup.py install"``) gives you access to the ``peak.util.symbols`` module, previously available only by installing the full PEAK toolkit. ``peak.util.symbols`` provides a ``Symbol`` type and two built-in symbols that are used by PEAK: ``NOT_FOUND`` and ``NOT_GIVEN``. You can create your own symbol objects using the ``Symbol`` type, by giving it the symbol name and the name of the module where the symbol is being created:: >>> from peak.util.symbols import Symbol >>> AN_EXAMPLE = Symbol('AN_EXAMPLE', __name__) The resulting object's ``repr()`` and ``str()`` forms are the same as the name you passed in:: >>> AN_EXAMPLE AN_EXAMPLE >>> str(AN_EXAMPLE) 'AN_EXAMPLE' But symbols compare equal only to themselves; they are not equal to strings:: >>> AN_EXAMPLE == 'AN_EXAMPLE' False >>> AN_EXAMPLE == AN_EXAMPLE True A symbol's ``__name__`` and ``__module__`` attributes are the original name and module used to create the symbol:: >>> from peak.util.symbols import NOT_FOUND >>> NOT_FOUND.__name__ 'NOT_FOUND' >>> NOT_FOUND.__module__ 'peak.util.symbols' The reason that symbols want to know their defining module is that this allows them to be pickled and unpickled correctly:: >>> import pickle >>> pickle.loads(pickle.dumps(NOT_FOUND)) NOT_FOUND Specifically, it's so that the result of unpickling a symbol is exactly the same object as the original symbol:: >>> pickle.loads(pickle.dumps(NOT_FOUND)) is NOT_FOUND True Note that this means the symbol must be defined at module level within its module, with the same name that's passed in to it, or else ``pickle`` will not be able to find it when unpickling. Last, but not least, symbol objects are immutable and cannot be changed in any way:: >>> AN_EXAMPLE.foo = "bar" Traceback (most recent call last): ... TypeError: Symbols are immutable Mailing List ------------ Please direct questions regarding this package to the PEAK mailing list; see http://www.eby-sarna.com/mailman/listinfo/PEAK/ for details. SymbolType-1.0/peak/0000755000000000000000000000000011637401374013105 5ustar rootrootSymbolType-1.0/peak/__init__.py0000666000000000000000000000007110434442252015212 0ustar rootroot__import__('pkg_resources').declare_namespace(__name__) SymbolType-1.0/peak/util/0000755000000000000000000000000011637401374014062 5ustar rootrootSymbolType-1.0/peak/util/symbols.py0000666000000000000000000000137510435273366016141 0ustar rootroot"""Symbolic global constants, like 'None', 'NOT_FOUND', etc.""" __all__ = [ 'Symbol','NOT_GIVEN','NOT_FOUND' ] class Symbol(object): """Symbolic global constant""" __slots__ = ['_name', '_module'] __name__ = property(lambda s: s._name) __module__ = property(lambda s: s._module) def __init__(self, symbol, moduleName): self.__class__._name.__set__(self,symbol) self.__class__._module.__set__(self,moduleName) def __reduce__(self): return self._name def __setattr__(self,attr,val): raise TypeError("Symbols are immutable") def __repr__(self): return self.__name__ __str__ = __repr__ NOT_GIVEN = Symbol("NOT_GIVEN", __name__) NOT_FOUND = Symbol("NOT_FOUND", __name__) SymbolType-1.0/peak/util/__init__.py0000666000000000000000000000007010434442260016165 0ustar rootroot__import__('pkg_resources').declare_namespace(__name__) SymbolType-1.0/ez_setup/0000755000000000000000000000000011637401374014023 5ustar rootrootSymbolType-1.0/ez_setup/__init__.py0000666000000000000000000001646610435276160016153 0ustar rootroot#!python """Bootstrap setuptools installation If you want to use setuptools in your package's setup.py, just include this file in the same directory with it, and add this to the top of your setup.py:: from ez_setup import use_setuptools use_setuptools() If you want to require a specific version of setuptools, set a download mirror, or use an alternate download directory, you can do so by supplying the appropriate options to ``use_setuptools()``. This file can also be run as a script to install or upgrade setuptools. """ import sys DEFAULT_VERSION = "0.6b1" DEFAULT_URL = "http://cheeseshop.python.org/packages/%s/s/setuptools/" % sys.version[:3] md5_data = { 'setuptools-0.6a10-py2.3.egg': '162d8357f1aff2b0349c6c247ee62987', 'setuptools-0.6a10-py2.4.egg': '803a2d8db501c1ac3b5b6fb4e907f788', 'setuptools-0.6a11-py2.3.egg': 'd12bf8e13aaeb25c91350c8d77f01a71', 'setuptools-0.6a11-py2.4.egg': 'a95d5bc7a070aa1028bc4dcb5270b133', 'setuptools-0.6b1-py2.3.egg': '8822caf901250d848b996b7f25c6e6ca', 'setuptools-0.6b1-py2.4.egg': 'b79a8a403e4502fbb85ee3f1941735cb', } import sys, os def _validate_md5(egg_name, data): if egg_name in md5_data: from md5 import md5 digest = md5(data).hexdigest() if digest != md5_data[egg_name]: print >>sys.stderr, ( "md5 validation of %s failed! (Possible download problem?)" % egg_name ) sys.exit(2) return data def use_setuptools( version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, download_delay=15 ): """Automatically find/download setuptools and make it available on sys.path `version` should be a valid setuptools version number that is available as an egg for download under the `download_base` URL (which should end with a '/'). `to_dir` is the directory where setuptools will be downloaded, if it is not already available. If `download_delay` is specified, it should be the number of seconds that will be paused before initiating a download, should one be required. If an older version of setuptools is installed, this routine will print a message to ``sys.stderr`` and raise SystemExit in an attempt to abort the calling script. """ try: import setuptools if setuptools.__version__ == '0.0.1': print >>sys.stderr, ( "You have an obsolete version of setuptools installed. Please\n" "remove it from your system entirely before rerunning this script." ) sys.exit(2) except ImportError: egg = download_setuptools(version, download_base, to_dir, download_delay) sys.path.insert(0, egg) import setuptools; setuptools.bootstrap_install_from = egg import pkg_resources try: pkg_resources.require("setuptools>="+version) except pkg_resources.VersionConflict: # XXX could we install in a subprocess here? print >>sys.stderr, ( "The required version of setuptools (>=%s) is not available, and\n" "can't be installed while this script is running. Please install\n" " a more recent version first." ) % version sys.exit(2) def download_setuptools( version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay = 15 ): """Download setuptools from a specified location and return its filename `version` should be a valid setuptools version number that is available as an egg for download under the `download_base` URL (which should end with a '/'). `to_dir` is the directory where the egg will be downloaded. `delay` is the number of seconds to pause before an actual download attempt. """ import urllib2, shutil egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3]) url = download_base + egg_name saveto = os.path.join(to_dir, egg_name) src = dst = None if not os.path.exists(saveto): # Avoid repeated downloads try: from distutils import log if delay: log.warn(""" --------------------------------------------------------------------------- This script requires setuptools version %s to run (even to display help). I will attempt to download it for you (from %s), but you may need to enable firewall access for this script first. I will start the download in %d seconds. (Note: if this machine does not have network access, please obtain the file %s and place it in this directory before rerunning this script.) ---------------------------------------------------------------------------""", version, download_base, delay, url ); from time import sleep; sleep(delay) log.warn("Downloading %s", url) src = urllib2.urlopen(url) # Read/write all in one block, so we don't create a corrupt file # if the download is interrupted. data = _validate_md5(egg_name, src.read()) dst = open(saveto,"wb"); dst.write(data) finally: if src: src.close() if dst: dst.close() return os.path.realpath(saveto) def main(argv, version=DEFAULT_VERSION): """Install or upgrade setuptools and EasyInstall""" try: import setuptools except ImportError: import tempfile, shutil tmpdir = tempfile.mkdtemp(prefix="easy_install-") try: egg = download_setuptools(version, to_dir=tmpdir, delay=0) sys.path.insert(0,egg) from setuptools.command.easy_install import main main(list(argv)+[egg]) finally: shutil.rmtree(tmpdir) else: if setuptools.__version__ == '0.0.1': # tell the user to uninstall obsolete version use_setuptools(version) req = "setuptools>="+version import pkg_resources try: pkg_resources.require(req) except pkg_resources.VersionConflict: try: from setuptools.command.easy_install import main except ImportError: from easy_install import main main(list(argv)+[download_setuptools(delay=0)]) sys.exit(0) # try to force an exit else: if argv: from setuptools.command.easy_install import main main(argv) else: print "Setuptools version",version,"or greater has been installed." print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)' def update_md5(filenames): """Update our built-in md5 registry""" import re from md5 import md5 for name in filenames: base = os.path.basename(name) f = open(name,'rb') md5_data[base] = md5(f.read()).hexdigest() f.close() data = [" %r: %r,\n" % it for it in md5_data.items()] data.sort() repl = "".join(data) import inspect srcfile = inspect.getsourcefile(sys.modules[__name__]) f = open(srcfile, 'rb'); src = f.read(); f.close() match = re.search("\nmd5_data = {\n([^}]+)}", src) if not match: print >>sys.stderr, "Internal error!" sys.exit(2) src = src[:match.start(1)] + repl + src[match.end(1):] f = open(srcfile,'w') f.write(src) f.close() if __name__=='__main__': if len(sys.argv)>2 and sys.argv[1]=='--md5update': update_md5(sys.argv[2:]) else: main(sys.argv[1:]) SymbolType-1.0/ez_setup/README.txt0000666000000000000000000000114610435276160015525 0ustar rootrootThis directory exists so that Subversion-based projects can share a single copy of the ``ez_setup`` bootstrap module for ``setuptools``, and have it automatically updated in their projects when ``setuptools`` is updated. For your convenience, you may use the following svn:externals definition:: ez_setup svn://svn.eby-sarna.com/svnroot/ez_setup You can set this by executing this command in your project directory:: svn propedit svn:externals . And then adding the line shown above to the file that comes up for editing. Then, whenever you update your project, ``ez_setup`` will be updated as well.