PK‘]¹47SäBEGG-INFO/namespace_packages.txtpeak peak.util PK‘]¹4‹O£ £ EGG-INFO/PKG-INFOMetadata-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 PK‘]¹4‰€¿yEGG-INFO/SOURCES.txtREADME.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 PK‘]¹4†êÁEGG-INFO/top_level.txtpeak PK‘]¹4EGG-INFO/zip-safePK/ ·4‰kÔ<99peak/__init__.py__import__('pkg_resources').declare_namespace(__name__) PK‘]¹4ºÑgéÍÍpeak/__init__.pyc;ò ™rDc@sedƒieƒdS(s pkg_resourcesN(s __import__sdeclare_namespaces__name__(((s&build\bdist.win32\egg\peak\__init__.pys?sPK›Z¹4•†Hýýpeak/util/symbols.py"""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__) PK‘]¹4m k*­­peak/util/symbols.pyc;ò VËuDc@sMdZdddgZdefd„ƒYZedeƒZedeƒZdS(s9Symbolic global constants, like 'None', 'NOT_FOUND', etc.sSymbols NOT_GIVENs NOT_FOUNDcBsbtZdZddgZed„ƒZed„ƒZd„Zd„Zd„Zd„ZeZ RS( sSymbolic global constants_names_modulecCs|iS(N(sss_name(ss((s*build\bdist.win32\egg\peak\util\symbols.pys scCs|iS(N(sss_module(ss((s*build\bdist.win32\egg\peak\util\symbols.pysscCs0|iii||ƒ|iii||ƒdS(N(sselfs __class__s_names__set__ssymbols_modules moduleName(sselfssymbols moduleName((s*build\bdist.win32\egg\peak\util\symbols.pys__init__scCs |iSdS(N(sselfs_name(sself((s*build\bdist.win32\egg\peak\util\symbols.pys __reduce__scCstdƒ‚dS(NsSymbols are immutable(s TypeError(sselfsattrsval((s*build\bdist.win32\egg\peak\util\symbols.pys __setattr__scCs |iSdS(N(sselfs__name__(sself((s*build\bdist.win32\egg\peak\util\symbols.pys__repr__s( s__name__s __module__s__doc__s __slots__spropertys__init__s __reduce__s __setattr__s__repr__s__str__(((s*build\bdist.win32\egg\peak\util\symbols.pysSymbols      N(s__doc__s__all__sobjectsSymbols__name__s NOT_GIVENs NOT_FOUND(s__all__sSymbols NOT_GIVENs NOT_FOUND((s*build\bdist.win32\egg\peak\util\symbols.pys?sPK2 ·4(åØ88peak/util/__init__.py__import__('pkg_resources').declare_namespace(__name__) PK‘]¹4™}µ7ÒÒpeak/util/__init__.pyc;ò ™rDc@sedƒieƒdS(s pkg_resourcesN(s __import__sdeclare_namespaces__name__(((s+build\bdist.win32\egg\peak\util\__init__.pys?sPK‘]¹47SäB¶EGG-INFO/namespace_packages.txtPK‘]¹4‹O£ £ ¶LEGG-INFO/PKG-INFOPK‘]¹4‰€¿y¶ EGG-INFO/SOURCES.txtPK‘]¹4†êÁ¶o EGG-INFO/top_level.txtPK‘]¹4¶¨ EGG-INFO/zip-safePK/ ·4‰kÔ<99¶× peak/__init__.pyPK‘]¹4ºÑgéÍͶ>peak/__init__.pycPK›Z¹4•†Hýý¶:peak/util/symbols.pyPK‘]¹4m k*­­¶ipeak/util/symbols.pycPK2 ·4(åØ88¶Ipeak/util/__init__.pyPK‘]¹4™}µ7ÒÒ¶´peak/util/__init__.pycPK Úº