Commits

Anonymous committed eeb1c4f

added an advanced example: fetching twitter timeline.

  • Participants
  • Parent commits 4a4e60e
  • Tags v0.1.2

Comments (0)

Files changed (1)

File doc/sample.rst

    == ==
    0
    == ==
+
+
+Advanced
+--------
+
+twitter
+^^^^^^^
+
+::
+
+  .. spreadsheet:: pipy's latest tweets
+     :eq: {1} = tweets[i]['name']
+          {2} = tweets[i]['version']
+          {3} = tweets[i]['desc']
+     :setup: import twitter
+             def parse(s):
+                 remain = s.text
+                 (name, remain) = remain.split(' ', 1)
+                 (version, remain) = remain.split(':', 1)
+                 (desc, remain) = remain.split('http://', 1)
+                 return dict(name=name, version=version, desc=desc)
+             api = twitter.Api()
+             statuses = api.GetUserTimeline('pypi')
+             tweets = map(parse, statuses)
+
+     === ======== ======== ==============================================
+     #   Name     Version  Description
+     === ======== ======== ==============================================
+     1
+     2
+     3
+     4
+     5
+     6
+     7
+     8
+     9
+     10
+     === ======== ======== ==============================================
+
+.. spreadsheet:: pipy's latest tweets
+   :eq: {1} = tweets[i]['name']
+        {2} = tweets[i]['version']
+        {3} = tweets[i]['desc']
+   :setup: import twitter
+           def parse(s):
+               remain = s.text
+               (name, remain) = remain.split(' ', 1)
+               (version, remain) = remain.split(':', 1)
+               (desc, remain) = remain.split('http://', 1)
+               return dict(name=name, version=version, desc=desc)
+           api = twitter.Api()
+           statuses = api.GetUserTimeline('pypi')
+           tweets = map(parse, statuses)
+
+   === ======== ======== ==============================================
+   #   Name     Version  Description
+   === ======== ======== ==============================================
+   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+   10
+   === ======== ======== ==============================================