def setUp(self): """Create an employee and it's associated data.""" self.bibbity = Employee('Bibbity', 'Bobbity', 60000)
import csv from employee import Employee with open("employees.csv", "r") as csvfile: reader = csv.reader(csvfile) next(reader) all_employees = [] for row in reader: row = [column.strip().replace('"', "") for column in row] current_employee = Employee(*row) all_employees.append(current_employee) # with open("employees.csv", "a") as csvfile: # writer = csv.writer(csvfile, quoting=csv.QUOTE_ALL) # # new_employee = ("Jenny", "Jones", 12.50, 40, 0) # # writer.writerow(new_employee) with open("employees.csv", "w") as csvfile: writer = csv.writer(csvfile, quoting=csv.QUOTE_ALL) writer.writerow([ "first_name", "last_name", "hourly_rate", "hours_worked", "amount_due" ]) for employee in all_employees: employee.amount_due = float(employee.hours_worked) * float( employee.hourly_rate)
def setUp(self): self.employee = Employee('a', 'b', 1000)
# Read in lines of employee data and create list of employee objects employees = [] with open('../../data/smalldata/small_user.csv', 'r') as f: reader = csv.reader(f) next(reader) for user in reader: attributes = {} attributes["id"] = user[0] attributes["department"] = user[1] attributes["cost_center"] = user[2] attributes["manager_id"] = user[3] attributes["location"] = user[4] attributes["lowest_dir_id"] = user[5] attributes["job_family"] = user[6] attributes["person_type"] = user[7] employee = Employee(attributes) employees.append(employee) # Create the company company = Company(employees, 258004) print(company.company) print(company.hierarchy) print(company.employees) # with open('../../data/smalldata/small_company_object.pkl', 'wb') as outfile: # pickle.dump(company, outfile) # Load in employee to resource JSON object to get employee usage data employee_resources = json.load( open("../../data/employee_resource_map.json", 'r'))
def setUp(self): print('setUp') self.emp1 = Employee('Danny', 'Wu', 1000) self.emp2 = Employee('Henry', 'Huang', 2000)
return c.fetchall() def update_salary(emp, pay): with conn: c.execute("""UPDATE employees SET pay = :pay WHERE id = :id AND last = :last""", {'id': emp.empid, 'last': emp.lname, 'pay': pay}) def remove_employee(emp): with conn: c.execute("DELETE from employees WHERE id = :id", {'id': emp.empid}) emp_1 = Employee('Obed', 'Junias', 120000) emp_2 = Employee('Abc', 'Def', 60000) t1 = (12,'a','b',15) t2 = (16,'c','d',56) c.executemany("INSERT INTO employees VALUES (?,?,?,?)",(t1,t2)) employees = get_employee('Junias') print(employees) update_salary(emp_2, 95000) remove_employee(emp_1)
def setUp(self): """ Create an Employee class to use for all test methods""" self.emp = Employee('Althafuddin', 'Shaik', 112000)
'last': emp.last, 'pay': emp.pay }) def remove_emp(emp): # context manager with conn: c.execute( "DELETE from employees WHERE first = :first AND last = :last", { 'first': emp.first, 'last': emp.last }) emp_1 = Employee('John', 'Duke', 90000) emp_2 = Employee('Marian', 'Dolores', 39000) insert_emp(emp_1) insert_emp(emp_2) emps = get_emps_by_name('Duke') print(emps) update_pay(emp_2, 95000) remove_emp(emp_1) emps = get_emps_by_name('Duke') print(emps) conn.close()
ba.printInfo() ba.depositCash(130.0) ba.depositCash(1) ba.printInfo() # ba.depositCash("123") sto = 100.00 ba.withdrawtCash(sto) ba.printInfo() ba.withdrawtCash(100) ba.printInfo() ba.withdrawtCash(-10) ba.printInfo() print(ba.getCash()) print("------- TEST Employee -------") e = Employee(1, "Alicja", "Baszak", 10) e.printInfo() e.raiseSalary(100) e.printInfo() e.raiseSalary(100) e.printInfo()
def setUp(self): self.info = Employee('john', 'conner', 3000) self.add = 6000 self.sal = [8000, 9000]
def setUp(self): """ Create an employee object for use in all test methods. """ self.employee = Employee('Gregor', 'Rowley', 90000)
def setUp(self): '''创建一个实例供测试''' self.me = Employee('Max', 'Well', 100000)
def setUp(self): self.employee = Employee("Ryan", "Ermita", 9999999)
def setUp(self): """Make an employee to use in tests""" self.jack = Employee('jack', 'robertson', 70000)
# This method creates the file if it does not exist # if it exists then it just connects conn = sqlite3.connect('employee.db') # create a curson c = conn.cursor() # create an employee table # Need to run this only once # c.execute("""CREATE TABLE employees( # first text, # last text, # pay integer # )""") emp_1 = Employee("John","Doe",80000) emp_2 = Employee("Jane","Doe",90000) # insert # c.execute("INSERT INTO employees VALUES ('Corey','Shafer',50000)") # c.execute("INSERT INTO employees VALUES ('Mary','Shafer',70000)") # first proper way # c.execute("INSERT INTO employees VALUES (?,?,?)", (emp_1.first, emp_1.last, emp_1.pay)) # commits the current transaction # conn.commit() # second proper way
'first': emp.first, 'last': emp.last, 'pay': pay }) def remove_emp(emp): with conn: c.execute( "DELETE from employees WHERE first = :first AND last = :last", { 'first': emp.first, 'last': emp.last }) emp_1 = Employee('Anna', 'Vieira', 90000) emp_2 = Employee('Pedro', 'Freitas', 900000) emp_3 = Employee('João', 'Freitas', 80000) insert_emp(emp_1) insert_emp(emp_2) insert_emp(emp_3) emps = get_emps_by_lastname('Freitas') print(emps) update_pay(emp_2, 12000000) remove_emp(emp_3) emps = get_emps_by_lastname('Freitas') print(emps)
def test_email(self): emp_1 = Employee('mohame', 'elshankety', 343) self.assertEqual(emp_1.email, '*****@*****.**')
screen = curses.initscr() screen.clear() screen.border(0) screen.addstr(1, 1, "Please enter a number...") screen.addstr(4, 4, "1 - Search for a person") screen.addstr(7, 4, "4 - Exit") screen.refresh() x = screen.getch() if x == ord('1'): person_id = get_param("Enter the person ID:") emp = Employee(person_id) if emp.pid is not None: screen.clear() screen.border(0) screen.addstr(2, 4, "Name:") addstr_bold(2, 14, emp.name.encode(code)) screen.addstr(3, 4, "Surname:") addstr_bold(3, 14, emp.surname.encode(code)) screen.addstr(7, 4, "Press any key to cotinue...") screen.refresh() screen.getch() curses.endwin() status = execute_cmd("python camera.py %s" % person_id)
from employee import Employee teacher = Employee('Elena', 'Mixailovna', 14000) print(teacher.annual_salary) teacher.give_raise(7000) print(teacher.annual_salary)
#!/usr/bin/env python # -*- coding: utf-8 -*- # # 11-3-raise.py # # Copyright 2017 c5220056 <c5220056@GMPTIC> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. # # from employee import Employee employee = Employee('Yejing', 'Huang', 5000) new_salary = employee.give_raise(increase=6000) print(new_salary)
import sqlite3 from employee import Employee #this demo show how to insert python var to database conn = sqlite3.connect('employee.db') #create connect obj c = conn.cursor() emp_1 = Employee('John', 'Doe', 80000) emp_2 = Employee('Jane', 'Doe', 90000) # print(emp_1.first) # print(emp_1.last) # print(emp_1.pay) #c.execute("INSERT INTO employees VALUES ('{}','{}',{})".format(emp_1.first,emp_1.last,emp_1.pay)) #bad way of insert subject to sql injection attack #c.execute("INSERT INTO employees VALUES (?,?,?)", (emp_1.first,emp_1.last,emp_1.pay)) #right way1, tuple #c.execute("INSERT INTO employees VALUES (:first,:last,:pay)", {'first':emp_2.first,'last':emp_2.last,'pay':emp_2.pay}) #right way2, dictionary #old method of fetching # c.execute("SELECT * FROM employees WHERE last='Doe'") # rows=c.fetchall() #get all remaining rows in a list # print(rows) # c.execute("SELECT * FROM employees WHERE last='Schafer'") # rows=c.fetchall() #get all remaining rows in a list # print(rows) #new fetching method1 c.execute("SELECT * FROM employees WHERE last=?", ('Schafer', )) #follow by tuple print(c.fetchall()) #new fetching method2 c.execute("SELECT * FROM employees WHERE last=:last",
def setUp(self): self.jared = Employee("Jared", "Winter", 100000)
import urllib3 import sys from authorization import Authorization from employee import Employee from erp_organization import Organization from workspace import Workspace from dbconnect import DBConnect urllib3.disable_warnings() env = sys.argv[1] space_name = sys.argv[2] email = sys.argv[3] new_space = Workspace(env) new_space_admin = Employee(env) db = DBConnect(env) space_guid = new_space.create_workspace(space_name=space_name, space_code=space_name) new_space_admin.create_admin_for_new_space(space_guid, email) auth = Authorization(env) headers = auth.create_headers(email) new_organization_guid = Organization(env, headers).add_organization('Owner') new_space.set_space_owner(new_organization_guid) new_space_admin.add_admin_to_employees(new_organization_guid, headers) print(space_guid, space_name, email)
def setUp(self): # print("setUp") self.emp_1 = Employee('Corey', 'Schafer', 50000) self.emp_2 = Employee('Sue', "Smith", 60000)
def setUp(self): self.employee = Employee('Chi', 'LI', 10000)
infer_tickers = sys.argv[4] if infer_tickers != 'True': tickers = infer_tickers.split(',') infer_tickers = False else: try: empl_file_lst = os.listdir(empl_path) tickers = [os.path.splitext(file_name)[0].upper() for file_name in empl_file_lst] infer_tickers = True except NotADirectoryError: print('NOT SUPPORTED: Tickers must be specified to run directly on data file') sys.exit(1) ## Initialize. Tickers include companies of interest rec = Records() employee = Employee() # default empty employee processor = EntryProcessor(employee, rec, tickers) empl_by_year = {} for ticker in tickers: empl_by_year[ticker] = Counter([]) if os.path.isdir(empl_path): if os.listdir(empl_path)[0].endswith('.csv'): csv_parser(processor, empl_by_year, empl_path, tickers, infer_tickers, primary_skills) else: json_parser(processor, empl_by_year, empl_path, tickers, infer_tickers, primary_skills) else: if empl_path.endswith('.csv'): print('Individual file processing supported only on json') sys.exit(1)
# -*- coding: utf-8 -*- """ Created on Mon Feb 24 14:41:02 2020 @author: keerthika02.TRN """ from enum_p import Feelings from employee import Employee import copy #List of Employees in the Management list_employee = [ Employee('John', ['html', 'css', 'java', 'c#', 'A-Frame']), Employee('Harry', ['java', 'c#', 'Babylon']), Employee('James', ['A-Frame', 'Babylon']), Employee('Mark', ['html', 'css', 'java', 'c#', 'A-Frame', 'Babylon']), Employee('Mary', ['html', 'css', 'bootstrap', 'kotlin', 'java']), Employee('Jeba', ['bootstrap', 'kotlin', 'java', 'c#', 'A-Frame', 'Babylon']), Employee('Kivi', ['bootstrap', 'kotlin', 'java', 'c#', 'A-Frame', 'Babylon']), Employee('puppu', ['html', 'css', 'bootstrap', 'A-Frame', 'Babylon']), Employee('Aparna', ['html', 'Babylon']), Employee('Jothi', ['html', 'A-Frame', 'Babylon']), Employee('Kali', ['html', 'c#', 'A-Frame', 'Babylon']), Employee('madhu', [ 'html', 'css', 'bootstrap', 'kotlin', 'java', 'c#', 'A-Frame', 'Babylon' ]), Employee('bala', ['kotlin', 'java', 'c#', 'A-Frame', 'Babylon']), Employee('Ravi', ['html', 'c#', 'A-Frame', 'Babylon']),
from employee import Employee from hourly_pay import Hourly_pay employees_list = [] employee1 = Employee('Matthew Swart', 1001) employee2 = Employee('Fiona Duff', 1002) employees_list.append(employee1) employees_list.append(employee2) hourly1 = Hourly_pay('Jordan Harrison', 1003, 9.95, 21.5) hourly2 = Hourly_pay('Mikola Christodoulo', 1004, 15.50, 112) employees_list.append(hourly1) employees_list.append(hourly2) for staff in employees_list: print staff print '\n'
def setUp(self): self.andy = Employee('andy', 'green', 150000)
def setUp(self): self.emp_1 = Employee('Catherine', 'Turcotte', 50000) self.emp_2 = Employee('Sue', 'Smith', 60000)