Пример #1
0
def command(timebook, config, switch, out, at, resume, messages, **kwargs):
    # get the db
    cfg = parse_config(config)
    db = Database(timebook, cfg)

    if switch:
        commands.switch.switch(db, switch)
        sheet = switch
    else:
        sheet = db.get_current_sheet()

    timestamp = parse_date_time_or_now(at)

    if out:
        commands.out.out(db, timestamp)

    if db.get_active_info(sheet):
        parser.error("the timesheet is already active")

    message = " ".join(messages)

    most_recent_clockout = db.get_most_recent_clockout(sheet)
    if most_recent_clockout:
        (previous_timestamp, previous_description) = most_recent_clockout
        if timestamp < previous_timestamp:
            parser.error("error: time periods could end up overlapping")
        if resume:
            if message:
                parser.error('"--resume" sets the note, so you cannot also ' "supply the message")
            message = previous_description

    _in(db, sheet, timestamp, message)
Пример #2
0
def command(timebook, config, at, sheet, **kwargs):
    # get the db
    cfg=parse_config(config)
    db=Database(timebook, cfg)

    sheet = sheet or db.get_current_sheet()
    timestamp = parse_date_time_or_now(at)

    if sheet not in db.get_sheet_names():
        parser.error('%s is not a known timesheet' % sheet)

    end(db, sheet, timestamp)