示例#1
0
    def ListarProfessores(self, codigoEscola):
        conn = sqlite3.connect('university.db')
        cursor = conn.cursor()

        cursor.execute(
            """
        SELECT * FROM Professor
        WHERE codEscola = ?
        """, (codigoEscola, ))

        aux = list()
        res = cursor.fetchall()

        for i in res:
            cursor.execute(
                """
            SELECT * FROM ProfessorTurma
            WHERE matriculaProfessor = ?
            """, (i[1], ))

            aux2 = list()

            for j in cursor.fetchall():
                aux2.append(turma.Turma(j[0], j[1]))

            aux.append(professor.Professor(i[0], i[1], i[2], i[3], aux2))

        conn.close()

        return aux
示例#2
0
    def GetProfessor(self, username, password):
        conn = sqlite3.connect('university.db')
        cursor = conn.cursor()

        cursor.execute(
            """
        SELECT * FROM Professor
        WHERE matricula = ? AND password = ?
        """, (username, password))

        res = cursor.fetchall()

        cursor.execute(
            """
        SELECT * FROM ProfessorTurma
        WHERE matriculaProfessor = ?
        """, (username, ))

        aux = list()

        for i in cursor.fetchall():
            aux.append(turma.Turma(i[1], i[2]))

        conn.close()

        if (len(res) != 0):
            return professor.Professor(res[0][0], res[0][1], res[0][2],
                                       res[0][3], aux)
        return None
示例#3
0
    def GetProfessorByMatricula(self, codigo):
        conn = sqlite3.connect('university.db')
        cursor = conn.cursor()

        cursor.execute(
            """
        SELECT * FROM Professor
        WHERE matricula = ?
        """, (codigo, ))

        aux = cursor.fetchall()

        conn.close()

        if (len(aux) != 0):
            return professor.Professor(aux[0][0], aux[0][1], aux[0][2],
                                       aux[0][3])
        return None
示例#4
0
    def googleScholarSearch(self, num):
        # profile = webdriver.FirefoxProfile()
        # profile.set_preference('network.proxy.type', 1)
        # profile.set_preference('network.proxy.http', '127.0.0.1')
        # profile.set_preference('network.proxy.http_port', 17890)  # int
        # profile.update_preferences()
        # browser = webdriver.Firefox(firefox_profile=profile)

        browser = webdriver.Firefox()  # 初始化Firefox浏览器
        filename = '%d%s' % (num, 'nameIeeeNum.txt')
        f = open(filename, 'a')
        while not pageUrlQueue.empty():
            nameDs = pageUrlQueue.get().split('!!!')
            parts = nameDs[0].split('|')
            tempProfe = professor.Professor(parts[0])
            tempProfe.university = parts[1]
            tempProfe.ieeeNum = parts[2]
            tempProfe.citations = parts[3]
            tempProfe.h_index = parts[4]
            tempProfe.studyArea = parts[5]
            papers = nameDs[1].split('*@*')

            authorFind = False
            for paper in papers:
                paper = paper.strip()
                try:
                    browser.get(googleSchalarUrl)  # 调用get方法抓取
                    browser.find_element_by_class_name('gs_in_txt').send_keys(
                        paper)
                    browser.find_element_by_id('gs_hp_tsb').click()
                except TimeoutException, e:
                    browser.get(googleSchalarUrl)
                    browser.find_element_by_class_name('gs_in_txt').send_keys(
                        paper)
                    browser.find_element_by_id('gs_hp_tsb').click()
                except WebDriverException, e:
                    continue

                if WebDriverWait(browser, 30, 0.5).until(
                        lambda browser: browser.find_element_by_class_name(
                            'gs_r')) == 'WrongPage':
                    # print "WrongPaper"
                    continue

                # 解析html
                soup = BeautifulSoup(browser.page_source,
                                     'html.parser',
                                     from_encoding='utf-8')

                items = soup.find_all('div', class_='gs_a')
                authors = None
                for item in items:
                    authors = item.find_all('a')
                    # authors = item.fing('div', class_='gs_a').find_all('a')
                    break

                if not authors:
                    continue

                for author in authors:
                    url = '%s%s' % (personPage, author['href'])
                    try:
                        browser.get(url)  # 调用get方法抓取
                    except TimeoutException, e:
                        browser.get(url)

                    if WebDriverWait(browser, 30, 0.5).until(
                            lambda browser: browser.find_element_by_class_name(
                                'gsc_rsb_std')) == 'WrongPage':
                        # print "WrongPaper"
                        continue

                    if browser.find_element_by_id(
                            'gsc_prf_in').text == tempProfe.englishName:
                        authorFind = True
                        # 解析html
                        soup = BeautifulSoup(browser.page_source,
                                             'html.parser',
                                             from_encoding='utf-8')

                        details = soup.find_all('div', class_='gsc_prf_il')

                        try:
                            tempProfe.university = details[0].find(
                                'a').get_text()
                        except:
                            tempProfe.university = details[0].get_text()
                        tempKeywords = []
                        keywords = details[1].find_all('a')
                        for keyword in keywords:
                            tempKeywords.append(keyword.get_text())

                        tempProfe.studyArea = ','.join(tempKeywords)

                        datas = soup.find_all('td', class_='gsc_rsb_std')
                        tempProfe.citations = datas[0].get_text()
                        tempProfe.h_index = datas[2].get_text()
示例#5
0
        while y > 0:
            if professor_list[y].get_count() < professor_list[y -
                                                              1].get_count():
                temp = professor_list[y]
                professor_list[y] = professor_list[y - 1]
                professor_list[y - 1] = temp
                y = y - 1
            else:
                break


f = open("reply.csv", "r", encoding="utf8")  # 1.改教授時間資料表(參考2015夏的excel)
csv_f = csv.reader(f)

for row in csv_f:
    pro = professor.Professor()
    for x in range(len(row) - 1):  #讀csv,前兩個是教授跟教授信箱
        if x == 1:
            pro._init_(row[x])
        elif x == 2:
            pro.set_email(row[x])
        elif x < 9:
            day = x - 4
            time = 0
            if "10:00~12:00" in row[x]:
                time += 1
            if "13:00~15:00" in row[x]:
                time += 2
            if "15:00~17:00" in row[x]:
                time += 4
            if time != 0:
示例#6
0
#classes importadas, a fim de serem instanciadas
import pessoa
import aluno
import professor

#execução do código

#Classe pessoa instanciada, com objetos Pessoa1 escolhido, seus atributos discriminados através dos métodos de inserção e retorno
pessoa1 = pessoa.Pessoa('Carlos', 'alberto')
print("Retornando as características de pessoa com nome e sobrenome:")
print("Nome da pessoa: {0} {1} ".format(pessoa1.getNome(),
                                        pessoa1.getSobrenome()))

#Classe aluno instanciada, com objeto aluno1 escolhido e seus atributos discriminados através dos métodos de inserção e retorno
aluno1 = aluno.Aluno(102010, 'Maurício', 'Matar')
print(
    "\nRetornando as características de aluno com nome,sobrenome e matrícula:")
print(
    "Nome do aluno: {0} {1} ".format(aluno1.getNome(), aluno1.getSobrenome()),
    "\nMatrícula do aluno:{} ".format(aluno1.getMatricula()))

#Classe Professor instanciada, com objeto professor1 escolhido e seus atributos discriminados através dos métodos de inserção e retorno
professor1 = professor.Professor(112030, 'João', 'Kesley')
print(
    "\nRetornando as características de professor com nome, sobrenome e código:"
)
print(
    "Nome do professor: {0} {1}".format(professor1.getNome(),
                                        professor1.getSobrenome()),
    "\nCódigo do professor:{} ".format(professor1.getCodigo()))
示例#7
0
    def getProfe(self, num):
        browser = webdriver.Firefox()  # 初始化Firefox浏览器
        filename = '%d%s' % (num, 'details.txt')
        f = open(filename, 'a')
        while not pageUrlQueue.empty():
            line = pageUrlQueue.get()
            parts = line.split('!!!')
            tempProfe = professor.Professor(parts[0].split('|')[0])
            # tempProfe.university = parts[0].split('|')[1]
            tempProfe.chiUniversity = parts[0].split('|')[1].split('/')[0]
            tempProfe.university = parts[0].split('|')[1].split('/')[1]
            tempProfe.ieeeNum = parts[0].split('|')[2]
            tempProfe.citations = parts[0].split('|')[3]
            tempProfe.h_index = parts[0].split('|')[4]
            tempProfe.studyArea = parts[0].split('|')[5]
            tempProfe.papers = parts[1]

            #学校名转换为机构名
            # self.getChiUniversity(browser, tempProfe)
            # print '%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s' % (
            # tempProfe.englishName, '|', tempProfe.chiUniversity, '/',
            # tempProfe.university, '|', tempProfe.ieeeNum, '|', tempProfe.citations, '|', tempProfe.h_index, '|',
            # tempProfe.studyArea, '!!!', tempProfe.papers.strip())
            #
            # f.write('%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s' % (
            # tempProfe.englishName, '|', tempProfe.chiUniversity, '/',
            # tempProfe.university, '|', tempProfe.ieeeNum, '|', tempProfe.citations, '|', tempProfe.h_index, '|',
            # tempProfe.studyArea, '!!!', tempProfe.papers))

            # 通过百度,edu.cn, ac.cn查找详细信息
            try:
                detailUrl, baike = self.getPagefromBaidu(browser, tempProfe)
            except:
                continue
            tempProfe.detailPage = detailUrl
            # if baike:
            #     self.baikeCheck(browser, baike, tempProfe)
            if detailUrl:
                self.getDetails(browser, detailUrl, tempProfe)

            if tempProfe.title:
                for i in tempProfe.nationalHonorSet:
                    tempProfe.nationalHonor = '%s%s%s' % (
                        tempProfe.nationalHonor, ' ', i)

                print '%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s' % (
                    tempProfe.englishName, '/', tempProfe.chineseName, '|',
                    tempProfe.chiUniversity, '/', tempProfe.university, '|',
                    tempProfe.ieeeNum, '|', tempProfe.citations, '|',
                    tempProfe.h_index, '|', tempProfe.title, '|',
                    tempProfe.adm, '|', tempProfe.nationalHonor, '|',
                    tempProfe.studyArea, '!!!', tempProfe.papers.strip())

                f.write(
                    '%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s' %
                    (tempProfe.englishName, '/', tempProfe.chineseName, '|',
                     tempProfe.chiUniversity, '/', tempProfe.university, '|',
                     tempProfe.ieeeNum, '|', tempProfe.citations, '|',
                     tempProfe.h_index, '|', tempProfe.title, '|',
                     tempProfe.adm, '|', tempProfe.nationalHonor, '|',
                     tempProfe.studyArea, '!!!', tempProfe.papers))

        browser.close()
示例#8
0
import pessoa
import aluno
import professor

#Retorna na tela dados de uma pessoa
pessoa1 = pessoa.Pessoa('Samuel','Silva')
print("Retornando as caracteristicas de pessoa com nome e sobrenome:")
print("Nome da pessoa: {0} {1} ".format(pessoa1.getNome(),pessoa1.getSobrenome()))

#Retorna na tela dados de um aluno
aluno1 = aluno.Aluno(91603356, 'Adriana','Mendes')
print("\nRetornando as caracteristicas de aluno com nome,sobrenome e matricula:")
print("Nome do aluno: {0} {1} ".format(aluno1.getNome(),aluno1.getSobrenome()),"\nMatricula do aluno:{} ".format(aluno1.getMatricula()))

#Retorna na tela dados de um professor
professor1 = professor.Professor(3678, 'Willian','Amaral')
print("\nRetornando as caracteristicas de professor com nome, sobrenome e codigo:")
print("Nome do professor: {0} {1}".format(professor1.getNome(),professor1.getSobrenome()),"\nCodigo do professor:{} ".format(professor1.getCodigo()))

示例#9
0
# st1.papers.append("Math")
# st2.papers.append("Literature")
#
# st1.papers_local.append("Physics")
# st2.papers_local.append("Astronomy")
#
# st1.print_papers()
# st2.print_papers()
#

import course
import professor
import student

if __name__ == "__main__":
    pr1 = professor.Professor("Dr. Adams")
    pr2 = professor.Professor("Dr. Smith")
    course1 = course.Course("ML")

    course1.add_lecturer(pr1)
    course1.add_lecturer(pr2)
    course1.print_info()

    pr1.add_course(course1)
    pr1.print_info()
    pr2.print_info()

    st1 = student.Student("Alice")
    st1.print_info(lang="UA")

    # print(pr1)
示例#10
0
def school_menu(schools_list, school_name, school_id, school_password):
    os.system("clear")

    print("Welcome {}\n".format(school_name))

    menu = {}
    menu["1"] = "Enroll a student"
    menu["2"] = "Hire a professor"
    menu["3"] = "Expel a student"
    menu["4"] = "Fire a professor"
    menu["5"] = "Change Password"
    menu["6"] = "See list of all students"
    menu["7"] = "See list of all professors"
    menu["8"] = "Exit"

    for k, v in menu.items():
        print("{}) {}".format(k, v))

    file_name = "{}".format(school_id)
    user_input = input()

    if (user_input == "1"):
        os.system("clear")
        print("------Creating a new student profile------")
        first_name = input("Enter first name of student: \n")
        last_name = input("Enter last name of student: \n")
        major = input("Enter student's area of study: \n")
        year = input("Enter student's age: \n")

        new_student = student.Student(first_name, last_name, major, year)

        infile = open(file_name, "rb")
        data_dict = pickle.load(infile)
        data_dict["Students"].append(new_student)
        infile.close()
        outfile = open(file_name, "wb")
        pickle.dump(data_dict, outfile)
        outfile.close()
        os.system("clear")
        print("Student successfully added\n")
        school_menu(schools_list, school_name, school_id, school_password)

    elif (user_input == "2"):
        os.system("clear")
        print("-----Hiring a professor-----\n\n")
        first_name = input("Enter professor's first name:\t")
        last_name = input("Enter professor's last name:\t")
        salary = input("Enter professor's salary\t")

        new_professor = professor.Professor(first_name, last_name, salary)

        infile = open(file_name, "rb")
        data_dict = pickle.load(infile)
        data_dict["Professors"].append(new_professor)
        infile.close()

        outfile = open(file_name, "wb")
        pickle.dump(data_dict, outfile)
        outfile.close()

        os.system("clear")
        print(">>>>>Professor successfully added\n")
        school_menu(schools_list, school_name, school_id, school_password)

    elif (user_input == "3"):
        os.system("clear")
        print("-----Expelling a student-----\n\n")
        print(
            "Enter number of student to expel or enter any other key to exit\n"
        )
        infile = open(file_name, "rb")
        data_dict = pickle.load(infile)
        print("Choose a student to delete\n\n")
        i = 1
        for stu in data_dict["Students"]:
            print("{}) {}, {}".format(i, stu.last_name, stu.first_name))
            i += 1
        infile.close()
        user_input = input()
        try:
            if (int(user_input) >= 1
                    and int(user_input) <= len(data_dict["Students"])):
                del data_dict["Students"][int(user_input) - 1]
                outfile = open(file_name, "wb")
                pickle.dump(data_dict, outfile)
                outfile.close()
                os.system("clear")
                print(">>>>>Student successfully expelled\n")
                school_menu(schools_list, school_name, school_id,
                            school_password)
            else:
                os.system("clear")
                school_menu(schools_list, school_name, school_id,
                            school_password)

        except ValueError:
            os.system("clear")
            school_menu(schools_list, school_name, school_id, school_password)

    elif (user_input == "4"):
        os.system("clear")
        print(
            "-----Enter number of professor to fire or enter any other key to exit-----\n\n"
        )

        infile = open(file_name, "rb")
        data_dict = pickle.load(infile)
        i = 1
        for prof in data_dict["Professors"]:
            print("{}) {}, {}".format(i, prof.last_name, prof.first_name))
            i += 1

        infile.close()

        user_input = input()
        try:
            if (int(user_input) >= 1
                    and int(user_input) <= len(data_dict["Professors"])):
                del data_dict["Professors"][int(user_input) - 1]
                os.system("clear")
                outfile = open(file_name, "wb")
                pickle.dump(data_dict, outfile)
                outfile.close()
                print(">>>>>Professor successfully fired\n")
                school_menu(schools_list, school_name, school_id,
                            school_password)
            else:
                os.system("clear")
                school_menu(schools_list, school_name, school_id,
                            school_password)

        except ValueError:
            os.system("clear")
            school_menu(schools_list, school_name, school_id, school_password)

    elif (user_input == "5"):
        print("5")
        # how to do this?
        # import schools list, import school, then change school[3] to it
        # need to then figure out like dumping the data but without pickling b/c didn't use that here
        os.system("clear")
        print("Enter old password:\t")
        old_password = input()
        # let have 3 tries
        num_of_tries = 3
        while (num_of_tries > 0):
            if old_password == school_password:
                os.system("clear")
                print("Enter new password:\t")
                new_password = input()
                # now change school[2] to be the new password somehow
                #schools = read_file("Schools.txt")
                #for school in schools:
                #if school[0] == school_name:
                #print("found school")
                f = open("Schools.txt", "r")
                lines = f.readlines()
                f.close()

                f = open("Schools.txt", "w")
                for line in lines:
                    if line != ("{}\t{}\t{}\n".format(school_name, school_id,
                                                      school_password)):
                        print("getting here as well")
                        f.write(line)
                new_line = "{}\t{}\t{}\n".format(school_name, school_id,
                                                 new_password)
                f.write(new_line)
                f.close()

                break
            else:
                num_of_tries -= 1
        school_menu(schools_list, school_name, school_id, school_password)
        # if get correct then ask to enter new password
    elif (user_input == "6"):
        os.system("clear")
        print("-----Enter any key to exit-----\n\n")
        infile = open(file_name, "rb")
        data_dict = pickle.load(infile)
        name_list = []
        for stu in data_dict["Students"]:
            name_list.append("{}, {}".format(stu.last_name.title(),
                                             stu.first_name.title()))
        name_list.sort()

        for stu in name_list:
            print(stu)

        #for stu in data_dict["Students"]:
        #print("{}, {}".format(stu.last_name, stu.first_name))
        infile.close()
        user_input = input()
        school_menu(schools_list, school_name, school_id, school_password)

    elif (user_input == "7"):
        os.system("clear")
        print("-----Enter any key to exit-----\n\n")

        infile = open(file_name, "rb")
        data_dict = pickle.load(infile)

        for prof in data_dict["Professors"]:
            print("{}\t{}\t{}".format(prof.first_name, prof.last_name,
                                      prof.salary))

        infile.close()

        u_input = input()
        os.system("clear")
        school_menu(schools_list, school_name, school_id, school_password)

    elif (user_input == "8"):
        os.system("clear")
        starting_menu.starting_menu()
    else:
        os.system("clear")
        print("ERROR 493: Invalid input\n")
        school_menu(schools_list, school_name, school_id, school_password)
示例#11
0
import pessoa
import aluno
import professor

#Retorna na tela dados de uma pessoa
pessoa1 = pessoa.Pessoa('João', 'Miller')
print("Retornando as caracteristicas de pessoa com nome e sobrenome:")
print("Nome da pessoa: {0} {1} ".format(pessoa1.getNome(),
                                        pessoa1.getSobrenome()))

#Retorna na tela dados de um aluno
aluno1 = aluno.Aluno(302010, 'Cesar', 'Vieira')
print(
    "\nRetornando as caracteristicas de aluno com nome,sobrenome e matricula:")
print(
    "Nome do aluno: {0} {1} ".format(aluno1.getNome(), aluno1.getSobrenome()),
    "\nMatricula do aluno:{} ".format(aluno1.getMatricula()))

#Retorna na tela dados de um professor
professor1 = professor.Professor(102030, 'Alan', 'Paulo')
print(
    "\nRetornando as caracteristicas de professor com nome, sobrenome e codigo:"
)
print(
    "Nome do professor: {0} {1}".format(professor1.getNome(),
                                        professor1.getSobrenome()),
    "\nCodigo do professor:{} ".format(professor1.getCodigo()))
示例#12
0
    def __init__(self):
        reload(sys)
        sys.setdefaultencoding('utf-8')
        # 指定file以utf-8的格式打开
        self.file = Workbook(encoding='utf-8')
        # 指定打开的文件名
        self.sheet = self.file.add_sheet('sheet')
        self.sheet.write(0, 0, '序号')
        self.sheet.write(0, 1, '名字')
        self.sheet.write(0, 2, '学科')
        self.sheet.write(0, 3, '研究领域')
        self.sheet.write(0, 4, '职称')
        self.sheet.write(0, 5, '所在学校、科研机构')
        self.sheet.write(0, 6, '国家称号')
        self.sheet.write(0, 7, '行政职务')
        self.sheet.write(0, 8, '发表论文情况')
        self.sheet.write(0, 9, '匹配度')
        self.professorMap = {}
        f = open('result4.txt', "r")
        lines = f.readlines()
        for line in lines:
            outputPart = line.split('!!!')[0]
            parts = outputPart.split('|')
            l = len(parts)
            name = parts[0].split('/')[0].strip()
            if not self.professorMap.has_key(name):
                profe = professor.Professor(name)
                if len(parts[0].split('/')) > 1:
                    profe.chineseName = parts[0].split('/')[1]
                if len(parts[1].split('/')) > 1:
                    profe.university = parts[1].split('/')[1]
                profe.chiUniversity = parts[1].split('/')[0]
                if l > 2:
                    profe.ieeeNum = parts[2].strip()
                    # profe.studyArea = parts[2].strip()
                    # profe.studyArea = profe.studyArea.replace('None ', '')
                if parts[3] != 'None':
                    profe.citations = parts[3].strip()
                if parts[4] != 'None':
                    profe.h_index = parts[4].strip()
                if parts[5] != 'None':
                    profe.title = parts[5].strip()
                if parts[6] != 'None':
                    profe.adm = parts[6].strip()
                if parts[7] != 'None':
                    profe.nationalHonor = parts[7].strip()
                if parts[8] != 'None':
                    profe.studyArea = parts[8].strip()

                if profe.nationalHonor and profe.nationalHonor != 'None':
                    profe.rank = 80
                elif profe.adm and profe.adm != 'None':
                    profe.rank = 70
                elif (profe.ieeeNum != 'not found'
                      and profe.h_index != 'not found'
                      and int(profe.ieeeNum) > 10 and int(profe.h_index) > 15
                      ) or (profe.ieeeNum == 'not found'
                            and profe.h_index == 'not found'):
                    profe.rank = 60
                else:
                    profe.rank = 0
                if profe.rank > 0:
                    self.professorMap[name] = profe
        f.close()