Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #760 add property gmail.project_name #762

Closed
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bugwarrior/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@ Contributors
- BinaryBabel (contributed support for YouTrack)
- Matthew Cengia (contributed extra support for Trello)
- Andrew Demas (contributed support for PivotalTracker)
- Stephan Meijer (contributed fixes for JIRA, extra support for Gmail)
1 change: 1 addition & 0 deletions bugwarrior/docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ Example Configuration
service = gmail
gmail.query = label:action OR label:readme
gmail.login_name = [email protected]
gmail.project_name = example

[pivotaltracker]
service = pivotaltracker
Expand Down
1 change: 1 addition & 0 deletions bugwarrior/docs/services/gmail.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Here's an example of a gmail target:
service = gmail
gmail.query = label:action OR label:readme
gmail.login_name = [email protected]
gmail.project_name = example_gmail

The specified query can be any gmail search term. By default it will select
starred threads. One task is created per selected thread, not per e-mail.
Expand Down
8 changes: 7 additions & 1 deletion bugwarrior/services/gmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def to_taskwarrior(self):
'entry': self.get_entry(),
'tags': [label for label in self.extra['labels'] if label not in self.EXCLUDE_LABELS],
'priority': self.origin['default_priority'],
'project': self.origin['project_name'],
self.THREAD_ID: self.record['id'],
self.SUBJECT: self.extra['subject'],
self.URL: self.extra['url'],
Expand Down Expand Up @@ -124,6 +125,8 @@ def __init__(self, *args, **kw):
'gmail_credentials_%s.pickle' % (credentials_name,))
self.gmail_api = self.build_api()

self.project_name = self.config.get('project_name', None)

def get_config_path(self, varname, default_path=None):
return os.path.expanduser(self.config.get(varname, default_path))

Expand Down Expand Up @@ -167,7 +170,7 @@ def get_credentials(self):

def get_labels(self):
result = self.gmail_api.users().labels().list(userId=self.login_name).execute()
return {label['id']: label['name'] for label in result['labels']}
return { label['id']: label['name'] for label in result['labels'] }

def get_threads(self):
thread_service = self.gmail_api.users().threads()
Expand All @@ -194,6 +197,9 @@ def issues(self):
yield issue


def get_service_metadata(self):
return { 'project_name': self.project_name }

def thread_extras(thread, labels):
name, address = thread_last_sender(thread)
last_message_id = thread_last_message_id(thread)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_gmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class TestGmailIssue(AbstractServiceTest, ServiceTest):
SERVICE_CONFIG = {
'gmail.add_tags': 'added',
'gmail.login_name': '[email protected]',
'gmail.project_name': 'test_project'
}

def setUp(self):
Expand Down Expand Up @@ -144,6 +145,7 @@ def test_to_taskwarrior(self):
'gmailurl': 'https://mail.google.com/mail/u/0/#all/1234',
'gmaillabels': 'CATEGORY_PERSONAL IMPORTANT postit sticky',
'priority': u'M',
'project': 'test_project',
'gmaillastsenderaddr': '[email protected]'}

taskwarrior = issue.to_taskwarrior()
Expand All @@ -162,6 +164,7 @@ def test_issues(self):
'gmaillastsender': 'Foo Bar',
'description': u'(bw)Is#1234 - Regarding Bugwarrior .. https://mail.google.com/mail/u/0/#all/1234',
'priority': u'M',
'project': 'test_project',
'tags': {'added', 'postit', 'sticky'},
'gmailsubject': 'Regarding Bugwarrior',
'gmailurl': 'https://mail.google.com/mail/u/0/#all/1234',
Expand Down