Esempio n. 1
0
def update_hours(days):
    for date in days.iterkeys():
        # New Keyholders get boosted to the median
        for key in tif.Keyholder.keyholders.itervalues():
            if key.start_date == date:
                key.credits = tif.Keyholder.keyholders['MED'].credits
        # And then we add the work on that day
        for record in days[date]:
            record['key'].add_work(
                tif.Credit(date, record['minutes'], record['flags']))
        old = tif.last_median()  # in minutes
        new = tif.compute_median()
        the_median = tif.from_initials(tif.MEDIAN)
        while ((new - old) >= tif.MEDIAN_INCREMENT):
            the_median.add_work(tif.Credit(date, tif.MEDIAN_INCREMENT))
            old = tif.last_median()
            for key in tif.Keyholder.keyholders.itervalues():
                if key.active_on(date) and key.gets_vacation(date):
                    key.add_work(tif.Credit(date, tif.MEDIAN_INCREMENT, "a"))
                    print "%s gets %d minutes of vacation credit on %r." % (
                        key.initials, tif.MEDIAN_INCREMENT.seconds / 60, date)
        old = tif.last_median()
        while (old >= tif.ROTATION_MAX):
            the_median.add_lameness(
                tif.Credit(date, tif.ROTATION_MAX - tif.ROTATION_MIN))
            minmed = tif.min_median_date()
            for key in tif.active_keys(date):
                key.add_lameness(
                    tif.Credit(date, tif.ROTATION_MAX - tif.ROTATION_MIN))
                key.expire_lameness(minmed)
            old = tif.last_median()
            print "Chart rotates, median moves back to %s on %s." % (
                tif.to_hours(tif.last_median()), date)
Esempio n. 2
0
def update_hours(days):
    for date in days.iterkeys():
        # New Keyholders get boosted to the median
        for key in tif.Keyholder.keyholders.itervalues(): 
            if key.start_date == date:
                key.credits = tif.Keyholder.keyholders['MED'].credits
        # And then we add the work on that day
        for record in days[date]:
            record['key'].add_work(tif.Credit(date,
                                              record['minutes'],
                                              record['flags']))
        old = tif.last_median() # in minutes
        new = tif.compute_median()
        the_median = tif.from_initials(tif.MEDIAN)
        while ((new - old) >= tif.MEDIAN_INCREMENT):
            the_median.add_work(tif.Credit(date,
                                           tif.MEDIAN_INCREMENT))
            old = tif.last_median()
            for key in tif.Keyholder.keyholders.itervalues():
                if key.active_on(date) and key.gets_vacation(date):
                    key.add_work(tif.Credit(date,
                                            tif.MEDIAN_INCREMENT,
                                            "a"))
                    print "%s gets %d minutes of vacation credit on %r." % (key.initials, tif.MEDIAN_INCREMENT.seconds/60, date)
        old = tif.last_median()
        while (old >= tif.ROTATION_MAX):
            the_median.add_lameness(tif.Credit(date,
                                               tif.ROTATION_MAX - tif.ROTATION_MIN))
            minmed = tif.min_median_date()
            for key in tif.active_keys(date):
                key.add_lameness(tif.Credit(date,
                                            tif.ROTATION_MAX - tif.ROTATION_MIN))
                key.expire_lameness(minmed)
            old = tif.last_median()
            print "Chart rotates, median moves back to %s on %s." % (tif.to_hours(tif.last_median()), date)
Esempio n. 3
0
        while ((new - old) >= tif.MEDIAN_INCREMENT):
            the_median.add_work(tif.Credit(date, tif.MEDIAN_INCREMENT))
            old = tif.last_median()
            for key in tif.Keyholder.keyholders.itervalues():
                if key.active_on(date) and key.gets_vacation(date):
                    key.add_work(tif.Credit(date, tif.MEDIAN_INCREMENT, "a"))
                    print "%s gets %d minutes of vacation credit on %r." % (
                        key.initials, tif.MEDIAN_INCREMENT.seconds / 60, date)
        old = tif.last_median()
        while (old >= tif.ROTATION_MAX):
            the_median.add_lameness(
                tif.Credit(date, tif.ROTATION_MAX - tif.ROTATION_MIN))
            minmed = tif.min_median_date()
            for key in tif.active_keys(date):
                key.add_lameness(
                    tif.Credit(date, tif.ROTATION_MAX - tif.ROTATION_MIN))
                key.expire_lameness(minmed)
            old = tif.last_median()
            print "Chart rotates, median moves back to %s on %s." % (
                tif.to_hours(tif.last_median()), date)


if __name__ == '__main__':
    tif.load()
    print "Median range starts at %s." % tif.min_median_date()
    print "Last date of record is %s." % tif.max_date()
    days = read_hours_files(sys.argv[1:])
    update_hours(days)
    tif.write_credits()
    tif.write_debits()
Esempio n. 4
0
        while ((new - old) >= tif.MEDIAN_INCREMENT):
            the_median.add_work(tif.Credit(date,
                                           tif.MEDIAN_INCREMENT))
            old = tif.last_median()
            for key in tif.Keyholder.keyholders.itervalues():
                if key.active_on(date) and key.gets_vacation(date):
                    key.add_work(tif.Credit(date,
                                            tif.MEDIAN_INCREMENT,
                                            "a"))
                    print "%s gets %d minutes of vacation credit on %r." % (key.initials, tif.MEDIAN_INCREMENT.seconds/60, date)
        old = tif.last_median()
        while (old >= tif.ROTATION_MAX):
            the_median.add_lameness(tif.Credit(date,
                                               tif.ROTATION_MAX - tif.ROTATION_MIN))
            minmed = tif.min_median_date()
            for key in tif.active_keys(date):
                key.add_lameness(tif.Credit(date,
                                            tif.ROTATION_MAX - tif.ROTATION_MIN))
                key.expire_lameness(minmed)
            old = tif.last_median()
            print "Chart rotates, median moves back to %s on %s." % (tif.to_hours(tif.last_median()), date)

if __name__=='__main__':
    tif.load()
    print "Median range starts at %s." % tif.min_median_date()
    print "Last date of record is %s." % tif.max_date()
    days = read_hours_files(sys.argv[1:])
    update_hours(days)
    tif.write_credits()
    tif.write_debits()