{"action":"created","comment":{"url":"https://api.github.com/repos/ralphbean/bugwarrior/pulls/comments/72067940","id":72067940,"diff_hunk":"@@ -0,0 +1,175 @@\n+import debianbts\n+import requests\n+\n+from bugwarrior.config import die, asbool\n+from bugwarrior.services import Issue, IssueService, ServiceClient\n+\n+import logging\n+log = logging.getLogger(__name__)\n+\n+UDD_BUGS_SEARCH = \"https://udd.debian.org/bugs/\"\n+\n+class BTSIssue(Issue):\n+    SUBJECT = 'btssubject'\n+    URL = 'btsurl'\n+    NUMBER = 'btsnumber'\n+    PACKAGE = 'btspackage'\n+    SOURCE = 'btssource'\n+    FORWARDED = 'btsforwarded'\n+\n+    UDAS = {\n+        SUBJECT: {\n+            'type': 'string',\n+            'label': 'Debian BTS Subject',\n+        },\n+        URL: {\n+            'type': 'string',\n+            'label': 'Debian BTS URL',\n+        },\n+        NUMBER: {\n+            'type': 'numeric',\n+            'label': 'Debian BTS Number',\n+        },\n+        PACKAGE: {\n+            'type': 'string',\n+            'label': 'Debian BTS Package',\n+        },\n+        SOURCE: {\n+            'type': 'string',\n+            'label': 'Debian BTS Source Package',\n+        },\n+        FORWARDED: {\n+            'type': 'string',\n+            'label': 'Debian BTS Forwarded URL',\n+        },\n+    }\n+    UNIQUE_KEY = (URL, )\n+\n+    PRIORITY_MAP = {\n+        'wishlist': 'L',\n+        'minor': 'L',\n+        'normal': 'M',\n+        'important': 'M',\n+        'serious': 'H',\n+        'grave': 'H',\n+        'critical': 'H',\n+    }\n+\n+    def to_taskwarrior(self):\n+        return {\n+            'priority': self.get_priority(),\n+\n+            self.URL: self.record['url'],\n+            self.SUBJECT: self.record['subject'],\n+            self.NUMBER: self.record['number'],\n+            self.PACKAGE: self.record['package'],\n+            self.SOURCE: self.record['source'],\n+            self.FORWARDED: self.record['forwarded'],\n+        }\n+\n+    def get_default_description(self):\n+\n+        return self.build_default_description(\n+            title=self.record['subject'],\n+            url=self.get_processed_url(self.record['url']),\n+            number=self.record['number'],\n+            cls='issue'\n+        )\n+\n+    def get_priority(self):\n+        return self.PRIORITY_MAP.get(\n+            self.record.get('severity'),\n+            self.origin['default_priority']\n+        )\n+\n+\n+class BTSService(IssueService, ServiceClient):\n+    ISSUE_CLASS = BTSIssue\n+    CONFIG_PREFIX = 'bts'\n+\n+    def __init__(self, *args, **kw):\n+        super(BTSService, self).__init__(*args, **kw)\n+        self.bts = debianbts","path":"bugwarrior/services/bts.py","position":92,"original_position":92,"commit_id":"7ab439cdc973d4e7566007c5f7ef1c06be4af172","original_commit_id":"7ab439cdc973d4e7566007c5f7ef1c06be4af172","user":{"login":"irl","id":1208651,"avatar_url":"https://avatars.githubusercontent.com/u/1208651?v=3","gravatar_id":"","url":"https://api.github.com/users/irl","html_url":"https://github.com/irl","followers_url":"https://api.github.com/users/irl/followers","following_url":"https://api.github.com/users/irl/following{/other_user}","gists_url":"https://api.github.com/users/irl/gists{/gist_id}","starred_url":"https://api.github.com/users/irl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/irl/subscriptions","organizations_url":"https://api.github.com/users/irl/orgs","repos_url":"https://api.github.com/users/irl/repos","events_url":"https://api.github.com/users/irl/events{/privacy}","received_events_url":"https://api.github.com/users/irl/received_events","type":"User","site_admin":false},"body":"```\r\ndef get_mock_service(self, *args, **kwargs):\r\n    bts.debianbts = FakeBTSLib()\r\n    service = super(TestBTSService, self).get_mock_service(\r\n        *args, **kwargs)\r\n    return service\r\n```\r\n\r\nHow about this? Replacing it in the scope of the service module but not having the service as an attribute of the service class.","created_at":"2016-07-25T14:00:12Z","updated_at":"2016-07-25T14:00:12Z","html_url":"https://github.com/ralphbean/bugwarrior/pull/348#discussion_r72067940","pull_request_url":"https://api.github.com/repos/ralphbean/bugwarrior/pulls/348","_links":{"self":{"href":"https://api.github.com/repos/ralphbean/bugwarrior/pulls/comments/72067940"},"html":{"href":"https://github.com/ralphbean/bugwarrior/pull/348#discussion_r72067940"},"pull_request":{"href":"https://api.github.com/repos/ralphbean/bugwarrior/pulls/348"}}},"pull_request":{"url":"https://api.github.com/repos/ralphbean/bugwarrior/pulls/348","id":76530575,"html_url":"https://github.com/ralphbean/bugwarrior/pull/348","diff_url":"https://github.com/ralphbean/bugwarrior/pull/348.diff","patch_url":"https://github.com/ralphbean/bugwarrior/pull/348.patch","issue_url":"https://api.github.com/repos/ralphbean/bugwarrior/issues/348","number":348,"state":"open","locked":false,"title":"[WIP] Debian BTS support","user":{"login":"irl","id":1208651,"avatar_url":"https://avatars.githubusercontent.com/u/1208651?v=3","gravatar_id":"","url":"https://api.github.com/users/irl","html_url":"https://github.com/irl","followers_url":"https://api.github.com/users/irl/followers","following_url":"https://api.github.com/users/irl/following{/other_user}","gists_url":"https://api.github.com/users/irl/gists{/gist_id}","starred_url":"https://api.github.com/users/irl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/irl/subscriptions","organizations_url":"https://api.github.com/users/irl/orgs","repos_url":"https://api.github.com/users/irl/repos","events_url":"https://api.github.com/users/irl/events{/privacy}","received_events_url":"https://api.github.com/users/irl/received_events","type":"User","site_admin":false},"body":"This pull request adds a service ```bts``` for the Debian Bug Tracking System (BTS) that is used to track bugs on packages distributed as part of the Debian Operating System.\r\n\r\nThis pull request closes #327.","created_at":"2016-07-07T02:22:26Z","updated_at":"2016-07-25T14:00:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"66f6f04554669eeb1a9793637987dc0d3e713cb3","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/ralphbean/bugwarrior/pulls/348/commits","review_comments_url":"https://api.github.com/repos/ralphbean/bugwarrior/pulls/348/comments","review_comment_url":"https://api.github.com/repos/ralphbean/bugwarrior/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ralphbean/bugwarrior/issues/348/comments","statuses_url":"https://api.github.com/repos/ralphbean/bugwarrior/statuses/7ab439cdc973d4e7566007c5f7ef1c06be4af172","head":{"label":"irl:feature/debianbts","ref":"feature/debianbts","sha":"7ab439cdc973d4e7566007c5f7ef1c06be4af172","user":{"login":"irl","id":1208651,"avatar_url":"https://avatars.githubusercontent.com/u/1208651?v=3","gravatar_id":"","url":"https://api.github.com/users/irl","html_url":"https://github.com/irl","followers_url":"https://api.github.com/users/irl/followers","following_url":"https://api.github.com/users/irl/following{/other_user}","gists_url":"https://api.github.com/users/irl/gists{/gist_id}","starred_url":"https://api.github.com/users/irl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/irl/subscriptions","organizations_url":"https://api.github.com/users/irl/orgs","repos_url":"https://api.github.com/users/irl/repos","events_url":"https://api.github.com/users/irl/events{/privacy}","received_events_url":"https://api.github.com/users/irl/received_events","type":"User","site_admin":false},"repo":{"id":56629763,"name":"bugwarrior","full_name":"irl/bugwarrior","owner":{"login":"irl","id":1208651,"avatar_url":"https://avatars.githubusercontent.com/u/1208651?v=3","gravatar_id":"","url":"https://api.github.com/users/irl","html_url":"https://github.com/irl","followers_url":"https://api.github.com/users/irl/followers","following_url":"https://api.github.com/users/irl/following{/other_user}","gists_url":"https://api.github.com/users/irl/gists{/gist_id}","starred_url":"https://api.github.com/users/irl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/irl/subscriptions","organizations_url":"https://api.github.com/users/irl/orgs","repos_url":"https://api.github.com/users/irl/repos","events_url":"https://api.github.com/users/irl/events{/privacy}","received_events_url":"https://api.github.com/users/irl/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/irl/bugwarrior","description":"Pull github, bitbucket, and trac issues into taskwarrior","fork":true,"url":"https://api.github.com/repos/irl/bugwarrior","forks_url":"https://api.github.com/repos/irl/bugwarrior/forks","keys_url":"https://api.github.com/repos/irl/bugwarrior/keys{/key_id}","collaborators_url":"https://api.github.com/repos/irl/bugwarrior/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/irl/bugwarrior/teams","hooks_url":"https://api.github.com/repos/irl/bugwarrior/hooks","issue_events_url":"https://api.github.com/repos/irl/bugwarrior/issues/events{/number}","events_url":"https://api.github.com/repos/irl/bugwarrior/events","assignees_url":"https://api.github.com/repos/irl/bugwarrior/assignees{/user}","branches_url":"https://api.github.com/repos/irl/bugwarrior/branches{/branch}","tags_url":"https://api.github.com/repos/irl/bugwarrior/tags","blobs_url":"https://api.github.com/repos/irl/bugwarrior/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/irl/bugwarrior/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/irl/bugwarrior/git/refs{/sha}","trees_url":"https://api.github.com/repos/irl/bugwarrior/git/trees{/sha}","statuses_url":"https://api.github.com/repos/irl/bugwarrior/statuses/{sha}","languages_url":"https://api.github.com/repos/irl/bugwarrior/languages","stargazers_url":"https://api.github.com/repos/irl/bugwarrior/stargazers","contributors_url":"https://api.github.com/repos/irl/bugwarrior/contributors","subscribers_url":"https://api.github.com/repos/irl/bugwarrior/subscribers","subscription_url":"https://api.github.com/repos/irl/bugwarrior/subscription","commits_url":"https://api.github.com/repos/irl/bugwarrior/commits{/sha}","git_commits_url":"https://api.github.com/repos/irl/bugwarrior/git/commits{/sha}","comments_url":"https://api.github.com/repos/irl/bugwarrior/comments{/number}","issue_comment_url":"https://api.github.com/repos/irl/bugwarrior/issues/comments{/number}","contents_url":"https://api.github.com/repos/irl/bugwarrior/contents/{+path}","compare_url":"https://api.github.com/repos/irl/bugwarrior/compare/{base}...{head}","merges_url":"https://api.github.com/repos/irl/bugwarrior/merges","archive_url":"https://api.github.com/repos/irl/bugwarrior/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/irl/bugwarrior/downloads","issues_url":"https://api.github.com/repos/irl/bugwarrior/issues{/number}","pulls_url":"https://api.github.com/repos/irl/bugwarrior/pulls{/number}","milestones_url":"https://api.github.com/repos/irl/bugwarrior/milestones{/number}","notifications_url":"https://api.github.com/repos/irl/bugwarrior/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/irl/bugwarrior/labels{/name}","releases_url":"https://api.github.com/repos/irl/bugwarrior/releases{/id}","deployments_url":"https://api.github.com/repos/irl/bugwarrior/deployments","created_at":"2016-04-19T20:30:14Z","updated_at":"2016-04-19T20:30:15Z","pushed_at":"2016-07-09T03:34:12Z","git_url":"git://github.com/irl/bugwarrior.git","ssh_url":"git@github.com:irl/bugwarrior.git","clone_url":"https://github.com/irl/bugwarrior.git","svn_url":"https://github.com/irl/bugwarrior","homepage":"http://pypi.python.org/pypi/bugwarrior","size":965,"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":"develop"}},"base":{"label":"ralphbean:develop","ref":"develop","sha":"22bd6e5c7e97061162a380338b7768636f1c0f89","user":{"login":"ralphbean","id":331338,"avatar_url":"https://avatars.githubusercontent.com/u/331338?v=3","gravatar_id":"","url":"https://api.github.com/users/ralphbean","html_url":"https://github.com/ralphbean","followers_url":"https://api.github.com/users/ralphbean/followers","following_url":"https://api.github.com/users/ralphbean/following{/other_user}","gists_url":"https://api.github.com/users/ralphbean/gists{/gist_id}","starred_url":"https://api.github.com/users/ralphbean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ralphbean/subscriptions","organizations_url":"https://api.github.com/users/ralphbean/orgs","repos_url":"https://api.github.com/users/ralphbean/repos","events_url":"https://api.github.com/users/ralphbean/events{/privacy}","received_events_url":"https://api.github.com/users/ralphbean/received_events","type":"User","site_admin":false},"repo":{"id":2985492,"name":"bugwarrior","full_name":"ralphbean/bugwarrior","owner":{"login":"ralphbean","id":331338,"avatar_url":"https://avatars.githubusercontent.com/u/331338?v=3","gravatar_id":"","url":"https://api.github.com/users/ralphbean","html_url":"https://github.com/ralphbean","followers_url":"https://api.github.com/users/ralphbean/followers","following_url":"https://api.github.com/users/ralphbean/following{/other_user}","gists_url":"https://api.github.com/users/ralphbean/gists{/gist_id}","starred_url":"https://api.github.com/users/ralphbean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ralphbean/subscriptions","organizations_url":"https://api.github.com/users/ralphbean/orgs","repos_url":"https://api.github.com/users/ralphbean/repos","events_url":"https://api.github.com/users/ralphbean/events{/privacy}","received_events_url":"https://api.github.com/users/ralphbean/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ralphbean/bugwarrior","description":"Pull github, bitbucket, and trac issues into taskwarrior","fork":false,"url":"https://api.github.com/repos/ralphbean/bugwarrior","forks_url":"https://api.github.com/repos/ralphbean/bugwarrior/forks","keys_url":"https://api.github.com/repos/ralphbean/bugwarrior/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ralphbean/bugwarrior/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ralphbean/bugwarrior/teams","hooks_url":"https://api.github.com/repos/ralphbean/bugwarrior/hooks","issue_events_url":"https://api.github.com/repos/ralphbean/bugwarrior/issues/events{/number}","events_url":"https://api.github.com/repos/ralphbean/bugwarrior/events","assignees_url":"https://api.github.com/repos/ralphbean/bugwarrior/assignees{/user}","branches_url":"https://api.github.com/repos/ralphbean/bugwarrior/branches{/branch}","tags_url":"https://api.github.com/repos/ralphbean/bugwarrior/tags","blobs_url":"https://api.github.com/repos/ralphbean/bugwarrior/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ralphbean/bugwarrior/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ralphbean/bugwarrior/git/refs{/sha}","trees_url":"https://api.github.com/repos/ralphbean/bugwarrior/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ralphbean/bugwarrior/statuses/{sha}","languages_url":"https://api.github.com/repos/ralphbean/bugwarrior/languages","stargazers_url":"https://api.github.com/repos/ralphbean/bugwarrior/stargazers","contributors_url":"https://api.github.com/repos/ralphbean/bugwarrior/contributors","subscribers_url":"https://api.github.com/repos/ralphbean/bugwarrior/subscribers","subscription_url":"https://api.github.com/repos/ralphbean/bugwarrior/subscription","commits_url":"https://api.github.com/repos/ralphbean/bugwarrior/commits{/sha}","git_commits_url":"https://api.github.com/repos/ralphbean/bugwarrior/git/commits{/sha}","comments_url":"https://api.github.com/repos/ralphbean/bugwarrior/comments{/number}","issue_comment_url":"https://api.github.com/repos/ralphbean/bugwarrior/issues/comments{/number}","contents_url":"https://api.github.com/repos/ralphbean/bugwarrior/contents/{+path}","compare_url":"https://api.github.com/repos/ralphbean/bugwarrior/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ralphbean/bugwarrior/merges","archive_url":"https://api.github.com/repos/ralphbean/bugwarrior/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ralphbean/bugwarrior/downloads","issues_url":"https://api.github.com/repos/ralphbean/bugwarrior/issues{/number}","pulls_url":"https://api.github.com/repos/ralphbean/bugwarrior/pulls{/number}","milestones_url":"https://api.github.com/repos/ralphbean/bugwarrior/milestones{/number}","notifications_url":"https://api.github.com/repos/ralphbean/bugwarrior/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ralphbean/bugwarrior/labels{/name}","releases_url":"https://api.github.com/repos/ralphbean/bugwarrior/releases{/id}","deployments_url":"https://api.github.com/repos/ralphbean/bugwarrior/deployments","created_at":"2011-12-15T05:02:33Z","updated_at":"2016-07-10T14:44:58Z","pushed_at":"2016-07-22T04:08:56Z","git_url":"git://github.com/ralphbean/bugwarrior.git","ssh_url":"git@github.com:ralphbean/bugwarrior.git","clone_url":"https://github.com/ralphbean/bugwarrior.git","svn_url":"https://github.com/ralphbean/bugwarrior","homepage":"http://pypi.python.org/pypi/bugwarrior","size":1158,"stargazers_count":207,"watchers_count":207,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":60,"mirror_url":null,"open_issues_count":36,"forks":60,"open_issues":36,"watchers":207,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/ralphbean/bugwarrior/pulls/348"},"html":{"href":"https://github.com/ralphbean/bugwarrior/pull/348"},"issue":{"href":"https://api.github.com/repos/ralphbean/bugwarrior/issues/348"},"comments":{"href":"https://api.github.com/repos/ralphbean/bugwarrior/issues/348/comments"},"review_comments":{"href":"https://api.github.com/repos/ralphbean/bugwarrior/pulls/348/comments"},"review_comment":{"href":"https://api.github.com/repos/ralphbean/bugwarrior/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ralphbean/bugwarrior/pulls/348/commits"},"statuses":{"href":"https://api.github.com/repos/ralphbean/bugwarrior/statuses/7ab439cdc973d4e7566007c5f7ef1c06be4af172"}}}}
{"actor":{"display_login":"irl"}}