Commits

Ralph Bean committed bbc120b

Moving sample data out of "prepare(...)"

Comments (0)

Files changed (2)

 
 setup(
     name='tw2.protovis.custom',
-    version='0.1.a2',
+    version='0.1.a3',
     description='toscawidgets2 wrapper for the stanford protovis toolkit',
     long_description=long_description,
     author='Ralph Bean',

tw2/protovis/custom/samples.py

     return map(f, range(n))
 
 class DemoStreamGraph(StreamGraph):
-    def prepare(self):
-        self.p_data = layers(20, 400)
-        super(DemoStreamGraph, self).prepare()
+    p_data = layers(20, 400)
+
+def make_bubblechart_data():
+    p_data = []
+    for tup in os.walk('.'):
+        dir, dirs, files = tup
+        for file in files:
+            if (file.endswith('pyc') 
+                or file.endswith('pyo')
+                or file.endswith('.swp')):
+                continue
+            nodename = "%s/%s" % (dir, file)
+            value = int(os.path.getsize(nodename)) + 1
+            clip = int(math.sqrt(value)/50.0) # trim text based on value
+            p_data.append({
+                'name' : nodename,
+                'value' : value,
+                'text' : nodename.split('/')[-1][:clip],
+                'group' : "/".join(nodename.split('/')[:-1]),
+            })
+    return p_data
 
 class DemoBubbleChart(BubbleChart):
     p_height = 750
     p_width = 750
-    def prepare(self):
-        self.p_data = []
-        for tup in os.walk('.'):
-            dir, dirs, files = tup
-            for file in files:
-                if (file.endswith('pyc') 
-                    or file.endswith('pyo')
-                    or file.endswith('.swp')):
-                    continue
-                nodename = "%s/%s" % (dir, file)
-                value = int(os.path.getsize(nodename)) + 1
-                clip = int(math.sqrt(value)/50.0) # trim text based on value
-                self.p_data.append({
-                    'name' : nodename,
-                    'value' : value,
-                    'text' : nodename.split('/')[-1][:clip],
-                    'group' : "/".join(nodename.split('/')[:-1]),
-                })
-        super(DemoBubbleChart, self).prepare()
-
+    p_data = make_bubblechart_data()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.