{"action":"created","comment":{"url":"https://api.github.com/repos/dobarkod/hnbex-python/pulls/comments/94030825","pull_request_review_id":14560485,"id":94030825,"diff_hunk":"@@ -0,0 +1,74 @@\n+import json\n+import re\n+import requests\n+from datetime import datetime\n+from decimal import Decimal\n+\n+\n+class Rate(object):\n+\n+    RE_VALIDATION_DICT = {\n+        'currency_code': r'^[A-Z]{3}$',\n+        'buying_rate': r'^[0-9]+.[0-9]{6}$',\n+        'selling_rate': r'^[0-9]+.[0-9]{6}$',\n+        'median_rate': r'^[0-9]+.[0-9]{6}$',\n+    }\n+\n+    URL = 'http://hnbex.eu/api/v1/rates/daily/'\n+\n+    def __init__(self, currency_code, rate_date, buying_rate, selling_rate,\n+                 median_rate, unit_value):\n+\n+        self._validate(currency_code, rate_date, buying_rate, selling_rate,\n+                       median_rate, unit_value)\n+\n+        self.code = currency_code\n+        self.date = rate_date\n+        self.buy = Decimal(buying_rate)\n+        self.sell = Decimal(selling_rate)\n+        self.median = Decimal(median_rate)\n+        self.unit_value = unit_value\n+\n+    def _validate(self, currency_code, rate_date, buying_rate, selling_rate,\n+                  median_rate, unit_value):\n+\n+        for var, regex in self.RE_VALIDATION_DICT.items():\n+            if re.match(regex, eval(var)) is None:\n+                raise self.ValidationException('{}: wrong format'.format(var))\n+\n+        if unit_value not in [1, 100]:\n+            raise self.ValidationException('unit_value must be 1 or 100')","path":"hnbex/__init__.py","position":40,"original_position":40,"commit_id":"795cdb2789ae0f98c932aff9f4aee681ef97558c","original_commit_id":"795cdb2789ae0f98c932aff9f4aee681ef97558c","user":{"login":"senko","id":3362,"avatar_url":"https://avatars.githubusercontent.com/u/3362?v=3","gravatar_id":"","url":"https://api.github.com/users/senko","html_url":"https://github.com/senko","followers_url":"https://api.github.com/users/senko/followers","following_url":"https://api.github.com/users/senko/following{/other_user}","gists_url":"https://api.github.com/users/senko/gists{/gist_id}","starred_url":"https://api.github.com/users/senko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/senko/subscriptions","organizations_url":"https://api.github.com/users/senko/orgs","repos_url":"https://api.github.com/users/senko/repos","events_url":"https://api.github.com/users/senko/events{/privacy}","received_events_url":"https://api.github.com/users/senko/received_events","type":"User","site_admin":false},"body":"It’s fine to use `ValueError` here, since the meaning is the same. In Python we’re encouraged to reuse the built-in exceptions if their meaning matches the desired one. Here, the meaning is “the argument value is not correct/applicable”, which is the exact meaning of ValueError.","created_at":"2016-12-28T13:09:57Z","updated_at":"2016-12-28T13:16:48Z","html_url":"https://github.com/dobarkod/hnbex-python/pull/2#discussion_r94030825","pull_request_url":"https://api.github.com/repos/dobarkod/hnbex-python/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/dobarkod/hnbex-python/pulls/comments/94030825"},"html":{"href":"https://github.com/dobarkod/hnbex-python/pull/2#discussion_r94030825"},"pull_request":{"href":"https://api.github.com/repos/dobarkod/hnbex-python/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/dobarkod/hnbex-python/pulls/2","id":99535156,"html_url":"https://github.com/dobarkod/hnbex-python/pull/2","diff_url":"https://github.com/dobarkod/hnbex-python/pull/2.diff","patch_url":"https://github.com/dobarkod/hnbex-python/pull/2.patch","issue_url":"https://api.github.com/repos/dobarkod/hnbex-python/issues/2","number":2,"state":"open","locked":false,"title":"Hbnex rate","user":{"login":"BubicaBu","id":11727082,"avatar_url":"https://avatars.githubusercontent.com/u/11727082?v=3","gravatar_id":"","url":"https://api.github.com/users/BubicaBu","html_url":"https://github.com/BubicaBu","followers_url":"https://api.github.com/users/BubicaBu/followers","following_url":"https://api.github.com/users/BubicaBu/following{/other_user}","gists_url":"https://api.github.com/users/BubicaBu/gists{/gist_id}","starred_url":"https://api.github.com/users/BubicaBu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BubicaBu/subscriptions","organizations_url":"https://api.github.com/users/BubicaBu/orgs","repos_url":"https://api.github.com/users/BubicaBu/repos","events_url":"https://api.github.com/users/BubicaBu/events{/privacy}","received_events_url":"https://api.github.com/users/BubicaBu/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-12-28T10:50:45Z","updated_at":"2016-12-28T13:16:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"596d6f41a8bb6178a86449e827dc2eb067f156b7","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/dobarkod/hnbex-python/pulls/2/commits","review_comments_url":"https://api.github.com/repos/dobarkod/hnbex-python/pulls/2/comments","review_comment_url":"https://api.github.com/repos/dobarkod/hnbex-python/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dobarkod/hnbex-python/issues/2/comments","statuses_url":"https://api.github.com/repos/dobarkod/hnbex-python/statuses/795cdb2789ae0f98c932aff9f4aee681ef97558c","head":{"label":"dobarkod:hbnex-rate","ref":"hbnex-rate","sha":"795cdb2789ae0f98c932aff9f4aee681ef97558c","user":{"login":"dobarkod","id":2169146,"avatar_url":"https://avatars.githubusercontent.com/u/2169146?v=3","gravatar_id":"","url":"https://api.github.com/users/dobarkod","html_url":"https://github.com/dobarkod","followers_url":"https://api.github.com/users/dobarkod/followers","following_url":"https://api.github.com/users/dobarkod/following{/other_user}","gists_url":"https://api.github.com/users/dobarkod/gists{/gist_id}","starred_url":"https://api.github.com/users/dobarkod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dobarkod/subscriptions","organizations_url":"https://api.github.com/users/dobarkod/orgs","repos_url":"https://api.github.com/users/dobarkod/repos","events_url":"https://api.github.com/users/dobarkod/events{/privacy}","received_events_url":"https://api.github.com/users/dobarkod/received_events","type":"Organization","site_admin":false},"repo":{"id":77485425,"name":"hnbex-python","full_name":"dobarkod/hnbex-python","owner":{"login":"dobarkod","id":2169146,"avatar_url":"https://avatars.githubusercontent.com/u/2169146?v=3","gravatar_id":"","url":"https://api.github.com/users/dobarkod","html_url":"https://github.com/dobarkod","followers_url":"https://api.github.com/users/dobarkod/followers","following_url":"https://api.github.com/users/dobarkod/following{/other_user}","gists_url":"https://api.github.com/users/dobarkod/gists{/gist_id}","starred_url":"https://api.github.com/users/dobarkod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dobarkod/subscriptions","organizations_url":"https://api.github.com/users/dobarkod/orgs","repos_url":"https://api.github.com/users/dobarkod/repos","events_url":"https://api.github.com/users/dobarkod/events{/privacy}","received_events_url":"https://api.github.com/users/dobarkod/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dobarkod/hnbex-python","description":"A Python package for accessing hnbex.eu service","fork":false,"url":"https://api.github.com/repos/dobarkod/hnbex-python","forks_url":"https://api.github.com/repos/dobarkod/hnbex-python/forks","keys_url":"https://api.github.com/repos/dobarkod/hnbex-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dobarkod/hnbex-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dobarkod/hnbex-python/teams","hooks_url":"https://api.github.com/repos/dobarkod/hnbex-python/hooks","issue_events_url":"https://api.github.com/repos/dobarkod/hnbex-python/issues/events{/number}","events_url":"https://api.github.com/repos/dobarkod/hnbex-python/events","assignees_url":"https://api.github.com/repos/dobarkod/hnbex-python/assignees{/user}","branches_url":"https://api.github.com/repos/dobarkod/hnbex-python/branches{/branch}","tags_url":"https://api.github.com/repos/dobarkod/hnbex-python/tags","blobs_url":"https://api.github.com/repos/dobarkod/hnbex-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dobarkod/hnbex-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dobarkod/hnbex-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/dobarkod/hnbex-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dobarkod/hnbex-python/statuses/{sha}","languages_url":"https://api.github.com/repos/dobarkod/hnbex-python/languages","stargazers_url":"https://api.github.com/repos/dobarkod/hnbex-python/stargazers","contributors_url":"https://api.github.com/repos/dobarkod/hnbex-python/contributors","subscribers_url":"https://api.github.com/repos/dobarkod/hnbex-python/subscribers","subscription_url":"https://api.github.com/repos/dobarkod/hnbex-python/subscription","commits_url":"https://api.github.com/repos/dobarkod/hnbex-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/dobarkod/hnbex-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/dobarkod/hnbex-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/dobarkod/hnbex-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/dobarkod/hnbex-python/contents/{+path}","compare_url":"https://api.github.com/repos/dobarkod/hnbex-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dobarkod/hnbex-python/merges","archive_url":"https://api.github.com/repos/dobarkod/hnbex-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dobarkod/hnbex-python/downloads","issues_url":"https://api.github.com/repos/dobarkod/hnbex-python/issues{/number}","pulls_url":"https://api.github.com/repos/dobarkod/hnbex-python/pulls{/number}","milestones_url":"https://api.github.com/repos/dobarkod/hnbex-python/milestones{/number}","notifications_url":"https://api.github.com/repos/dobarkod/hnbex-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dobarkod/hnbex-python/labels{/name}","releases_url":"https://api.github.com/repos/dobarkod/hnbex-python/releases{/id}","deployments_url":"https://api.github.com/repos/dobarkod/hnbex-python/deployments","created_at":"2016-12-27T22:08:55Z","updated_at":"2016-12-28T13:01:32Z","pushed_at":"2016-12-28T13:01:33Z","git_url":"git://github.com/dobarkod/hnbex-python.git","ssh_url":"git@github.com:dobarkod/hnbex-python.git","clone_url":"https://github.com/dobarkod/hnbex-python.git","svn_url":"https://github.com/dobarkod/hnbex-python","homepage":null,"size":3,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"dobarkod:master","ref":"master","sha":"d9f7a6e36380cf8ebfc44c7fa9162533d3faccc6","user":{"login":"dobarkod","id":2169146,"avatar_url":"https://avatars.githubusercontent.com/u/2169146?v=3","gravatar_id":"","url":"https://api.github.com/users/dobarkod","html_url":"https://github.com/dobarkod","followers_url":"https://api.github.com/users/dobarkod/followers","following_url":"https://api.github.com/users/dobarkod/following{/other_user}","gists_url":"https://api.github.com/users/dobarkod/gists{/gist_id}","starred_url":"https://api.github.com/users/dobarkod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dobarkod/subscriptions","organizations_url":"https://api.github.com/users/dobarkod/orgs","repos_url":"https://api.github.com/users/dobarkod/repos","events_url":"https://api.github.com/users/dobarkod/events{/privacy}","received_events_url":"https://api.github.com/users/dobarkod/received_events","type":"Organization","site_admin":false},"repo":{"id":77485425,"name":"hnbex-python","full_name":"dobarkod/hnbex-python","owner":{"login":"dobarkod","id":2169146,"avatar_url":"https://avatars.githubusercontent.com/u/2169146?v=3","gravatar_id":"","url":"https://api.github.com/users/dobarkod","html_url":"https://github.com/dobarkod","followers_url":"https://api.github.com/users/dobarkod/followers","following_url":"https://api.github.com/users/dobarkod/following{/other_user}","gists_url":"https://api.github.com/users/dobarkod/gists{/gist_id}","starred_url":"https://api.github.com/users/dobarkod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dobarkod/subscriptions","organizations_url":"https://api.github.com/users/dobarkod/orgs","repos_url":"https://api.github.com/users/dobarkod/repos","events_url":"https://api.github.com/users/dobarkod/events{/privacy}","received_events_url":"https://api.github.com/users/dobarkod/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dobarkod/hnbex-python","description":"A Python package for accessing hnbex.eu service","fork":false,"url":"https://api.github.com/repos/dobarkod/hnbex-python","forks_url":"https://api.github.com/repos/dobarkod/hnbex-python/forks","keys_url":"https://api.github.com/repos/dobarkod/hnbex-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dobarkod/hnbex-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dobarkod/hnbex-python/teams","hooks_url":"https://api.github.com/repos/dobarkod/hnbex-python/hooks","issue_events_url":"https://api.github.com/repos/dobarkod/hnbex-python/issues/events{/number}","events_url":"https://api.github.com/repos/dobarkod/hnbex-python/events","assignees_url":"https://api.github.com/repos/dobarkod/hnbex-python/assignees{/user}","branches_url":"https://api.github.com/repos/dobarkod/hnbex-python/branches{/branch}","tags_url":"https://api.github.com/repos/dobarkod/hnbex-python/tags","blobs_url":"https://api.github.com/repos/dobarkod/hnbex-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dobarkod/hnbex-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dobarkod/hnbex-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/dobarkod/hnbex-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dobarkod/hnbex-python/statuses/{sha}","languages_url":"https://api.github.com/repos/dobarkod/hnbex-python/languages","stargazers_url":"https://api.github.com/repos/dobarkod/hnbex-python/stargazers","contributors_url":"https://api.github.com/repos/dobarkod/hnbex-python/contributors","subscribers_url":"https://api.github.com/repos/dobarkod/hnbex-python/subscribers","subscription_url":"https://api.github.com/repos/dobarkod/hnbex-python/subscription","commits_url":"https://api.github.com/repos/dobarkod/hnbex-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/dobarkod/hnbex-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/dobarkod/hnbex-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/dobarkod/hnbex-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/dobarkod/hnbex-python/contents/{+path}","compare_url":"https://api.github.com/repos/dobarkod/hnbex-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dobarkod/hnbex-python/merges","archive_url":"https://api.github.com/repos/dobarkod/hnbex-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dobarkod/hnbex-python/downloads","issues_url":"https://api.github.com/repos/dobarkod/hnbex-python/issues{/number}","pulls_url":"https://api.github.com/repos/dobarkod/hnbex-python/pulls{/number}","milestones_url":"https://api.github.com/repos/dobarkod/hnbex-python/milestones{/number}","notifications_url":"https://api.github.com/repos/dobarkod/hnbex-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dobarkod/hnbex-python/labels{/name}","releases_url":"https://api.github.com/repos/dobarkod/hnbex-python/releases{/id}","deployments_url":"https://api.github.com/repos/dobarkod/hnbex-python/deployments","created_at":"2016-12-27T22:08:55Z","updated_at":"2016-12-28T13:01:32Z","pushed_at":"2016-12-28T13:01:33Z","git_url":"git://github.com/dobarkod/hnbex-python.git","ssh_url":"git@github.com:dobarkod/hnbex-python.git","clone_url":"https://github.com/dobarkod/hnbex-python.git","svn_url":"https://github.com/dobarkod/hnbex-python","homepage":null,"size":3,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dobarkod/hnbex-python/pulls/2"},"html":{"href":"https://github.com/dobarkod/hnbex-python/pull/2"},"issue":{"href":"https://api.github.com/repos/dobarkod/hnbex-python/issues/2"},"comments":{"href":"https://api.github.com/repos/dobarkod/hnbex-python/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/dobarkod/hnbex-python/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/dobarkod/hnbex-python/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dobarkod/hnbex-python/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/dobarkod/hnbex-python/statuses/795cdb2789ae0f98c932aff9f4aee681ef97558c"}}}}
{"actor":{"display_login":"senko"}}