changeset 1:12ac99c240ca tip

* add documentation * add 1..10 autostep feature * bump version
author Jeff Hammel <k0scist@gmail.com>
date Wed, 10 Mar 2010 17:48:11 -0500
parents 1eea6356d2e5
children
files README.txt setup.py webcalc/webcalc.py
diffstat 3 files changed, 43 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
new file mode 100644
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,26 @@
+webcalc
+=======
+
+*through the web calculator*
+
+Usage
+-----
+
+webcalc uses the full path of the URL as a calculator:
+
+ ``http://127.0.0.1:5151/(5+3)/2``
+
+Should yield a ``text/plain`` document with contents ``4.0``.
+
+Query string arguments may be used to iterate over arguments:
+
+ ``http://127.0.0.1:5151/(5+a)/2?a=1..10``
+
+Values and ranges may be comma separated (e.g. ``a=1,3,5..10``).
+Ranges may be specified as *start, step, end*.  If *step* is omitted,
+it is taken to be 1.0.
+
+TODO
+----
+
+ * add multiple front ends, including a graphing calculator
--- a/setup.py
+++ b/setup.py
@@ -1,17 +1,24 @@
 from setuptools import setup, find_packages
+import os
 
-version = "0.1"
+# get the description from the README
+try:
+    filename = os.path.join(os.path.dirname(__file__), 'README.txt')
+    description = file(filename).read()
+except:
+    description = ''
+
+version = "0.1.1"
 
 setup(name='webcalc',
       version=version,
       description="web-based calculator",
-      long_description="""
-""",
+      long_description=description,
       classifiers=[], # Get strings from http://www.python.org/pypi?%3Aaction=list_classifiers
       author='Jeff Hammel',
       author_email='k0scist@gmail.com',
       url='',
       license="GPL",
       packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
       include_package_data=True,
       zip_safe=False,
--- a/webcalc/webcalc.py
+++ b/webcalc/webcalc.py
@@ -124,17 +124,23 @@ class WebcalcView(object):
                   if i.strip()]
         for token in tokens:
             try: 
                 value = float(token)
                 retval.append(value)
                 continue
             except ValueError:
                 pass
-            start, step, end = token.split('..')
+            count = token.count('..')
+            assert count in set([1,2])
+            if count == 1:
+                start, end = token.split('..')
+                step = 1.0
+            else: # count == 2
+                start, step, end = token.split('..')
             start = float(start)
             step = float(step)
             end = float(end)
             
             values = [ start ]
             npoints = (end - start)/step
             npoints = int(npoints)
             values.extend([i*step + start