Пример #1
0
def execute():
    newRecordName = '{}-record.py'.format(helpers.date_stamp())

    settings['record'] = newRecordName

    content = "settings = {}".format(helpers.glue_updated_record(settings))

    newRecordBlueprint = '''{
	"current" : "",
	"projects" : {}
}'''
    print
    print "==========================================="
    print
    print "Creating new record file: {}".format(newRecordName)
    helpers.write_file(settings['record_url'] + newRecordName,
                       newRecordBlueprint)

    print '''
Updating settings file:

...
    "record" : "{}"
...
'''.format(newRecordName)
    print "==========================================="
    print
    # print os.path.realpath(__file__).replace('archive.py', '') + 'settings.py'
    # print json.dumps(content)
    helpers.write_file(
        os.path.realpath(__file__).replace('archive.py', '') + 'settings.py',
        content)
Пример #2
0
def execute():
    record = helpers.load_record()

    current = record['current']

    if current == "":
        msg.no_current_project()
    else:
        obj = {}
        spentList = []
        for item in record['projects'][current]['time']:
            spentList.append(item['spent'])
            if item['end'] == '':
                obj = item

        if len(obj) > 0:
            recordedTime = helpers.time_stamp()
            recordedDate = helpers.date_stamp()
            obj['end'] = recordedTime
            obj['spent'] = helpers.time_spent(obj['start'], obj['end'])
            obj['spent_date'] = recordedDate

            content = helpers.glue_updated_record(record)
            helpers.write_file(helpers.recordPath, content)

            msg.untracking_message(obj)
        else:
            msg.nothing_being_tracked()
Пример #3
0
def execute():
    record = helpers.load_record()

    current = record['current']
    if current == "":
        msg.no_current_project()
    else:
        description = record['projects'][current]['description']
        today = helpers.date_stamp()
        current_time = helpers.time_stamp()
        tt = '00:00'

        tracking = False
        for i in record['projects'][current]['time']:
            if i['end'] == '':
                tracking = True
            if i['start'][:-6] == today:
                s = i['spent']
                if s == '':
                    s = helpers.time_spent(i['start'], current_time)
                tt = helpers.calculate_time(tt, s)

        totalTime = helpers.calculate_total_time(
            record['projects'][current]['time'])

        msg.currentProject(current, description, totalTime, tt, tracking)
Пример #4
0
def execute():
    record = helpers.load_record()

    while True:
        projectSelection = msg.select_project_for_times(record)

        if projectSelection is 'x':
            break

        projectName = helpers.retrieve_project_name(
            projectSelection, helpers.project_list(record))

        totalTimeDict = helpers.calculate_total_time_daily(
            record['projects'][projectName]['time'])
        totalTime = helpers.calculate_total_time(
            record['projects'][projectName]['time'])

        print '''
===========================================

{title} ({total})
Description: {description}

Breakdown by Day:
-----------------'''.format(
            title=projectName,
            description=record['projects'][projectName]['description'],
            total=totalTime)
        i = 0
        for item in totalTimeDict:
            if item['date'] == '':
                item['date'] = "-- {} --".format(helpers.date_stamp())
                item['spent'] = "currently tracking"
            i += 1
            print '''
{itemNumber}.  Date:{date}
    Spent: {spent}

===========================================
'''.format(itemNumber=i, date=item['date'], spent=item['spent'])
    print
    print '[Finished]'
    print
Пример #5
0
def execute():
    record = helpers.load_record()

    projectName = record['current']

    if projectName == "":
        msg.no_current_project()
    else:
        totalTimeDict = helpers.calculate_total_time_daily(
            record['projects'][projectName]['time'])
        totalTime = helpers.calculate_total_time(
            record['projects'][projectName]['time'])

        print '''
===========================================

{title} ({total})
Description: {description}

Breakdown by Day:
-----------------'''.format(
            title=projectName,
            description=record['projects'][projectName]['description'],
            total=totalTime)
        i = 0
        for item in totalTimeDict:
            if item['date'] == '':
                item['date'] = "-- {} --".format(helpers.date_stamp())
                item['spent'] = "currently tracking"
            i += 1
            print '''
{itemNumber}.  Date: {date}
    Spent: {spent}'''.format(itemNumber=i,
                             date=item['date'],
                             spent=item['spent'])
        print
        print '[Finished]'
        print "==========================================="
        print