Ejemplo n.º 1
0
    def print(self):
        self.simple_summary.print()
        p = Printer()
        p.newline()
        p.add_header(f"Summary For {self.area_name}")
        p.newline()

        minimum = None
        maximum = None
        average = datetime.timedelta()

        for entry in self.area_time_map[self.area]:
            if minimum is None or minimum > entry:
                minimum = entry
            if maximum is None or maximum < entry:
                maximum = entry
            average += entry

        average = average / len(self.area_time_map[self.area])

        p.add(
            f"The lowest recorded entry for {self.area_name} is ",
            f"{utils.format_time_delta(minimum)}.",
        )
        p.add(
            f"The highest recorded entry for {self.area_name} is ",
            f"{utils.format_time_delta(maximum)}.",
        )
        p.add(
            f"The average entry for {self.area_name} is ",
            f"{utils.format_time_delta(average)}.",
        )

        p.newline()
        p.add_header(f"Entry Time Distribution for {self.area_name}")
        p.newline()
        box = (BoxPlot(self.area_time_map).set_max_width(
            utils.max_width(self.config.get_max_graph_width())
        ).set_exclude_list(
            self.config.get_exclude_from_entry_time_distribution()).generate())
        for row in box:
            p.add_nowrap(row)
        p.newline()
        p.add_header("LAST {0} ENTRIES".format(len(self.last_entries)))
        p.newline()
        for entry in self.last_entries:
            if self.config.get_use_wending():
                start_date = entry.start.strftime("{daeg} {month} {gere}")
            else:
                start_date = entry.start.strftime("%d %b %Y")
            p.add(*utils.get_rendered_string(
                entry.area,
                self.config.get_area(entry.area),
                start_date,
                self.config.get_object_name(entry.area, entry.obj),
                utils.time_diff(entry.start, entry.end),
                entry.purpose,
            ))
        p.print()
Ejemplo n.º 2
0
 def print(self):
     self.simple_summary.print()
     p = Printer()
     p.newline()
     p.add_header("Total Time Logged Per Area")
     p.newline()
     # Sum all the timedeltas for the summary graph
     summary_time_map = dict(
         map(
             lambda x: (x[0], sum(x[1], datetime.timedelta())),
             self.area_time_map.items(),
         )
     )
     graph = (
         SummaryGraph(summary_time_map)
         .set_max_width(utils.max_width(self.config.max_graph_width))
         .set_exclude_list(self.config.exclude_from_total_time)
         .generate()
     )
     for row in graph:
         p.add_nowrap(row)
     p.newline()
     p.add_header("ENTRY TIME DISTRIBUTION PER AREA")
     p.newline()
     box = (
         BoxPlot(self.area_time_map)
         .set_max_width(utils.max_width(self.config.max_graph_width))
         .set_exclude_list(self.config.exclude_from_entry_time_distribution)
         .generate()
     )
     for row in box:
         p.add_nowrap(row)
     p.newline()
     p.add_header("LAST {0} ENTRIES".format(len(self.last_entries)))
     p.newline()
     for entry in self.last_entries:
         if self.config.use_wending:
             start_date = entry.start.strftime("{daeg} {month} {gere}")
         else:
             start_date = entry.start.strftime("%d %b %Y")
         p.add(
             *utils.get_rendered_string(
                 entry.area,
                 self.config.get_area(entry.area),
                 start_date,
                 self.config.get_object_name(entry.area, entry.obj),
                 utils.time_diff(entry.start, entry.end),
                 entry.purpose,
             )
         )
     p.print()
Ejemplo n.º 3
0
 def __str__(self):
     date_display = (self.from_date.strftime("{daeg} {month} {gere}")
                     if self.config.use_wending else
                     self.from_date.strftime("%d %b %Y"))
     duration = utils.time_diff(self.from_date, self.to_date)
     rendered_string = utils.get_rendered_string(
         self.area,
         self.config.get_area(self.area),
         date_display,
         self.config.get_object_name(self.area, self.object),
         duration,
         self.purpose,
     )
     return "".join(str(s) for s in rendered_string)
Ejemplo n.º 4
0
 def input_duration(self):
     from_date = None
     to_date = None
     while from_date is None and to_date is None:
         while from_date is None:
             from_input = prompt("From :: ", vi_mode=True)
             from_date = self.convert_input_date(from_input)
         while to_date is None:
             to_input = prompt("To :: ", vi_mode=True)
             to_date = self.convert_input_date(to_input)
         if from_date >= to_date:
             print("Invalid Duration :: {0}".format(
                 utils.time_diff(from_date, to_date)))
             from_date = None
             to_date = None
     return from_date, to_date
Ejemplo n.º 5
0
    def gather_inputs(self):
        Printer().newline().add_header("Area").newline().add("[ {0} ]".format(
            " // ".join(self.config.get_areas().keys()))).newline().print()
        area = self.input_area()
        if area in self.config.get_project_areas():
            Printer().newline().add_header("Project").newline(
            ).add("[ {0} ]".format(" // ".join(
                sorted(self.config.get_projects().keys())))).newline().print()
            object = self.input_project_object()
        else:
            Printer().newline().add_header("Object").newline().print()
            object = self.input_non_project_object(area)
        Printer().newline().add_header("Duration").newline().print()
        from_date, to_date = self.input_duration()
        time_diff = utils.time_diff(from_date, to_date)
        print()
        if self.config.get_use_wending:
            date_display = from_date.strftime("{daeg} {month} {gere}")
        else:
            date_display = from_date.strftime("%d %b %Y")
        if area in self.config.get_project_areas():
            Printer().newline().add_header("Purpose").newline().print()
            purpose = self.input_purpose()
        else:
            purpose = None
        utils.print_rendered_string(
            area,
            self.config.get_areas()[area],
            date_display,
            self.config.get_object_name(area, object),
            time_diff,
            purpose,
        )
        confirmation = prompt("Is this correct? (y/n) :: ", vi_mode=True)
        if confirmation.lower() == "y":
            return {
                "area": area,
                "object": object,
                "start": from_date,
                "end": to_date,
                "purpose": purpose,
            }

        else:
            return None