{"action":"created","comment":{"url":"https://api.github.com/repos/holvi/python-stdnum/pulls/comments/28215716","id":28215716,"diff_hunk":"@@ -0,0 +1,116 @@\n+# kennitala.py - functions for handling Icelandic identity codes\n+# coding: utf-8\n+#\n+# Copyright (C) 2011 Jussi Judin\n+# Copyright (C) 2012, 2013 Arthur de Jong\n+#\n+# This library is free software; you can redistribute it and/or\n+# modify it under the terms of the GNU Lesser General Public\n+# License as published by the Free Software Foundation; either\n+# version 2.1 of the License, or (at your option) any later version.\n+#\n+# This library is distributed in the hope that it will be useful,\n+# but WITHOUT ANY WARRANTY; without even the implied warranty of\n+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+# Lesser General Public License for more details.\n+#\n+# You should have received a copy of the GNU Lesser General Public\n+# License along with this library; if not, write to the Free Software\n+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\n+# 02110-1301 USA\n+\n+\"\"\"Kennitala (Icelandic personal and organisation identity code).\n+\n+Module for handling Icelandic personal and organisation identity codes\n+(kennitala).\n+\n+>>> validate('530575-0209')  # organisation\n+'530575-0209'\n+>>> validate('120174-3399')  # individual\n+'1201743399'\n+>>> validate('530575-0299')\n+Traceback (most recent call last):\n+    ...\n+InvalidChecksum: ...\n+>>> validate('320174-3399')\n+Traceback (most recent call last):\n+    ...\n+InvalidComponent: ...\n+>>> compact('530575-0209')\n+'5305750209'\n+\"\"\"\n+\n+import re\n+import datetime\n+\n+from stdnum.exceptions import *\n+from stdnum.util import clean\n+\n+\n+# Icelandic personal and organisation identity codes are composed of\n+# date part, a dash, two random digits, a checksum, and a century\n+# indicator where '9' for 1900-1999 and '0' for 2000 and beyond. For\n+# organisations instead of birth date, the registration date is used,\n+# and number 4 is added to the first digit.\n+_kennitala_re = re.compile(r'^(?P<day>[01234567]\\d)(?P<month>[01]\\d)(?P<year>\\d\\d)'\n+                           r'(?P<random>\\d\\d)(?P<control>\\d)'\n+                           r'(?P<century>[09])$')\n+\n+\n+def compact(number):\n+    \"\"\"Convert the kennitala to the minimal representation. This\n+    strips surrounding whitespace and separation dash, and converts it\n+    to upper case.\"\"\"\n+    return clean(number, '-').upper().strip()","path":"stdnum/isl/kennitala.py","position":64,"original_position":64,"commit_id":"8d5a3ab17a9324df37b88d85b8bdff57f8366e81","original_commit_id":"8d5a3ab17a9324df37b88d85b8bdff57f8366e81","user":{"login":"grastenis","id":1920883,"avatar_url":"https://avatars.githubusercontent.com/u/1920883?v=3","gravatar_id":"","url":"https://api.github.com/users/grastenis","html_url":"https://github.com/grastenis","followers_url":"https://api.github.com/users/grastenis/followers","following_url":"https://api.github.com/users/grastenis/following{/other_user}","gists_url":"https://api.github.com/users/grastenis/gists{/gist_id}","starred_url":"https://api.github.com/users/grastenis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grastenis/subscriptions","organizations_url":"https://api.github.com/users/grastenis/orgs","repos_url":"https://api.github.com/users/grastenis/repos","events_url":"https://api.github.com/users/grastenis/events{/privacy}","received_events_url":"https://api.github.com/users/grastenis/received_events","type":"User","site_admin":false},"body":"@toivotuo looks quite strange when upper is applied to number :) though no harm there","created_at":"2015-04-13T05:56:41Z","updated_at":"2015-04-13T05:56:41Z","html_url":"https://github.com/holvi/python-stdnum/pull/2#discussion_r28215716","pull_request_url":"https://api.github.com/repos/holvi/python-stdnum/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/holvi/python-stdnum/pulls/comments/28215716"},"html":{"href":"https://github.com/holvi/python-stdnum/pull/2#discussion_r28215716"},"pull_request":{"href":"https://api.github.com/repos/holvi/python-stdnum/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/holvi/python-stdnum/pulls/2","id":33108856,"html_url":"https://github.com/holvi/python-stdnum/pull/2","diff_url":"https://github.com/holvi/python-stdnum/pull/2.diff","patch_url":"https://github.com/holvi/python-stdnum/pull/2.patch","issue_url":"https://api.github.com/repos/holvi/python-stdnum/issues/2","number":2,"state":"open","locked":false,"title":"Support for Icelandic personal, organisation and VAT identifiers","user":{"login":"toivotuo","id":45169,"avatar_url":"https://avatars.githubusercontent.com/u/45169?v=3","gravatar_id":"","url":"https://api.github.com/users/toivotuo","html_url":"https://github.com/toivotuo","followers_url":"https://api.github.com/users/toivotuo/followers","following_url":"https://api.github.com/users/toivotuo/following{/other_user}","gists_url":"https://api.github.com/users/toivotuo/gists{/gist_id}","starred_url":"https://api.github.com/users/toivotuo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toivotuo/subscriptions","organizations_url":"https://api.github.com/users/toivotuo/orgs","repos_url":"https://api.github.com/users/toivotuo/repos","events_url":"https://api.github.com/users/toivotuo/events{/privacy}","received_events_url":"https://api.github.com/users/toivotuo/received_events","type":"User","site_admin":false},"body":"Support \"kennitala\", the Icelanding personal and organisation number, and \"VSK\", the Icelandic VAT identifier.","created_at":"2015-04-11T19:45:12Z","updated_at":"2015-04-13T05:56:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"12d907980c9ab9af557a9ac3779a24707c293814","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/holvi/python-stdnum/pulls/2/commits","review_comments_url":"https://api.github.com/repos/holvi/python-stdnum/pulls/2/comments","review_comment_url":"https://api.github.com/repos/holvi/python-stdnum/pulls/comments{/number}","comments_url":"https://api.github.com/repos/holvi/python-stdnum/issues/2/comments","statuses_url":"https://api.github.com/repos/holvi/python-stdnum/statuses/8d5a3ab17a9324df37b88d85b8bdff57f8366e81","head":{"label":"holvi:support-icelandic-kennitala","ref":"support-icelandic-kennitala","sha":"8d5a3ab17a9324df37b88d85b8bdff57f8366e81","user":{"login":"holvi","id":1920642,"avatar_url":"https://avatars.githubusercontent.com/u/1920642?v=3","gravatar_id":"","url":"https://api.github.com/users/holvi","html_url":"https://github.com/holvi","followers_url":"https://api.github.com/users/holvi/followers","following_url":"https://api.github.com/users/holvi/following{/other_user}","gists_url":"https://api.github.com/users/holvi/gists{/gist_id}","starred_url":"https://api.github.com/users/holvi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/holvi/subscriptions","organizations_url":"https://api.github.com/users/holvi/orgs","repos_url":"https://api.github.com/users/holvi/repos","events_url":"https://api.github.com/users/holvi/events{/privacy}","received_events_url":"https://api.github.com/users/holvi/received_events","type":"Organization","site_admin":false},"repo":{"id":33785377,"name":"python-stdnum","full_name":"holvi/python-stdnum","owner":{"login":"holvi","id":1920642,"avatar_url":"https://avatars.githubusercontent.com/u/1920642?v=3","gravatar_id":"","url":"https://api.github.com/users/holvi","html_url":"https://github.com/holvi","followers_url":"https://api.github.com/users/holvi/followers","following_url":"https://api.github.com/users/holvi/following{/other_user}","gists_url":"https://api.github.com/users/holvi/gists{/gist_id}","starred_url":"https://api.github.com/users/holvi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/holvi/subscriptions","organizations_url":"https://api.github.com/users/holvi/orgs","repos_url":"https://api.github.com/users/holvi/repos","events_url":"https://api.github.com/users/holvi/events{/privacy}","received_events_url":"https://api.github.com/users/holvi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/holvi/python-stdnum","description":"A Python library to provide functions to handle, parse and validate standard numbers.","fork":true,"url":"https://api.github.com/repos/holvi/python-stdnum","forks_url":"https://api.github.com/repos/holvi/python-stdnum/forks","keys_url":"https://api.github.com/repos/holvi/python-stdnum/keys{/key_id}","collaborators_url":"https://api.github.com/repos/holvi/python-stdnum/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/holvi/python-stdnum/teams","hooks_url":"https://api.github.com/repos/holvi/python-stdnum/hooks","issue_events_url":"https://api.github.com/repos/holvi/python-stdnum/issues/events{/number}","events_url":"https://api.github.com/repos/holvi/python-stdnum/events","assignees_url":"https://api.github.com/repos/holvi/python-stdnum/assignees{/user}","branches_url":"https://api.github.com/repos/holvi/python-stdnum/branches{/branch}","tags_url":"https://api.github.com/repos/holvi/python-stdnum/tags","blobs_url":"https://api.github.com/repos/holvi/python-stdnum/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/holvi/python-stdnum/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/holvi/python-stdnum/git/refs{/sha}","trees_url":"https://api.github.com/repos/holvi/python-stdnum/git/trees{/sha}","statuses_url":"https://api.github.com/repos/holvi/python-stdnum/statuses/{sha}","languages_url":"https://api.github.com/repos/holvi/python-stdnum/languages","stargazers_url":"https://api.github.com/repos/holvi/python-stdnum/stargazers","contributors_url":"https://api.github.com/repos/holvi/python-stdnum/contributors","subscribers_url":"https://api.github.com/repos/holvi/python-stdnum/subscribers","subscription_url":"https://api.github.com/repos/holvi/python-stdnum/subscription","commits_url":"https://api.github.com/repos/holvi/python-stdnum/commits{/sha}","git_commits_url":"https://api.github.com/repos/holvi/python-stdnum/git/commits{/sha}","comments_url":"https://api.github.com/repos/holvi/python-stdnum/comments{/number}","issue_comment_url":"https://api.github.com/repos/holvi/python-stdnum/issues/comments{/number}","contents_url":"https://api.github.com/repos/holvi/python-stdnum/contents/{+path}","compare_url":"https://api.github.com/repos/holvi/python-stdnum/compare/{base}...{head}","merges_url":"https://api.github.com/repos/holvi/python-stdnum/merges","archive_url":"https://api.github.com/repos/holvi/python-stdnum/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/holvi/python-stdnum/downloads","issues_url":"https://api.github.com/repos/holvi/python-stdnum/issues{/number}","pulls_url":"https://api.github.com/repos/holvi/python-stdnum/pulls{/number}","milestones_url":"https://api.github.com/repos/holvi/python-stdnum/milestones{/number}","notifications_url":"https://api.github.com/repos/holvi/python-stdnum/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/holvi/python-stdnum/labels{/name}","releases_url":"https://api.github.com/repos/holvi/python-stdnum/releases{/id}","created_at":"2015-04-11T17:31:59Z","updated_at":"2015-04-11T17:31:59Z","pushed_at":"2015-04-11T20:39:33Z","git_url":"git://github.com/holvi/python-stdnum.git","ssh_url":"git@github.com:holvi/python-stdnum.git","clone_url":"https://github.com/holvi/python-stdnum.git","svn_url":"https://github.com/holvi/python-stdnum","homepage":"http://arthurdejong.org/python-stdnum/","size":730,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"holvi:master","ref":"master","sha":"3a7c9f7d2ffe14a9d2f9bc37f6eaeba4f897970c","user":{"login":"holvi","id":1920642,"avatar_url":"https://avatars.githubusercontent.com/u/1920642?v=3","gravatar_id":"","url":"https://api.github.com/users/holvi","html_url":"https://github.com/holvi","followers_url":"https://api.github.com/users/holvi/followers","following_url":"https://api.github.com/users/holvi/following{/other_user}","gists_url":"https://api.github.com/users/holvi/gists{/gist_id}","starred_url":"https://api.github.com/users/holvi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/holvi/subscriptions","organizations_url":"https://api.github.com/users/holvi/orgs","repos_url":"https://api.github.com/users/holvi/repos","events_url":"https://api.github.com/users/holvi/events{/privacy}","received_events_url":"https://api.github.com/users/holvi/received_events","type":"Organization","site_admin":false},"repo":{"id":33785377,"name":"python-stdnum","full_name":"holvi/python-stdnum","owner":{"login":"holvi","id":1920642,"avatar_url":"https://avatars.githubusercontent.com/u/1920642?v=3","gravatar_id":"","url":"https://api.github.com/users/holvi","html_url":"https://github.com/holvi","followers_url":"https://api.github.com/users/holvi/followers","following_url":"https://api.github.com/users/holvi/following{/other_user}","gists_url":"https://api.github.com/users/holvi/gists{/gist_id}","starred_url":"https://api.github.com/users/holvi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/holvi/subscriptions","organizations_url":"https://api.github.com/users/holvi/orgs","repos_url":"https://api.github.com/users/holvi/repos","events_url":"https://api.github.com/users/holvi/events{/privacy}","received_events_url":"https://api.github.com/users/holvi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/holvi/python-stdnum","description":"A Python library to provide functions to handle, parse and validate standard numbers.","fork":true,"url":"https://api.github.com/repos/holvi/python-stdnum","forks_url":"https://api.github.com/repos/holvi/python-stdnum/forks","keys_url":"https://api.github.com/repos/holvi/python-stdnum/keys{/key_id}","collaborators_url":"https://api.github.com/repos/holvi/python-stdnum/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/holvi/python-stdnum/teams","hooks_url":"https://api.github.com/repos/holvi/python-stdnum/hooks","issue_events_url":"https://api.github.com/repos/holvi/python-stdnum/issues/events{/number}","events_url":"https://api.github.com/repos/holvi/python-stdnum/events","assignees_url":"https://api.github.com/repos/holvi/python-stdnum/assignees{/user}","branches_url":"https://api.github.com/repos/holvi/python-stdnum/branches{/branch}","tags_url":"https://api.github.com/repos/holvi/python-stdnum/tags","blobs_url":"https://api.github.com/repos/holvi/python-stdnum/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/holvi/python-stdnum/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/holvi/python-stdnum/git/refs{/sha}","trees_url":"https://api.github.com/repos/holvi/python-stdnum/git/trees{/sha}","statuses_url":"https://api.github.com/repos/holvi/python-stdnum/statuses/{sha}","languages_url":"https://api.github.com/repos/holvi/python-stdnum/languages","stargazers_url":"https://api.github.com/repos/holvi/python-stdnum/stargazers","contributors_url":"https://api.github.com/repos/holvi/python-stdnum/contributors","subscribers_url":"https://api.github.com/repos/holvi/python-stdnum/subscribers","subscription_url":"https://api.github.com/repos/holvi/python-stdnum/subscription","commits_url":"https://api.github.com/repos/holvi/python-stdnum/commits{/sha}","git_commits_url":"https://api.github.com/repos/holvi/python-stdnum/git/commits{/sha}","comments_url":"https://api.github.com/repos/holvi/python-stdnum/comments{/number}","issue_comment_url":"https://api.github.com/repos/holvi/python-stdnum/issues/comments{/number}","contents_url":"https://api.github.com/repos/holvi/python-stdnum/contents/{+path}","compare_url":"https://api.github.com/repos/holvi/python-stdnum/compare/{base}...{head}","merges_url":"https://api.github.com/repos/holvi/python-stdnum/merges","archive_url":"https://api.github.com/repos/holvi/python-stdnum/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/holvi/python-stdnum/downloads","issues_url":"https://api.github.com/repos/holvi/python-stdnum/issues{/number}","pulls_url":"https://api.github.com/repos/holvi/python-stdnum/pulls{/number}","milestones_url":"https://api.github.com/repos/holvi/python-stdnum/milestones{/number}","notifications_url":"https://api.github.com/repos/holvi/python-stdnum/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/holvi/python-stdnum/labels{/name}","releases_url":"https://api.github.com/repos/holvi/python-stdnum/releases{/id}","created_at":"2015-04-11T17:31:59Z","updated_at":"2015-04-11T17:31:59Z","pushed_at":"2015-04-11T20:39:33Z","git_url":"git://github.com/holvi/python-stdnum.git","ssh_url":"git@github.com:holvi/python-stdnum.git","clone_url":"https://github.com/holvi/python-stdnum.git","svn_url":"https://github.com/holvi/python-stdnum","homepage":"http://arthurdejong.org/python-stdnum/","size":730,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"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/holvi/python-stdnum/pulls/2"},"html":{"href":"https://github.com/holvi/python-stdnum/pull/2"},"issue":{"href":"https://api.github.com/repos/holvi/python-stdnum/issues/2"},"comments":{"href":"https://api.github.com/repos/holvi/python-stdnum/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/holvi/python-stdnum/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/holvi/python-stdnum/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/holvi/python-stdnum/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/holvi/python-stdnum/statuses/8d5a3ab17a9324df37b88d85b8bdff57f8366e81"}}}}