def init_data():
    global current_schedule
    global current_line
    global current_run
    global fridays
    global unused_fridays
    global production_lines
    global schedules
    global schedule_directory
    global script_root_directory
    current_schedule = None
    current_line = None
    current_run = None
    fridays = generate_fridays()
    unused_fridays = [0] * len(
        fridays
    )  # this is a bit vector to keep track of the next avaialble friday for auto schedule creation
    production_lines = entity_loader.build_lines(
        script_root_directory)  # load production line data
    # get existing schedules
    print("\nLoading previous schedules...")
    prev_schedules = os.listdir(schedule_directory)
    for ps in prev_schedules:
        ps.rstrip('.csv')
    schedules = schedule_loader.build_multiple_schedules(
        prev_schedules, schedule_directory)
    # process loaded schedules
    if len(schedules) > 0:
        print("\n" + str(len(schedules)) + " schedules loaded:")
        for s in schedules:
            print(s.to_pretty_string())
            mark_date_as_used(s.date)  # mark availability
def init_data():
    global current_schedule
    global current_line
    global current_run
    global fridays
    global unused_fridays
    global production_lines
    global schedules
    global schedule_directory
    global script_root_directory
    current_schedule = None
    current_line = None
    current_run = None
    fridays = generate_fridays()
    unused_fridays = [0] * len(fridays) # this is a bit vector to keep track of the next avaialble friday for auto schedule creation
    production_lines = entity_loader.build_lines(script_root_directory) # load production line data
    # get existing schedules
    print ("\nLoading previous schedules...")
    prev_schedules = os.listdir(schedule_directory)
    for ps in prev_schedules:
        ps.rstrip('.csv')
    schedules = schedule_loader.build_multiple_schedules(prev_schedules, schedule_directory)
    # process loaded schedules
    if len(schedules) > 0:   
        print ("\n"+str(len(schedules))+" schedules loaded:")
        for s in schedules:
            print(s.to_pretty_string())
            mark_date_as_used(s.date) # mark availability
def load_schedules():
    global schedules
    global script_root_directory
    working_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) # this will return the filepath of the src directory
    if working_dir.endswith('/src'): # unix 
        script_root_directory = working_dir[:-4] # removes the final four characters
        schedule_directory = script_root_directory + '/data/schedules/' #this works for Mac, not sure yet about windows
    elif working_dir.endswith('\\src'): #windows
        script_root_directory = working_dir[:-4] # removes the final four characters
        schedule_directory = script_root_directory + '\\data\\schedules\\'
    else:
        print ("Loading error: script not launched from within src directory")
        sys.exit()

    prev_schedules = os.listdir(schedule_directory)
    schedules = s_loader.build_multiple_schedules(prev_schedules, schedule_directory)
    print ("Schedules loaded.")
def load_schedules():
    global schedules
    global script_root_directory
    working_dir = os.path.dirname(
        os.path.abspath(inspect.getfile(inspect.currentframe()))
    )  # this will return the filepath of the src directory
    if working_dir.endswith('/src'):  # unix
        script_root_directory = working_dir[:
                                            -4]  # removes the final four characters
        schedule_directory = script_root_directory + '/data/schedules/'  #this works for Mac, not sure yet about windows
    elif working_dir.endswith('\\src'):  #windows
        script_root_directory = working_dir[:
                                            -4]  # removes the final four characters
        schedule_directory = script_root_directory + '\\data\\schedules\\'
    else:
        print("Loading error: script not launched from within src directory")
        sys.exit()

    prev_schedules = os.listdir(schedule_directory)
    schedules = s_loader.build_multiple_schedules(prev_schedules,
                                                  schedule_directory)
    print("Schedules loaded.")