def main(): # Creating Programmer instances coder = models.Programmer("Yak", generate_email(), 67) print(coder.work()) print(coder.check_salary(10)) coder2 = models.Programmer("Yak1", generate_email(), 66) print(f"{coder}, {coder2}") # Creating Recruiter instance recruiter = models.Recruiter("Jak", generate_email(), 58) print(recruiter.work()) print(recruiter.check_salary(10)) print(f"{recruiter}") # Creating candidates instances candidate1 = models.Candidate("candidate1", generate_email(), "technologies", "skill", 2) candidate2 = models.Candidate("candidate2", generate_email(), "technologies", "skill", 2) candidate3 = models.Candidate("candidate3", generate_email(), "technologies", "skill", 2) print(f"{candidate1}, {candidate2}, {candidate3}") # Creating vacancy instances vacancy1 = models.Vacancy("title", "skill", 2) vacancy2 = models.Vacancy("title2", "skill", 2) print(f"{vacancy1}, {vacancy2}") # Checking email validation try: inv_email = models.Programmer("", "invalid_email", 56) except TypeError as e: logging.exception(e) else: print("email validation don't work") # Checking email uniquity try: with open("emails.txt", "r") as f: inv_email = f.readline() inv_entity = models.Programmer("", inv_email[:len(inv_email) - 1], 78) except ValueError as e: logging.exception(e) else: print("Two identical emails exists!!!") # Checking work exception try: candidate1.work() except models.UnableToWorkException as e: logging.exception(e)
def main(): ivan = mod.Recruiter("Ivan", '*****@*****.**', 100, 23) print(ivan) alex = mod.Programmer( "Alex", '*****@*****.**', 200, 23, {'knowledge of English ', 'Python', 'JS', 'Git', 'html&css'}) print(alex) alesha = mod.Programmer( "Alesha", '*****@*****.**', 200, 23, {'knowledge of English ', 'Python', 'Flask', 'Django'}) print(alesha) vitalik = mod.Candidate('Vitalik', '*****@*****.**', {'Python', 'Git', 'Postgresql'}, 'Python', 'Middle') petr = mod.Candidate('Petr', '*****@*****.**', {'Java', 'Git', 'Postgresql'}, 'Java', 'Senior') python_vacancy = mod.Vacancy('Vacancy Python', 'Python', 'Middle') java_vacancy = mod.Vacancy('Vacancy Java', 'Java', 'Senior')
def post(self): candidate = models.Candidate(name=self.request.get('name'), role=self.request.get('role'), gender=self.request.get('gender')) candidate.put() return webapp2.redirect('/candidate/{0}'.format( candidate.key.urlsafe()))
def main(): try: ivan = mod.Recruiter("Ivan", '*****@*****.**', 100, 23) print(ivan) alex = mod.Programmer("Alex", '*****@*****.**', 200, 23, {'knowledge of English ', 'Python', 'JS', 'Git', 'html&css'}) print(alex) alesha = mod.Programmer("Alesha", '*****@*****.**', 200, 23, {'knowledge of English ', 'Python', 'Flask', 'Django'}) print(alesha) vitalik = mod.Candidate('Vitalik', '*****@*****.**', {'Python', 'Git', 'Postgresql'}, 'Python', 'Middle') petr = mod.Candidate('Petr', '*****@*****.**', {'Java', 'Git', 'Postgresql'}, 'Java', 'Senior') python_vacancy = mod.Vacancy('Vacancy Python', 'Python', 'Middle') java_vacancy = mod.Vacancy('Vacancy Java', 'Java', 'Senior') alfa=alex+alesha print(alfa) except Exception as e: with open('logs.py', 'a+') as fh: fh.write(str(datetime.datetime.today()) + ' ') logging.exception(e)
def main(): recruiter = models.Recruiter('Sam', 'Serioussam', 150) programmer_phyton = models.Programmer('Hitman', '*****@*****.**', 200) programmer_java = models.Programmer('Putin', '*****@*****.**', 1) candidate_phyton = models.Candidate('Eric Davidovich', '*****@*****.**', 'programming', 'phyton', 'junior') candidate_phyton2 = models.Candidate('Vladimir Zelencskiy', '*****@*****.**', 'phyton', 'programming', 'senior') candidate_phyton3 = models.Candidate('Petr Poroshenko', '*****@*****.**', 'phyton', 'programming', 'junior') vacancy_first = models.Vacancy("Phyton", 'django', 'senior') vacancy_second = models.Vacancy("Phyton", 'django', 'junior') print( f'{recruiter}\n{programmer_phyton}\n{programmer_java}\n{candidate_phyton}' f'\n{candidate_phyton2}\n{candidate_phyton3}\n{vacancy_first}\n{vacancy_second}' )
def randomNeighbor(model, currentCandidate, lives=100): if lives == 0: return None newCandidate = models.Candidate() for i in xrange(len(currentCandidate.decisions)): newDec = currentCandidate.decisions[i] if random.random() < 0.3 or len(currentCandidate.decisions) == 1: low, high = model.decisionRanges[i] newDec += (high-low)/10.0*random.random()*(1 if random.random() < 0.5 else -1) newCandidate.decisions.append(newDec) if model.isValid(newCandidate): return model.eval(newCandidate, energyFunction=model.sumNormalizedEnergyFunction) else: return randomNeighbor(model, currentCandidate, lives=lives-1)
def main(): # try: ivan = mod.Recruiter("Ivan", '*****@*****.**', 100, 23) print(ivan) print(ivan.cheak_salary()) alex = mod.Programmer( "Alex", '*****@*****.**', 200, 23, {'knowledge of English ', 'Python', 'JS', 'Git', 'html&css'}) print(alex) alesha = mod.Programmer( "Alesha", '*****@*****.**', 200, 23, {'knowledge of English ', 'Python', 'Flask', 'Django'}) print(alesha) vitalik = mod.Candidate('Vitalik', '*****@*****.**', {'Python', 'Git', 'Postgresql'}, 'Python', 'Middle') petr = mod.Candidate('Petr', '*****@*****.**', {'Java', 'Git', 'Postgresql'}, 'Java', 'Senior') python_vacancy = mod.Vacancy('Vacancy Python', 'Python', 'Middle') java_vacancy = mod.Vacancy('Vacancy Java', 'Java', 'Senior') alfa = alex + alesha print(alfa) print(alex.full_info) mod.Candidate.create_candidates(file="candidates.csv")
def index(): initEverything() app.logger.debug("database cleared and refilled") #create new mayor models.Candidate.objects.delete() newCan = models.Candidate() newCan.name = "Mayor" categories = models.Category.objects() for c in categories: ranNum = random.randint(2, 5) newCan.currScores[c.title] = ranNum newCan.save() metrics = {} metrics = sorted(newCan.currScores, key=lambda key: newCan.currScores[key]) questions = models.Question.objects(category=metrics[0]) ranNum = random.randint(1, len(questions) - 1) question = questions[ranNum] data = {'currScores': newCan.currScores, 'question': question} return render_template("start.html", **data)
import traceback from datetime import datetime import models if __name__ == '__main__': try: recruiter_aleks = models.Recruiter('Aleks', '*****@*****.**', 50) programmer_semen = models.Programmer('S***n', '*****@*****.**', 70, 'java', 'js', 'python') programmer_kris = models.Programmer('Kris', '*****@*****.**', 60, 'html', 'css', 'js') candidate_ivan = models.Candidate('Ivan', '*****@*****.**', 'python', 'senior', 'python', 'php', 'js', 'ruby') candidate_dmytro = models.Candidate('Dmytro', '*****@*****.**', 'python', 'junior', 'python', 'js') candidate_artem = models.Candidate('Artem', '*****@*****.**', 'java', 'middle', 'java', 'js', 'c++') vacancy_python_dev = models.Vacancy('python developer', 'python', 'senior') vacancy_java_dev = models.Vacancy('java developer', 'java', 'junior') # print(recruiter_aleks.ret_employee) # print(models.Employee.check_salary(50)) data = 'candidates.csv' cand1, cand2, cand3 = models.Candidate.create_candidate(data) print(cand1.work()) print(candidate_dmytro.work()) except Exception as err: tb = traceback.format_exc()
import models as mod if __name__ == '__main__': ivan = mod.Recruiter("Ivan", 100, 23) print(ivan) alex = mod.Programmer("Alex", 200, 23, {'knowledge of English ', 'Python', 'JS', 'Git', 'html&css'}) print(alex) alesha = mod.Programmer("Alesha", 200, 23, {'knowledge of English ', 'Python', 'Flask', 'Django'}) print(alesha) vitalik= mod.Candidate('Vitalik', '*****@*****.**', 'Python', 'Python', 'Python') petr=mod.Candidate('Petr', '*****@*****.**', 'Java', 'Java', 'Java') python_vacancy=mod.Vacancy('Python', 'Python', 'Python') java_vacancy= mod.Vacancy('Java', 'Java', 'Java')