{"number":66,"pull_request":{"number":66,"issue_url":"https://github.com/ask/python-github2/issues/66","head":{"repo":{"master_branch":null,"name":"python-github2","created_at":"2011-10-09T16:41:52Z","size":124,"clone_url":"https://github.com/twidi/python-github2.git","private":false,"updated_at":"2011-10-17T23:37:07Z","watchers":1,"ssh_url":"git@github.com:twidi/python-github2.git","url":"https://api.github.com/repos/twidi/python-github2","git_url":"git://github.com/twidi/python-github2.git","language":"Python","fork":true,"svn_url":"https://svn.github.com/twidi/python-github2","id":2543396,"pushed_at":"2011-10-17T23:37:07Z","open_issues":0,"homepage":"http://packages.python.org/github2","description":"github client in python, with issues support.","forks":0,"html_url":"https://github.com/twidi/python-github2","owner":{"avatar_url":"https://secure.gravatar.com/avatar/4929cd99d0f54b7fa03081f9ab8bb0d4?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"4929cd99d0f54b7fa03081f9ab8bb0d4","url":"https://api.github.com/users/twidi","id":193474,"login":"twidi"}},"label":"twidi:master","sha":"41f4977c593f096e925a40a6416ce99f832bc859","ref":"master","user":{"avatar_url":"https://secure.gravatar.com/avatar/4929cd99d0f54b7fa03081f9ab8bb0d4?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"4929cd99d0f54b7fa03081f9ab8bb0d4","url":"https://api.github.com/users/twidi","id":193474,"login":"twidi"}},"merged_by":null,"created_at":"2011-10-17T21:04:55Z","changed_files":5,"merged":false,"body":"For each method asking github for a list, i added a `page` parameter, default to None.\r\n\r\nThe `get_values` method catch this paramter and then create (or update) a `post_data` paramter sent to `make_request`.\r\n\r\nThere is no easy way with the current code to know how much pages exist for a given list, so it's up to the user to manage the number of pages to retrieve.\r\n\r\nIn my code i do something like this:\r\n\r\n```python\r\n# store all data from all pages\r\nresult = []\r\n# start with page one\r\npage = 1\r\n# we don't know yet the max length of a page\r\nmax_length = 0\r\n\r\nwhile True:\r\n    # get data for the current page\r\n    page_result = github.repos.watching(username, page=page)\r\n    # no result ? it's the end\r\n    if not page_result:\r\n        break\r\n    # save the result\r\n    result += page_result\r\n    # check length of result\r\n    l_page = len(page_result)\r\n    # if smaller than max, it's the last page\r\n    if l_page < max_length:\r\n        break\r\n    # if bigger, it's the new max\r\n    if l_page > max_length:\r\n        max_length = l_page\r\n    # go next page\r\n    page += 1\r\n\r\nreturn result\r\n```    \r\n","comments":13,"title":"Pagination support for lists","additions":23,"diff_url":"https://github.com/ask/python-github2/pull/66.diff","updated_at":"2011-10-20T05:57:19Z","url":"https://api.github.com/repos/ask/python-github2/pulls/66","id":409465,"patch_url":"https://github.com/ask/python-github2/pull/66.patch","mergeable":true,"merged_at":null,"commits":3,"closed_at":"2011-10-20T05:57:19Z","user":{"avatar_url":"https://secure.gravatar.com/avatar/4929cd99d0f54b7fa03081f9ab8bb0d4?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"4929cd99d0f54b7fa03081f9ab8bb0d4","url":"https://api.github.com/users/twidi","id":193474,"login":"twidi"},"deletions":8,"html_url":"https://github.com/ask/python-github2/pull/66","base":{"repo":{"master_branch":null,"name":"python-github2","created_at":"2009-04-18T15:31:12Z","size":364,"clone_url":"https://github.com/ask/python-github2.git","private":false,"updated_at":"2011-10-20T05:57:19Z","watchers":151,"ssh_url":"git@github.com:ask/python-github2.git","url":"https://api.github.com/repos/ask/python-github2","git_url":"git://github.com/ask/python-github2.git","language":"Python","fork":false,"svn_url":"https://svn.github.com/ask/python-github2","id":179358,"pushed_at":"2011-10-20T05:57:19Z","open_issues":4,"homepage":"http://packages.python.org/github2","description":"github client in python, with issues support.","forks":58,"html_url":"https://github.com/ask/python-github2","owner":{"avatar_url":"https://secure.gravatar.com/avatar/7e8b501f7f579c66ddac7e65cb7962b4?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"7e8b501f7f579c66ddac7e65cb7962b4","url":"https://api.github.com/users/ask","id":1558,"login":"ask"}},"label":"ask:master","sha":"00e2ce5f3a1c199fa74591d5944d6dbbe5c57a8a","ref":"master","user":{"avatar_url":"https://secure.gravatar.com/avatar/7e8b501f7f579c66ddac7e65cb7962b4?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"7e8b501f7f579c66ddac7e65cb7962b4","url":"https://api.github.com/users/ask","id":1558,"login":"ask"}},"state":"closed"},"action":"closed"}