예제 #1
0
파일: in.py 프로젝트: davisd/timebook3
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
파일: kill.py 프로젝트: davisd/timebook3
def command(timebook, config, sheet, **kwargs):
    # get the db
    cfg=parse_config(config)
    db=Database(timebook, cfg)

    switch_to_default=False

    current_sheet = db.get_current_sheet()
    if not sheet or sheet == current_sheet:
        switch_to_default=True
    if not sheet:
        sheet = current_sheet

    try:
        confirm=(input('Delete timesheet "%s"? [y/N]: ' % sheet).strip().lower() == 'y')
    except(KeyboardInterrupt, EOFError):
        confirm=False

    if not confirm:
        print('cancelled')
        return None

    kill(db, sheet)
    if switch_to_default:
        commands.switch.switch(db, 'default')
예제 #3
0
파일: money.py 프로젝트: davisd/timebook3
def command(timebook, config, rate, sheet, **kwargs):
    # get the db
    cfg=parse_config(config)
    db=Database(timebook, cfg)

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

    money(db, sheet, rate)
예제 #4
0
파일: end.py 프로젝트: davisd/timebook3
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)
예제 #5
0
파일: display.py 프로젝트: davisd/timebook3
def command(timebook, config, sheet, start, end, billing, format, money, **kwargs):
    # get the db
    cfg=parse_config(config)
    db=Database(timebook, cfg)

    sheet = sheet or db.get_current_sheet()

    start_timestamp = parse_date_time(start) if start else None
    end_timestamp = parse_date_time(end) if end else None

    if billing:
        if start or end:
            parser.error('if you specify --billing, you cannot specify a start ' \
                'or end ')

        billing_time = db.get_billing_start_time(sheet)

        if billing_time:
            start_timestamp = billing_time

    display(db, sheet, start_timestamp, end_timestamp, format, money)
예제 #6
0
파일: put.py 프로젝트: davisd/timebook3
def command(timebook, config, switch, start_time, end_time, 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_in=parse_date_time(start_time)
    timestamp_out=parse_date_time(end_time)

    current_start = db.get_start_time(sheet)
    if current_start:
        if timestamp_out > current_start[1]:
            parser.error('cannot put this entry into the timesheet because ' \
                'it may cause overlap with the active timer - clock out first')

    message = ' '.join(messages)

    put(db, sheet, timestamp_in, timestamp_out, message)