Пример #1
0
def assignees():
    r = memberships()
    nees = {}
    for member in r:
        mainrole = min(member['roles'], key=lambda x: x['id'])  # idが小さいrole程権限がでかいと仮定
        if int(mainrole['id']) < 5:
            u = user(nested_access(member, 'user.id'))
            nees[u['id']] = {'login':u['login'], 'name':u['firstname'] + u' ' + u['lastname']}
    return nees
Пример #2
0
def comments(number, params={}):
    cfg = config.parseconfig()
    r = _request('get', ISSUE_COMMENTS.format(issueid=number, **cfg), params=params)
    comments = [ticket.Comment(number = x['id'],
                               body = x['body'],
                               creator = nested_access(x, 'user.login'),
                               created = todatetime(x['created_at']),
                               updated = todatetime(x['updated_at'])) for x in r]
    return comments
Пример #3
0
def assignees():
    r = memberships()
    nees = {}
    for member in r:
        mainrole = min(member['roles'], key=lambda x: x['id'])  # idが小さいrole程権限がでかいと仮定
        if int(mainrole['id']) < 5:
            u = user(nested_access(member, 'user.id'))
            nees[u['id']] = {'login':u['login'], 'name':u['firstname'] + u' ' + u['lastname']}
    return nees
Пример #4
0
def comments(number, params={}):
    cfg = config.parseconfig()
    cj = _request('get', ISSUE_COMMENTS.format(issueid=number, **cfg), {'limit':50})
    cj = [x for x in cj if x['content'] is not None]
    # commentは特殊。statusの変更がコメント化され、Web上では表示できるが、APIからは補足できない。
    comments = [ticket.Comment(number = x['comment_id'],
                               body = x['content'],
                               creator = nested_access(x, 'author_info.username'),
                               created = _todatetime(x['utc_created_on']),
                               updated = _todatetime(x['utc_updated_on'])) for x in cj]
    return comments
Пример #5
0
def comments(number, params={}):
    cfg = config.parseconfig()
    cj = _request('get', ISSUE_COMMENTS.format(issueid=number, **cfg), {'limit':50})
    cj = [x for x in cj if x['content'] is not None]
    # commentは特殊。statusの変更がコメント化され、Web上では表示できるが、APIからは補足できない。
    comments = [ticket.Comment(number = x['comment_id'],
                               body = x['content'],
                               creator = nested_access(x, 'author_info.username'),
                               created = _todatetime(x['utc_created_on']),
                               updated = _todatetime(x['utc_updated_on'])) for x in cj]
    return comments
Пример #6
0
def comments(number, params={}):
    cfg = config.parseconfig()
    r = _request('get',
                 ISSUE_COMMENTS.format(issueid=number, **cfg),
                 params=params)
    comments = [
        ticket.Comment(number=x['id'],
                       body=x['body'],
                       creator=nested_access(x, 'user.login'),
                       created=todatetime(x['created_at']),
                       updated=todatetime(x['updated_at'])) for x in r
    ]
    return comments
Пример #7
0
def _parse_journal(j):
    term = blessings.Terminal()
    r = {}
    r['number'] = j['id']
    r['creator'] = nested_access(j, 'user.name')
    r['created'] = _todatetime(j['created_on'])
    r['body'] = u''
    # make body
    if 'notes' in j:
        r['body'] += j['notes'] + u'\n'
    r['body'] += u'\n'.join(u'{term.red}*{term.normal} ' + _parse_detail(x) for x in j['details'])
    r['body'] = r['body'].strip()
    r['body'] = r['body'].format(term = term)
    return r
Пример #8
0
def _parse_journal(j):
    term = blessings.Terminal()
    r = {}
    r['number'] = j['id']
    r['creator'] = nested_access(j, 'user.name')
    r['created'] = _todatetime(j['created_on'])
    r['body'] = u''
    # make body
    if 'notes' in j:
        r['body'] += j['notes'] + u'\n'
    r['body'] += u'\n'.join(u'{term.red}*{term.normal} ' + _parse_detail(x) for x in j['details'])
    r['body'] = r['body'].strip()
    r['body'] = r['body'].format(term = term)
    return r
Пример #9
0
def _toticket(d):
    cfg = config.parseconfig()
    j = dict(number = d['id'],
             state = nested_access(d, 'status.name'),
             priority = nested_access(d, 'priority.name'),
             labels = nested_access(d, 'tracker.name'),
             html_url = ISSUE_URL.format(issueid=d['id'], **cfg),
             title = d['subject'],
             body = d.get('description', None),
             creator = user(nested_access(d, 'author.id'))['login'],
             creator_fullname = nested_access(d, 'author.name'),
             assignee_fullname = nested_access(d, 'assigned_to.name'),
             created = _todatetime(d['created_on']),
             updated = _todatetime(d['updated_on']))
    if 'assigned_to' in d:
        j['assignee'] = user(nested_access(d, 'assigned_to.id'))['login']
    tic = ticket.Ticket(**j)
    setattr(tic, 'priority_id', nested_access(d, 'priority.id'))  # Redmineにpriorityを取得するAPIがないためあとで参照しなければならない
    return tic
Пример #10
0
def _toticket(d):
    cfg = config.parseconfig()
    j = dict(number = d['id'],
             state = nested_access(d, 'status.name'),
             priority = nested_access(d, 'priority.name'),
             labels = nested_access(d, 'tracker.name'),
             html_url = ISSUE_URL.format(issueid=d['id'], **cfg),
             title = d['subject'],
             body = d.get('description', None),
             creator = user(nested_access(d, 'author.id'))['login'],
             creator_fullname = nested_access(d, 'author.name'),
             assignee_fullname = nested_access(d, 'assigned_to.name'),
             created = _todatetime(d['created_on']),
             updated = _todatetime(d['updated_on']))
    if 'assigned_to' in d:
        j['assignee'] = user(nested_access(d, 'assigned_to.id'))['login']
    tic = ticket.Ticket(**j)
    setattr(tic, 'priority_id', nested_access(d, 'priority.id'))  # Redmineにpriorityを取得するAPIがないためあとで参照しなければならない
    return tic
Пример #11
0
def _toticket(d):
    cfg = config.parseconfig()
    j = dict(number=d['local_id'],
             state=d['status'],
             title=d['title'],
             body=d['content'],
             labels=nested_access(d, 'metadata.kind'),
             priority=d['priority'],
             milestone=nested_access(d, 'metadata.milestone'),
             creator=nested_access(d, 'reported_by.username'),
             creator_fullname=u' '.join(
                 (nested_access(d, 'reported_by.first_name'),
                  nested_access(d, 'reported_by.last_name'))),
             html_url=ISSUEURL.format(issueid=d['local_id'], **cfg),
             assignee=nested_access(d, 'responsible.username'),
             comments=d['comment_count'],
             created=_todatetime(d['utc_created_on']),
             updated=_todatetime(d['utc_last_updated']))
    if 'responsible' in d:
        j['assignee_fullname'] = u' '.join(
            (nested_access(d, 'responsible.first_name'),
             nested_access(d, 'responsible.last_name')))
    return ticket.Ticket(**j)
Пример #12
0
def _toticket(d):
    cfg = config.parseconfig()
    j = dict(number = d['local_id'],
             state = d['status'],
             title = d['title'],
             body = d['content'],
             labels = nested_access(d, 'metadata.kind'),
             priority = d['priority'],
             milestone = nested_access(d, 'metadata.milestone'),
             creator = nested_access(d, 'reported_by.username'),
             creator_fullname = u' '.join((nested_access(d, 'reported_by.first_name'), nested_access(d, 'reported_by.last_name'))),
             html_url = ISSUEURL.format(issueid=d['local_id'], **cfg),
             assignee = nested_access(d, 'responsible.username'),
             comments = d['comment_count'],
             created = _todatetime(d['utc_created_on']),
             updated = _todatetime(d['utc_last_updated']))
    if 'responsible' in d:
        j['assignee_fullname'] = u' '.join((nested_access(d, 'responsible.first_name'), nested_access(d, 'responsible.last_name')))
    return ticket.Ticket(**j)
Пример #13
0
def _toticket(d):
    j = dict(number=d['number'],
             state=d['state'],
             title=d['title'],
             body=d['body'],
             creator=nested_access(d, 'user.login'),
             assignee=nested_access(d, 'assignee.login'),
             labels=[x['name'] for x in d['labels']],
             comments=d['comments'],
             milestone=nested_access(d, 'milestone.title'),
             created=todatetime(d['created_at']),
             updated=todatetime(d['updated_at']),
             closed=todatetime(d['closed_at']),
             html_url=d['html_url'])
    if nested_access(d, 'pull_request.html_url'):
        j['pull_request'] = 'Pull Request'
    t = ticket.Ticket(**j)
    if nested_access(d, 'milestone.id'):
        t.milestone_id = nested_access(d, 'milestone.id')
    return t
Пример #14
0
def _toticket(d):
    j = dict(number = d['number'],
             state = d['state'],
             title = d['title'],
             body = d['body'],
             creator = nested_access(d, 'user.login'),
             assignee = nested_access(d, 'assignee.login'),
             labels = [x['name'] for x in d['labels']],
             comments = d['comments'],
             milestone = nested_access(d, 'milestone.title'),
             created = todatetime(d['created_at']),
             updated = todatetime(d['updated_at']),
             closed = todatetime(d['closed_at']),
             html_url = d['html_url']
             )
    if nested_access(d, 'pull_request.html_url'):
        j['pull_request'] = 'Pull Request'
    t = ticket.Ticket(**j)
    if nested_access(d, 'milestone.id'):
        t.milestone_id = nested_access(d, 'milestone.id')
    return t