[Checkins] SVN: z3c.gibberish/trunk/ Tests passing. Test currently
depend on the buildout.
Ross Patterson
me at rpatterson.net
Sun Dec 16 22:31:23 EST 2007
Log message for revision 82305:
Tests passing. Test currently depend on the buildout.
Changed:
_U z3c.gibberish/trunk/
A z3c.gibberish/trunk/.cvsignore
A z3c.gibberish/trunk/EXTERNALS.txt
A z3c.gibberish/trunk/buildout.cfg
A z3c.gibberish/trunk/paste.cfg
A z3c.gibberish/trunk/setup.cfg
A z3c.gibberish/trunk/setup.py
A z3c.gibberish/trunk/z3c/
A z3c.gibberish/trunk/z3c/__init__.py
A z3c.gibberish/trunk/z3c/gibberish/
A z3c.gibberish/trunk/z3c/gibberish/README.txt
A z3c.gibberish/trunk/z3c/gibberish/__init__.py
A z3c.gibberish/trunk/z3c/gibberish/tests.py
-=-
Property changes on: z3c.gibberish/trunk
___________________________________________________________________
Name: svn:ignore
+ .installed.cfg
bin
develop-eggs
parts
build
dist
temp
Name: svn:externals
+ #
# applied by: svn propset svn:externals -F EXTERNALS.txt .
#
bootstrap svn://svn.zope.org/repos/main/zc.buildout/trunk/bootstrap
Added: z3c.gibberish/trunk/.cvsignore
===================================================================
--- z3c.gibberish/trunk/.cvsignore (rev 0)
+++ z3c.gibberish/trunk/.cvsignore 2007-12-17 03:31:23 UTC (rev 82305)
@@ -0,0 +1,7 @@
+.installed.cfg
+bin
+develop-eggs
+parts
+build
+dist
+temp
\ No newline at end of file
Added: z3c.gibberish/trunk/EXTERNALS.txt
===================================================================
--- z3c.gibberish/trunk/EXTERNALS.txt (rev 0)
+++ z3c.gibberish/trunk/EXTERNALS.txt 2007-12-17 03:31:23 UTC (rev 82305)
@@ -0,0 +1,4 @@
+#
+# applied by: svn propset svn:externals -F EXTERNALS.txt .
+#
+bootstrap svn://svn.zope.org/repos/main/zc.buildout/trunk/bootstrap
Added: z3c.gibberish/trunk/buildout.cfg
===================================================================
--- z3c.gibberish/trunk/buildout.cfg (rev 0)
+++ z3c.gibberish/trunk/buildout.cfg 2007-12-17 03:31:23 UTC (rev 82305)
@@ -0,0 +1,11 @@
+[buildout]
+develop = .
+parts = gibberish test
+
+[gibberish]
+recipe = zc.recipe.egg:scripts
+eggs = z3c.gibberish
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = z3c.gibberish
\ No newline at end of file
Added: z3c.gibberish/trunk/paste.cfg
===================================================================
--- z3c.gibberish/trunk/paste.cfg (rev 0)
+++ z3c.gibberish/trunk/paste.cfg 2007-12-17 03:31:23 UTC (rev 82305)
@@ -0,0 +1,15 @@
+[pastescript]
+# python2.4 /usr/bin/paster create -t basic_namespace --config=paste.cfg --svn-repository=svn+ssh://rossp@svn.zope.org/repos/main z3c.gibberish &
+namespace_package = z3c
+egg = z3c.gibberish
+url = http://cheeseshop.python.org/pypi/z3c.gibberish
+description = Generate CSV files containing random words from a dictionary
+author = Ross Patterson
+author_email = me at rpatterson.net
+license_name = GPL
+version = 0.1
+plus = +
+zip_safe = True
+keywords =
+long_description =
+dot = .
Added: z3c.gibberish/trunk/setup.cfg
===================================================================
--- z3c.gibberish/trunk/setup.cfg (rev 0)
+++ z3c.gibberish/trunk/setup.cfg 2007-12-17 03:31:23 UTC (rev 82305)
@@ -0,0 +1,3 @@
+[egg_info]
+tag_build = dev
+tag_svn_revision = true
Added: z3c.gibberish/trunk/setup.py
===================================================================
--- z3c.gibberish/trunk/setup.py (rev 0)
+++ z3c.gibberish/trunk/setup.py 2007-12-17 03:31:23 UTC (rev 82305)
@@ -0,0 +1,37 @@
+from setuptools import setup, find_packages
+
+version = '0.1'
+
+setup(name='z3c.gibberish',
+ version=version,
+ description="Generate CSV files containing random words from a dictionary",
+ long_description="""\
+""",
+ # Get more strings from http://www.python.org/pypi?%3Aaction=list_classifiers
+ classifiers=[
+ "Framework :: Plone",
+ "Framework :: Zope2",
+ "Framework :: Zope3",
+ "Programming Language :: Python",
+ "Topic :: Software Development :: Libraries :: Python Modules",
+ ],
+ keywords='',
+ author='Ross Patterson',
+ author_email='me at rpatterson.net',
+ url='http://cheeseshop.python.org/pypi/z3c.gibberish',
+ license='GPL',
+ packages=find_packages(exclude=['ez_setup']),
+ namespace_packages=['z3c'],
+ include_package_data=True,
+ zip_safe=False,
+ install_requires=[
+ 'setuptools',
+ # -*- Extra requirements: -*-
+ ],
+ extras_require=dict(test=['zc.buildout']),
+ entry_points="""
+ # -*- Entry points: -*-
+ [console_scripts]
+ gibberish = z3c.gibberish:main
+ """,
+ )
Added: z3c.gibberish/trunk/z3c/__init__.py
===================================================================
--- z3c.gibberish/trunk/z3c/__init__.py (rev 0)
+++ z3c.gibberish/trunk/z3c/__init__.py 2007-12-17 03:31:23 UTC (rev 82305)
@@ -0,0 +1,6 @@
+# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
+try:
+ __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+ from pkgutil import extend_path
+ __path__ = extend_path(__path__, __name__)
Added: z3c.gibberish/trunk/z3c/gibberish/README.txt
===================================================================
--- z3c.gibberish/trunk/z3c/gibberish/README.txt (rev 0)
+++ z3c.gibberish/trunk/z3c/gibberish/README.txt 2007-12-17 03:31:23 UTC (rev 82305)
@@ -0,0 +1,107 @@
+;-*-Doctest-*-
+=============
+z3c.gibberish
+=============
+
+Generate CSV files containing random words from a dictionary
+
+Get the script from the buildout::
+
+ >>> import os
+ >>> gibberish = os.path.join(
+ ... reduce(lambda path, _: os.path.dirname(path),
+ ... range(3), __file__), 'bin', 'gibberish')
+
+Print the help::
+
+ >>> from zc.buildout.testing import system
+ >>> print system(gibberish+' --help'),
+ usage: gibberish [options] LINES COLUMN [COLUMN ...]
+ <BLANKLINE>
+ Generate lines of CSV consisting of random words from a
+ dictionary. The number of lines of CSV must be specified either
+ as a single integer to specify a fixed number of lines or two
+ integers separated by a dash to specify that a random number of
+ lines between the two integers should be used. The columns are
+ specified in the same manner where the numbers represent the
+ number of words in that column for a given line.
+ <BLANKLINE>
+ options:
+ -h, --help show this help message and exit
+ -w WORDS, --words=WORDS
+ File containing the words to be chosen
+ from [default: /usr/share/dict/words]
+
+Make a simple file with one line and one column containing one word::
+
+ >>> import StringIO, csv
+ >>> result = list(csv.reader(StringIO.StringIO(
+ ... system(gibberish+' 1 1'))))
+ >>> len(result)
+ 1
+ >>> len(result[0])
+ 1
+ >>> len(result[0][0].split())
+ 1
+
+With two words in the column::
+
+ >>> import StringIO, csv
+ >>> result = list(csv.reader(StringIO.StringIO(
+ ... system(gibberish+' 1 2'))))
+ >>> len(result)
+ 1
+ >>> len(result[0])
+ 1
+ >>> len(result[0][0].split())
+ 2
+
+With a random number of words in the column::
+
+ >>> import StringIO, csv
+ >>> result = list(csv.reader(StringIO.StringIO(
+ ... system(gibberish+' 1 1-10'))))
+ >>> len(result)
+ 1
+ >>> len(result[0])
+ 1
+ >>> 1 <= len(result[0][0].split()) <= 10
+ True
+
+With 10 lines::
+
+ >>> import StringIO, csv
+ >>> result = list(csv.reader(StringIO.StringIO(
+ ... system(gibberish+' 10 2'))))
+ >>> len(result)
+ 10
+ >>> len(result[0])
+ 1
+ >>> len(result[0][0].split())
+ 2
+
+With a random number of lines::
+
+ >>> import StringIO, csv
+ >>> result = list(csv.reader(StringIO.StringIO(
+ ... system(gibberish+' 1-10 2'))))
+ >>> 1 <= len(result) <= 10
+ True
+ >>> len(result[0])
+ 1
+ >>> len(result[0][0].split())
+ 2
+
+With two columns::
+
+ >>> import StringIO, csv
+ >>> result = list(csv.reader(StringIO.StringIO(
+ ... system(gibberish+' 1 2 3'))))
+ >>> len(result)
+ 1
+ >>> len(result[0])
+ 2
+ >>> len(result[0][0].split())
+ 2
+ >>> len(result[0][1].split())
+ 3
Added: z3c.gibberish/trunk/z3c/gibberish/__init__.py
===================================================================
--- z3c.gibberish/trunk/z3c/gibberish/__init__.py (rev 0)
+++ z3c.gibberish/trunk/z3c/gibberish/__init__.py 2007-12-17 03:31:23 UTC (rev 82305)
@@ -0,0 +1,52 @@
+import sys, os, random, optparse, csv, itertools
+
+parser = optparse.OptionParser(
+ usage="usage: %prog [options] LINES COLUMN [COLUMN ...]",
+ description=(
+ "Generate lines of CSV consisting of random words from a "
+ "dictionary. "
+
+ "The number of lines of CSV must be specified either as a "
+ "single integer to specify a fixed number of lines or two "
+ "integers separated by a dash to specify that a random "
+ "number of lines between the two integers should be used. "
+
+ "The columns are specified in the same manner where the "
+ "numbers represent the number of words in that column for a "
+ "given line."))
+parser.add_option(
+ "-w", "--words",
+ default=os.path.join('/', 'usr', 'share', 'dict', 'words'),
+ help=("File containing the words to be chosen from "
+ "[default: %default]"))
+
+def get_num(range):
+ range = [int(i) for i in range.split('-')]
+ if len(range) == 2:
+ return random.randint(*range)
+ else:
+ num, = range
+ return num
+
+def random_words(words):
+ words = file(words)
+ length = 0
+ for line in words:
+ length += 1
+ words.seek(0)
+
+ while True:
+ yield itertools.islice(
+ words, random.randint(0, length), length).next()
+ words.seek(0)
+
+def main():
+ options, args = parser.parse_args()
+ lines = get_num(args[0])
+ columns = args[1:]
+
+ words = random_words(options.words)
+ csv.writer(sys.stdout).writerows(
+ [' '.join(itertools.islice(words, get_num(column)))
+ for column in columns]
+ for _ in xrange(lines))
Added: z3c.gibberish/trunk/z3c/gibberish/tests.py
===================================================================
--- z3c.gibberish/trunk/z3c/gibberish/tests.py (rev 0)
+++ z3c.gibberish/trunk/z3c/gibberish/tests.py 2007-12-17 03:31:23 UTC (rev 82305)
@@ -0,0 +1,10 @@
+import unittest, os, tempfile, shutil
+from zope.testing import doctest
+
+def test_suite():
+ return doctest.DocFileSuite(
+ 'README.txt',
+ optionflags=doctest.REPORT_NDIFF|doctest.NORMALIZE_WHITESPACE)
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
More information about the Checkins
mailing list