def to_tce(entry): ticket, comment = _split_description(z.get('description', entry)) return TicketCommentEntry(ticket, comment, entry)
def split_description(group): description, entries = group parts = description.split(' ', 1) # Allow for descriptions with a Jira task identifier but no accomanying description if len(parts) > 1: return parts, entries return (parts[0], ''), entries def _split_description(description): parts = description.split(' ', 1) if len(parts) > 1: return tuple(parts) return description, '' sum_as_timedelta = lambda entries: timedelta(seconds=total_duration(entries)) total_duration = z.compose(sum, z.pluck('duration', default=0)) toggl_to_jira_datefmt = z.compose( jira_strftime, toggl_strptime, ) get_valid_invalid = z.get([False, True], default=[]) group_by_has_error = z.groupby(has_error) split_entries = z.compose( get_valid_invalid, group_by_has_error, validate_many, )