GitHub PullRequestReviewCommentEvent at 2014-07-07 17:07:28
Repository: lillith
Actor: agrif
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/agrif/lillith/pulls/comments/14608405","id":14608405,"diff_hunk":"@@ -0,0 +1,157 @@\n+from .config import _getcf\n+\n+\n+import time\n+import urllib.parse\n+import urllib.request\n+import xml.etree.ElementTree as ET\n+import datetime\n+\n+__all__ = [\"initialize\"]\n+\n+\n+def xml_to_dict(s):\n+    root = ET.fromstring(s)\n+    if not root.tag == 'eveapi' or not root.attrib.get('version') in ['1', '2']:\n+        raise ValueError(\"not valid EVE API data\")\n+    \n+    def parse_row(elems, base):\n+        for rowset in elems:\n+            # tags that are not rowsets are stuck in directly\n+            if not rowset.tag == 'rowset':\n+                base[rowset.tag] = rowset.text\n+                continue\n+            \n+            # it must be a rowset\n+            if 'key' not in rowset.attrib or \\\n+               'name' not in rowset.attrib:\n+                raise ValueError(\"badly formed EVE API data\")\n+            \n+            # collect all rows in this rowset\n+            name = rowset.attrib['name']\n+            key = rowset.attrib['key']\n+            rows = []\n+            for row in rowset:\n+                if not row.tag == 'row' or key not in row.attrib:\n+                    raise ValueError(\"badly formed EVE API data\")\n+                rowproto = row.attrib.copy()\n+                # if the row has text, instead of subtags, use it\n+                if row.text:\n+                    rowproto['text'] = row.text\n+                # parse subtags of this row, and add it to our gathered rows\n+                rows.append(parse_row(row, rowproto))\n+            # insert this row\n+            base[name] = rows\n+        return base\n+    \n+    currenttime = None\n+    cacheduntil = None\n+    cachetime = None\n+    result = None\n+    for child in root:\n+        if child.tag == 'currentTime':\n+            currenttime = datetime.datetime.strptime(child.text, \"%Y-%m-%d %H:%M:%S\")\n+        elif child.tag == 'cachedUntil':\n+            cacheduntil = datetime.datetime.strptime(child.text, \"%Y-%m-%d %H:%M:%S\")\n+        elif child.tag == 'result':\n+            result = parse_row(child, {})\n+        else:\n+            raise ValueError(\"badly formed EVE API data\")\n+    if currenttime and cacheduntil:\n+        cachetime = (cacheduntil - currenttime).total_seconds()\n+    return cachetime, result\n+\n+class Api:\n+    _base_url = 'https://api.eveonline.com/'\n+    keyID = None\n+    vCode = None\n+    _cachetime = None # this means use the cacheexpire time from the result document \n+\n+    @classmethod\n+    def initialize(self, keyID, vCode):\n+        self.keyID = keyID\n+        self.vCode = vCode\n+        self.cfg = _getcf()","path":"lillith/Api.py","position":74,"original_position":74,"commit_id":"27259a3f34b3db116f7e4341e87b9507cc88e8cd","original_commit_id":"27259a3f34b3db116f7e4341e87b9507cc88e8cd","user":{"login":"agrif","id":308296,"avatar_url":"https://avatars.githubusercontent.com/u/308296?","gravatar_id":"5f4fde3431ef1a5525844c2f80760536","url":"https://api.github.com/users/agrif","html_url":"https://github.com/agrif","followers_url":"https://api.github.com/users/agrif/followers","following_url":"https://api.github.com/users/agrif/following{/other_user}","gists_url":"https://api.github.com/users/agrif/gists{/gist_id}","starred_url":"https://api.github.com/users/agrif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agrif/subscriptions","organizations_url":"https://api.github.com/users/agrif/orgs","repos_url":"https://api.github.com/users/agrif/repos","events_url":"https://api.github.com/users/agrif/events{/privacy}","received_events_url":"https://api.github.com/users/agrif/received_events","type":"User","site_admin":false},"body":"the return to `_getcf()` (and anything under it) isn't supposed to be cached like this. The original plan was to replace this with a [parameter object](https://pypi.python.org/pypi/parameterize), meaning the return value might change depending on where the function is called.\r\n\r\nAlso, stick keyID and vCode inside the config object, and make them parameters to the package-wide initialize. For the moment this will be a little awkward (needing to provide so much data to initialize) but I have some ideas in that area I wanna play around with.","created_at":"2014-07-07T17:07:28Z","updated_at":"2014-07-07T17:07:28Z","html_url":"https://github.com/agrif/lillith/pull/1#discussion_r14608405","pull_request_url":"https://api.github.com/repos/agrif/lillith/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/agrif/lillith/pulls/comments/14608405"},"html":{"href":"https://github.com/agrif/lillith/pull/1#discussion_r14608405"},"pull_request":{"href":"https://api.github.com/repos/agrif/lillith/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/agrif/lillith/pulls/1","id":18054029,"html_url":"https://github.com/agrif/lillith/pull/1","diff_url":"https://github.com/agrif/lillith/pull/1.diff","patch_url":"https://github.com/agrif/lillith/pull/1.patch","issue_url":"https://api.github.com/repos/agrif/lillith/issues/1","number":1,"state":"open","title":"Support for the EVE Api","user":{"login":"eminence","id":402454,"avatar_url":"https://avatars.githubusercontent.com/u/402454?","gravatar_id":"caf42c4dfa8a0db63d7159a9b7a8c5ee","url":"https://api.github.com/users/eminence","html_url":"https://github.com/eminence","followers_url":"https://api.github.com/users/eminence/followers","following_url":"https://api.github.com/users/eminence/following{/other_user}","gists_url":"https://api.github.com/users/eminence/gists{/gist_id}","starred_url":"https://api.github.com/users/eminence/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eminence/subscriptions","organizations_url":"https://api.github.com/users/eminence/orgs","repos_url":"https://api.github.com/users/eminence/repos","events_url":"https://api.github.com/users/eminence/events{/privacy}","received_events_url":"https://api.github.com/users/eminence/received_events","type":"User","site_admin":false},"body":"After calling `lillith.initialize`, call:\r\n\r\n```python\r\nlillith.Api.initialize('keyID', 'verificationCode')\r\n```","created_at":"2014-07-07T16:23:53Z","updated_at":"2014-07-07T17:07:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f909d5eab00bcfb1bd05062b5a52f2eb9f745aeb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/agrif/lillith/pulls/1/commits","review_comments_url":"https://api.github.com/repos/agrif/lillith/pulls/1/comments","review_comment_url":"https://api.github.com/repos/agrif/lillith/pulls/comments/{number}","comments_url":"https://api.github.com/repos/agrif/lillith/issues/1/comments","statuses_url":"https://api.github.com/repos/agrif/lillith/statuses/27259a3f34b3db116f7e4341e87b9507cc88e8cd","head":{"label":"eminence:master","ref":"master","sha":"27259a3f34b3db116f7e4341e87b9507cc88e8cd","user":{"login":"eminence","id":402454,"avatar_url":"https://avatars.githubusercontent.com/u/402454?","gravatar_id":"caf42c4dfa8a0db63d7159a9b7a8c5ee","url":"https://api.github.com/users/eminence","html_url":"https://github.com/eminence","followers_url":"https://api.github.com/users/eminence/followers","following_url":"https://api.github.com/users/eminence/following{/other_user}","gists_url":"https://api.github.com/users/eminence/gists{/gist_id}","starred_url":"https://api.github.com/users/eminence/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eminence/subscriptions","organizations_url":"https://api.github.com/users/eminence/orgs","repos_url":"https://api.github.com/users/eminence/repos","events_url":"https://api.github.com/users/eminence/events{/privacy}","received_events_url":"https://api.github.com/users/eminence/received_events","type":"User","site_admin":false},"repo":{"id":21528599,"name":"lillith","full_name":"eminence/lillith","owner":{"login":"eminence","id":402454,"avatar_url":"https://avatars.githubusercontent.com/u/402454?","gravatar_id":"caf42c4dfa8a0db63d7159a9b7a8c5ee","url":"https://api.github.com/users/eminence","html_url":"https://github.com/eminence","followers_url":"https://api.github.com/users/eminence/followers","following_url":"https://api.github.com/users/eminence/following{/other_user}","gists_url":"https://api.github.com/users/eminence/gists{/gist_id}","starred_url":"https://api.github.com/users/eminence/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eminence/subscriptions","organizations_url":"https://api.github.com/users/eminence/orgs","repos_url":"https://api.github.com/users/eminence/repos","events_url":"https://api.github.com/users/eminence/events{/privacy}","received_events_url":"https://api.github.com/users/eminence/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/eminence/lillith","description":"a sane Python API for EVE","fork":true,"url":"https://api.github.com/repos/eminence/lillith","forks_url":"https://api.github.com/repos/eminence/lillith/forks","keys_url":"https://api.github.com/repos/eminence/lillith/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eminence/lillith/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eminence/lillith/teams","hooks_url":"https://api.github.com/repos/eminence/lillith/hooks","issue_events_url":"https://api.github.com/repos/eminence/lillith/issues/events{/number}","events_url":"https://api.github.com/repos/eminence/lillith/events","assignees_url":"https://api.github.com/repos/eminence/lillith/assignees{/user}","branches_url":"https://api.github.com/repos/eminence/lillith/branches{/branch}","tags_url":"https://api.github.com/repos/eminence/lillith/tags","blobs_url":"https://api.github.com/repos/eminence/lillith/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eminence/lillith/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eminence/lillith/git/refs{/sha}","trees_url":"https://api.github.com/repos/eminence/lillith/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eminence/lillith/statuses/{sha}","languages_url":"https://api.github.com/repos/eminence/lillith/languages","stargazers_url":"https://api.github.com/repos/eminence/lillith/stargazers","contributors_url":"https://api.github.com/repos/eminence/lillith/contributors","subscribers_url":"https://api.github.com/repos/eminence/lillith/subscribers","subscription_url":"https://api.github.com/repos/eminence/lillith/subscription","commits_url":"https://api.github.com/repos/eminence/lillith/commits{/sha}","git_commits_url":"https://api.github.com/repos/eminence/lillith/git/commits{/sha}","comments_url":"https://api.github.com/repos/eminence/lillith/comments{/number}","issue_comment_url":"https://api.github.com/repos/eminence/lillith/issues/comments/{number}","contents_url":"https://api.github.com/repos/eminence/lillith/contents/{+path}","compare_url":"https://api.github.com/repos/eminence/lillith/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eminence/lillith/merges","archive_url":"https://api.github.com/repos/eminence/lillith/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eminence/lillith/downloads","issues_url":"https://api.github.com/repos/eminence/lillith/issues{/number}","pulls_url":"https://api.github.com/repos/eminence/lillith/pulls{/number}","milestones_url":"https://api.github.com/repos/eminence/lillith/milestones{/number}","notifications_url":"https://api.github.com/repos/eminence/lillith/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eminence/lillith/labels{/name}","releases_url":"https://api.github.com/repos/eminence/lillith/releases{/id}","created_at":"2014-07-05T21:29:49Z","updated_at":"2014-07-07T02:12:30Z","pushed_at":"2014-07-07T16:22:22Z","git_url":"git://github.com/eminence/lillith.git","ssh_url":"git@github.com:eminence/lillith.git","clone_url":"https://github.com/eminence/lillith.git","svn_url":"https://github.com/eminence/lillith","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"agrif:master","ref":"master","sha":"d14d129b63948ef59045437fcc8e5352cb560752","user":{"login":"agrif","id":308296,"avatar_url":"https://avatars.githubusercontent.com/u/308296?","gravatar_id":"5f4fde3431ef1a5525844c2f80760536","url":"https://api.github.com/users/agrif","html_url":"https://github.com/agrif","followers_url":"https://api.github.com/users/agrif/followers","following_url":"https://api.github.com/users/agrif/following{/other_user}","gists_url":"https://api.github.com/users/agrif/gists{/gist_id}","starred_url":"https://api.github.com/users/agrif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agrif/subscriptions","organizations_url":"https://api.github.com/users/agrif/orgs","repos_url":"https://api.github.com/users/agrif/repos","events_url":"https://api.github.com/users/agrif/events{/privacy}","received_events_url":"https://api.github.com/users/agrif/received_events","type":"User","site_admin":false},"repo":{"id":21527714,"name":"lillith","full_name":"agrif/lillith","owner":{"login":"agrif","id":308296,"avatar_url":"https://avatars.githubusercontent.com/u/308296?","gravatar_id":"5f4fde3431ef1a5525844c2f80760536","url":"https://api.github.com/users/agrif","html_url":"https://github.com/agrif","followers_url":"https://api.github.com/users/agrif/followers","following_url":"https://api.github.com/users/agrif/following{/other_user}","gists_url":"https://api.github.com/users/agrif/gists{/gist_id}","starred_url":"https://api.github.com/users/agrif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agrif/subscriptions","organizations_url":"https://api.github.com/users/agrif/orgs","repos_url":"https://api.github.com/users/agrif/repos","events_url":"https://api.github.com/users/agrif/events{/privacy}","received_events_url":"https://api.github.com/users/agrif/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/agrif/lillith","description":"a sane Python API for EVE","fork":false,"url":"https://api.github.com/repos/agrif/lillith","forks_url":"https://api.github.com/repos/agrif/lillith/forks","keys_url":"https://api.github.com/repos/agrif/lillith/keys{/key_id}","collaborators_url":"https://api.github.com/repos/agrif/lillith/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/agrif/lillith/teams","hooks_url":"https://api.github.com/repos/agrif/lillith/hooks","issue_events_url":"https://api.github.com/repos/agrif/lillith/issues/events{/number}","events_url":"https://api.github.com/repos/agrif/lillith/events","assignees_url":"https://api.github.com/repos/agrif/lillith/assignees{/user}","branches_url":"https://api.github.com/repos/agrif/lillith/branches{/branch}","tags_url":"https://api.github.com/repos/agrif/lillith/tags","blobs_url":"https://api.github.com/repos/agrif/lillith/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/agrif/lillith/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/agrif/lillith/git/refs{/sha}","trees_url":"https://api.github.com/repos/agrif/lillith/git/trees{/sha}","statuses_url":"https://api.github.com/repos/agrif/lillith/statuses/{sha}","languages_url":"https://api.github.com/repos/agrif/lillith/languages","stargazers_url":"https://api.github.com/repos/agrif/lillith/stargazers","contributors_url":"https://api.github.com/repos/agrif/lillith/contributors","subscribers_url":"https://api.github.com/repos/agrif/lillith/subscribers","subscription_url":"https://api.github.com/repos/agrif/lillith/subscription","commits_url":"https://api.github.com/repos/agrif/lillith/commits{/sha}","git_commits_url":"https://api.github.com/repos/agrif/lillith/git/commits{/sha}","comments_url":"https://api.github.com/repos/agrif/lillith/comments{/number}","issue_comment_url":"https://api.github.com/repos/agrif/lillith/issues/comments/{number}","contents_url":"https://api.github.com/repos/agrif/lillith/contents/{+path}","compare_url":"https://api.github.com/repos/agrif/lillith/compare/{base}...{head}","merges_url":"https://api.github.com/repos/agrif/lillith/merges","archive_url":"https://api.github.com/repos/agrif/lillith/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/agrif/lillith/downloads","issues_url":"https://api.github.com/repos/agrif/lillith/issues{/number}","pulls_url":"https://api.github.com/repos/agrif/lillith/pulls{/number}","milestones_url":"https://api.github.com/repos/agrif/lillith/milestones{/number}","notifications_url":"https://api.github.com/repos/agrif/lillith/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/agrif/lillith/labels{/name}","releases_url":"https://api.github.com/repos/agrif/lillith/releases{/id}","created_at":"2014-07-05T20:28:58Z","updated_at":"2014-07-05T20:29:18Z","pushed_at":"2014-07-05T20:29:17Z","git_url":"git://github.com/agrif/lillith.git","ssh_url":"git@github.com:agrif/lillith.git","clone_url":"https://github.com/agrif/lillith.git","svn_url":"https://github.com/agrif/lillith","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/agrif/lillith/pulls/1"},"html":{"href":"https://github.com/agrif/lillith/pull/1"},"issue":{"href":"https://api.github.com/repos/agrif/lillith/issues/1"},"comments":{"href":"https://api.github.com/repos/agrif/lillith/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/agrif/lillith/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/agrif/lillith/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/agrif/lillith/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/agrif/lillith/statuses/27259a3f34b3db116f7e4341e87b9507cc88e8cd"}}}}