예제 #1
0
def build_graph(filename):
    """ This method takes the text file and builds the graph """
    if not os.path.isfile(filename):
        # If the file does not exist, return nothing
        raise NonExistentFile("%s does not exist." % filename)

    # Create the graph file
    orgchart = OrganisationChart()
    # Open the file and loop through the data
    f = open(filename, 'r')
    # Read the column headers
    header = f.readline()

    file_data = []
    for line in f:
        # Split the line into rows
        line_data = line.split("|")
        # Take in the appropriate data, and remove trailing and leading spaces
        id = line_data[1].lstrip().rstrip()
        name = line_data[2].lstrip().rstrip()
        manager = line_data[3].lstrip().rstrip()
        emp = Employee(name, id, manager)
        orgchart.add_employee(emp)

    return orgchart
예제 #2
0
 def setUp(self):  # this has to be capital U: setUp vs setup
     """
     create employees so I don't have do this each time
     """
     self.my_employee = Employee('Derel', 'Merel', 80000)
     self.salary = 80000
     self.name = 'Derel'
     self.last_name = 'Merel'
예제 #3
0
def addEmployee(session):
    person = addPerson(session)
    employeeDetails = _parseUserInput("Enter basic employee details in teh following format: \n role seniority location salary", 4)
    employeeDetails[0] = _setString(employeeDetails[0])
    employeeDetails[1] = _setString(employeeDetails[1])
    employeeDetails[2] = _setString(employeeDetails[2])
    employeeDetails[3] = _setString(employeeDetails[3])

    employee = Employee(role=employeeDetails[0],
                        seniority=employeeDetails[1],
                        location=employeeDetails[2],
                        salary=employeeDetails[3],
                        person=person)
    session.add(employee)
    session.commit()
예제 #4
0
 def setUp(self):
     #this runs before every test
     print('setUp')
     self.emp_1 = Employee('Corey', 'Schafer', 50000)
     self.emp_2 = Employee('Sue', 'Smith', 60000)
예제 #5
0
from classes import Person, Employee

person = Person('Katy', 43)
person.age = 35
person.print_info()

employee = Employee('Nick', 30, 'Yandex')
employee.print_info()
employee.more_info()
print(employee)
from classes import Person, Employee

person = Person('Katy', 30)
person.age = 35
person.print_info()

employee = Employee('Nick', 30)
employee.print_info()
employee.more_info()
예제 #7
0
# modules and packages
# modules - pieces of code split into logical sections. these python files can be imported and reused
# packages - a collection of modules

#Example:
from classes import Employee

chiya = Employee('chiya', 2000, 5)
print(f'Employee name: {chiya.name}')
print(f'Salary: {chiya.salary}')
print(f'time spent at work: {chiya.duration}')
print(chiya.time_spent())

#Package
#setup:
# create folder
# add __init__.py file
#add other py files in folder
예제 #8
0
from classes import Person, Employee

person2 = Person('Katy', 32)
person2.age = 40
person2.print_info()

employee = Employee('Nik', 22)
employee.print_info()
employee.more_info()
예제 #9
0
from classes import Person, Employee

person = Person('Katy', 30)
person.age = 35
person.print_info()

employee = Employee('Job', 25, 'Google')
employee.print_info()
employee.more_info()
employee.__str__()
print(employee)












예제 #10
0
 def test_pay_taxes(self):
     self.age = 48
     self.salary = 50000
     imp1 = Employee(self)
     self.assertEqual(imp1.pay_tax, "Paga impuestos")
from classes import Employee

emp2 = Employee("Hasan","*****@*****.**","FrontEnd",40000)

print(emp2.impinfo())

emp2.increase_pay()

print(emp2.pay)
print(emp2.__dict__)
from classes import Employee

test_emp1 = Employee('sadia', '*****@*****.**', 'BBA', 35000)
test_emp2 = Employee('dipa', '*****@*****.**', 'abal', 36000)
print(test_emp1)

print(int.__add__(1, 2))
print(str.__add__('hola ', 'buenas tardas'))

print(test_emp1 + test_emp2)
예제 #13
0
from package import *
from classes import Employee, Student
a()
b()
c()

e1 = Employee(101, "Rajat", 21, 10000, "pat")
e1.display()

e2 = Student(101, "Rajat", 21)
e2.display()
from classes import Person, Employee

person = Person('Katy', 30)
person.age = 35
person.print_info()

employee = Employee('Nick', 30, 'Google')
employee.print_info()
employee.more_info()
print(employee)
예제 #15
0
from classes import Employee
import datetime

emp3 = Employee('Sarah', '*****@*****.**', 'backend', 48000)

Employee.set_period_bonus(6000)
print(emp3.impinfo())
emp3.increase_pay()
print(emp3.pay)

date = datetime.date(2021, 3, 20)
Employee.is_working_day(date)
예제 #16
0
파일: lesson39.py 프로젝트: isxoq/forlesson
from classes import Employee

a = Employee("isxoqjon", 'iTeach')

print(a.company)
예제 #17
0
 def test_no_pay_taxes(self):
     self.age = 23
     self.salary = 31999
     imp2 = Employee(self)
     self.assertEqual(imp2.pay_tax, "No paga impuestos")
예제 #18
0
from classes import Person, Employee

person2 = Person('Katy', 32)
person2.age = 40
person2.print_info()

employee = Employee('Nik', 22, 'Google')
employee.print_info()
employee.more_info()
print(employee)
예제 #19
0
from functions import *
from classes import Employee, Student

a()
b()
c()

e1 = Employee(101, "Payal", 22, 1000000, "CEO")
e1.display()

s1 = Student(11, "ranu", 12)
s1.display()
예제 #20
0
def main():
    print("Creating 'Supervisor' object 'tyler'")
    tyler = Supervisor("Tyler Whitney", "09171987", "Computing Systems")
    tyler.printName()
    print("Is Manager? " + str(tyler.isManager()))
    print("Service: " + tyler.getService())

    print('')

    print("Creating 'Employee' object 'one'")
    one = Employee("John Doe", 9, 12, 1982)
    one.printName()
    print("Service Length: " + str(one.getService()))

    print('')

    print("Added 'one' as employee under 'tyler'")
    tyler.addEmployee(one)
    print("-- Emplyoees under 'tyler' object")
    tyler.printEmployeeNames()
    print(" ----- ")
    print("Is 'tyler' Manager? " + str(tyler.isManager()))

    print('')

    print("Creating 'Supervisor' object 'two'")
    two = Supervisor("Eric Twofer", "08231999", "Marketing and Communications")
    two.printName()
    print("Changing name of 'two' to a different name and department")
    two.setName("Eric J Twofer", "MarCom")
    two.printName()
    print("Service Length: " + str(two.getService()))

    print('')

    print("Setting contact info for object 'tyler'")
    tyler.setContactInfo("5642449", "5552400", "*****@*****.**")
    info = tyler.getContactInfo()
    print("-- Printing Contact Info from 'getContactInfo' method --")
    print("Phone: " + info['phone'])
    print("Fax: " + info['fax'])
    print("Email: " + info['email'])
    print(" ----- ")
    print(
        "-- Printing Contact Info from individual 'getPhone', 'getFax', 'getEmail' methods --"
    )
    print("Phone: " + tyler.getPhone())
    print("Fax: " + tyler.getFax())
    print("Email: " + tyler.getEmail())
    print(" ----- ")

    print('')

    print("Adding 'two' object as employee under 'tyler'")
    tyler.addEmployee(two)
    print("-- Employees under 'tyler' object -- ")
    tyler.printEmployeeNames()
    print(" ----- ")
    print(
        "Removing 'two' object from employee under 'tyler', ('Eric J Twofer')")
    tyler.removeEmployee("Eric J Twofer")
    print("-- Employees under 'tyler' object --")
    tyler.printEmployeeNames()
    print(" ----- ")
예제 #21
0
 def setUp(self):
     '''Create set of caracteristics for the employee'''
     self.my_employee = Employee('jay', 'gonzalez', 45000)