pivotalcli/commands/__init__.py

40 lines
1.2 KiB
Python
Raw Normal View History

2018-04-03 10:56:07 +00:00
import api.projects
from typing import Dict, Any
from util import Color
COLOR_TITLE = Color(Color.YELLOW)
COLOR_HEADER = Color(Color.CYAN)
COLOR_WHITE = Color(Color.BRIGHT_WHITE)
COLOR_PLANNED = Color(Color.BRIGHT_BLACK)
COLOR_STARTED = Color(226)
COLOR_FINISHED = Color(Color.BRIGHT_BLUE)
COLOR_DELIVERED = Color(208)
COLOR_ACCEPTED = Color(Color.BRIGHT_GREEN)
COLOR_REJECTED = Color(Color.BRIGHT_RED)
2018-04-03 10:56:07 +00:00
def _format_state(state: str) -> str:
STATES = {
'accepted': COLOR_ACCEPTED.format('accepted'),
'rejected': COLOR_REJECTED.format('rejected'),
'delivered': COLOR_DELIVERED.format('delivered'),
'finished': COLOR_FINISHED.format('finished'),
'started': COLOR_STARTED.format('started'),
'planned': COLOR_PLANNED.format('planned'),
'unstarted': COLOR_PLANNED.format('unstarted'),
2018-04-03 10:56:07 +00:00
}
return STATES[state]
def _get_persons(token: str, project_id: int) -> Dict[int, Dict[str, Any]]:
memberships = api.projects.get_memberships(token, project_id)
persons: Dict[int, Dict[str, Any]] = {}
for membership in memberships:
person = membership['person']
persons[person['id']] = person
return persons