[pypy-svn] r20395 - pypy/dist/pypy/doc/statistic

cfbolz at codespeak.net cfbolz at codespeak.net
Tue Nov 29 16:36:36 CET 2005


Author: cfbolz
Date: Tue Nov 29 16:36:35 2005
New Revision: 20395

Added:
   pypy/dist/pypy/doc/statistic/format.py
Modified:
   pypy/dist/pypy/doc/statistic/loc.txt
Log:
beginning of a plot generation script


Added: pypy/dist/pypy/doc/statistic/format.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/doc/statistic/format.py	Tue Nov 29 16:36:35 2005
@@ -0,0 +1,50 @@
+import py
+import datetime
+import dateutil
+from dateutil import parser
+
+import pylab
+import matplotlib
+
+def get_data(p):
+    data = p.readlines()
+    title = data[0].strip()
+    axis = data[1].strip().split(',')
+    data = [convert_data(t) for t in zip(*[l.strip().split(',') for l in data[2:]])]
+    return title, axis, data
+
+def convert_data(row):
+    if not row:
+        return []
+    first = row[0]
+    try:
+        int(first)
+        return [int(elt) for elt in row]
+    except ValueError:
+        pass
+    try:
+        float(first)
+        return [float(elt) for elt in row]
+    except ValueError:
+        pass
+    parsedate(first)
+    return [parsedate(elt) for elt in row]
+
+def parsedate(s):
+    if len(s) <= 7:
+        year, month = s.split("-")
+        result = datetime.datetime(int(year), int(month), 1)
+    else:
+        result = parser.parse(s)
+    return pylab.date2num(result)
+
+if __name__ == '__main__':
+    p = py.path.local("pypy-svn-post.txt")
+    title, axis, data = get_data(p)
+    print title
+    print axis
+    print data
+    line,  = pylab.plot_date(data[0], data[1])
+    pylab.title(title)
+    pylab.show()
+    

Modified: pypy/dist/pypy/doc/statistic/loc.txt
==============================================================================
--- pypy/dist/pypy/doc/statistic/loc.txt	(original)
+++ pypy/dist/pypy/doc/statistic/loc.txt	Tue Nov 29 16:36:35 2005
@@ -1,3 +1,4 @@
+Lines of Code in the pypy subtree
 date, number of commits (inaccurate), number of files, number of testfiles, lines of code, lines of testcode
 2005-11-23, 66, 683, 232, 152830, 32830
 2005-11-22, 52, 683, 232, 152844, 32830



More information about the Pypy-commit mailing list