コード例 #1
0
ファイル: employees.py プロジェクト: jdamian/dev-started
 def __init__(self):
     self._employees = [
         {
             'id': 1,
             'name': 'Mary Poppins',
             'role': 'manager'
         },
         {
             'id': 2,
             'name': 'John Smith',
             'role': 'secretary'
         },
         {
             'id': 3,
             'name': 'Kevin Bacon',
             'role': 'sales'
         },
         {
             'id': 4,
             'name': 'Jane Doe',
             'role': 'factory'
         },
         {
             'id': 5,
             'name': 'Robin Williams',
             'role': 'secretary'
         },
     ]
     self.productivity = ProductivitySystem()
     self.payroll = PayrollSystem()
     self.employee_addresses = AddressBook()
コード例 #2
0
 def __init__(self):
     self._employees = [
         {
             "id": 1,
             "name": "Mary Poppins",
             "role": "manager"
         },
         {
             "id": 2,
             "name": "John Smith",
             "role": "secretary"
         },
         {
             "id": 3,
             "name": "Kevin Bacon",
             "role": "sales"
         },
         {
             "id": 4,
             "name": "Jane Doe",
             "role": "factory"
         },
         {
             "id": 5,
             "name": "Robin Williams",
             "role": "secretary"
         },
     ]
     self.productivity = ProductivitySystem()
     self.payroll = PayrollSystem()
     self.employee_addresses = AddressBook()
コード例 #3
0
ファイル: employees.py プロジェクト: ilmoi/realpython
    def __init__(self):
        self._employees = [{
            'id': 1,
            'name': 'm',
            'role': 'manager'
        }, {
            'id': 2,
            'name': 's',
            'role': 'secretary'
        }, {
            'id': 3,
            'name': 's',
            'role': 'sales'
        }, {
            'id': 4,
            'name': 'f',
            'role': 'factory'
        }, {
            'id': 5,
            'name': 'ts',
            'role': 'secretary'
        }]

        # link components
        self.productivity = ProductivitySystem(
        )  # should I be calling this somewhere?
        self.payroll = PayrollSystem()
        self.addresses = AddressBook()
コード例 #4
0
 def __init__(self):
     # employees = session.query(DB_Employee).all()
     # _employees = []
     # for emp in employees:
     #     emp_data = {
     #         'id': emp.id,
     #         'name': emp.name,
     #         'role': emp.role,
     #     }
     #     _employees.append(emp_data)
     #
     # self._employees = _employees
     self._employees = [
         {
             'id': 1,
             'name': 'Mary Poppins',
             'role': 'manager'
         },
         {
             'id': 2,
             'name': 'John Smith',
             'role': 'secretary'
         },
         {
             'id': 3,
             'name': 'Kevin Bacon',
             'role': 'sales'
         },
         {
             'id': 4,
             'name': 'Jane Doe',
             'role': 'factory'
         },
         {
             'id': 5,
             'name': 'Robin Williams',
             'role': 'secretary'
         },
     ]
     self.productivity = ProductivitySystem()
     self.payroll = PayrollSystem()
     self.employee_addresses = AddressBook()
コード例 #5
0
class EmployeeDatabase:
    def __init__(self):
        # employees = session.query(DB_Employee).all()
        # _employees = []
        # for emp in employees:
        #     emp_data = {
        #         'id': emp.id,
        #         'name': emp.name,
        #         'role': emp.role,
        #     }
        #     _employees.append(emp_data)
        #
        # self._employees = _employees
        self._employees = [
            {
                'id': 1,
                'name': 'Mary Poppins',
                'role': 'manager'
            },
            {
                'id': 2,
                'name': 'John Smith',
                'role': 'secretary'
            },
            {
                'id': 3,
                'name': 'Kevin Bacon',
                'role': 'sales'
            },
            {
                'id': 4,
                'name': 'Jane Doe',
                'role': 'factory'
            },
            {
                'id': 5,
                'name': 'Robin Williams',
                'role': 'secretary'
            },
        ]
        self.productivity = ProductivitySystem()
        self.payroll = PayrollSystem()
        self.employee_addresses = AddressBook()

    @property
    def employees(self):
        return [self._create_employee(**data) for data in self._employees]

    def _create_employee(self, id, name, role):
        address = self.employee_addresses.get_employee_address(id)
        employee_role = self.productivity.get_role(role)
        payroll_policy = self.payroll.get_policy(id)
        return Employee(id, name, address, employee_role, payroll_policy)
コード例 #6
0
ファイル: employees.py プロジェクト: ilmoi/realpython
class EmployeeDatabase(object):
    def __init__(self):
        self._employees = [{
            'id': 1,
            'name': 'm',
            'role': 'manager'
        }, {
            'id': 2,
            'name': 's',
            'role': 'secretary'
        }, {
            'id': 3,
            'name': 's',
            'role': 'sales'
        }, {
            'id': 4,
            'name': 'f',
            'role': 'factory'
        }, {
            'id': 5,
            'name': 'ts',
            'role': 'secretary'
        }]

        # link components
        self.productivity = ProductivitySystem(
        )  # should I be calling this somewhere?
        self.payroll = PayrollSystem()
        self.addresses = AddressBook()

    @property  # getter for employees list
    def employees(self):
        return [self._create_employee(i + 1) for i in range(5)]

    def _create_employee(self, id):
        self.id = id
        self.name = self._employees[id - 1].get('name')
        self.role = self.productivity.get_role(self._employees[id -
                                                               2].get('role'))
        self.policy = self.payroll.get_policy(id)
        self.address = self.addresses.get_employee_address(id)

        return Employee(self.id, self.name, self.role, self.policy,
                        self.address)
コード例 #7
0
ファイル: employees.py プロジェクト: jovicon/my_pythonic_path
class EmployeeDatabase:
    def __init__(self):
        self._employees = [
            {
                'id': 1,
                'name': 'Mary Poppins',
                'role': 'manager'
            },
            {
                'id': 2,
                'name': 'John Smith',
                'role': 'secretary'
            },
            {
                'id': 3,
                'name': 'Kevin Bacon',
                'role': 'sales'
            },
            {
                'id': 4,
                'name': 'Jane Doe',
                'role': 'factory'
            },
            {
                'id': 5,
                'name': 'Robin Williams',
                'role': 'secretary'
            }
        ]

        self.productivity = ProductivitySystem()
        self.payroll = PayrollSystem()
        self.employee_addresses = AddressBook()

    def employees(self):
        return [self._create_employee(**data) for data in self._employees]

    def _create_employee(self, id, name, role):
        address = self.employee_addresses.get_employee_address(id)
        employee_role = self.productivity.get_role(role)
        payroll_policy = self.payroll.get_policy(id)
        return Employee(id, name, address, employee_role, payroll_policy)
コード例 #8
0
class EmployeeDatabase:
    def __init__(self):
        self._employees = [
            {
                "id": 1,
                "name": "Mary Poppins",
                "role": "manager"
            },
            {
                "id": 2,
                "name": "John Smith",
                "role": "secretary"
            },
            {
                "id": 3,
                "name": "Kevin Bacon",
                "role": "sales"
            },
            {
                "id": 4,
                "name": "Jane Doe",
                "role": "factory"
            },
            {
                "id": 5,
                "name": "Robin Williams",
                "role": "secretary"
            },
        ]
        self.productivity = ProductivitySystem()
        self.payroll = PayrollSystem()
        self.employee_addresses = AddressBook()

    @property
    def employees(self):
        return [self._create_employee(**data) for data in self._employees]

    def _create_employee(self, id, name, role):
        address = self.employee_addresses.get_employee_address(id)
        employee_role = self.productivity.get_role(role)
        payroll_policy = self.payroll.get_policy(id)
        return Employee(id, name, address, employee_role, payroll_policy)
コード例 #9
0
ファイル: program.py プロジェクト: J0shu4B0y/Practice-Python
from hr import PayrollSystem
from employees import Manager, Secretary, SalesPerson, FactoryWorker
from productivity import ProductivitySystem

manager = Manager(id=1, name="John Smith", weekly_salary=1500)
secretary = Secretary(id=2, name="Rebeka Newman", weekly_salary=1200)
sales_guy = SalesPerson(id=3, name="Tom Jones", weekly_salary=1400, commission=350)
factory_worker = FactoryWorker(id=4, name="PetePeterson", hours_worked=40, hour_rate=15)

employees = [manager, secretary, sales_guy, factory_worker]

productivity_system = ProductivitySystem()
productivity_system.track(employees=employees, hours=40)

payroll_system = PayrollSystem()
payroll_system.calculate_payroll(employees=employees)