예제 #1
0
def terminate_project():
    print(
        "Terminated projects will be removed from current project file and written to terminated projects file"
    )
    choice = input(
        "Press Y or YES to begin termination process, any other key to go back to menu\n"
    )
    choice_list = ['y', 'yes', 'Y', 'YES']
    if choice in choice_list:
        search = 'Project ID: ' + (
            input("Enter Project ID you wish to terminate:"))
        search = search.rstrip('\n')
        list = file_manipuli.txt_file_to_list('Projects.txt')
        termiList = file_manipuli.txt_file_to_list('TermiProjects.txt')
        try:
            idIndex = int(list.index(search))
        except ValueError:
            print('Project Id not found!')
            return ()
        for i in range(SIZE_OF_ENTRY_IN_PROJECT_LIST):
            termiList.append(list[idIndex])
            list.remove(list[idIndex])
        global currentDate
        termiList.append("Project termination date: " + currentDate)
        file_manipuli.update_file_from_DictList(list, 'Projects.txt')
        file_manipuli.update_file_from_DictList(termiList, 'TermiProjects.txt')
        print(search + " has been terminated!")
예제 #2
0
def get_time_list(lookFor):
    list = file_manipuli.txt_file_to_list('TermiProjects.txt')
    handleList = []
    flag = [0, 0]
    for i in list:
        if (lookFor) in i:
            accDate = i.split(": ")
            accDay = int(accDate[1].split("/")[0])
            accMonth = int(accDate[1].split("/")[1])
            accYear = int(accDate[1].split("/")[2])
            accDateObj = datetime.date(accYear, accMonth, accDay)
            flag[0] = 1
        if ("Project termination date") in i:
            termiDate = i.split(": ")
            termiDay = int(termiDate[1].split("/")[0])
            termiMonth = int(termiDate[1].split("/")[1])
            termiYear = int(termiDate[1].split("/")[2])
            termDateObj = datetime.date(termiYear, termiMonth, termiDay)
            flag[1] = 1
        if flag == [1, 1]:
            handleTimeObj = termDateObj - accDateObj
            handleList.append(int(handleTimeObj.total_seconds() / 24 / 60 /
                                  60))
            flag = [0, 0]
    return handleList
예제 #3
0
def edit_project_details():
    search = 'Project ID: ' + (input("Enter Project ID you wish to edit:\n"))
    search = search.rstrip('\n')
    list = file_manipuli.txt_file_to_list('Projects.txt')
    try:
        idIndex = int(list.index(search))
    except ValueError:
        print('Project Id not found!')
        return ()
    repeatChoices = ['y', 'yes', 'Y', 'YES']
    repeat = 'y'
    while repeat in repeatChoices:
        choice = input(
            "choose action: \nPress D to edit due date\nPress N to edit name\n"
        )
        choice_list = ['d', 'D', 'date', 'Date', 'n', 'N', 'name', 'Name']
        if choice in ['d', 'D', 'date', 'Date']:
            print("Current " + list[idIndex + 3])
            date = input_validation.project_date_validation()
            list[idIndex + 3] = "Project due date: " + date
            print("Updated " + list[idIndex + 3])

        elif choice in ['n', 'N', 'name', 'Name']:
            print("Current " + list[idIndex + 1])
            name = input_validation.project_name_validation()
            list[idIndex + 1] = "Project name: " + name
            print("Updated " + list[idIndex + 1])
        else:
            print("Invalid input! please follow instructions")
        repeat = input(
            "Would you like to preform another action?\n(press Yes or Y to edit more details, anything else to save edited information and return to menu)\n"
        )
    file_manipuli.update_file_from_DictList(list, 'Projects.txt')
    print("All updates in: " + search +
          " has been succesfully made and written to Projects.txt!\n")
예제 #4
0
def get_mf_ratio():
    data_list=file_manipuli.txt_file_to_list('Employees.txt')
    length=len(data_list)
    i=0
    male_count=0
    female_count=0
    while i<length:
        if data_list[i].find('Male')!=-1:
            male_count+=1
        elif data_list[i].find('Female')!=-1:
            female_count+=1

        i+=1
    values = [male_count, female_count]
    Labels = ['male count', 'female count']
    explode = (0, 0.1)
    colors=['orange','pink']
    plt.pie(values, labels=Labels, explode=explode, startangle=120, autopct='%.1f%%',colors=colors)
    try:
        ratio=float(male_count/female_count)
    except ZeroDivisionError:
        print('No females were found in the company!')
        return

    plt.title('Male/Female ratio:\n'+str(ratio))

    plt.show()
예제 #5
0
def delete_employee(empl_filename,pass_filename):
    list = file_manipuli.txt_file_to_list(empl_filename)
    flag=0
    while flag==0:
        search =(input("Enter ID number to delete:"))
        try:
            index = int(list.index('ID number:'+search))
            flag=1
        except ValueError:
            print("Id wasn't found!")

    i = 0

    while i < ROWS_OF_INFO_PER_PERSON:  # כמספר השורות מידע על כל בן אדם
        list.remove(list[index])  # לא מעדכנים את האינדקס למחיקה כי לאחר כל מחיקה הרשימה מצטמצמת ומעדכנת אינדקסים
        i += 1
    file_manipuli.update_file_from_list(list,empl_filename,'t')

    pass_list=file_manipuli.binfile_to_list(pass_filename)
    i=0
    while i<len(pass_list):
        if pass_list[i].startswith(search):
            pass_list.remove(pass_list[i])
        i+=1

    file_manipuli.update_bin_file_from_list(pass_list,PASSWORD_FILE_GIVEN_NAME)
    print('The file has been updated!')
예제 #6
0
def show_projects(file, headline):
    print("projects in " + headline + " Projects file :")
    list = file_manipuli.txt_file_to_list(file)
    for i in list:
        if ("Project ID") in i:
            print("----------------------")
        print(i)
    print("----------------------")
예제 #7
0
def get_details_by_ID():
    search = 'Project ID: ' + (input("Enter Project ID to extract details:"))
    list = file_manipuli.txt_file_to_list('Projects.txt')
    try:
        idIndex = int(list.index(search))
    except (ValueError):
        print('Project Id not found!')
        return ()
    print(list[idIndex + 1])
    print(list[idIndex + 2])
    print(list[idIndex + 3])
예제 #8
0
def show_emp_name_list(empl_filename):
    list=file_manipuli.txt_file_to_list(empl_filename)
    emp_index=1
    i=1
    j=0
    print('Employees list:')
    while j<len(list):

        print(str(emp_index)+'.'+list[i+j].strip('Full name'))
        emp_index+=1
        j+=6
예제 #9
0
def get_email_by_name(empl_filename):
    search = 'Full name:'+ (input("Enter full name to extract email address:"))
    list = file_manipuli.txt_file_to_list(empl_filename)

    try:
        idIndex = int(list.index(search))

    except ValueError:
        print('Id not found!')

    print(list[idIndex + 3])
예제 #10
0
def get_phone_by_ID(empl_filename):
    search = 'ID number:' + (input("Enter ID number to extract phone number:"))
    list = file_manipuli.txt_file_to_list(empl_filename)

    try:
        idIndex = int(list.index(search))

    except ValueError:
        print('Id not found!')

    print(list[idIndex + 5])
예제 #11
0
def change_depart(empl_filename):
    list = file_manipuli.txt_file_to_list(empl_filename)
    search = 'ID number:'+(input("Enter ID number to update:"))
    try:
        idIndex = int(list.index(search))
    except ValueError:
        print("Id wasn't found!")
    new_dept= (input("Enter the new department:"))
    dept_index = int(idIndex + 3)
    list[dept_index] = 'Department:' + str(new_dept)
    file_manipuli.update_file_from_list(list,EMPLOYEES_FILE_GIVEN_NAME,'t')
    print("Department updated!\n")
예제 #12
0
def check_expiring_projects():
    global currentDate
    list = file_manipuli.txt_file_to_list('Projects.txt')
    noExpiring = True
    for i in list:
        if ("Project ID") in i:
            ID = i.split(": ")
        if ("Project name") in i:
            name = i.split(": ")
        if ("Project due date") in i:
            date = i.split(": ")
            if project_date_too_close(date[1]):
                noExpiring = False
                print(
                    "Warning! the following project is reaching it's due date (less than 7 days):"
                )
                print(ID)
                print(name)
                print(date)
    if noExpiring:
        print("No projects are due to this week")