Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Some pep8. #57

Merged
merged 2 commits into from

1 participant

@ralphbean
Owner

Cleaning up some style that's been falling off.

@ralphbean ralphbean merged commit 3700fbe into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 26, 2013
  1. Some pep8.

    authored
  2. Finished pep8 pass.

    authored
This page is out of date. Refresh to see the latest.
View
78 bugwarrior/services/activecollab2.py
@@ -25,7 +25,7 @@ def format_date(self, date):
if date is None:
return
d = datetime.datetime.fromtimestamp(time.mktime(time.strptime(
- date, "%Y-%m-%d")))
+ date, "%Y-%m-%d")))
timestamp = int(time.mktime(d.timetuple()))
return timestamp
@@ -41,11 +41,13 @@ def find_issues(self, user_id=None, project_id=None, project_name=None):
1. Get user ID from .bugwarriorrc file
2. Get list of tickets from /user-tasks for a given project
- 3. For each ticket/task returned from #2, get ticket/task info and check
- if logged-in user is primary (look at `is_owner` and `user_id`)
+ 3. For each ticket/task returned from #2, get ticket/task info and
+ check if logged-in user is primary (look at `is_owner` and
+ `user_id`)
"""
- user_tasks_data = self.call_api("/projects/" + str(project_id) + "/user-tasks")
+ user_tasks_data = self.call_api(
+ "/projects/" + str(project_id) + "/user-tasks")
global task_count
assigned_tasks = []
@@ -56,25 +58,37 @@ def find_issues(self, user_id=None, project_id=None, project_name=None):
if task[u'type'] == 'Ticket':
# Load Ticket data
# @todo Implement threading here.
- ticket_data = self.call_api("/projects/" + str(task[u'project_id']) + "/tickets/" + str(task[u'ticket_id']))
+ ticket_data = self.call_api(
+ "/projects/" + str(task[u'project_id']) +
+ "/tickets/" + str(task[u'ticket_id']))
assignees = ticket_data[u'assignees']
for k, v in enumerate(assignees):
- if ((v[u'is_owner'] is True) and (v[u'user_id'] == int(self.user_id))):
- assigned_task['permalink'] = ticket_data[u'permalink']
- assigned_task['ticket_id'] = ticket_data[u'ticket_id']
- assigned_task['project_id'] = ticket_data[u'project_id']
+ if ((v[u'is_owner'] is True)
+ and (v[u'user_id'] == int(self.user_id))):
+ assigned_task['permalink'] = \
+ ticket_data[u'permalink']
+ assigned_task['ticket_id'] = \
+ ticket_data[u'ticket_id']
+ assigned_task['project_id'] = \
+ ticket_data[u'project_id']
assigned_task['project'] = project_name
assigned_task['description'] = ticket_data[u'name']
assigned_task['type'] = "ticket"
- assigned_task['created_on'] = ticket_data[u'created_on']
- assigned_task['created_by_id'] = ticket_data[u'created_by_id']
+ assigned_task['created_on'] = \
+ ticket_data[u'created_on']
+ assigned_task['created_by_id'] = \
+ ticket_data[u'created_by_id']
if 'priority' in ticket_data:
- assigned_task['priority'] = self.format_priority(ticket_data[u'priority'])
+ assigned_task['priority'] = \
+ self.format_priority(
+ ticket_data[u'priority'])
else:
- assigned_task['priority'] = self.default_priority
+ assigned_task['priority'] = \
+ self.default_priority
if ticket_data[u'due_on'] is not None:
- assigned_task['due'] = self.format_date(ticket_data[u'due_on'])
+ assigned_task['due'] = self.format_date(
+ ticket_data[u'due_on'])
elif task[u'type'] == 'Task':
# Load Task data
@@ -87,24 +101,30 @@ def find_issues(self, user_id=None, project_id=None, project_name=None):
assigned_task['created_on'] = task[u'created_on']
assigned_task['created_by_id'] = task[u'created_by_id']
if 'priority' in task:
- assigned_task['priority'] = self.format_priority(task[u'priority'])
+ assigned_task['priority'] = self.format_priority(
+ task[u'priority'])
else:
assigned_task['priority'] = self.default_priority
if task[u'due_on'] is not None:
- assigned_task['due'] = self.format_date(task[u'due_on'])
+ assigned_task['due'] = self.format_date(
+ task[u'due_on'])
if assigned_task:
- log.name(self.target).debug(" Adding '" + assigned_task['description'] + "' to task list.")
+ log.name(self.target).debug(
+ " Adding '" + assigned_task['description'] +
+ "' to task list.")
assigned_tasks.append(assigned_task)
except:
- log.name(self.target).debug(' No user tasks loaded for "%s".' % project_name)
+ log.name(self.target).debug(
+ ' No user tasks loaded for "%s".' % project_name)
return assigned_tasks
def call_api(self, uri, get=None):
global api_count
api_count += 1
- url = self.url.rstrip("/") + "?token=" + self.key + "&path_info=" + uri + "&format=json"
+ url = self.url.rstrip("/") + "?token=" + self.key + \
+ "&path_info=" + uri + "&format=json"
req = urllib2.Request(url)
res = urllib2.urlopen(req)
@@ -180,23 +200,29 @@ def issues(self):
# @todo Implement threading here.
for project in projects:
for project_id, project_name in project.iteritems():
- log.name(self.target).debug(" Getting tasks for #" + project_id + " " + project_name + '"')
- issues += self.client.find_issues(self.user_id, project_id, project_name)
+ log.name(self.target).debug(
+ " Getting tasks for #" + project_id +
+ " " + project_name + '"')
+ issues += self.client.find_issues(
+ self.user_id, project_id, project_name)
log.name(self.target).debug(" Found {0} total.", len(issues))
global api_count
log.name(self.target).debug(" {0} API calls", api_count)
- log.name(self.target).debug(" {0} tasks and tickets analyzed", task_count)
- log.name(self.target).debug(" Elapsed Time: %s" % (time.time() - start))
+ log.name(self.target).debug(
+ " {0} tasks and tickets analyzed", task_count)
+ log.name(self.target).debug(
+ " Elapsed Time: %s" % (time.time() - start))
formatted_issues = []
for issue in issues:
formatted_issue = dict(
description=self.description(
- issue["description"],
- issue["project_id"], issue["ticket_id"], issue["type"],
- ),
+ issue["description"],
+ issue["project_id"],
+ issue["ticket_id"],
+ issue["type"]),
project=self.get_project_name(issue),
priority=issue["priority"],
**self.annotations(issue)
View
65 bugwarrior/services/activecollab3.py
@@ -12,15 +12,18 @@
api_count = 0
task_count = 0
+
class ActiveCollabApi():
def call_api(self, uri, key, url):
global api_count
api_count += 1
- url = url.rstrip("/") + "?auth_api_token=" + key + "&path_info=" + uri + "&format=json"
+ url = url.rstrip("/") + "?auth_api_token=" + key + \
+ "&path_info=" + uri + "&format=json"
req = urllib2.Request(url)
res = urllib2.urlopen(req)
return json.loads(res.read())
+
class Client(object):
def __init__(self, url, key, user_id, projects):
self.url = url
@@ -33,7 +36,7 @@ def format_date(self, date):
if date is None:
return
d = datetime.datetime.fromtimestamp(time.mktime(time.strptime(
- date, "%Y-%m-%d")))
+ date, "%Y-%m-%d")))
timestamp = int(time.mktime(d.timetuple()))
return timestamp
@@ -47,8 +50,10 @@ def find_issues(self, user_id=None, project_id=None, project_name=None):
ac = ActiveCollabApi()
user_tasks_data = []
user_subtasks_data = []
- user_tasks_data = ac.call_api("/projects/" + str(project_id) + "/tasks", self.key, self.url)
- user_subtasks_data = ac.call_api("/projects/" + str(project_id) + "/subtasks", self.key, self.url)
+ user_tasks_data = ac.call_api(
+ "/projects/" + str(project_id) + "/tasks", self.key, self.url)
+ user_subtasks_data = ac.call_api(
+ "/projects/" + str(project_id) + "/subtasks", self.key, self.url)
global task_count
assigned_tasks = []
@@ -58,7 +63,9 @@ def find_issues(self, user_id=None, project_id=None, project_name=None):
assigned_task = dict()
# Load Task data
# @todo Implement threading here.
- if ((task[u'assignee_id'] == int(self.user_id)) and (task[u'completed_on'] is None)):
+ if ((task[u'assignee_id'] == int(self.user_id))
+ and (task[u'completed_on'] is None)):
+
assigned_task['permalink'] = task[u'permalink']
assigned_task['task_id'] = task[u'task_id']
assigned_task['id'] = task[u'id']
@@ -69,11 +76,13 @@ def find_issues(self, user_id=None, project_id=None, project_name=None):
assigned_task['created_on'] = task[u'created_on'][u'mysql']
assigned_task['created_by_id'] = task[u'created_by_id']
if 'priority' in task:
- assigned_task['priority'] = self.format_priority(task[u'priority'])
+ assigned_task['priority'] = \
+ self.format_priority(task[u'priority'])
else:
assigned_task['priority'] = self.default_priority
if task[u'due_on'] is not None:
- assigned_task['due'] = self.format_date(task[u'due_on'][u'mysql'])
+ assigned_task['due'] = \
+ self.format_date(task[u'due_on'][u'mysql'])
if assigned_task:
assigned_tasks.append(assigned_task)
@@ -82,14 +91,17 @@ def find_issues(self, user_id=None, project_id=None, project_name=None):
for key, subtask in enumerate(user_subtasks_data):
task_count += 1
assigned_task = dict()
- if ((subtask[u'assignee_id'] == int(self.user_id)) and (subtask[u'completed_on'] is None)):
+ if ((subtask[u'assignee_id'] == int(self.user_id))
+ and (subtask[u'completed_on'] is None)):
# Get permalink
- assigned_task['permalink'] = (self.url).rstrip('api.php') + 'projects/' + str(project_id) + '/tasks'
+ assigned_task['permalink'] = self.url.rstrip('api.php') + \
+ 'projects/' + str(project_id) + '/tasks'
if assigned_tasks:
for k, t in enumerate(assigned_tasks):
if 'id' in t:
if subtask[u'parent_id'] == t[u'id']:
- assigned_task['permalink'] = t[u'permalink']
+ assigned_task['permalink'] = \
+ t[u'permalink']
assigned_task['task_id'] = subtask[u'id']
assigned_task['project'] = project_name
assigned_task['project_id'] = project_id
@@ -98,16 +110,19 @@ def find_issues(self, user_id=None, project_id=None, project_name=None):
assigned_task['created_on'] = subtask[u'created_on']
assigned_task['created_by_id'] = subtask[u'created_by_id']
if 'priority' in subtask:
- assigned_task['priority'] = self.format_priority(subtask[u'priority'])
+ assigned_task['priority'] = \
+ self.format_priority(subtask[u'priority'])
else:
assigned_task['priority'] = self.default_priority
if subtask[u'due_on'] is not None:
- assigned_task['due'] = self.format_date(subtask[u'due_on'])
+ assigned_task['due'] = \
+ self.format_date(subtask[u'due_on'])
if assigned_task:
assigned_tasks.append(assigned_task)
return assigned_tasks
+
class ActiveCollab3Service(IssueService):
def __init__(self, *args, **kw):
super(ActiveCollab3Service, self).__init__(*args, **kw)
@@ -174,26 +189,33 @@ def issues(self):
issues = []
projects = self.projects
# @todo Implement threading here.
- log.name(self.target).debug(" {0} projects in favorites list.", len(projects))
+ log.name(self.target).debug(
+ " {0} projects in favorites list.", len(projects))
for project in projects:
for project_id, project_name in project.iteritems():
- log.name(self.target).debug(" Getting tasks for #" + str(project_id) + " " + str(project_name) + '"')
- issues += self.client.find_issues(self.user_id, project_id, project_name)
+ log.name(self.target).debug(
+ " Getting tasks for #" + str(project_id) +
+ " " + str(project_name) + '"')
+ issues += self.client.find_issues(
+ self.user_id, project_id, project_name)
log.name(self.target).debug(" Found {0} total.", len(issues))
global api_count
log.name(self.target).debug(" {0} API calls", api_count)
- log.name(self.target).debug(" {0} tasks and subtasks analyzed", task_count)
- log.name(self.target).debug(" Elapsed Time: %s" % (time.time() - start))
+ log.name(self.target).debug(" {0} tasks and subtasks analyzed",
+ task_count)
+ log.name(self.target).debug(" Elapsed Time: %s" % (
+ time.time() - start))
formatted_issues = []
for issue in issues:
formatted_issue = dict(
description=self.description(
- issue["description"],
- issue["project_id"], issue["task_id"], issue["type"],
- ),
+ issue["description"],
+ issue["project_id"],
+ issue["task_id"],
+ issue["type"]),
project=self.get_project_name(issue),
priority=issue["priority"],
**self.annotations(issue)
@@ -201,5 +223,6 @@ def issues(self):
if "due" in issue:
formatted_issue["due"] = issue["due"]
formatted_issues.append(formatted_issue)
- log.name(self.target).debug(" {0} tasks assigned to you", len(formatted_issues))
+ log.name(self.target).debug(
+ " {0} tasks assigned to you", len(formatted_issues))
return formatted_issues
View
3  bugwarrior/services/bitbucket.py
@@ -93,8 +93,7 @@ def issues(self):
return [dict(
description=self.description(
issue['title'], issue['url'],
- issue['local_id'], cls="issue",
- ),
+ issue['local_id'], cls="issue"),
project=tag.split('/')[1],
priority=self.priorities.get(
issue['priority'],
View
3  bugwarrior/services/bz.py
@@ -117,8 +117,7 @@ def issues(self):
return [dict(
description=self.description(
issue['summary'], issue['url'],
- issue['id'], cls="issue",
- ),
+ issue['id'], cls="issue"),
project=issue['component'],
priority=self.priorities.get(
issue['priority'],
View
2  bugwarrior/services/github.py
@@ -56,7 +56,7 @@ def issues(self):
# First get and prune all the real issues
has_issues = lambda repo: repo['has_issues'] and \
- repo['open_issues_count'] > 0
+ repo['open_issues_count'] > 0
repos = filter(has_issues, all_repos)
issues = sum([self._issues(user + "/" + r['name']) for r in repos], [])
log.name(self.target).debug(" Found {0} total.", len(issues))
View
2  bugwarrior/services/githubutils.py
@@ -46,7 +46,7 @@ def get_issues(username, repo, auth):
def get_comments(username, repo, number, auth):
tmpl = "https://api.github.com/repos/{username}/{repo}/issues/" + \
- "{number}/comments?per_page=100"
+ "{number}/comments?per_page=100"
url = tmpl.format(username=username, repo=repo, number=number)
return _getter(url, auth)
View
29 bugwarrior/services/jira.py
@@ -9,6 +9,7 @@
from bugwarrior.services import IssueService
from bugwarrior.config import die
+
def get_priority(priority):
if priority is None:
return 'Major'
@@ -30,12 +31,20 @@ def __init__(self, *args, **kw):
super(JiraService, self).__init__(*args, **kw)
self.username = self.config.get(self.target, 'jira.username')
self.url = self.config.get(self.target, 'jira.base_uri')
- default_query = 'assignee=' + self.username + ' AND status != closed and status != resolved'
+ default_query = 'assignee=' + self.username + \
+ ' AND status != closed and status != resolved'
self.query = self.config.get(self.target, 'jira.query', default_query)
- self.project_prefix = self.config.get(self.target, 'jira.project_prefix', '')
- self.jira = JIRA(options={'server': self.config.get(self.target, 'jira.base_uri')},
- basic_auth=(self.username,
- self.config.get(self.target, 'jira.password')))
+ self.project_prefix = self.config.get(
+ self.target, 'jira.project_prefix', '')
+ self.jira = JIRA(
+ options={
+ 'server': self.config.get(self.target, 'jira.base_uri')
+ },
+ basic_auth=(
+ self.username,
+ self.config.get(self.target, 'jira.password')
+ )
+ )
@classmethod
def validate_config(cls, config, target):
@@ -58,9 +67,11 @@ def annotations(self, issue):
pass
else:
for comment in comments:
- created = date.fromtimestamp(time.mktime(time.strptime(comment.created[0:10], '%Y-%m-%d')))
+ created = date.fromtimestamp(time.mktime(time.strptime(
+ comment.created[0:10], '%Y-%m-%d')))
- annotations.append(self.format_annotation(created, comment.author.name, comment.body))
+ annotations.append(self.format_annotation(
+ created, comment.author.name, comment.body))
return dict(annotations)
@@ -73,8 +84,8 @@ def issues(self):
description=self.description(
title=case.fields.summary,
url=self.url + '/browse/' + case.key,
- number=case.key.rsplit('-', 1)[1], cls="issue",
- ),
+ number=case.key.rsplit('-', 1)[1],
+ cls="issue"),
project=self.project_prefix + case.key.rsplit('-', 1)[0],
priority=self.priorities.get(
get_priority(case.fields.priority),
View
4 bugwarrior/services/mplan.py
@@ -53,8 +53,8 @@ def issues(self):
description=self.description(
self.get_issue_title(issue),
self.get_issue_url(issue),
- self.get_issue_id(issue), cls="issue",
- ),
+ self.get_issue_id(issue),
+ cls="issue"),
project=self.project_name,
priority=self.default_priority,
) for issue in issues]
View
3  bugwarrior/services/redmine.py
@@ -72,8 +72,7 @@ def issues(self):
description=self.description(
issue["subject"],
self.get_issue_url(issue),
- issue["id"], cls="issue",
- ),
+ issue["id"], cls="issue"),
project=self.get_project_name(issue),
priority=self.default_priority,
) for issue in issues]
View
10 bugwarrior/services/teamlab.py
@@ -93,21 +93,21 @@ def get_priority(self, issue):
def issues(self):
issues = self.client.get_task_list()
- log.name(self.target).debug(" Remote has {0} total issues.", len(issues))
+ log.name(self.target).debug(
+ " Remote has {0} total issues.", len(issues))
if not issues:
return []
# Filter out closed tasks.
issues = filter(lambda i: i["status"] == 1, issues)
- log.name(self.target).debug(" Remote has {0} active issues.", len(issues))
+ log.name(self.target).debug(
+ " Remote has {0} active issues.", len(issues))
return [dict(
description=self.description(
issue["title"],
self.get_issue_url(issue),
- issue["id"], cls="issue",
- ),
+ issue["id"], cls="issue"),
project=self.project_name,
priority=self.get_priority(issue),
) for issue in issues]
-
View
3  bugwarrior/services/trac.py
@@ -66,8 +66,7 @@ def issues(self):
return [dict(
description=self.description(
issue['summary'], issue['url'],
- issue['number'], cls="issue",
- ),
+ issue['number'], cls="issue"),
project=tag,
priority=self.priorities.get(
issue['priority'],
View
12 setup.py
@@ -12,12 +12,12 @@
description="Sync github, bitbucket, and trac issues with taskwarrior",
long_description=long_description,
classifiers=[
- "Development Status :: 4 - Beta",
- "Intended Audience :: Developers",
- "License :: OSI Approved :: GNU General Public License (GPL)",
- "Programming Language :: Python :: 2",
- "Topic :: Software Development :: Bug Tracking",
- "Topic :: Utilities",
+ "Development Status :: 4 - Beta",
+ "Intended Audience :: Developers",
+ "License :: OSI Approved :: GNU General Public License (GPL)",
+ "Programming Language :: Python :: 2",
+ "Topic :: Software Development :: Bug Tracking",
+ "Topic :: Utilities",
],
keywords='task taskwarrior todo github ',
author='Ralph Bean',
Something went wrong with that request. Please try again.