{"action":"created","comment":{"url":"https://api.github.com/repos/prawn-cake/simple-models/pulls/comments/75590327","id":75590327,"diff_hunk":"@@ -164,6 +165,36 @@ def _prepare_fields(self, kwargs):\n         return kwargs\n \n     @classmethod\n+    def _get_path(cls, root, path, name):\n+        \"\"\"\n+        Helper method to read value from nested data structure by given path.\n+\n+        :param root: root object with data\n+        :param path: beginning of the path\n+        :param name: last element name\n+        :return: extracted value or None\n+        \"\"\"\n+\n+        if isinstance(path, six.string_types):\n+            path = path.split('/')\n+\n+        path = list(filter(None, path)) if path else []\n+        path = path + [name]\n+        cur = root\n+        for seg in path:\n+            try:\n+                cur = cur[seg]\n+            except (KeyError, IndexError):\n+                return None\n+            except TypeError:\n+                try:","path":"simplemodels/models.py","position":57,"original_position":57,"commit_id":"f4c3a7944caf5cdd797d3d0d8a77e2ba038909f5","original_commit_id":"7337b4ea49a3ae03b95a59c43715f2621572df67","user":{"login":"grundic","id":207278,"avatar_url":"https://avatars.githubusercontent.com/u/207278?v=3","gravatar_id":"","url":"https://api.github.com/users/grundic","html_url":"https://github.com/grundic","followers_url":"https://api.github.com/users/grundic/followers","following_url":"https://api.github.com/users/grundic/following{/other_user}","gists_url":"https://api.github.com/users/grundic/gists{/gist_id}","starred_url":"https://api.github.com/users/grundic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grundic/subscriptions","organizations_url":"https://api.github.com/users/grundic/orgs","repos_url":"https://api.github.com/users/grundic/repos","events_url":"https://api.github.com/users/grundic/events{/privacy}","received_events_url":"https://api.github.com/users/grundic/received_events","type":"User","site_admin":false},"body":"I borrowed this method from boltons [iterutils](https://github.com/mahmoud/boltons/blob/4f506cff3cd82ceb07e82b5946190eeada0d75ba/boltons/iterutils.py#L911) module.\r\n\r\nThe purpose of it is to get value from some complex nested structure either dict based or index based. First it tries to get value by name from dictionary, if it fails it tries to convert value to int and get it by index.\r\nAdded some tests, please have a look.","created_at":"2016-08-21T07:41:15Z","updated_at":"2016-08-21T07:41:15Z","html_url":"https://github.com/prawn-cake/simple-models/pull/14#discussion_r75590327","pull_request_url":"https://api.github.com/repos/prawn-cake/simple-models/pulls/14","_links":{"self":{"href":"https://api.github.com/repos/prawn-cake/simple-models/pulls/comments/75590327"},"html":{"href":"https://github.com/prawn-cake/simple-models/pull/14#discussion_r75590327"},"pull_request":{"href":"https://api.github.com/repos/prawn-cake/simple-models/pulls/14"}}},"pull_request":{"url":"https://api.github.com/repos/prawn-cake/simple-models/pulls/14","id":82092533,"html_url":"https://github.com/prawn-cake/simple-models/pull/14","diff_url":"https://github.com/prawn-cake/simple-models/pull/14.diff","patch_url":"https://github.com/prawn-cake/simple-models/pull/14.patch","issue_url":"https://api.github.com/repos/prawn-cake/simple-models/issues/14","number":14,"state":"open","locked":false,"title":"Solution for #12","user":{"login":"grundic","id":207278,"avatar_url":"https://avatars.githubusercontent.com/u/207278?v=3","gravatar_id":"","url":"https://api.github.com/users/grundic","html_url":"https://github.com/grundic","followers_url":"https://api.github.com/users/grundic/followers","following_url":"https://api.github.com/users/grundic/following{/other_user}","gists_url":"https://api.github.com/users/grundic/gists{/gist_id}","starred_url":"https://api.github.com/users/grundic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grundic/subscriptions","organizations_url":"https://api.github.com/users/grundic/orgs","repos_url":"https://api.github.com/users/grundic/repos","events_url":"https://api.github.com/users/grundic/events{/privacy}","received_events_url":"https://api.github.com/users/grundic/received_events","type":"User","site_admin":false},"body":"Hello,\r\nthis should be enough to fix #12.","created_at":"2016-08-20T23:34:54Z","updated_at":"2016-08-21T07:41:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fbb17a7c17d82527dc39eb91afd80135ab81140a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/prawn-cake/simple-models/pulls/14/commits","review_comments_url":"https://api.github.com/repos/prawn-cake/simple-models/pulls/14/comments","review_comment_url":"https://api.github.com/repos/prawn-cake/simple-models/pulls/comments{/number}","comments_url":"https://api.github.com/repos/prawn-cake/simple-models/issues/14/comments","statuses_url":"https://api.github.com/repos/prawn-cake/simple-models/statuses/f4c3a7944caf5cdd797d3d0d8a77e2ba038909f5","head":{"label":"grundic:develop","ref":"develop","sha":"f4c3a7944caf5cdd797d3d0d8a77e2ba038909f5","user":{"login":"grundic","id":207278,"avatar_url":"https://avatars.githubusercontent.com/u/207278?v=3","gravatar_id":"","url":"https://api.github.com/users/grundic","html_url":"https://github.com/grundic","followers_url":"https://api.github.com/users/grundic/followers","following_url":"https://api.github.com/users/grundic/following{/other_user}","gists_url":"https://api.github.com/users/grundic/gists{/gist_id}","starred_url":"https://api.github.com/users/grundic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grundic/subscriptions","organizations_url":"https://api.github.com/users/grundic/orgs","repos_url":"https://api.github.com/users/grundic/repos","events_url":"https://api.github.com/users/grundic/events{/privacy}","received_events_url":"https://api.github.com/users/grundic/received_events","type":"User","site_admin":false},"repo":{"id":66168491,"name":"simple-models","full_name":"grundic/simple-models","owner":{"login":"grundic","id":207278,"avatar_url":"https://avatars.githubusercontent.com/u/207278?v=3","gravatar_id":"","url":"https://api.github.com/users/grundic","html_url":"https://github.com/grundic","followers_url":"https://api.github.com/users/grundic/followers","following_url":"https://api.github.com/users/grundic/following{/other_user}","gists_url":"https://api.github.com/users/grundic/gists{/gist_id}","starred_url":"https://api.github.com/users/grundic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grundic/subscriptions","organizations_url":"https://api.github.com/users/grundic/orgs","repos_url":"https://api.github.com/users/grundic/repos","events_url":"https://api.github.com/users/grundic/events{/privacy}","received_events_url":"https://api.github.com/users/grundic/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/grundic/simple-models","description":"Simple models - keep your API messages in shape with validation and handy descriptors based object intergace","fork":true,"url":"https://api.github.com/repos/grundic/simple-models","forks_url":"https://api.github.com/repos/grundic/simple-models/forks","keys_url":"https://api.github.com/repos/grundic/simple-models/keys{/key_id}","collaborators_url":"https://api.github.com/repos/grundic/simple-models/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/grundic/simple-models/teams","hooks_url":"https://api.github.com/repos/grundic/simple-models/hooks","issue_events_url":"https://api.github.com/repos/grundic/simple-models/issues/events{/number}","events_url":"https://api.github.com/repos/grundic/simple-models/events","assignees_url":"https://api.github.com/repos/grundic/simple-models/assignees{/user}","branches_url":"https://api.github.com/repos/grundic/simple-models/branches{/branch}","tags_url":"https://api.github.com/repos/grundic/simple-models/tags","blobs_url":"https://api.github.com/repos/grundic/simple-models/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/grundic/simple-models/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/grundic/simple-models/git/refs{/sha}","trees_url":"https://api.github.com/repos/grundic/simple-models/git/trees{/sha}","statuses_url":"https://api.github.com/repos/grundic/simple-models/statuses/{sha}","languages_url":"https://api.github.com/repos/grundic/simple-models/languages","stargazers_url":"https://api.github.com/repos/grundic/simple-models/stargazers","contributors_url":"https://api.github.com/repos/grundic/simple-models/contributors","subscribers_url":"https://api.github.com/repos/grundic/simple-models/subscribers","subscription_url":"https://api.github.com/repos/grundic/simple-models/subscription","commits_url":"https://api.github.com/repos/grundic/simple-models/commits{/sha}","git_commits_url":"https://api.github.com/repos/grundic/simple-models/git/commits{/sha}","comments_url":"https://api.github.com/repos/grundic/simple-models/comments{/number}","issue_comment_url":"https://api.github.com/repos/grundic/simple-models/issues/comments{/number}","contents_url":"https://api.github.com/repos/grundic/simple-models/contents/{+path}","compare_url":"https://api.github.com/repos/grundic/simple-models/compare/{base}...{head}","merges_url":"https://api.github.com/repos/grundic/simple-models/merges","archive_url":"https://api.github.com/repos/grundic/simple-models/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/grundic/simple-models/downloads","issues_url":"https://api.github.com/repos/grundic/simple-models/issues{/number}","pulls_url":"https://api.github.com/repos/grundic/simple-models/pulls{/number}","milestones_url":"https://api.github.com/repos/grundic/simple-models/milestones{/number}","notifications_url":"https://api.github.com/repos/grundic/simple-models/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/grundic/simple-models/labels{/name}","releases_url":"https://api.github.com/repos/grundic/simple-models/releases{/id}","deployments_url":"https://api.github.com/repos/grundic/simple-models/deployments","created_at":"2016-08-20T21:19:34Z","updated_at":"2016-08-20T21:19:35Z","pushed_at":"2016-08-21T07:38:42Z","git_url":"git://github.com/grundic/simple-models.git","ssh_url":"git@github.com:grundic/simple-models.git","clone_url":"https://github.com/grundic/simple-models.git","svn_url":"https://github.com/grundic/simple-models","homepage":"","size":261,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"prawn-cake:develop","ref":"develop","sha":"f265404830d4ca83498e4ead9ef97386ab25aee5","user":{"login":"prawn-cake","id":5894089,"avatar_url":"https://avatars.githubusercontent.com/u/5894089?v=3","gravatar_id":"","url":"https://api.github.com/users/prawn-cake","html_url":"https://github.com/prawn-cake","followers_url":"https://api.github.com/users/prawn-cake/followers","following_url":"https://api.github.com/users/prawn-cake/following{/other_user}","gists_url":"https://api.github.com/users/prawn-cake/gists{/gist_id}","starred_url":"https://api.github.com/users/prawn-cake/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prawn-cake/subscriptions","organizations_url":"https://api.github.com/users/prawn-cake/orgs","repos_url":"https://api.github.com/users/prawn-cake/repos","events_url":"https://api.github.com/users/prawn-cake/events{/privacy}","received_events_url":"https://api.github.com/users/prawn-cake/received_events","type":"User","site_admin":false},"repo":{"id":16650124,"name":"simple-models","full_name":"prawn-cake/simple-models","owner":{"login":"prawn-cake","id":5894089,"avatar_url":"https://avatars.githubusercontent.com/u/5894089?v=3","gravatar_id":"","url":"https://api.github.com/users/prawn-cake","html_url":"https://github.com/prawn-cake","followers_url":"https://api.github.com/users/prawn-cake/followers","following_url":"https://api.github.com/users/prawn-cake/following{/other_user}","gists_url":"https://api.github.com/users/prawn-cake/gists{/gist_id}","starred_url":"https://api.github.com/users/prawn-cake/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prawn-cake/subscriptions","organizations_url":"https://api.github.com/users/prawn-cake/orgs","repos_url":"https://api.github.com/users/prawn-cake/repos","events_url":"https://api.github.com/users/prawn-cake/events{/privacy}","received_events_url":"https://api.github.com/users/prawn-cake/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/prawn-cake/simple-models","description":"Simple models - keep your API messages in shape with validation and handy descriptors based object intergace","fork":false,"url":"https://api.github.com/repos/prawn-cake/simple-models","forks_url":"https://api.github.com/repos/prawn-cake/simple-models/forks","keys_url":"https://api.github.com/repos/prawn-cake/simple-models/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prawn-cake/simple-models/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prawn-cake/simple-models/teams","hooks_url":"https://api.github.com/repos/prawn-cake/simple-models/hooks","issue_events_url":"https://api.github.com/repos/prawn-cake/simple-models/issues/events{/number}","events_url":"https://api.github.com/repos/prawn-cake/simple-models/events","assignees_url":"https://api.github.com/repos/prawn-cake/simple-models/assignees{/user}","branches_url":"https://api.github.com/repos/prawn-cake/simple-models/branches{/branch}","tags_url":"https://api.github.com/repos/prawn-cake/simple-models/tags","blobs_url":"https://api.github.com/repos/prawn-cake/simple-models/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prawn-cake/simple-models/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prawn-cake/simple-models/git/refs{/sha}","trees_url":"https://api.github.com/repos/prawn-cake/simple-models/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prawn-cake/simple-models/statuses/{sha}","languages_url":"https://api.github.com/repos/prawn-cake/simple-models/languages","stargazers_url":"https://api.github.com/repos/prawn-cake/simple-models/stargazers","contributors_url":"https://api.github.com/repos/prawn-cake/simple-models/contributors","subscribers_url":"https://api.github.com/repos/prawn-cake/simple-models/subscribers","subscription_url":"https://api.github.com/repos/prawn-cake/simple-models/subscription","commits_url":"https://api.github.com/repos/prawn-cake/simple-models/commits{/sha}","git_commits_url":"https://api.github.com/repos/prawn-cake/simple-models/git/commits{/sha}","comments_url":"https://api.github.com/repos/prawn-cake/simple-models/comments{/number}","issue_comment_url":"https://api.github.com/repos/prawn-cake/simple-models/issues/comments{/number}","contents_url":"https://api.github.com/repos/prawn-cake/simple-models/contents/{+path}","compare_url":"https://api.github.com/repos/prawn-cake/simple-models/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prawn-cake/simple-models/merges","archive_url":"https://api.github.com/repos/prawn-cake/simple-models/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prawn-cake/simple-models/downloads","issues_url":"https://api.github.com/repos/prawn-cake/simple-models/issues{/number}","pulls_url":"https://api.github.com/repos/prawn-cake/simple-models/pulls{/number}","milestones_url":"https://api.github.com/repos/prawn-cake/simple-models/milestones{/number}","notifications_url":"https://api.github.com/repos/prawn-cake/simple-models/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prawn-cake/simple-models/labels{/name}","releases_url":"https://api.github.com/repos/prawn-cake/simple-models/releases{/id}","deployments_url":"https://api.github.com/repos/prawn-cake/simple-models/deployments","created_at":"2014-02-08T18:42:57Z","updated_at":"2016-08-04T14:42:29Z","pushed_at":"2016-08-21T07:38:42Z","git_url":"git://github.com/prawn-cake/simple-models.git","ssh_url":"git@github.com:prawn-cake/simple-models.git","clone_url":"https://github.com/prawn-cake/simple-models.git","svn_url":"https://github.com/prawn-cake/simple-models","homepage":"","size":255,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/prawn-cake/simple-models/pulls/14"},"html":{"href":"https://github.com/prawn-cake/simple-models/pull/14"},"issue":{"href":"https://api.github.com/repos/prawn-cake/simple-models/issues/14"},"comments":{"href":"https://api.github.com/repos/prawn-cake/simple-models/issues/14/comments"},"review_comments":{"href":"https://api.github.com/repos/prawn-cake/simple-models/pulls/14/comments"},"review_comment":{"href":"https://api.github.com/repos/prawn-cake/simple-models/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/prawn-cake/simple-models/pulls/14/commits"},"statuses":{"href":"https://api.github.com/repos/prawn-cake/simple-models/statuses/f4c3a7944caf5cdd797d3d0d8a77e2ba038909f5"}}}}
{"actor":{"display_login":"grundic"}}