{"action":"created","comment":{"url":"https://api.github.com/repos/trigger/trigger/pulls/comments/51069646","id":51069646,"diff_hunk":"@@ -916,32 +916,15 @@ def match(self, **kwargs):\n \n             :returns: List of NetDevice objects\n             \"\"\"\n-            # Only build the lower-to-regular mapping once per instance and\n-            # only on the first time .match() is called.\n-            if not hasattr(self, '_device_key_map'):\n-                mydev = self.all()[0]\n-                dev_data = vars(mydev)\n-                key_map = {}\n-                for key in dev_data:\n-                    key_map[key.lower()] = key\n-\n-                self._device_key_map = key_map\n-\n-            def attr(key):\n-                \"\"\"Helper function for the lowercase to regular attribute mapping.\"\"\"\n-                return self._device_key_map[key]\n-\n             # Here we build a list comprehension and then eval it at the end.\n             query_prefix = \"[dev for dev in self.all() if \"\n             query_suffix = \"]\"\n-            template = \"'%s'.lower() in getattr(dev, attr('%s')).lower()\"\n-            list_body = ' and '.join(template % (v,k.lower()) for k,v in kwargs.iteritems())\n+            template = \"%r.lower() in getattr(dev, %r, '').lower()\"\n+            list_body = ' and '.join(\n+                template % (v, k.lower()) for k, v in kwargs.iteritems()\n+            )\n             list_comp = query_prefix + list_body + query_suffix\n \n-            # This was for the case-sensitive version\n-            #template = \"'%s' in dev.%s\"\n-            #list_body = ' and '.join(template % (v,k) for k,v in kwargs.iteritems())\n-\n             return eval(list_comp)","path":"trigger/netdevices/__init__.py","position":34,"original_position":34,"commit_id":"3b2f317ec45c8a7f39c0ca73a271d1ee4cc3785a","original_commit_id":"3b2f317ec45c8a7f39c0ca73a271d1ee4cc3785a","user":{"login":"coxley","id":8285973,"avatar_url":"https://avatars.githubusercontent.com/u/8285973?v=3","gravatar_id":"","url":"https://api.github.com/users/coxley","html_url":"https://github.com/coxley","followers_url":"https://api.github.com/users/coxley/followers","following_url":"https://api.github.com/users/coxley/following{/other_user}","gists_url":"https://api.github.com/users/coxley/gists{/gist_id}","starred_url":"https://api.github.com/users/coxley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coxley/subscriptions","organizations_url":"https://api.github.com/users/coxley/orgs","repos_url":"https://api.github.com/users/coxley/repos","events_url":"https://api.github.com/users/coxley/events{/privacy}","received_events_url":"https://api.github.com/users/coxley/received_events","type":"User","site_admin":false},"body":"v2.0 will definitely do this a better way","created_at":"2016-01-27T23:46:48Z","updated_at":"2016-01-27T23:46:48Z","html_url":"https://github.com/trigger/trigger/pull/242#discussion_r51069646","pull_request_url":"https://api.github.com/repos/trigger/trigger/pulls/242","_links":{"self":{"href":"https://api.github.com/repos/trigger/trigger/pulls/comments/51069646"},"html":{"href":"https://github.com/trigger/trigger/pull/242#discussion_r51069646"},"pull_request":{"href":"https://api.github.com/repos/trigger/trigger/pulls/242"}}},"pull_request":{"url":"https://api.github.com/repos/trigger/trigger/pulls/242","id":57440785,"html_url":"https://github.com/trigger/trigger/pull/242","diff_url":"https://github.com/trigger/trigger/pull/242.diff","patch_url":"https://github.com/trigger/trigger/pull/242.patch","issue_url":"https://api.github.com/repos/trigger/trigger/issues/242","number":242,"state":"closed","locked":false,"title":"NetDevices.match() now quietly skips devices without matching attrs.","user":{"login":"jathanism","id":138052,"avatar_url":"https://avatars.githubusercontent.com/u/138052?v=3","gravatar_id":"","url":"https://api.github.com/users/jathanism","html_url":"https://github.com/jathanism","followers_url":"https://api.github.com/users/jathanism/followers","following_url":"https://api.github.com/users/jathanism/following{/other_user}","gists_url":"https://api.github.com/users/jathanism/gists{/gist_id}","starred_url":"https://api.github.com/users/jathanism/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jathanism/subscriptions","organizations_url":"https://api.github.com/users/jathanism/orgs","repos_url":"https://api.github.com/users/jathanism/repos","events_url":"https://api.github.com/users/jathanism/events{/privacy}","received_events_url":"https://api.github.com/users/jathanism/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-01-27T23:31:45Z","updated_at":"2016-01-27T23:46:48Z","closed_at":"2016-01-27T23:44:50Z","merged_at":"2016-01-27T23:44:50Z","merge_commit_sha":"c6eabde85bc904528118a6ea5f7824a3d717d36a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/trigger/trigger/pulls/242/commits","review_comments_url":"https://api.github.com/repos/trigger/trigger/pulls/242/comments","review_comment_url":"https://api.github.com/repos/trigger/trigger/pulls/comments{/number}","comments_url":"https://api.github.com/repos/trigger/trigger/issues/242/comments","statuses_url":"https://api.github.com/repos/trigger/trigger/statuses/3b2f317ec45c8a7f39c0ca73a271d1ee4cc3785a","head":{"label":"jathanism:netdevices-match-fix","ref":"netdevices-match-fix","sha":"3b2f317ec45c8a7f39c0ca73a271d1ee4cc3785a","user":{"login":"jathanism","id":138052,"avatar_url":"https://avatars.githubusercontent.com/u/138052?v=3","gravatar_id":"","url":"https://api.github.com/users/jathanism","html_url":"https://github.com/jathanism","followers_url":"https://api.github.com/users/jathanism/followers","following_url":"https://api.github.com/users/jathanism/following{/other_user}","gists_url":"https://api.github.com/users/jathanism/gists{/gist_id}","starred_url":"https://api.github.com/users/jathanism/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jathanism/subscriptions","organizations_url":"https://api.github.com/users/jathanism/orgs","repos_url":"https://api.github.com/users/jathanism/repos","events_url":"https://api.github.com/users/jathanism/events{/privacy}","received_events_url":"https://api.github.com/users/jathanism/received_events","type":"User","site_admin":false},"repo":{"id":6357414,"name":"trigger","full_name":"jathanism/trigger","owner":{"login":"jathanism","id":138052,"avatar_url":"https://avatars.githubusercontent.com/u/138052?v=3","gravatar_id":"","url":"https://api.github.com/users/jathanism","html_url":"https://github.com/jathanism","followers_url":"https://api.github.com/users/jathanism/followers","following_url":"https://api.github.com/users/jathanism/following{/other_user}","gists_url":"https://api.github.com/users/jathanism/gists{/gist_id}","starred_url":"https://api.github.com/users/jathanism/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jathanism/subscriptions","organizations_url":"https://api.github.com/users/jathanism/orgs","repos_url":"https://api.github.com/users/jathanism/repos","events_url":"https://api.github.com/users/jathanism/events{/privacy}","received_events_url":"https://api.github.com/users/jathanism/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jathanism/trigger","description":"Trigger is a robust network engineering toolkit written in Python designed for interfacing with network devices and managing network configuration and security policy. ","fork":true,"url":"https://api.github.com/repos/jathanism/trigger","forks_url":"https://api.github.com/repos/jathanism/trigger/forks","keys_url":"https://api.github.com/repos/jathanism/trigger/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jathanism/trigger/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jathanism/trigger/teams","hooks_url":"https://api.github.com/repos/jathanism/trigger/hooks","issue_events_url":"https://api.github.com/repos/jathanism/trigger/issues/events{/number}","events_url":"https://api.github.com/repos/jathanism/trigger/events","assignees_url":"https://api.github.com/repos/jathanism/trigger/assignees{/user}","branches_url":"https://api.github.com/repos/jathanism/trigger/branches{/branch}","tags_url":"https://api.github.com/repos/jathanism/trigger/tags","blobs_url":"https://api.github.com/repos/jathanism/trigger/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jathanism/trigger/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jathanism/trigger/git/refs{/sha}","trees_url":"https://api.github.com/repos/jathanism/trigger/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jathanism/trigger/statuses/{sha}","languages_url":"https://api.github.com/repos/jathanism/trigger/languages","stargazers_url":"https://api.github.com/repos/jathanism/trigger/stargazers","contributors_url":"https://api.github.com/repos/jathanism/trigger/contributors","subscribers_url":"https://api.github.com/repos/jathanism/trigger/subscribers","subscription_url":"https://api.github.com/repos/jathanism/trigger/subscription","commits_url":"https://api.github.com/repos/jathanism/trigger/commits{/sha}","git_commits_url":"https://api.github.com/repos/jathanism/trigger/git/commits{/sha}","comments_url":"https://api.github.com/repos/jathanism/trigger/comments{/number}","issue_comment_url":"https://api.github.com/repos/jathanism/trigger/issues/comments{/number}","contents_url":"https://api.github.com/repos/jathanism/trigger/contents/{+path}","compare_url":"https://api.github.com/repos/jathanism/trigger/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jathanism/trigger/merges","archive_url":"https://api.github.com/repos/jathanism/trigger/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jathanism/trigger/downloads","issues_url":"https://api.github.com/repos/jathanism/trigger/issues{/number}","pulls_url":"https://api.github.com/repos/jathanism/trigger/pulls{/number}","milestones_url":"https://api.github.com/repos/jathanism/trigger/milestones{/number}","notifications_url":"https://api.github.com/repos/jathanism/trigger/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jathanism/trigger/labels{/name}","releases_url":"https://api.github.com/repos/jathanism/trigger/releases{/id}","deployments_url":"https://api.github.com/repos/jathanism/trigger/deployments","created_at":"2012-10-23T18:13:41Z","updated_at":"2015-11-26T07:37:06Z","pushed_at":"2016-01-27T23:45:26Z","git_url":"git://github.com/jathanism/trigger.git","ssh_url":"git@github.com:jathanism/trigger.git","clone_url":"https://github.com/jathanism/trigger.git","svn_url":"https://github.com/jathanism/trigger","homepage":"trigger.rtfd.org","size":1476,"stargazers_count":1,"watchers_count":1,"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":1,"default_branch":"develop"}},"base":{"label":"trigger:develop","ref":"develop","sha":"9133b877d3d1c2036e35d358af702fac9a7c9404","user":{"login":"trigger","id":3708702,"avatar_url":"https://avatars.githubusercontent.com/u/3708702?v=3","gravatar_id":"","url":"https://api.github.com/users/trigger","html_url":"https://github.com/trigger","followers_url":"https://api.github.com/users/trigger/followers","following_url":"https://api.github.com/users/trigger/following{/other_user}","gists_url":"https://api.github.com/users/trigger/gists{/gist_id}","starred_url":"https://api.github.com/users/trigger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trigger/subscriptions","organizations_url":"https://api.github.com/users/trigger/orgs","repos_url":"https://api.github.com/users/trigger/repos","events_url":"https://api.github.com/users/trigger/events{/privacy}","received_events_url":"https://api.github.com/users/trigger/received_events","type":"Organization","site_admin":false},"repo":{"id":3575995,"name":"trigger","full_name":"trigger/trigger","owner":{"login":"trigger","id":3708702,"avatar_url":"https://avatars.githubusercontent.com/u/3708702?v=3","gravatar_id":"","url":"https://api.github.com/users/trigger","html_url":"https://github.com/trigger","followers_url":"https://api.github.com/users/trigger/followers","following_url":"https://api.github.com/users/trigger/following{/other_user}","gists_url":"https://api.github.com/users/trigger/gists{/gist_id}","starred_url":"https://api.github.com/users/trigger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trigger/subscriptions","organizations_url":"https://api.github.com/users/trigger/orgs","repos_url":"https://api.github.com/users/trigger/repos","events_url":"https://api.github.com/users/trigger/events{/privacy}","received_events_url":"https://api.github.com/users/trigger/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/trigger/trigger","description":"Trigger is a robust network automation toolkit written in Python that was designed for interfacing with network devices.","fork":false,"url":"https://api.github.com/repos/trigger/trigger","forks_url":"https://api.github.com/repos/trigger/trigger/forks","keys_url":"https://api.github.com/repos/trigger/trigger/keys{/key_id}","collaborators_url":"https://api.github.com/repos/trigger/trigger/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/trigger/trigger/teams","hooks_url":"https://api.github.com/repos/trigger/trigger/hooks","issue_events_url":"https://api.github.com/repos/trigger/trigger/issues/events{/number}","events_url":"https://api.github.com/repos/trigger/trigger/events","assignees_url":"https://api.github.com/repos/trigger/trigger/assignees{/user}","branches_url":"https://api.github.com/repos/trigger/trigger/branches{/branch}","tags_url":"https://api.github.com/repos/trigger/trigger/tags","blobs_url":"https://api.github.com/repos/trigger/trigger/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/trigger/trigger/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/trigger/trigger/git/refs{/sha}","trees_url":"https://api.github.com/repos/trigger/trigger/git/trees{/sha}","statuses_url":"https://api.github.com/repos/trigger/trigger/statuses/{sha}","languages_url":"https://api.github.com/repos/trigger/trigger/languages","stargazers_url":"https://api.github.com/repos/trigger/trigger/stargazers","contributors_url":"https://api.github.com/repos/trigger/trigger/contributors","subscribers_url":"https://api.github.com/repos/trigger/trigger/subscribers","subscription_url":"https://api.github.com/repos/trigger/trigger/subscription","commits_url":"https://api.github.com/repos/trigger/trigger/commits{/sha}","git_commits_url":"https://api.github.com/repos/trigger/trigger/git/commits{/sha}","comments_url":"https://api.github.com/repos/trigger/trigger/comments{/number}","issue_comment_url":"https://api.github.com/repos/trigger/trigger/issues/comments{/number}","contents_url":"https://api.github.com/repos/trigger/trigger/contents/{+path}","compare_url":"https://api.github.com/repos/trigger/trigger/compare/{base}...{head}","merges_url":"https://api.github.com/repos/trigger/trigger/merges","archive_url":"https://api.github.com/repos/trigger/trigger/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/trigger/trigger/downloads","issues_url":"https://api.github.com/repos/trigger/trigger/issues{/number}","pulls_url":"https://api.github.com/repos/trigger/trigger/pulls{/number}","milestones_url":"https://api.github.com/repos/trigger/trigger/milestones{/number}","notifications_url":"https://api.github.com/repos/trigger/trigger/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/trigger/trigger/labels{/name}","releases_url":"https://api.github.com/repos/trigger/trigger/releases{/id}","deployments_url":"https://api.github.com/repos/trigger/trigger/deployments","created_at":"2012-02-28T21:57:00Z","updated_at":"2016-01-24T19:12:40Z","pushed_at":"2016-01-27T23:44:50Z","git_url":"git://github.com/trigger/trigger.git","ssh_url":"git@github.com:trigger/trigger.git","clone_url":"https://github.com/trigger/trigger.git","svn_url":"https://github.com/trigger/trigger","homepage":"trigger.readthedocs.org","size":1476,"stargazers_count":278,"watchers_count":278,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":60,"mirror_url":null,"open_issues_count":70,"forks":60,"open_issues":70,"watchers":278,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/trigger/trigger/pulls/242"},"html":{"href":"https://github.com/trigger/trigger/pull/242"},"issue":{"href":"https://api.github.com/repos/trigger/trigger/issues/242"},"comments":{"href":"https://api.github.com/repos/trigger/trigger/issues/242/comments"},"review_comments":{"href":"https://api.github.com/repos/trigger/trigger/pulls/242/comments"},"review_comment":{"href":"https://api.github.com/repos/trigger/trigger/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/trigger/trigger/pulls/242/commits"},"statuses":{"href":"https://api.github.com/repos/trigger/trigger/statuses/3b2f317ec45c8a7f39c0ca73a271d1ee4cc3785a"}}}}