Example #1
0
def render_logged_holiday_log(log):
    for item in log:
        assert isinstance(item, LogItem)
        print u"{date} | {how_long} ({how_long_hours}) | {typ} | {descr}".format(
            date=item.when.strftime(settings.LOG_DATE_FORMAT),
            how_long=time_humanize(item.how_long, True),
            how_long_hours=time_humanize(item.how_long, True),
            typ=item.kind,
            descr=item.description,
        )
Example #2
0
def render(report):

    if len(report.issues_log) > 0:
        assert isinstance(report, Report)
        print u"############## ISSUES ({hours}) ################".format(hours=time_humanize(report.issues_secs, True))
        render_issues_log(report.issues_log)

    if len(report.additional_work_log) > 0:
        print u""
        print u"######### ADDITIONAL WORK ({hours}) ############".format(
            hours=time_humanize(report.additional_work_sec, True)
        )
        render_logged_holiday_log(report.additional_work_log)

    if (
        len(report.national_holidays_log) > 0
        or len(report.payed_holidays_log) > 0
        or len(report.unpayed_holidays_log) > 0
    ):
        print u""
        print u"############# HOLIDAYS ###############"
        if len(report.national_holidays_log) > 0:
            print u"National:"
            render_holiday_log(report.national_holidays_log)

        if len(report.payed_holidays_log) > 0:
            print u"Payed:"
            render_logged_holiday_log(report.payed_holidays_log)

        if len(report.unpayed_holidays_log) > 0:
            print u"Not payed:"
            render_logged_holiday_log(report.unpayed_holidays_log)

    print u""
    print u"#####################################"
    print (u"PRESENCE IN OFFICE = {presence:.2f}%".format(presence=100.0 * report.presence))
    print (u"EFFICIENCY = {x:.2f}%".format(x=100.0 * report.efficiency))
    print (
        u"TOTAL_ISSUES_TIME = {time} ({time_hours})".format(
            time=time_humanize(report.total_issues_time), time_hours=time_humanize(report.total_issues_time, True)
        )
    )
Example #3
0
def calc_total(json_response):
    total_time = 0
    log = []

    for issue in json_response["issues"]:
        summary = issue["fields"]["summary"]
        estimate = issue['fields']['aggregatetimeoriginalestimate']  # in seconds

        log.append(
            Issue(issue["key"], time_humanize(estimate), summary)
        )

        if type(estimate) == int:
            total_time += estimate

    return total_time, log
Example #4
0
def log(args):
    how_long = time_humanize(str_to_secs(args.t))
    description = args.m
    when = datetime.datetime.strptime(args.d, settings.LOG_DATE_FORMAT).date()
    typ = args.type

    try:
        os.makedirs(os.path.join(settings.LOG_DIR_PATH, "storage"))
    except OSError:
        pass

    log_path = get_log_file_path(month=when.month, year=when.year)

    with open(log_path, "a") as f:
        f.write(u"{when}{sep}{how_long}{sep}{typ}{sep}{description}\n".format(
            sep=settings.LOG_SEPARATOR,
            when=when.strftime(settings.LOG_DATE_FORMAT),
            how_long=how_long,
            description=description,
            typ=typ,
        ))