diff --git a/input/institutes/theo4 b/input/institutes/theo4 index fb81cde03a9873c08dedc8ba9b5aaf73106d4259..cb5cad20e125162ac21060ea4164dac86c119af1 100644 --- a/input/institutes/theo4 +++ b/input/institutes/theo4 @@ -3,5 +3,4 @@ street = "Staudtstraße 7" city = "Erlangen" postcode = "91058" faculty = "nat" -logo = "input/figures/theo4-logo.pdf" - +logo = "input/figures/nat-logo.pdf" diff --git a/python/arbeitsstundenzettel.py b/python/arbeitsstundenzettel.py index efa97a4d96c400a74f9c8cdd3436f418e191441e..462b1f0af47712aff141becbc98be369275229fc 100644 --- a/python/arbeitsstundenzettel.py +++ b/python/arbeitsstundenzettel.py @@ -111,7 +111,7 @@ def move_filled_week(list_of_workinghours, workingday_list_position, list_of_fil def make_up_workinghours(month, start, end, workhours_per_week, workdays_per_week, already_worked = 0): - + full_months = diff_full_months(start, end) months = diff_months(start, end) weeks = diff_weeks(start, end) @@ -133,7 +133,7 @@ def make_up_workinghours(month, start, end, workhours_per_week, workdays_per_wee print("Urlaubsanspruch in Stunden: ", holidayhours_total) print("Urlaubstage: ", holidaydays_total) print("") - + full_date_list = [(start + dt.timedelta( days = x )).date() for x in range(0, days)] holiday_list = holidays.Holidays(start.year, 'BY').get_holiday_list()[0] + holidays.Holidays(end.year, 'BY').get_holiday_list()[0] @@ -141,8 +141,9 @@ def make_up_workinghours(month, start, end, workhours_per_week, workdays_per_wee global start_time_earliest global start_time_latest global preferred_weekdays + global fixed_times_weekdays global exclude_list - + timestep = 0.5 start_time_earliest = 9 start_time_latest = 12 @@ -151,7 +152,7 @@ def make_up_workinghours(month, start, end, workhours_per_week, workdays_per_wee exclude_list = [] if advanced_settings: - + timestep = input( '''Working hours are distributed over random days by adding a certain amount of time to them. @@ -181,7 +182,7 @@ Must be integer [0:23]. Defaults to 9. > ''' ) - + if start_time_earliest != "": start_time_earliest = int(start_time_earliest) else: @@ -193,16 +194,16 @@ Must be integer [0:23] >= earliest start time. Defaults to 12. > ''' ) - + if start_time_latest != "": start_time_latest = int(start_time_latest) else: start_time_latest = 12 if start_time_latest <= start_time_earliest: - print("Lastest start time before easlierst start time. I will continue with easliest start time + 2.") + print("Lastest start time before earliest start time. I will continue with earliest start time + 2.") start_time_latest = start_time_earliest + 2 - + preferred_weekdays = input( '''Which weekdays do you prefer to work on? Must be comma separated list of integers [0:5]. Defaults to [0,1,2,3,4]. @@ -219,7 +220,7 @@ Example Meaning: Your preferred weekdays are Monday, Tuesday and Wednesday. > ''' ) - + if preferred_weekdays != "": preferred_weekdays = [int(x) for x in preferred_weekdays.replace(" ","").split(",")] else: @@ -240,13 +241,69 @@ Example Meaning: You worked 3 hours on 12.01.2019 and 5 hours on 13.01.2019. > ''' ) + if len(preferred_weekdays) < workdays_per_week: + print("Not enough preferred weekdays given. I will continue with default.") + preferred_weekdays = [0,1,2,3,4] + + preset_list = input( +'''Are there any specific dates you want to preset the amount of hours you worked? +Must be comma separated list of hours mapped to dates. Defaults to []. + +Example Input: 3 => 12.01.2019, 5 => 13.01.2019 +Example Meaning: You worked 3 hours on 12.01.2019 and 5 hours on 13.01.2019. + +> ''' + ) + + + + fixed_times_weekdays = input( +'''Which weekdays do you prefer to work on? +Must be comma separated list of touples of integers [0:5] (days) and times hh-hh separeted by "=>". Defaults to []. + + 0 = Monday + 1 = Tuesday + 2 = Wednesday + 3 = Thursday + 4 = Friday + 5 = Saturday + +Example Input: 3 => 13-16 +Example Meaning: You always work thursday from 13:00 to 16:00 + +> ''' + ) + + if fixed_times_weekdays != "": + # split the days + fixed_times_weekdays = [x for x in fixed_times_weekdays.replace(" ","").split(",")] + day_time_dict = dict() + for day_time_touple in fixed_times_weekdays: + day, times = day_time_touple.split("=>") + + day = int(day) + + times = times.split("-") + times = [int(t) for t in times] + tstart = min(times) + tlength = max(times)-tstart + if day in day_time_dict: + print("Day {} more than once in list, ignoring all occurances except the first one.".format(day)) + else: + day_time_dict[day] = [tstart, tlength] + fixed_times_weekdays = day_time_dict + + else: + fixed_times_weekdays = dict() + + if preset_list != "": preset_duration = [float(x.split("=>")[0]) for x in preset_list.replace(" ","").split(",")] preset_workingdays = [dt.datetime.strptime(x.split("=>")[1], "%d.%m.%Y").date() for x in preset_list.replace(" ","").split(",")] preset_list = [preset_workingdays, preset_duration] else: preset_list = [[],[]] - + exclude_list = input( '''Are there any specific dates you want to exclude from the list of working days? Must be space separated list of dates. Defaults to []. @@ -279,19 +336,28 @@ Example Meaning: Those three dates are treated like public holidays. made_up_workinghours = [] make_up_workinghours = [] - + for i in range(len(date_list)): - + workingday = date_list[i] - make_up_start_time = random.randint(start_time_earliest,start_time_latest) - make_up_end_time = random.randint(16,20) + + make_up_duration = 0.0 + + if workingday.weekday() in fixed_times_weekdays: + tstart, tlength = fixed_times_weekdays[workingday.weekday()] + make_up_start_time = tstart + make_up_end_time = random.randint(tstart+tlength,20) + make_up_duration = tlength + else: + make_up_start_time = random.randint(start_time_earliest,start_time_latest) + make_up_end_time = random.randint(16,20) + if workingday in preset_list[0]: ind = preset_list[0].index(workingday) make_up_duration = preset_list[1][ind] - else: - make_up_duration = 0.0 + make_up_break = sp.random.choice([0, 0.25, 0.5, 0.75, 1.0], p=[0.8, 0.025, 0.075, 0.025, 0.075]) - + make_up_workinghours.append([workingday]) make_up_workinghours[i].append(workingday.strftime("%d.%m.%Y")) make_up_workinghours[i].append(cal.day_abbr[workingday.weekday()]) @@ -304,64 +370,63 @@ Example Meaning: Those three dates are treated like public holidays. make_up_workinghours[i].append(make_up_break) make_up_workinghours[i].append(float2duration(make_up_break)) make_up_workinghours[i].append('') - for preset_workingday in preset_list[0]: - + preset_workingday = [workingday[0] for workingday in make_up_workinghours].index(preset_workingday) make_up_workinghours, made_up_workinghours = move_filled_day(make_up_workinghours, preset_workingday, made_up_workinghours) used_workinghours = 0 + sum(preset_list[1]) while (used_workinghours < workhours_total): - + if (used_workinghours + timestep > workhours_total): timestep = timestep / 2 if (len(make_up_workinghours) == 0): break - - random_workingday = random.randint( 0, len(make_up_workinghours) - 1 ) + + random_workingday = random.randint( 0, len(make_up_workinghours) - 1 ) check_week = check_week_hours(make_up_workinghours, random_workingday, timestep, made_up_workinghours) check_day = check_day_hours(make_up_workinghours, random_workingday, timestep) - + if (check_week == True and check_day == True): - + make_up_duration = make_up_workinghours[random_workingday][7] + timestep make_up_workinghours[random_workingday][7] = make_up_duration make_up_workinghours[random_workingday][8] = float2duration(make_up_duration) used_workinghours = used_workinghours + timestep - + elif (check_week == True and check_day == False): - + make_up_workinghours, made_up_workinghours = move_filled_day(make_up_workinghours, random_workingday, made_up_workinghours) - + else: - + make_up_workinghours, made_up_workinghours = move_filled_week(make_up_workinghours, random_workingday, made_up_workinghours) - + if (used_workinghours == workhours_total): - - remaining_filled_days = [filled_day for filled_day in make_up_workinghours if filled_day[7] != 0] - + + remaining_filled_days = [filled_day for filled_day in make_up_workinghours if filled_day[7] != 0] + for j in range(len(remaining_filled_days)): - + made_up_workinghours.append(remaining_filled_days[j]) - + break - + for i in range(len(made_up_workinghours)): - + made_up_start_time = made_up_workinghours[i][3] made_up_duration = made_up_workinghours[i][7] made_up_break = made_up_workinghours[i][9] made_up_end_time = made_up_start_time + made_up_duration + made_up_break - + made_up_workinghours[i][5] = made_up_end_time made_up_workinghours[i][6] = float2time(made_up_end_time) - + used_holidayhours = 0 while (used_holidayhours < holidayhours_total): @@ -372,11 +437,11 @@ Example Meaning: Those three dates are treated like public holidays. made_up_workinghours[random_holidayday][11] = "Urlaub" used_holidayhours = used_holidayhours + made_up_workinghours[random_holidayday][7] - + if (used_workinghours == workhours_total and used_holidayhours == holidayhours_total): - + break - + if retry == 0: print( '''I finished making up working hours for you. @@ -517,7 +582,7 @@ Currently implemented are: med: Faculty of Medicine nat: Faculty of Sciences tech: Faculty of Engeneering - + > ''' ) @@ -599,12 +664,12 @@ if filename == '': month = (start.month + m - 1) % 12 + 1 monthname = cal.month_name[month] - + print(month) entries = [day for day in workinghours[0] if day[0].month == month] entries.sort() - + year = entries[0][0].year total = 0 @@ -666,7 +731,7 @@ You can find it in the pdf-folder, it is named ''' + filename + '''.pdf.''' zippy.write(filename + '.csv') os.rename(filename + '.zip', "../output/" + filename + '.zip') - + os.unlink(filename + '.pdf') os.unlink(filename + '.csv') os.unlink(filename + '.tex') @@ -688,7 +753,7 @@ Want me to redo my work (no further input needed)? (yes/no) should_i_make_up_workinghours = False else: - + workinghours = [] with open(filename, 'r') as csvfile: @@ -699,7 +764,7 @@ else: for row in file: row = [x.strip(' ') for x in row] workinghours.append(row) - + if (dt.datetime.strptime(workinghours[0][0], "%Y-%m-%d").date() - start).days < 0: print("Es wurden Daten angegeben, die vor dem Beginn des Arbeitsvertrages liegen!") elif (dt.datetime.strptime(workinghours[0][0], "%Y-%m-%d").month - start.month) > 0: @@ -720,4 +785,3 @@ else: made_up = make_up_workinghours(2, start, end, workhours_per_week, workdays_per_week) workinghours.append(made_up) -