{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/pulls/comments/24529716","id":24529716,"diff_hunk":"@@ -23,104 +22,32 @@ def load_and_parse_json(file_name):\n def raise_type_error(file_name, key, expected_type):\n   raise Exception('ERROR: \"' + key + '\" must be of type \"' + expected_type + '\" (' + file_name + ')')\n \n-def parse_and_rebase_images(images, file_name, prefix, rebase_path):\n-  for (index, entry) in enumerate(images):\n-    i = str(index)\n-    if not isinstance(entry, dict):\n-      raise_type_error(file_name, prefix + \"[\" + i + \"]\", \"object\")\n-    if not (\"src\" in entry) or not isinstance(entry[\"src\"], basestring):\n-      raise_type_error(file_name, prefix + \"[\" + i + \"]/src\", \"string\")\n-    if not (\"scale\" in entry) or not isinstance(entry[\"scale\"], numbers.Number):\n-      raise_type_error(file_name, prefix + \"[\" + i + \"]/scale\", \"number\")\n+def parse_and_rebase_images(images, rebase_path):\n+  for entry in images:\n     entry[\"src\"] = os.path.join(rebase_path, entry[\"src\"])\n \n-def parse_orientation(d, file_name, prefix, rebase_path):\n-  if not (\"width\" in d) or not isinstance(d[\"width\"], numbers.Number) or d[\"width\"] < 0 or d[\"width\"] > 10000 or abs(d[\"width\"]) != d[\"width\"]:\n-    raise_type_error(file_name, prefix + \"/width\", \"number\")\n-  if not (\"height\" in d) or not isinstance(d[\"height\"], numbers.Number) or d[\"height\"] < 0 or d[\"height\"] > 10000 or abs(d[\"height\"]) != d[\"height\"]:\n-    raise_type_error(file_name, prefix + \"/height\", \"number\")\n-\n+def parse_orientation(d, file_name, prefix):\n   if not (\"outline\" in d):\n     return\n-  outline = d[\"outline\"]\n-  if not isinstance(outline, dict):\n-    raise_type_error(file_name, prefix + \"/outline\", \"object\")\n-  if not (\"images\" in outline) or not isinstance(outline[\"images\"], (list, tuple)):\n-    raise_type_error(file_name, prefix + \"/outline/images\", \"array\")\n-  parse_and_rebase_images(outline[\"images\"], file_name, prefix + \"/outline/images\", rebase_path)\n-  if not (\"insets\" in outline) or not isinstance(outline[\"insets\"], dict):\n-    raise_type_error(file_name, prefix + \"/outline/insets\", \"object\")\n-  if not (\"left\" in outline[\"insets\"]) or not isinstance(outline[\"insets\"][\"left\"], numbers.Number) or outline[\"insets\"][\"left\"] < 0:\n-    raise_type_error(file_name, prefix + \"/outline/insets/left\", \"number\")\n-  if not (\"top\" in outline[\"insets\"]) or not isinstance(outline[\"insets\"][\"top\"], numbers.Number) or outline[\"insets\"][\"top\"] < 0:\n-    raise_type_error(file_name, prefix + \"/outline/insets/top\", \"number\")\n-\n-def parse_modes(modes, file_name, prefix, rebase_path):\n-  for (index, mode) in enumerate(modes):\n-    i = str(index)\n-    if not isinstance(mode, dict):\n-      raise_type_error(file_name, prefix + \"[\" + i + \"]\", \"object\")\n-    if not (\"title\" in mode) or not isinstance(mode[\"title\"], basestring):\n-      raise_type_error(file_name, prefix + \"[\" + i + \"]/title\", \"string\")\n-    if not (\"orientation\" in mode) or not isinstance(mode[\"orientation\"], basestring):\n-      raise_type_error(file_name, prefix + \"[\" + i + \"]/orientation\", \"string\")\n-    if mode[\"orientation\"] != \"vertical\" and mode[\"orientation\"] != \"horizontal\":\n-      raise Exception('ERROR: \"' + prefix + '[' + i + ']/orientation\" must be one of the following: [horizontal, vertical] (' + file_name + ')')\n-\n-    if not (\"images\" in mode) or not isinstance(mode[\"images\"], (list, tuple)):\n-      raise_type_error(file_name, prefix + \"[\" + i + \"]/images\", \"array\")\n-    parse_and_rebase_images(mode[\"images\"], file_name, prefix + \"[\" + i + \"]/images\", rebase_path)\n-\n-    if not (\"page-rect\" in mode) or not isinstance(mode[\"page-rect\"], dict):\n-      raise_type_error(file_name, prefix + \"[\" + i + \"]/page-rect\", \"object\")\n-    if not (\"left\" in mode[\"page-rect\"]) or not isinstance(mode[\"page-rect\"][\"left\"], numbers.Number) or mode[\"page-rect\"][\"left\"] < 0:\n-      raise_type_error(file_name, prefix + \"[\" + i + \"]/page-rect/left\", \"object\")\n-    if not (\"top\" in mode[\"page-rect\"]) or not isinstance(mode[\"page-rect\"][\"top\"], numbers.Number) or mode[\"page-rect\"][\"top\"] < 0:\n-      raise_type_error(file_name, prefix + \"[\" + i + \"]/page-rect/top\", \"object\")\n-    if not (\"width\" in mode[\"page-rect\"]) or not isinstance(mode[\"page-rect\"][\"width\"], numbers.Number) or mode[\"page-rect\"][\"width\"] < 0:\n-      raise_type_error(file_name, prefix + \"[\" + i + \"]/page-rect/width\", \"object\")\n-    if not (\"height\" in mode[\"page-rect\"]) or not isinstance(mode[\"page-rect\"][\"height\"], numbers.Number) or mode[\"page-rect\"][\"height\"] < 0:\n-      raise_type_error(file_name, prefix + \"[\" + i + \"]/page-rect/height\", \"object\")\n-\n-def parse_device_json(file_name, rebase_path):\n-  json = load_and_parse_json(file_name)\n \n-  if not (\"title\" in json) or not isinstance(json[\"title\"], basestring):\n-    raise_type_error(file_name, \"title\", \"string\")\n+  parse_and_rebase_images(d[\"outline\"][\"images\"], file_name)\n \n-  if not (\"type\" in json) or not isinstance(json[\"type\"], basestring):\n-    raise_type_error(file_name, \"type\", \"string\")\n-  if not (json[\"type\"] in POSSIBLE_TYPES):\n-    raise Exception('ERROR: \"type\" must be one of the following: [' + \", \".join(POSSIBLE_TYPES) + '] (' + file_name + ')')\n+def parse_modes(modes, file_name):\n+  for mode in modes:\n+    parse_and_rebase_images(mode[\"images\"], file_name)","path":"generate_devices_list.py","position":95,"original_position":95,"commit_id":"def3713b391e0681a4b515e5e113e915a3497681","original_commit_id":"def3713b391e0681a4b515e5e113e915a3497681","user":{"login":"rrev","id":3382153,"avatar_url":"https://avatars.githubusercontent.com/u/3382153?v=3","gravatar_id":"","url":"https://api.github.com/users/rrev","html_url":"https://github.com/rrev","followers_url":"https://api.github.com/users/rrev/followers","following_url":"https://api.github.com/users/rrev/following{/other_user}","gists_url":"https://api.github.com/users/rrev/gists{/gist_id}","starred_url":"https://api.github.com/users/rrev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rrev/subscriptions","organizations_url":"https://api.github.com/users/rrev/orgs","repos_url":"https://api.github.com/users/rrev/repos","events_url":"https://api.github.com/users/rrev/events{/privacy}","received_events_url":"https://api.github.com/users/rrev/received_events","type":"User","site_admin":false},"body":"can I drop ```raise_type_error``` too? It's not used anymore","created_at":"2015-02-11T20:22:32Z","updated_at":"2015-02-11T20:22:32Z","html_url":"https://github.com/GoogleChrome/devtools-device-data/pull/11#discussion_r24529716","pull_request_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/GoogleChrome/devtools-device-data/pulls/comments/24529716"},"html":{"href":"https://github.com/GoogleChrome/devtools-device-data/pull/11#discussion_r24529716"},"pull_request":{"href":"https://api.github.com/repos/GoogleChrome/devtools-device-data/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/pulls/11","id":28952278,"html_url":"https://github.com/GoogleChrome/devtools-device-data/pull/11","diff_url":"https://github.com/GoogleChrome/devtools-device-data/pull/11.diff","patch_url":"https://github.com/GoogleChrome/devtools-device-data/pull/11.patch","issue_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/issues/11","number":11,"state":"open","locked":false,"title":"JSON file validation using JSON Schema file","user":{"login":"rrev","id":3382153,"avatar_url":"https://avatars.githubusercontent.com/u/3382153?v=3","gravatar_id":"","url":"https://api.github.com/users/rrev","html_url":"https://github.com/rrev","followers_url":"https://api.github.com/users/rrev/followers","following_url":"https://api.github.com/users/rrev/following{/other_user}","gists_url":"https://api.github.com/users/rrev/gists{/gist_id}","starred_url":"https://api.github.com/users/rrev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rrev/subscriptions","organizations_url":"https://api.github.com/users/rrev/orgs","repos_url":"https://api.github.com/users/rrev/repos","events_url":"https://api.github.com/users/rrev/events{/privacy}","received_events_url":"https://api.github.com/users/rrev/received_events","type":"User","site_admin":false},"body":"See #9 \r\n\r\nI would like to edit this section\r\n\r\n```\r\n  if abs(d[\"width\"]) != d[\"width\"]:\r\n    raise_type_error(file_name, prefix + \"/width\", \"number\")\r\n\r\n  if abs(d[\"height\"]) != d[\"height\"]:\r\n    raise_type_error(file_name, prefix + \"/height\", \"number\")\r\n```\r\n\r\nby proving a more useful error message instead of a `Error: X should be of type Number` but I don't know what this code does.\r\n\r\nI throw away the entire python validation code (without changing the structure much -- but anyway, it's very clean) and created the schema file by reading the python code","created_at":"2015-02-09T20:11:37Z","updated_at":"2015-02-11T20:22:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"02fe36e511e60d7bfd03f802b162f31b73062013","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/pulls/11/commits","review_comments_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/pulls/11/comments","review_comment_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/pulls/comments/{number}","comments_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/issues/11/comments","statuses_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/statuses/def3713b391e0681a4b515e5e113e915a3497681","head":{"label":"rrev:schema","ref":"schema","sha":"def3713b391e0681a4b515e5e113e915a3497681","user":{"login":"rrev","id":3382153,"avatar_url":"https://avatars.githubusercontent.com/u/3382153?v=3","gravatar_id":"","url":"https://api.github.com/users/rrev","html_url":"https://github.com/rrev","followers_url":"https://api.github.com/users/rrev/followers","following_url":"https://api.github.com/users/rrev/following{/other_user}","gists_url":"https://api.github.com/users/rrev/gists{/gist_id}","starred_url":"https://api.github.com/users/rrev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rrev/subscriptions","organizations_url":"https://api.github.com/users/rrev/orgs","repos_url":"https://api.github.com/users/rrev/repos","events_url":"https://api.github.com/users/rrev/events{/privacy}","received_events_url":"https://api.github.com/users/rrev/received_events","type":"User","site_admin":false},"repo":{"id":30554538,"name":"devtools-device-data","full_name":"rrev/devtools-device-data","owner":{"login":"rrev","id":3382153,"avatar_url":"https://avatars.githubusercontent.com/u/3382153?v=3","gravatar_id":"","url":"https://api.github.com/users/rrev","html_url":"https://github.com/rrev","followers_url":"https://api.github.com/users/rrev/followers","following_url":"https://api.github.com/users/rrev/following{/other_user}","gists_url":"https://api.github.com/users/rrev/gists{/gist_id}","starred_url":"https://api.github.com/users/rrev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rrev/subscriptions","organizations_url":"https://api.github.com/users/rrev/orgs","repos_url":"https://api.github.com/users/rrev/repos","events_url":"https://api.github.com/users/rrev/events{/privacy}","received_events_url":"https://api.github.com/users/rrev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rrev/devtools-device-data","description":"","fork":true,"url":"https://api.github.com/repos/rrev/devtools-device-data","forks_url":"https://api.github.com/repos/rrev/devtools-device-data/forks","keys_url":"https://api.github.com/repos/rrev/devtools-device-data/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rrev/devtools-device-data/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rrev/devtools-device-data/teams","hooks_url":"https://api.github.com/repos/rrev/devtools-device-data/hooks","issue_events_url":"https://api.github.com/repos/rrev/devtools-device-data/issues/events{/number}","events_url":"https://api.github.com/repos/rrev/devtools-device-data/events","assignees_url":"https://api.github.com/repos/rrev/devtools-device-data/assignees{/user}","branches_url":"https://api.github.com/repos/rrev/devtools-device-data/branches{/branch}","tags_url":"https://api.github.com/repos/rrev/devtools-device-data/tags","blobs_url":"https://api.github.com/repos/rrev/devtools-device-data/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rrev/devtools-device-data/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rrev/devtools-device-data/git/refs{/sha}","trees_url":"https://api.github.com/repos/rrev/devtools-device-data/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rrev/devtools-device-data/statuses/{sha}","languages_url":"https://api.github.com/repos/rrev/devtools-device-data/languages","stargazers_url":"https://api.github.com/repos/rrev/devtools-device-data/stargazers","contributors_url":"https://api.github.com/repos/rrev/devtools-device-data/contributors","subscribers_url":"https://api.github.com/repos/rrev/devtools-device-data/subscribers","subscription_url":"https://api.github.com/repos/rrev/devtools-device-data/subscription","commits_url":"https://api.github.com/repos/rrev/devtools-device-data/commits{/sha}","git_commits_url":"https://api.github.com/repos/rrev/devtools-device-data/git/commits{/sha}","comments_url":"https://api.github.com/repos/rrev/devtools-device-data/comments{/number}","issue_comment_url":"https://api.github.com/repos/rrev/devtools-device-data/issues/comments/{number}","contents_url":"https://api.github.com/repos/rrev/devtools-device-data/contents/{+path}","compare_url":"https://api.github.com/repos/rrev/devtools-device-data/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rrev/devtools-device-data/merges","archive_url":"https://api.github.com/repos/rrev/devtools-device-data/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rrev/devtools-device-data/downloads","issues_url":"https://api.github.com/repos/rrev/devtools-device-data/issues{/number}","pulls_url":"https://api.github.com/repos/rrev/devtools-device-data/pulls{/number}","milestones_url":"https://api.github.com/repos/rrev/devtools-device-data/milestones{/number}","notifications_url":"https://api.github.com/repos/rrev/devtools-device-data/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rrev/devtools-device-data/labels{/name}","releases_url":"https://api.github.com/repos/rrev/devtools-device-data/releases{/id}","created_at":"2015-02-09T19:40:04Z","updated_at":"2015-02-09T19:40:04Z","pushed_at":"2015-02-11T15:24:02Z","git_url":"git://github.com/rrev/devtools-device-data.git","ssh_url":"git@github.com:rrev/devtools-device-data.git","clone_url":"https://github.com/rrev/devtools-device-data.git","svn_url":"https://github.com/rrev/devtools-device-data","homepage":null,"size":363,"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":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"GoogleChrome:master","ref":"master","sha":"fcc7b5a90f27ed429d66e0f2bb2df5b08d2ccb29","user":{"login":"GoogleChrome","id":1778935,"avatar_url":"https://avatars.githubusercontent.com/u/1778935?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleChrome","html_url":"https://github.com/GoogleChrome","followers_url":"https://api.github.com/users/GoogleChrome/followers","following_url":"https://api.github.com/users/GoogleChrome/following{/other_user}","gists_url":"https://api.github.com/users/GoogleChrome/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleChrome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleChrome/subscriptions","organizations_url":"https://api.github.com/users/GoogleChrome/orgs","repos_url":"https://api.github.com/users/GoogleChrome/repos","events_url":"https://api.github.com/users/GoogleChrome/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleChrome/received_events","type":"Organization","site_admin":false},"repo":{"id":28062115,"name":"devtools-device-data","full_name":"GoogleChrome/devtools-device-data","owner":{"login":"GoogleChrome","id":1778935,"avatar_url":"https://avatars.githubusercontent.com/u/1778935?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleChrome","html_url":"https://github.com/GoogleChrome","followers_url":"https://api.github.com/users/GoogleChrome/followers","following_url":"https://api.github.com/users/GoogleChrome/following{/other_user}","gists_url":"https://api.github.com/users/GoogleChrome/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleChrome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleChrome/subscriptions","organizations_url":"https://api.github.com/users/GoogleChrome/orgs","repos_url":"https://api.github.com/users/GoogleChrome/repos","events_url":"https://api.github.com/users/GoogleChrome/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleChrome/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleChrome/devtools-device-data","description":"","fork":false,"url":"https://api.github.com/repos/GoogleChrome/devtools-device-data","forks_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/forks","keys_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/teams","hooks_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/hooks","issue_events_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/events","assignees_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/tags","blobs_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/languages","stargazers_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/stargazers","contributors_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/contributors","subscribers_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/subscribers","subscription_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/subscription","commits_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/issues/comments/{number}","contents_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/merges","archive_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/downloads","issues_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/labels{/name}","releases_url":"https://api.github.com/repos/GoogleChrome/devtools-device-data/releases{/id}","created_at":"2014-12-15T23:59:58Z","updated_at":"2015-02-11T12:51:19Z","pushed_at":"2015-02-09T14:46:36Z","git_url":"git://github.com/GoogleChrome/devtools-device-data.git","ssh_url":"git@github.com:GoogleChrome/devtools-device-data.git","clone_url":"https://github.com/GoogleChrome/devtools-device-data.git","svn_url":"https://github.com/GoogleChrome/devtools-device-data","homepage":null,"size":509,"stargazers_count":19,"watchers_count":19,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":6,"forks":6,"open_issues":6,"watchers":19,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleChrome/devtools-device-data/pulls/11"},"html":{"href":"https://github.com/GoogleChrome/devtools-device-data/pull/11"},"issue":{"href":"https://api.github.com/repos/GoogleChrome/devtools-device-data/issues/11"},"comments":{"href":"https://api.github.com/repos/GoogleChrome/devtools-device-data/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleChrome/devtools-device-data/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleChrome/devtools-device-data/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/GoogleChrome/devtools-device-data/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleChrome/devtools-device-data/statuses/def3713b391e0681a4b515e5e113e915a3497681"}}}}