{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/fjord/pulls/comments/37585868","id":37585868,"diff_hunk":"@@ -0,0 +1,253 @@\n+import re\n+\n+from django.db import models\n+from django.utils.lru_cache import lru_cache\n+\n+from product_details import product_details\n+\n+from fjord.base.models import ModelBase\n+from fjord.feedback.models import Product\n+\n+\n+def _lang_native(locale):\n+    \"\"\"Look up locale code for native word\n+\n+    Note: This is case-sensitive. e.g. \"en-US\" matches English, but\n+    \"en-us\" matches nothing.\n+\n+    :arg locale: locale string\n+\n+    :returns: language native name for that locale\n+    \"\"\"\n+    try:\n+        return product_details.languages[locale]['native']\n+    except KeyError:\n+        return locale\n+\n+\n+class TriggerRuleManager(models.Manager):\n+    def all_enabled(self):\n+        return self.filter(is_enabled=True).order_by('sortorder')\n+\n+\n+@lru_cache()\n+def _generate_keywords_regex(keywords):\n+    \"\"\"Generates a Regex object to compare with\n+\n+    * splits keywords into parts\n+    * for each part\n+      * converts to unicode\n+      * converts white space to '\\s+'\n+    * joins the parts to create a middle\n+    * joins that with empty string bounds\n+    * compiles it into a Regex and returns it\n+\n+    :arg keywords: list of words and phrases to match\n+\n+    :returns: regex object\n+    \"\"\"\n+    assert isinstance(keywords, unicode)\n+\n+    def _escape(utext):","path":"fjord/suggest/providers/trigger/models.py","position":51,"original_position":51,"commit_id":"59eb88dbf49ff4ef1210214cd7fc927f3c1c0ac9","original_commit_id":"59eb88dbf49ff4ef1210214cd7fc927f3c1c0ac9","user":{"login":"willkg","id":820826,"avatar_url":"https://avatars.githubusercontent.com/u/820826?v=3","gravatar_id":"","url":"https://api.github.com/users/willkg","html_url":"https://github.com/willkg","followers_url":"https://api.github.com/users/willkg/followers","following_url":"https://api.github.com/users/willkg/following{/other_user}","gists_url":"https://api.github.com/users/willkg/gists{/gist_id}","starred_url":"https://api.github.com/users/willkg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/willkg/subscriptions","organizations_url":"https://api.github.com/users/willkg/orgs","repos_url":"https://api.github.com/users/willkg/repos","events_url":"https://api.github.com/users/willkg/events{/privacy}","received_events_url":"https://api.github.com/users/willkg/received_events","type":"User","site_admin":false},"body":"Actually, `re.escape` doesn't do what I want. It escapes everything that's not an ascii alphanumeric character which makes a mess of things because I want to do different things with spaces and it doesn't work well with utf-8.\r\n\r\nThis probably isn't perfect, but it covers all the characters I suspect someone writing a trigger rule would need covered.","created_at":"2015-08-20T21:55:26Z","updated_at":"2015-08-20T21:55:26Z","html_url":"https://github.com/mozilla/fjord/pull/643#discussion_r37585868","pull_request_url":"https://api.github.com/repos/mozilla/fjord/pulls/643","_links":{"self":{"href":"https://api.github.com/repos/mozilla/fjord/pulls/comments/37585868"},"html":{"href":"https://github.com/mozilla/fjord/pull/643#discussion_r37585868"},"pull_request":{"href":"https://api.github.com/repos/mozilla/fjord/pulls/643"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/fjord/pulls/643","id":42973723,"html_url":"https://github.com/mozilla/fjord/pull/643","diff_url":"https://github.com/mozilla/fjord/pull/643.diff","patch_url":"https://github.com/mozilla/fjord/pull/643.patch","issue_url":"https://api.github.com/repos/mozilla/fjord/issues/643","number":643,"state":"open","locked":false,"title":"[bug 1175123] Initial implementation of Trigger suggester","user":{"login":"willkg","id":820826,"avatar_url":"https://avatars.githubusercontent.com/u/820826?v=3","gravatar_id":"","url":"https://api.github.com/users/willkg","html_url":"https://github.com/willkg","followers_url":"https://api.github.com/users/willkg/followers","following_url":"https://api.github.com/users/willkg/following{/other_user}","gists_url":"https://api.github.com/users/willkg/gists{/gist_id}","starred_url":"https://api.github.com/users/willkg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/willkg/subscriptions","organizations_url":"https://api.github.com/users/willkg/orgs","repos_url":"https://api.github.com/users/willkg/repos","events_url":"https://api.github.com/users/willkg/events{/privacy}","received_events_url":"https://api.github.com/users/willkg/received_events","type":"User","site_admin":false},"body":"Implements the Trigger suggester which allows analyzers to set up\r\ntrigger rules for adding suggestions to feedback that match those rules.\r\n\r\nr?","created_at":"2015-08-20T20:22:00Z","updated_at":"2015-08-20T21:55:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7d456328377e8305ee695d72ced83476fceafd41","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/fjord/pulls/643/commits","review_comments_url":"https://api.github.com/repos/mozilla/fjord/pulls/643/comments","review_comment_url":"https://api.github.com/repos/mozilla/fjord/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/fjord/issues/643/comments","statuses_url":"https://api.github.com/repos/mozilla/fjord/statuses/59eb88dbf49ff4ef1210214cd7fc927f3c1c0ac9","head":{"label":"willkg:1175123-trigger","ref":"1175123-trigger","sha":"59eb88dbf49ff4ef1210214cd7fc927f3c1c0ac9","user":{"login":"willkg","id":820826,"avatar_url":"https://avatars.githubusercontent.com/u/820826?v=3","gravatar_id":"","url":"https://api.github.com/users/willkg","html_url":"https://github.com/willkg","followers_url":"https://api.github.com/users/willkg/followers","following_url":"https://api.github.com/users/willkg/following{/other_user}","gists_url":"https://api.github.com/users/willkg/gists{/gist_id}","starred_url":"https://api.github.com/users/willkg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/willkg/subscriptions","organizations_url":"https://api.github.com/users/willkg/orgs","repos_url":"https://api.github.com/users/willkg/repos","events_url":"https://api.github.com/users/willkg/events{/privacy}","received_events_url":"https://api.github.com/users/willkg/received_events","type":"User","site_admin":false},"repo":{"id":5204498,"name":"fjord","full_name":"willkg/fjord","owner":{"login":"willkg","id":820826,"avatar_url":"https://avatars.githubusercontent.com/u/820826?v=3","gravatar_id":"","url":"https://api.github.com/users/willkg","html_url":"https://github.com/willkg","followers_url":"https://api.github.com/users/willkg/followers","following_url":"https://api.github.com/users/willkg/following{/other_user}","gists_url":"https://api.github.com/users/willkg/gists{/gist_id}","starred_url":"https://api.github.com/users/willkg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/willkg/subscriptions","organizations_url":"https://api.github.com/users/willkg/orgs","repos_url":"https://api.github.com/users/willkg/repos","events_url":"https://api.github.com/users/willkg/events{/privacy}","received_events_url":"https://api.github.com/users/willkg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/willkg/fjord","description":"Software that runs the new input.mozilla.org","fork":true,"url":"https://api.github.com/repos/willkg/fjord","forks_url":"https://api.github.com/repos/willkg/fjord/forks","keys_url":"https://api.github.com/repos/willkg/fjord/keys{/key_id}","collaborators_url":"https://api.github.com/repos/willkg/fjord/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/willkg/fjord/teams","hooks_url":"https://api.github.com/repos/willkg/fjord/hooks","issue_events_url":"https://api.github.com/repos/willkg/fjord/issues/events{/number}","events_url":"https://api.github.com/repos/willkg/fjord/events","assignees_url":"https://api.github.com/repos/willkg/fjord/assignees{/user}","branches_url":"https://api.github.com/repos/willkg/fjord/branches{/branch}","tags_url":"https://api.github.com/repos/willkg/fjord/tags","blobs_url":"https://api.github.com/repos/willkg/fjord/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/willkg/fjord/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/willkg/fjord/git/refs{/sha}","trees_url":"https://api.github.com/repos/willkg/fjord/git/trees{/sha}","statuses_url":"https://api.github.com/repos/willkg/fjord/statuses/{sha}","languages_url":"https://api.github.com/repos/willkg/fjord/languages","stargazers_url":"https://api.github.com/repos/willkg/fjord/stargazers","contributors_url":"https://api.github.com/repos/willkg/fjord/contributors","subscribers_url":"https://api.github.com/repos/willkg/fjord/subscribers","subscription_url":"https://api.github.com/repos/willkg/fjord/subscription","commits_url":"https://api.github.com/repos/willkg/fjord/commits{/sha}","git_commits_url":"https://api.github.com/repos/willkg/fjord/git/commits{/sha}","comments_url":"https://api.github.com/repos/willkg/fjord/comments{/number}","issue_comment_url":"https://api.github.com/repos/willkg/fjord/issues/comments{/number}","contents_url":"https://api.github.com/repos/willkg/fjord/contents/{+path}","compare_url":"https://api.github.com/repos/willkg/fjord/compare/{base}...{head}","merges_url":"https://api.github.com/repos/willkg/fjord/merges","archive_url":"https://api.github.com/repos/willkg/fjord/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/willkg/fjord/downloads","issues_url":"https://api.github.com/repos/willkg/fjord/issues{/number}","pulls_url":"https://api.github.com/repos/willkg/fjord/pulls{/number}","milestones_url":"https://api.github.com/repos/willkg/fjord/milestones{/number}","notifications_url":"https://api.github.com/repos/willkg/fjord/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/willkg/fjord/labels{/name}","releases_url":"https://api.github.com/repos/willkg/fjord/releases{/id}","created_at":"2012-07-27T12:53:19Z","updated_at":"2015-04-27T14:46:28Z","pushed_at":"2015-08-20T20:21:46Z","git_url":"git://github.com/willkg/fjord.git","ssh_url":"git@github.com:willkg/fjord.git","clone_url":"https://github.com/willkg/fjord.git","svn_url":"https://github.com/willkg/fjord","homepage":null,"size":70705,"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":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"d6482c97e7494b35fad0a2f6639fb7136a61431c","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":5197539,"name":"fjord","full_name":"mozilla/fjord","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/fjord","description":"Software that runs the new input.mozilla.org","fork":false,"url":"https://api.github.com/repos/mozilla/fjord","forks_url":"https://api.github.com/repos/mozilla/fjord/forks","keys_url":"https://api.github.com/repos/mozilla/fjord/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/fjord/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/fjord/teams","hooks_url":"https://api.github.com/repos/mozilla/fjord/hooks","issue_events_url":"https://api.github.com/repos/mozilla/fjord/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/fjord/events","assignees_url":"https://api.github.com/repos/mozilla/fjord/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/fjord/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/fjord/tags","blobs_url":"https://api.github.com/repos/mozilla/fjord/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/fjord/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/fjord/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/fjord/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/fjord/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/fjord/languages","stargazers_url":"https://api.github.com/repos/mozilla/fjord/stargazers","contributors_url":"https://api.github.com/repos/mozilla/fjord/contributors","subscribers_url":"https://api.github.com/repos/mozilla/fjord/subscribers","subscription_url":"https://api.github.com/repos/mozilla/fjord/subscription","commits_url":"https://api.github.com/repos/mozilla/fjord/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/fjord/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/fjord/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/fjord/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/fjord/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/fjord/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/fjord/merges","archive_url":"https://api.github.com/repos/mozilla/fjord/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/fjord/downloads","issues_url":"https://api.github.com/repos/mozilla/fjord/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/fjord/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/fjord/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/fjord/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/fjord/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/fjord/releases{/id}","created_at":"2012-07-26T21:25:00Z","updated_at":"2015-08-11T18:19:44Z","pushed_at":"2015-08-20T20:22:01Z","git_url":"git://github.com/mozilla/fjord.git","ssh_url":"git@github.com:mozilla/fjord.git","clone_url":"https://github.com/mozilla/fjord.git","svn_url":"https://github.com/mozilla/fjord","homepage":null,"size":74931,"stargazers_count":20,"watchers_count":20,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":40,"mirror_url":null,"open_issues_count":1,"forks":40,"open_issues":1,"watchers":20,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/fjord/pulls/643"},"html":{"href":"https://github.com/mozilla/fjord/pull/643"},"issue":{"href":"https://api.github.com/repos/mozilla/fjord/issues/643"},"comments":{"href":"https://api.github.com/repos/mozilla/fjord/issues/643/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/fjord/pulls/643/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/fjord/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/fjord/pulls/643/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/fjord/statuses/59eb88dbf49ff4ef1210214cd7fc927f3c1c0ac9"}}}}