def pomodoro(self):
if not self._initialized:<EOL><INDENT>self._init()<EOL><DEDENT>cached_until = self.py3.time_in(<NUM_LIT:0>)<EOL>if self._running:<EOL><INDENT>self._time_left = ceil(self._end_time - time())<EOL>time_left = ceil(self._time_left)<EOL><DEDENT>else:<EOL><INDENT>time_left = ceil(self._time_left)<EOL><DEDENT>vals = {"<STR_LIT>": int(time_left), "<STR_LIT>": int(ceil(time_left / <NUM_LIT>))}<EOL>if self.py3.format_contains(self.format, "<STR_LIT>"):<EOL><INDENT>hours, rest = divmod(time_left, <NUM_LIT>)<EOL>mins, seconds = divmod(rest, <NUM_LIT>)<EOL>if hours:<EOL><INDENT>vals["<STR_LIT>"] = u"<STR_LIT>" % (<EOL>hours,<EOL>self.format_separator,<EOL>mins,<EOL>self.format_separator,<EOL>seconds,<EOL>)<EOL><DEDENT>else:<EOL><INDENT>vals["<STR_LIT>"] = u"<STR_LIT>" % (mins, self.format_separator, seconds)<EOL><DEDENT><DEDENT>if self.py3.format_contains(self.format, "<STR_LIT:bar>"):<EOL><INDENT>vals["<STR_LIT:bar>"] = self._setup_bar()<EOL><DEDENT>formatted = self.format.format(**vals)<EOL>if self._running:<EOL><INDENT>if self._active:<EOL><INDENT>format = self.format_active<EOL><DEDENT>else:<EOL><INDENT>format = self.format_break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if self._active:<EOL><INDENT>format = self.format_stopped<EOL><DEDENT>else:<EOL><INDENT>format = self.format_break_stopped<EOL><DEDENT>cached_until = self.py3.CACHE_FOREVER<EOL><DEDENT>response = {<EOL>"<STR_LIT>": format.format(<EOL>breakno=self._break_number, format=formatted, **vals<EOL>),<EOL>"<STR_LIT>": cached_until,<EOL>}<EOL>if self._alert:<EOL><INDENT>response["<STR_LIT>"] = True<EOL>self._alert = False<EOL><DEDENT>if not self._running:<EOL><INDENT>response["<STR_LIT>"] = self.py3.COLOR_BAD<EOL><DEDENT>else:<EOL><INDENT>if self._active:<EOL><INDENT>response["<STR_LIT>"] = self.py3.COLOR_GOOD<EOL><DEDENT>else:<EOL><INDENT>response["<STR_LIT>"] = self.py3.COLOR_DEGRADED<EOL><DEDENT><DEDENT>return response<EOL>
Pomodoro response handling and countdown