[Assorted-commits] SF.net SVN: assorted: [814] python-commons/tags
Brought to you by:
yangzhang
From: <yan...@us...> - 2008-05-14 18:02:58
|
Revision: 814 http://assorted.svn.sourceforge.net/assorted/?rev=814&view=rev Author: yangzhang Date: 2008-05-14 11:00:58 -0700 (Wed, 14 May 2008) Log Message: ----------- tagged 0.5 release! Modified Paths: -------------- python-commons/tags/0.5/publish.bash python-commons/tags/0.5/setup.py python-commons/tags/0.5/src/commons/__init__.py Added Paths: ----------- python-commons/tags/0.5/ python-commons/tags/0.5/README python-commons/tags/0.5/src/commons/setup.py python-commons/tags/0.5/src/commons/strs.py Removed Paths: ------------- python-commons/tags/0.5/README python-commons/tags/0.5/src/commons/setup.py python-commons/tags/0.5/src/commons/strs.py Copied: python-commons/tags/0.5 (from rev 791, python-commons/trunk) Deleted: python-commons/tags/0.5/README =================================================================== --- python-commons/trunk/README 2008-05-10 05:46:06 UTC (rev 791) +++ python-commons/tags/0.5/README 2008-05-14 18:00:58 UTC (rev 814) @@ -1,65 +0,0 @@ -[documentation](doc) - -Overview --------- - -Python Commons is a general-purpose library for Python. To get a sense of -what it provides, please glance over the [documentation](doc). - -Requirements ------------- - -- [Python](http://python.org/) 2.5 -- [setuptools](http://peak.telecommunity.com/DevCenter/setuptools) 0.6 - -Certain sub-modules have extra requirements: - -- `async` requires [Twisted](http://twistedmatrix.com/trac/) 2.5 -- `files` requires [path](http://www.jorendorff.com/articles/python/path/) 2.2 - -This library has only been tested on Linux. - -Setup ------ - -To install, run `easy_install python-commons`, or download the source tarball -and run `python setup.py install`. - -Related Work ------------- - -- [ASPN Cookbook]: a valuable repository of Python snippets -- [AIMA Utilities]: accompaniment to a popular AI textbook - -[ASPN Cookbook]: http://aspn.activestate.com/ASPN/Cookbook/Python -[AIMA Utilities]: http://aima.cs.berkeley.edu/python/utils.py - -Changes -------- - -version 0.4 - -- removed extraneous debug print statements -- added `logout()` context manager -- added `seq()`, `default_if_none()` -- fixed missing `import` bug -- released for [Mailing List - Filter](http://assorted.sf.net/mailing-list-filter/) - -version 0.3 - -- added versioned guards -- added file memoization -- added retry with exp backoff -- added `countstep()` -- released for - [gbookmark2delicious](http://gbookmark2delicious.googlecode.com/) - -version 0.2 - -- added `clients`, `setup` -- released for [icedb](http://cartel.csail.mit.edu/icedb/) - -version 0.1 - -- initial release Copied: python-commons/tags/0.5/README (from rev 812, python-commons/trunk/README) =================================================================== --- python-commons/tags/0.5/README (rev 0) +++ python-commons/tags/0.5/README 2008-05-14 18:00:58 UTC (rev 814) @@ -0,0 +1,72 @@ +[documentation](doc) + +Overview +-------- + +Python Commons is a general-purpose library for Python. To get a sense of +what it provides, please glance over the [documentation](doc). + +Requirements +------------ + +- [Python](http://python.org/) 2.5 +- [setuptools](http://peak.telecommunity.com/DevCenter/setuptools) 0.6 + +Certain sub-modules have extra requirements: + +- `async` requires [Twisted](http://twistedmatrix.com/trac/) 2.5 +- `files` requires [path](http://www.jorendorff.com/articles/python/path/) 2.2 + +This library has only been tested on Linux. + +Setup +----- + +To install, run `easy_install python-commons`, or download the source tarball +and run `python setup.py install`. + +Related Work +------------ + +- [ASPN Cookbook]: a valuable repository of Python snippets +- [AIMA Utilities]: accompaniment to a popular AI textbook + +[ASPN Cookbook]: http://aspn.activestate.com/ASPN/Cookbook/Python +[AIMA Utilities]: http://aima.cs.berkeley.edu/python/utils.py + +Changes +------- + +version 0.5, 2008-05-14 + +- added `cp1252_to_unicode()` +- made `setup()` more flexible +- released for + [gbookmark2delicious](http://gbookmark2delicious.googlecode.com/) + +version 0.4, 2008-05-08 + +- removed extraneous debug print statements +- added `logout()` context manager +- added `seq()`, `default_if_none()` +- fixed missing `import` bug +- released for [Mailing List + Filter](http://assorted.sf.net/mailing-list-filter/) + +version 0.3, 2008-04-30 + +- added versioned guards +- added file memoization +- added retry with exp backoff +- added `countstep()` +- released for + [gbookmark2delicious](http://gbookmark2delicious.googlecode.com/) + +version 0.2, 2008-02-04 + +- added `clients`, `setup` +- released for [icedb](http://cartel.csail.mit.edu/icedb/) + +version 0.1, 2007-03-24 + +- initial release Modified: python-commons/tags/0.5/publish.bash =================================================================== --- python-commons/trunk/publish.bash 2008-05-10 05:46:06 UTC (rev 791) +++ python-commons/tags/0.5/publish.bash 2008-05-14 18:00:58 UTC (rev 814) @@ -4,8 +4,11 @@ epydoc -o $stagedir/doc src/commons/ } +echo 'Remember to keep versions in sync in all three locations:' +echo '__init__.py, README (Changes), setup.bash, and setup.py' + fullname='Python Commons' -version=0.4 +version=0.5 license=psf websrcs=( README ) rels=( pypi: ) Modified: python-commons/tags/0.5/setup.py =================================================================== --- python-commons/trunk/setup.py 2008-05-10 05:46:06 UTC (rev 791) +++ python-commons/tags/0.5/setup.py 2008-05-14 18:00:58 UTC (rev 814) @@ -9,7 +9,7 @@ pkg_info_text = """ Metadata-Version: 1.1 Name: python-commons -Version: 0.4 +Version: 0.5 Author: Yang Zhang Author-email: yaaang NOSPAM at REMOVECAPS gmail Home-page: http://assorted.sourceforge.net/python-commons Modified: python-commons/tags/0.5/src/commons/__init__.py =================================================================== --- python-commons/trunk/src/commons/__init__.py 2008-05-10 05:46:06 UTC (rev 791) +++ python-commons/tags/0.5/src/commons/__init__.py 2008-05-14 18:00:58 UTC (rev 814) @@ -10,7 +10,7 @@ @license: PSF """ -__version__ = ( 0, 2, 0 ) +__version__ = ( 0, 5, 0 ) __all__ = [ 'async', 'control', 'decs', Deleted: python-commons/tags/0.5/src/commons/setup.py =================================================================== --- python-commons/trunk/src/commons/setup.py 2008-05-10 05:46:06 UTC (rev 791) +++ python-commons/tags/0.5/src/commons/setup.py 2008-05-14 18:00:58 UTC (rev 814) @@ -1,100 +0,0 @@ -#!/usr/bin/env python -# -*- mode: python; tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4; -*- -# vim:ft=python:et:sw=4:ts=4 - -""" -Common code for setup.py files. Details about the Trove classifiers are -available at -U{http://pypi.python.org/pypi?%3Aaction=list_classifiers}. -""" - -arg_keys = """ -name -version -author -author_email -description: Summary -download_url: Download-url -long_description: Description -keywords: Keywords -url: Home-page -license -classifiers: Classifier -platforms: Platform -""" - -import sys -if not hasattr(sys, "version_info") or sys.version_info < (2, 3): - from distutils.core import setup - _setup = setup - def setup(**kwargs): - for key in [ - # distutils >= Python 2.3 args - # XXX probably download_url came in earlier than 2.3 - "classifiers", "download_url", - # setuptools args - "install_requires", "zip_safe", "test_suite", - ]: - if kwargs.has_key(key): - del kwargs[key] - # Only want packages keyword if this is a package, - # only want py_modules keyword if this is a single-file module, - # so get rid of packages or py_modules keyword as appropriate. - if kwargs["packages"] is None: - del kwargs["packages"] - else: - del kwargs["py_modules"] - apply(_setup, (), kwargs) -else: - from setuptools import setup, find_packages - -def run_setup( pkg_info_text, *orig_args, **orig_kwargs ): - list_keys = set( [ 'Classifier' ] ) - pkg_info = {} - for line in pkg_info_text.split( '\n' ): - if line.strip() != '': - if line.startswith( ' '*8 ): - pkg_info[ key ] += line[ 7 : ] - else: - key, value = line.split( ': ', 1 ) - if key in list_keys: - try: - pkg_info[ key ].append( value ) - except: - pkg_info[ key ] = [ value ] - else: - pkg_info[ key ] = value - - args_nontranslations = set() - args_translations = {} - for line in arg_keys.split( '\n' ): - if line.strip() != '': - splitted = line.split( ': ', 1 ) - dest_name = splitted[ 0 ] - if len( splitted ) == 2: - source_name = splitted[ 1 ] - args_translations[ source_name ] = dest_name - else: - args_nontranslations.add( dest_name ) - - args = {} - for key, value in pkg_info.iteritems(): - dest_name = None - try: - dest_name = args_translations[ key ] - except KeyError: - key = key.lower().replace('-','_') - if key in args_nontranslations: - dest_name = key - if dest_name is not None: - args[ dest_name ] = value - - # this also allows user to override our args - args.update( orig_kwargs ) - args.update( { - 'package_dir': {'':'src'}, - 'packages': find_packages('src'), - 'zip_safe': True, - } ) - - setup( *orig_args, **args ) Copied: python-commons/tags/0.5/src/commons/setup.py (from rev 805, python-commons/trunk/src/commons/setup.py) =================================================================== --- python-commons/tags/0.5/src/commons/setup.py (rev 0) +++ python-commons/tags/0.5/src/commons/setup.py 2008-05-14 18:00:58 UTC (rev 814) @@ -0,0 +1,100 @@ +#!/usr/bin/env python +# -*- mode: python; tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4; -*- +# vim:ft=python:et:sw=4:ts=4 + +""" +Common code for setup.py files. Details about the Trove classifiers are +available at +U{http://pypi.python.org/pypi?%3Aaction=list_classifiers}. +""" + +arg_keys = """ +name +version +author +author_email +description: Summary +download_url: Download-url +long_description: Description +keywords: Keywords +url: Home-page +license +classifiers: Classifier +platforms: Platform +""" + +import sys +if not hasattr(sys, "version_info") or sys.version_info < (2, 3): + from distutils.core import setup + _setup = setup + def setup(**kwargs): + for key in [ + # distutils >= Python 2.3 args + # XXX probably download_url came in earlier than 2.3 + "classifiers", "download_url", + # setuptools args + "install_requires", "zip_safe", "test_suite", + ]: + if kwargs.has_key(key): + del kwargs[key] + # Only want packages keyword if this is a package, + # only want py_modules keyword if this is a single-file module, + # so get rid of packages or py_modules keyword as appropriate. + if kwargs["packages"] is None: + del kwargs["packages"] + else: + del kwargs["py_modules"] + apply(_setup, (), kwargs) +else: + from setuptools import setup, find_packages + +def run_setup( pkg_info_text, srcdir = 'src', *orig_args, **orig_kwargs ): + list_keys = set( [ 'Classifier' ] ) + pkg_info = {} + for line in pkg_info_text.split( '\n' ): + if line.strip() != '': + if line.startswith( ' '*8 ): + pkg_info[ key ] += line[ 7 : ] + else: + key, value = line.split( ': ', 1 ) + if key in list_keys: + try: + pkg_info[ key ].append( value ) + except: + pkg_info[ key ] = [ value ] + else: + pkg_info[ key ] = value + + args_nontranslations = set() + args_translations = {} + for line in arg_keys.split( '\n' ): + if line.strip() != '': + splitted = line.split( ': ', 1 ) + dest_name = splitted[ 0 ] + if len( splitted ) == 2: + source_name = splitted[ 1 ] + args_translations[ source_name ] = dest_name + else: + args_nontranslations.add( dest_name ) + + args = {} + for key, value in pkg_info.iteritems(): + dest_name = None + try: + dest_name = args_translations[ key ] + except KeyError: + key = key.lower().replace('-','_') + if key in args_nontranslations: + dest_name = key + if dest_name is not None: + args[ dest_name ] = value + + # this also allows user to override our args + args.update( orig_kwargs ) + args.update( { + 'package_dir': {'':srcdir}, + 'packages': find_packages(srcdir), + 'zip_safe': True, + } ) + + setup( *orig_args, **args ) Deleted: python-commons/tags/0.5/src/commons/strs.py =================================================================== --- python-commons/trunk/src/commons/strs.py 2008-05-10 05:46:06 UTC (rev 791) +++ python-commons/tags/0.5/src/commons/strs.py 2008-05-14 18:00:58 UTC (rev 814) @@ -1,20 +0,0 @@ -# -*- mode: python; tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4; -*- -# vim:ft=python:et:sw=4:ts=4 - -""" -String formatting. -""" - -import itertools - -def format( *args ): - """Formats the args as they would be by the C{print} built-in.""" - return ' '.join( itertools.imap( str, args ) ) - -def safe_ascii( s ): - """Casts a Unicode string to a regular ASCCII string. This may be - lossy.""" - if isinstance( s, unicode ) and s == str( s ): - return str( s ) - else: - return s Copied: python-commons/tags/0.5/src/commons/strs.py (from rev 804, python-commons/trunk/src/commons/strs.py) =================================================================== --- python-commons/tags/0.5/src/commons/strs.py (rev 0) +++ python-commons/tags/0.5/src/commons/strs.py 2008-05-14 18:00:58 UTC (rev 814) @@ -0,0 +1,58 @@ +# -*- mode: python; tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4; -*- +# vim:ft=python:et:sw=4:ts=4 + +""" +String formatting. +""" + +import itertools + +def format( *args ): + """Formats the args as they would be by the C{print} built-in.""" + return ' '.join( itertools.imap( str, args ) ) + +def safe_ascii( s ): + """Casts a Unicode string to a regular ASCCII string. This may be + lossy.""" + if isinstance( s, unicode ) and s == str( s ): + return str( s ) + else: + return s + +cp1252_to_unicode_translations = [ (u'\x80',u'\u20AC'), + (u'\x82',u'\u201A'), + (u'\x83',u'\u0192'), + (u'\x84',u'\u201E'), + (u'\x85',u'\u2026'), + (u'\x86',u'\u2020'), + (u'\x87',u'\u2021'), + (u'\x88',u'\u02C6'), + (u'\x89',u'\u2030'), + (u'\x8A',u'\u0160'), + (u'\x8B',u'\u2039'), + (u'\x8C',u'\u0152'), + (u'\x8E',u'\u017D'), + (u'\x91',u'\u2018'), + (u'\x92',u'\u2019'), + (u'\x93',u'\u201C'), + (u'\x94',u'\u201D'), + (u'\x95',u'\u2022'), + (u'\x96',u'\u2013'), + (u'\x97',u'\u2014'), + (u'\x98',u'\u02DC'), + (u'\x99',u'\u2122'), + (u'\x9A',u'\u0161'), + (u'\x9B',u'\u203A'), + (u'\x9C',u'\u0153'), + (u'\x9E',u'\u017E'), + (u'\x9F',u'\u0178') ] + +def cp1252_to_unicode(x): + """Converts characters 0x80 through 0x9f to their proper Unicode + equivalents. See + U{http://www.intertwingly.net/stories/2004/04/14/i18n.html} for the nice + translation table on which this is based.""" + for a,b in cp1252_to_unicode_translations: + x = x.replace(a,b) + return x + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |