Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return self.origin['project_name']
def get_issue_url(self):
return "http://%s/products/projects/tasks.aspx?prjID=%d&id=%d" % (
self.origin['hostname'],
self.record["projectOwner"]["id"],
self.record["id"]
)
def get_priority(self):
if self.record.get("priority") == 1:
return "H"
return self.origin['default_priority']
class TeamLabService(IssueService):
ISSUE_CLASS = TeamLabIssue
CONFIG_PREFIX = 'teamlab'
def __init__(self, *args, **kw):
super(TeamLabService, self).__init__(*args, **kw)
self.hostname = self.config.get('hostname')
_login = self.config.get('login')
_password = self.get_password('password', _login)
self.client = TeamLabClient(self.hostname)
self.client.authenticate(_login, _password)
self.project_name = self.config.get('project_name', self.hostname)
@staticmethod
return 'M'
def get_default_description(self):
return self.build_default_description(
title=(
self.record.get('name')
if self.record.get('name')
else self.record.get('body')
),
url=self.get_processed_url(self.record['permalink']),
number=self.record['id'],
cls=self.record.get('type', 'subtask').lower(),
)
class ActiveCollabService(IssueService):
ISSUE_CLASS = ActiveCollabIssue
CONFIG_PREFIX = 'activecollab'
def __init__(self, *args, **kw):
super(ActiveCollabService, self).__init__(*args, **kw)
self.url = self.config.get('url').rstrip('/')
self.key = self.config.get('key')
self.user_id = int(self.config.get('user_id'))
self.client = ActiveCollabClient(
self.url, self.key, self.user_id
)
self.activecollab = activeCollab(url=self.url, key=self.key,
user_id=self.user_id)
@classmethod
'project': self.record["project-name"],
'priority': self.get_priority(),
'due': due,
'entry': created,
'end': end,
'modified': modified,
'annotations': self.extra.get('annotations', []),
self.URL: task_url,
self.TITLE: self.record.get("content", ""),
self.DESCRIPTION_LONG: self.record.get("description", ""),
self.PROJECT_ID: int(self.record["project-id"]),
self.STATUS: status,
self.ID: int(self.record["id"]),
}
class TeamworkService(IssueService):
ISSUE_CLASS = TeamworkIssue
CONFIG_PREFIX = 'teamwork_projects'
def __init__(self, *args, **kwargs):
super(TeamworkService, self).__init__(*args, **kwargs)
self.host = self.config.get('host', '')
self.token = self.config.get('token', '')
self.client = TeamworkClient(self.host, self.token)
user = self.client.authenticate()
self.user_id = user["account"]["userId"]
self.name = user["account"]["firstname"] + " " + user["account"]["lastname"]
def get_comments(self, issue):
if self.annotation_comments:
if issue.get("comments-count", 0) > 0:
endpoint = "/tasks/{task_id}/comments.json".format(task_id=issue["id"])
try:
return self.record['fields'].get('fixVersions', [{}])[0].get('name')
except (IndexError, KeyError, AttributeError, TypeError):
return None
def get_status(self):
return self.record['fields']['status']['name']
def get_subtasks(self):
return ','.join(task['key'] for task in self.record['fields']['subtasks'])
def get_issue_type(self):
return self.record['fields']['issuetype']['name']
class JiraService(IssueService):
ISSUE_CLASS = JiraIssue
CONFIG_PREFIX = 'jira'
def __init__(self, *args, **kw):
super(JiraService, self).__init__(*args, **kw)
self.username = self.config.get('username')
self.url = self.config.get('base_uri')
password = self.get_password('password', self.username)
default_query = 'assignee="' + self.username + \
'" AND resolution is null'
self.query = self.config.get('query', default_query)
self.use_cookies = self.config.get(
'use_cookies', default=False, to_type=asbool
)
def validate_config(cls, service_config, target):
for k in ('url', 'key'):
if k not in service_config:
die("[%s] has no 'redmine.%s'" % (target, k))
IssueService.validate_config(service_config, target)
# TODO: It would be nice to use the project slug (if the Redmine
# instance supports it), but this would require (1) an API call
# to get the list of projects, and then a look up between the
# project ID contained in self.record and the list of projects.
return re.sub(r'[^a-zA-Z0-9]', '', self.record["project"]["name"]).lower()
def get_default_description(self):
return self.build_default_description(
title=self.record['subject'],
url=self.get_processed_url(self.get_issue_url()),
number=self.record['id'],
cls='issue',
)
class RedMineService(IssueService):
ISSUE_CLASS = RedMineIssue
CONFIG_PREFIX = 'redmine'
def __init__(self, *args, **kw):
super(RedMineService, self).__init__(*args, **kw)
self.url = self.config.get('url').rstrip("/")
self.key = self.get_password('key')
self.issue_limit = self.config.get('issue_limit')
self.verify_ssl = self.config.get(
'verify_ssl', default=True, to_type=asbool
)
login = self.config.get('login')
if login: