def get_total_sum(self, entries): total_sum = datetime.timedelta(0) for d, entry in entries.items(): total_sum += self.get_total_sum_for_entry(entry) return dateutils.format_duration(total_sum)
def get_content(self, data): content = [] for client, client_info in data.items(): content.append('%s:%s%s' % (client.capitalize(), ' ' * (COLUMN_WIDTH - len(client)), dateutils.format_duration(client_info[DURATION]))) if client_info[TASKS] and self.tasks: content.append('\n%s' % ''.join(client_info[TASKS])) return content
def get_result(self, data_report): TOTAL = 'Total time' result = [] entry_dates = [elem for elem in data_report.keys()] entry_dates.sort() general_total = datetime.timedelta(0) for entry_date in entry_dates: current_data = data_report[entry_date] total_time = self.get_total_sum_for_entry(current_data) general_total += total_time result.append('\n# %s\n' % entry_date.strftime('%d/%m/%Y')) result = result + self.get_content(current_data) result.append('\n%s:%s%s' % ( TOTAL, ' ' * (COLUMN_WIDTH - len(TOTAL)), dateutils.format_duration(total_time) )) general_total = dateutils.format_duration(general_total) result.append('\nTOTAL: %s' % general_total) return result