[Checkins] SVN: zc.parse_addr/trunk/ Tiny utility that I'm tired of writing over and over.

Jim Fulton jim at zope.com
Wed Dec 21 11:35:27 UTC 2011


Log message for revision 123846:
  Tiny utility that I'm tired of writing over and over.

Changed:
  D   zc.parse_addr/trunk/README.txt
  U   zc.parse_addr/trunk/buildout.cfg
  U   zc.parse_addr/trunk/setup.py
  A   zc.parse_addr/trunk/src/zc/parse_addr.py

-=-
Deleted: zc.parse_addr/trunk/README.txt
===================================================================
--- zc.parse_addr/trunk/README.txt	2011-12-21 11:27:57 UTC (rev 123845)
+++ zc.parse_addr/trunk/README.txt	2011-12-21 11:35:27 UTC (rev 123846)
@@ -1,14 +0,0 @@
-Title Here
-**********
-
-
-To learn more, see
-
-
-Changes
-*******
-
-0.1.0 (yyyy-mm-dd)
-==================
-
-Initial release

Modified: zc.parse_addr/trunk/buildout.cfg
===================================================================
--- zc.parse_addr/trunk/buildout.cfg	2011-12-21 11:27:57 UTC (rev 123845)
+++ zc.parse_addr/trunk/buildout.cfg	2011-12-21 11:35:27 UTC (rev 123846)
@@ -1,12 +1,8 @@
 [buildout]
 develop = .
-parts = test py
+parts = py
 
-[test]
-recipe = zc.recipe.testrunner
-eggs = 
-
 [py]
 recipe = zc.recipe.egg
-eggs = ${test:eggs}
+eggs = zc.parse_addr
 interpreter = py

Modified: zc.parse_addr/trunk/setup.py
===================================================================
--- zc.parse_addr/trunk/setup.py	2011-12-21 11:27:57 UTC (rev 123845)
+++ zc.parse_addr/trunk/setup.py	2011-12-21 11:35:27 UTC (rev 123846)
@@ -11,32 +11,29 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-name, version = 'zc.', '0'
+name, version = 'zc.parse_addr', '0'
 
 install_requires = ['setuptools']
-extras_require = dict(test=['zope.testing'])
 
-entry_points = """
-"""
-
 from setuptools import setup
 
+import os
+doc = open(
+    os.path.join(os.path.dirname(__file__), 'src', *name.split('.'))+'.py'
+    ).read().split('"""')[1]
+
 setup(
     author = 'Jim Fulton',
     author_email = 'jim at zope.com',
     license = 'ZPL 2.1',
 
     name = name, version = version,
-    long_description=open('README.txt').read(),
-    description = open('README.txt').read().strip().split('\n')[0],
-    packages = [name.split('.')[0], name],
+    long_description=doc,
+    description = doc.split('\n')[0],
+    packages = [name.split('.')[0]],
     namespace_packages = [name.split('.')[0]],
     package_dir = {'': 'src'},
     install_requires = install_requires,
     zip_safe = False,
-    entry_points=entry_points,
-    package_data = {name: ['*.txt', '*.test', '*.html']},
-    extras_require = extras_require,
-    tests_require = extras_require['test'],
-    test_suite = name+'.tests.test_suite',
+    test_suite = name+'.test_suite',
     )

Added: zc.parse_addr/trunk/src/zc/parse_addr.py
===================================================================
--- zc.parse_addr/trunk/src/zc/parse_addr.py	                        (rev 0)
+++ zc.parse_addr/trunk/src/zc/parse_addr.py	2011-12-21 11:35:27 UTC (rev 123846)
@@ -0,0 +1,33 @@
+##############################################################################
+#
+# Copyright (c) Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
+__all__ = ['parse_addr']
+
+def parse_addr(s):
+    """Parse network addresses of the form: HOST:PORT
+
+    >>> import zc.parse_addr
+    >>> zc.parse_addr.parse_addr('1.2.3.4:56')
+    ('1.2.3.4', 56)
+
+    It would be great if this little utility function was part
+    of the socket module.
+    """
+    host, port = s.rsplit(':', 1)
+    return host, int(port)
+
+def test_suite():
+    import doctest
+    return doctest.DocTestSuite()
+


Property changes on: zc.parse_addr/trunk/src/zc/parse_addr.py
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native



More information about the checkins mailing list