from jiggl import curried_toolz as z from jiggl.utils import get_val, get_error def print_error_group((err, entries)): print print bcolors.bold(bcolors.underline(err)) print '\n'.join(map(str, [e.get('description', e['id']) for e in entries])) print def _log(key, l): return l log = z.curry(_log) print_invalid_entries = z.compose(list, log('final'), z.map(print_error_group), log('iteritems'), iteritems, log('valmap'), z.valmap(z.map(get_val)), log('groupby'), z.groupby(get_error), log('initital')) def print_valid_entries(entries): print bcolors.header(bcolors.underline('\nLogging to Jira\n')) # entries = map(get_val, entries) groups = z.groupby(z.get('description', default=''), entries) cleaned = map(split_description, groups.iteritems()) for (issue, comment), es in cleaned:
def _get_transition_id(status, ticket): """ Returns the Jira id for the transition that will move the ticket to the requested status :param status: ID of the desired status after the transition :param ticket: a ticket id or Issue :return: """ raw_transitions = jira.transitions(ticket) transitions = list(z.filter(lambda transition: z.get_in(['to', 'id'], transition) == status, raw_transitions)) assert len(transitions) == 1 return transitions[0]['id'] get_transition_id = z.curry(_get_transition_id) reopen_transition = get_transition_id(REOPENED) @contextmanager def ensure_open_ticket(ticket_id): """ Allows us to reopen a ticket once, and log against it a bunch of times. :param ticket_id: :return: """ # TODO: This gives race conditions if someone updates a ticket while we are logging time. ticket = jira.issue(ticket_id) status_id = ticket.fields.status.id if status_id == COMPLETE:
""" Returns the Jira id for the transition that will move the ticket to the requested status :param status: ID of the desired status after the transition :param ticket: a ticket id or Issue :return: """ raw_transitions = jira.transitions(ticket) transitions = list( z.filter( lambda transition: z.get_in(['to', 'id'], transition) == status, raw_transitions)) assert len(transitions) == 1 return transitions[0]['id'] get_transition_id = z.curry(_get_transition_id) reopen_transition = get_transition_id(REOPENED) @contextmanager def ensure_open_ticket(ticket_id): """ Allows us to reopen a ticket once, and log against it a bunch of times. :param ticket_id: :return: """ # TODO: This gives race conditions if someone updates a ticket while we are logging time. ticket = jira.issue(ticket_id) status_id = ticket.fields.status.id if status_id == COMPLETE:
from jiggl import curried_toolz as z from jiggl.utils import get_val, get_error def print_error_group((err, entries)): print print bcolors.bold(bcolors.underline(err)) print "\n".join(map(str, [e.get("description", e["id"]) for e in entries])) print def _log(key, l): return l log = z.curry(_log) print_invalid_entries = z.compose( list, log("final"), z.map(print_error_group), log("iteritems"), iteritems, log("valmap"), z.valmap(z.map(get_val)), log("groupby"), z.groupby(get_error), log("initital"), ) def print_valid_entries(entries):