Exemple #1
0
    def __init__(self, input):

        #If no name, author, bar amount or time signature are provided in the file,
        # they are defaulted to "None", "None", 4 and 4/4.
        self.staff = Staff("None", "None", 4, 4 / 4)

        try:
            line = self.getNextLine(input)

            if line.strip() != "#SHEETMUSIC":
                raise CorruptedFileError("Unknown data file (missing header)")

            line = self.getNextLine(input)
            while line != "" and line != "#END":
                line = line.strip().upper()
                if line == "#SONG INFO":
                    line = self.handleInfo(input)
                if line == "#TIME":
                    line = self.handleTime(input)
                if line == "#NOTES":
                    line = self.handleNotes(input)
                if line == "#LYRICS":
                    line = self.handleLyrics(input)
                line = self.getNextLine(input)

        #If the file is faulty in some way, raise an error
        except CorruptedFileError as e:
            print("Corrupted file error:", e)
def update_member(id):
    """updates employee object based on their ID"""
    content = request.json
    try:
        if id <= 0:
            response = app.response_class(status=400)
            return response
        if content['type'] == 'staff':
            team_member = Staff(content['first_name'], content['last_name'],
                                content['date_of_birth'], content['position'],
                                content['hire_date'], content['previous_team'],
                                content['type'])
        elif content['type'] == 'player':
            team_member = Player(content['first_name'], content['last_name'],
                                 content['date_of_birth'], content['position'],
                                 float(content['height']),
                                 float(content['weight']),
                                 int(content['player_number']),
                                 content['shoot'], content['type'])
        else:
            raise ValueError
        team_member.id = id
        canucks.update(team_member)
        response = app.response_class(response="OK", status=200)
    except ValueError as e:
        status_code = 400
        if str(e) == "Team Member does not exist":
            status_code = 404
        response = app.response_class(response=str(e), status=status_code)
    return response
Exemple #3
0
    def test_profit_04_notProfit(self):

        Nackadmein = School("Nackademin")
        iot = Program("IoT")
        java = Program("Java")
        Nackadmein.addProgram(iot)
        Nackadmein.addProgram(java)

        studentx = Student("john", "gatan 12", "iot", 17, 50)
        studenty = Student("peter", "gatan 2", "iot", 17, 50)
        studentz = Student("peter", "gatan 2", "iot", 17, 40)
        iot.addStudent(studentx)
        iot.addStudent(studenty)
        java.addStudent(studentz)

        staff1 = Staff("Mark", "Tomteboda 1", "Nackademin", 50)
        staff2 = Staff("Pike", "Tomteboda 3", "Nackademin", 50)
        staff3 = Staff("Moa", "Tomteboda 1", "Nackademin", 50)
        Nackadmein.addStaff(staff1)
        Nackadmein.addStaff(staff2)
        Nackadmein.addStaff(staff3)

        self.assertEqual(
            Nackadmein.getProfit(Nackadmein.sumOfPay(), Nackadmein.totalFee()),
            False)
def setUser():
    s = Staff('Sue', '*****@*****.**', 'high', 'Manager')
    print(s.getEmail())
    print(s.getName())
    print(s.getSecurityLevel())

    print(s)
Exemple #5
0
 def test_profit_02_sumOfPay(self):
     Nackadmein = School("Nackademin")
     staff1 = Staff("Mark", "Tomteboda 1", "Nackademin", 50)
     staff2 = Staff("Pike", "Tomteboda 3", "Nackademin", 50)
     Nackadmein.addStaff(staff1)
     Nackadmein.addStaff(staff2)
     self.assertEqual(Nackadmein.sumOfPay(), 100)
Exemple #6
0
class TestStaff(TestCase):
    def setUp(self):
        self.staff = Staff()

    def test_add_book(self):
        self.staff.add_book("tbook", "tauthor")
        self.assertEqual((LibraryDB.book_list[-1]).book_title, "tbook")
        self.assertEqual((LibraryDB.book_list[-1]).author, "tauthor")
Exemple #7
0
    def prepare(self):
        super().prepare()
        
        # Read the songbook and load the first song
        self.songbook = SongBook.load()
        if self.songbook is None:
            self.songbook = SongBook()
        self.songbook.validate()
        self.songbook.sort()

        # Add a new song supplied on the command line
        song_args = {
            "--song-add": "",
            "--song-track": "1",
        }
        if MidiMaster.get_cmd_argument(song_args):
            song_path = os.path.join(".", song_args["--song-add"])
            song_track = int(song_args["--song-track"])
            
            def add_song(path:str, track=None):
                new_song = Song()
                new_song.from_midi_file(path, track)
                self.songbook.add_update_song(new_song)

            if os.path.exists(song_path):
                if os.path.isdir(song_path):
                    for file in os.listdir(song_path):
                        full_path = os.path.join(song_path, file)
                        if os.path.isfile(full_path) and file.find("mid") >= 0:
                            add_song(full_path, song_track)    
                elif os.path.isfile(song_path):
                    add_song(song_path, song_track)                
            else:
                print(f"Cannot find specificed midi file or folder {song_path}! Exiting.")
                exit()

        # Setup all the game systems
        self.staff = Staff()
        self.menu = Menu(self.graphics, self.input, self.gui, self.window_width, self.window_height, self.textures)
        self.font_game = Font(os.path.join("ext", "BlackMetalSans.ttf"), self.graphics, self.window)
        self.staff.prepare(self.menu.get_menu(Menus.GAME), self.textures)
        self.note_render = NoteRender(self.graphics, self.window_width / self.window_height, self.staff)
        self.music = Music(self.graphics, self.note_render, self.staff)
        self.menu.prepare(self.font_game, self.music, self.songbook)
        
        if GameSettings.DEV_MODE:
            default_song = self.songbook.get_default_song()
            if default_song is None:
                print("Invalid or missing song data file, unable to continue!")
            else:
                self.music.load(default_song)
        
        # Connect midi inputs and outputs and player input
        self.devices = MidiDevices()
        self.devices.open_input_default()
        self.devices.open_output_default()
        self.setup_input()
Exemple #8
0
def worker(sublist):
    print(sublist)
    #for link in sublist:
    print(base_url + sublist)
    workerHtmlTree = BeautifulSoup(
        requests.get(base_url + sublist).text, "lxml")
    staff = Staff(*Staff.populateObjectFromHTML(workerHtmlTree),
                  base_url + sublist)
    #print(staff.toJSON().decode('utf8'))
    return staff
Exemple #9
0
def main():

    p1 = Person('felix', "男", (1994, 11, 15), '14434216')
    p2 = Person('刘笑', "男", (1993, 4, 5), '14434213')
    p3 = Person('小明', "男", (1994, 5, 15), '14434234')
    p4 = Person('刘红', "女", (1993, 1, 5), '14434201')
    plist = [p1, p2, p3, p4]
    for p in plist:
        print(p)
    #按照编号对人员进行排序
    plist.sort()
    for p in plist:
        print(p.details())

    print('People created:', Person.num(), '\n')

    p5 = Staff("张", "女", (1974, 10, 16))
    print(p5)
    p5.set_department("数学")
    p5.set_position("副教授")
    p5.set_salary(30000)

    print(p5.details())

    p6 = Student("gg", "女", (1994, 11, 15), "计算机")
    print(p6)
    print(p6._enroll_date)
    p6.set_course("微积分")
    print(p6._courses)
    p6.set_course("c")
    print(p6._courses)
    p6.set_score("c", 66)
    print(p6.score())
    print(p6.details())
Exemple #10
0
    def find_staff_lines(self):
        row_sums = np.sum(self.inverted_music, axis=1) / 255

        # plt.barh(np.arange(row_sums.shape[0]), row_sums)
        # plt.show()
        # plt.waitforuserinput()

        highest = np.max(row_sums)
        avg = int(np.average(np.where(row_sums > 0)))

        print(highest)
        print(avg)

        staffs = []
        last_staff_line = None
        current_line = []
        current_staff = Staff()

        for row, line in enumerate(row_sums):
            # We are at a staff line
            if in_tolerance(line, highest, 0.2):
                current_line.append(row)

            # We are not at a staff line,
            # append if the current line
            # is not empty
            elif len(current_line) > 0:
                next_staffline = StaffLine.from_ys(current_line)
                next_center = next_staffline.center()

                if last_staff_line is None or abs(
                        next_center -
                        last_staff_line.center()) < 2 * self.staffspace_height:
                    current_staff.add_line(next_staffline)
                else:
                    if current_staff.len() == 5:
                        staffs.append(current_staff)

                    current_staff = Staff()
                    current_staff.add_line(next_staffline)

                last_staff_line = next_staffline
                current_line = []

        if current_staff.len() > 0:
            staffs.append(current_staff)

        self.staffs = staffs
Exemple #11
0
class Amity(object):
    def __init__(self):
        print("Welcome to Amity\n")
        self.office = Office()
        self.livingspace = LivingSpace()
        self.staff = Staff()
        self.fellow = Fellow()

    def ready(self):
        command = None
        while command != "exit":
            command = self.get_input()
            if command.lower() == "exit":
                command = "exit"
            else:
                method_params = map(str.lower, command.split())
                getattr(self, method_params[0])(method_params[1::])
        return

    def get_input(self):
        return raw_input(">> ").strip()

    """
     create_room OFFICE carat vvida minion
     create_room LIVINGSPACE carat vvida minion
    """

    def create_room(self, rooms):
        if rooms[0] == "office":
            self.office.create(rooms)
        else:
            self.livingspace.create(rooms)

    """
    add_person bukky FELLOW Y
    add_person tosin STAFF
    """

    def add_person(self, person_details):
        if len(person_details) == 2:
            person_details.append("N")

        if person_details[1] == "fellow":
            self.fellow.add(person_details)
            self.fellow.allocate_room(self.office, self.livingspace)
        else:
            self.staff.add(person_details)
            self.staff.allocate_room(self.office)
Exemple #12
0
    def load_people(self, args):
        """Creates people from a specified file and allocates each person based on person type"""

        path = args['<file_location>']
        if not Util.is_file(path):
            Util.print_line('File location is invalid')
            return False

        with open(path, 'r') as file:
            for line in file:
                records = line.split()
                living_space = False
                firstname = records[0]
                lastname = records[1]
                person_type = records[2]
                if person_type.upper() == 'FELLOW':
                    if (records[3].upper() == 'Y'):
                        living_space = True
                    person = Fellow(firstname, lastname, living_space)
                else:
                    person = Staff(firstname, lastname)

                self.people.append(person)
                Util.print_line(person.name() + ' succesfully created')
                self.allocate(person, None, 'OFFICE')
                if person.is_fellow():
                    self.allocate(person)
            self.save_state_to_pickle()
def add_member():
    """adds employee object based on type and assigns object an ID number"""
    content = request.json
    try:
        if content['type'] == 'staff':
            staff = Staff(content['first_name'], content['last_name'],
                          content['date_of_birth'], content['position'],
                          content['hire_date'], content['previous_team'],
                          content['type'])
            id = canucks.add(staff)
        elif content['type'] == 'player':
            player = Player(content['first_name'], content['last_name'],
                            content['date_of_birth'], content['position'],
                            float(content['height']), float(content['weight']),
                            int(content['player_number']), content['shoot'],
                            content['type'])

            id = canucks.add(player)
        else:
            raise ValueError

        response = app.response_class(response=str(id), status=200)

    except:
        response = app.response_class(response="Input invalid", status=400)
    return response
Exemple #14
0
    def staffs(self):
        draw = False
        staffs = []

        for i, vs in enumerate(self.getStaffSegments()):
            #self.ap.paintHLine(vs.bottom)
            x = nu.arange(vs.top, vs.bottom)
            #self.ap.paintRav(nu.column_stack((x,i*2*nu.ones(len(x)))),color=(10,10,10))
            log().info('Processing staff segment {0}'.format(i))
            #vs.draw = i==2
            staffs.extend(
                [Staff(self, s, vs.top, vs.bottom) for s in vs.staffLines])

        staffs = self.selectStaffs(staffs)

        if len(staffs) % 2 != 0:
            log().warn(
                'Detected unequal number of staffs for file:\n\t{0}'.format(
                    self.fn))
            log().info('TODO: retry to find an equal number of staffs')

        if draw:
            for staff in staffs:
                staff.draw()
            self.ap.writeImage('tst.png')
            self.ap.reset()

        return staffs
Exemple #15
0
 def get_staff(self, staff_id):
     with dbapi2.connect(self.dbfile) as connection:
         cursor = connection.cursor()
         query = "select * from staff where (id = %s)"
         cursor.execute(query, (staff_id, ))
         if (cursor.rowcount == 0):
             return None
     found_staff = Staff(*cursor.fetchone()[:])
     return found_staff
Exemple #16
0
 def get_all_staff(self):
     all_staff = []
     with dbapi2.connect(self.dbfile) as connection:
         cursor = connection.cursor()
         query = "select * from staff order by id asc"
         cursor.execute(query)
         for row in cursor:
             staf = Staff(*row[:])
             all_staff.append(staf)
     return all_staff
Exemple #17
0
 def get_shift_staff(self):
     staff_list = list()
     for l in self.f:
         values = l.rstrip().split(",")
         emp_id = int(values[0])
         name = values[1]
         role = values[2]
         staff = Staff(emp_id, name, StaffRole[role])
         staff_list.append(staff)
     return staff_list
Exemple #18
0
 def __init__(self, graphics: Graphics, note_render: NoteRender,
              staff: Staff):
     self.graphics = graphics
     self.staff = staff
     self.note_positions = staff.get_note_positions()
     self.notes = Notes(graphics, note_render, staff, self.note_positions)
     self.song = None
     self.tempo_bpm = 60
     self.ticks_per_beat = Song.SDQNotesPerBeat
     self.backing_index = {}
     self.backing_time = {}
Exemple #19
0
    def test_profit_03_isProfit(self):

        Nackadmein = School("Nackademin")
        iot = Program("IoT")
        Nackadmein.addProgram(iot)

        studentA = Student("john", "gatan 12", "iot", 17, 50)
        studentB = Student("peter", "gatan 2", "iot", 17, 50)
        studentC = Student("pjotr", "gatan 2", "iot", 17, 50)
        iot.addStudent(studentA)
        iot.addStudent(studentB)
        iot.addStudent(studentC)

        staff1 = Staff("Mark", "Tomteboda 1", "Nackademin", 50)
        staff2 = Staff("Pike", "Tomteboda 3", "Nackademin", 50)
        Nackadmein.addStaff(staff1)
        Nackadmein.addStaff(staff2)

        self.assertEqual(
            Nackadmein.getProfit(Nackadmein.sumOfPay(), iot.sumOfFee()), True)
def get_staffs(image):
    """
    Returns a list of Staff
    :param image: image to get staffs from
    :return: list of Staff
    """
    processed_image, thresholded = preprocess_image(image)
    hough = cv2.HoughLines(processed_image, 1, np.pi / 150, 200)
    all_lines, lines_image_color = detect_lines(hough, thresholded, 80)
    staffs = detect_staffs(all_lines)
    draw_staffs(lines_image_color, staffs)
    return [Staff(staff[0], staff[1]) for staff in staffs]
Exemple #21
0
def unpack(line):
    """ takes in a line of Staff Data, and unpacks the values,
        returns a new object of Staff data
    """

    (id, firstName, lastName, twh, tot, superFirst, superLast,
     employDate) = line.split()

    new1 = Staff(id, firstName, lastName, twh, tot, superFirst, superLast,
                 employDate)

    return new1
Exemple #22
0
    def get_people_table(self, allocated=True):
        """ Returns the list of people with headers as the first item in the list """

        records = [Staff.headers()]
        counter = 0
        for person in self.people:
            if not person.is_allocated and not allocated:
                counter += 1
                records.append([counter] + person.details_list())
            else:
                counter += 1
                records.append([counter] + person.details_list())
        return records
    def test_add(self):
        """Test if it's adding correctly and test if it raises a error in case it's provided the wrong type"""
        team1 = Player("Bo", "Horvat", "12/02/2000", "C", 6.0, 215, 53, "L",
                       "player")
        team2 = Staff("Jim", "Benning", "1/2/1945", "General Manager",
                      "01/07/2015", "Boston Bruins", "staff")

        self.team_mgr.add(team1)
        self.team_mgr.add(team2)

        team_list = self.team_mgr.get_all()
        print(team_list)
        self.assertEqual(len(team_list), 2)
Exemple #24
0
class Room:
    s = "staff"
    f = "fellow"
    input = raw_input(
        "Hi, please identify yourself by either:  staff or fellow ::")

    if input == s:

        Staff.member()  #runs the member method in a static manner.
    elif input == f:

        Fellow.fellower()  #runs the fellower method in a static manner
    else:
        print "Invalid option"
Exemple #25
0
 def populate(self):
     """ Populate the pub """
     self.door = Door(self, Coord(0, 1))
     self.map.add_building(self.door.pos, self.door)
     self.add_walls()
     self.add_bar()
     self.add_tables()
     self.add_chairs()
     self.new_customer()
     self.add_supplies()
     for i in range(self.num_staff):
         pos = self.map.free_people_loc()
         serv = Staff(pub=self, name=f"Staff_{i}", pos=pos)
         self.map.add_people(pos, serv)
         self.staff.append(serv)
    def test_get_all(self):
        """test get all"""
        team_all = self.team_mgr.get_all()
        self.assertEqual(len(team_all), 0)

        team1 = Player("Bo", "Horvat", "12/02/2000", "C", 6.0, 215, 53, "L",
                       "player")
        team2 = Staff("Jim", "Benning", "1/2/1945", "General Manager",
                      "01/07/2015", "Boston Bruins", "staff")

        team1_id = self.team_mgr.add(team1)
        team2_id = self.team_mgr.add(team2)

        team_all = self.team_mgr.get_all()
        self.assertEqual(len(team_all), 2)
Exemple #27
0
    def add_person(self, firstname, lastname, role, wants_accomodation="N"):
        try:
            fellow = {}
            staff = {}
            roles = ["fellow", "staff", "F", "S"]
            wants_accomodation_options = ["Yes", "N", "Y" "No", None]
            if type(firstname) != str or type(lastname) != str:
                print("Please enter valid names.")
            else:
                if role not in roles:
                    return "Please enter valid role."
                else:
                    if role == "fellow" or role == "F":
                        fellow_name = firstname + " " + lastname
                        self.fellow_counter = self.fellow_counter+1
                        fellow_id = "F"+str(self.fellow_counter)
                        fellow["id"] = fellow_id
                        fellow["name"] = fellow_name
                        fellow["office"] = self.allocate_office(fellow_id)
                        if wants_accomodation == "Yes" or wants_accomodation == "Y":
                            fellow["living_space"] = self.allocate_living_space(
                                fellow_id, "topaz")

                        elif wants_accomodation == "no" or wants_accomodation == "N":
                            pass
                        else:
                            print(
                                "invalid accomodation option, fellow created but not assigned living space.")
                        self.fellows.append(fellow)
                        fellow = Fellow()
                    else:
                        self.staff_counter = self.staff_counter + 1
                        staff_id = "S" + str(self.staff_counter)
                        staff["id"] = staff_id
                        staff["name"] = firstname + " " + lastname
                        staff["office"] = self.allocate_office(staff_id)
                        self.staff.append(staff)
                        staff = Staff()
                        if wants_accomodation == "yes" or wants_accomodation == "Y":
                            print(
                                "Staff does not get living space. staff created with no living space.")
                        elif wants_accomodation == "no" or wants_accomodation == "N":
                            pass
                        else:
                            print("invalid accomodation")

        except():
            return "Please try again"
Exemple #28
0
def get_staffs(image, i):
    try:
        print('mean: ' + repr(np.mean(image)) + ' std: ' +
              repr(np.std(image)) + ' m/s: ' +
              repr(np.mean(image) / np.std(image)))
    except:
        return
    processed_image, thresholded = preprocess_image(image, i)
    # hough = cv2.HoughLines(processed_image, 1, np.pi / 150, 200)
    hough = cv2.HoughLines(processed_image, 1, np.pi / 100, 100)
    # print(hough2.size-hough1.size)
    all_lines, lines_image_color = detect_lines(hough, thresholded, 80, i)
    staffs = detect_staffs(all_lines)
    draw_staffs(lines_image_color, staffs, i)

    return [Staff(staff[0], staff[1]) for staff in staffs]
Exemple #29
0
    def add_person(self, person_name, person_type, wants_accomodation='N'):
        random_office = None
        random_livingspace = None
        if self.get_available_rooms("office"):
            random_office = random.choice(self.get_available_rooms("office"))
        if self.get_available_rooms("livingspace"):
            random_livingspace = random.choice(
                self.get_available_rooms("livingspace"))

        if person_type == 'fellow':
            if wants_accomodation and wants_accomodation == 'Y':
                new_fellow = Fellow(person_name, "fellow", random_office,
                                    random_livingspace)

                self.fellows_added.append(new_fellow)
                if random_office:
                    new_fellow.office.number_of_occupants += 1
                    print((new_fellow.office.name,
                           str(new_fellow.office.number_of_occupants)))

                if random_livingspace:
                    new_fellow.livingspace.number_of_occupants += 1
                return 'Fellow ' + person_name + ' has successfully been added.'

            else:
                new_fellow = Fellow(person_name, "fellow", random_office, None)
                self.fellows_added.append(new_fellow)
                if random_office:
                    new_fellow.office.number_of_occupants += 1
                    print((new_fellow.office.name,
                           str(new_fellow.office.number_of_occupants)))

                return 'Fellow ' + person_name + ' has successfully been added.'

        if person_type == 'staff':
            if wants_accomodation and wants_accomodation == 'Y':
                return 'Staff cannot be allocated livingspace'
            else:
                new_staff = Staff(person_name, "staff", random_office)
                self.staff_added.append(new_staff)
                if random_office:
                    new_staff.office.number_of_occupants += 1
                    print((new_staff.office.name,
                           str(new_staff.office.number_of_occupants)))

                return 'Staff ' + person_name + ' has successfully been added.'
def staff_dashboard():
    """Function to display options for staff member
    :return: None
    """

    print("STAFF DASHBOARD")
    print("1. Add books")
    print("2. Delete books")
    print("3. View Transactions")
    print("4. Back to home page")
    print("5. Exit")
    ch = int(input())
    staff = Staff()
    while True:
        if ch == 1:
            print("Enter the title of the book : ")
            book_title = input()
            print("Enter the author name : ")
            author = input()
            staff.add_book(book_title, author)

        elif ch == 2:
            print(*[book for book in LibraryDB.book_list], sep="\n")
            print("Enter the id of the book you want to delete : ")
            req_id = int(input())
            staff.delete_book(req_id)

        elif ch == 3:
            staff.view_report()

        elif ch == 4:
            return

        else:
            exit()

        print("\nSTAFF DASHBOARD")
        print("1. Add books")
        print("2. Delete books")
        print("3. View Transactions")
        print("4. Back to home page")
        print("5. Exit")
        ch = int(input())
 def __init__(self, queue_name, queue_region, aws_access_key_id, aws_secret_access_key):
     Staff.__init__(self, aws_access_key_id, aws_secret_access_key)     
     self.queue = SQSUtils(queue_name, queue_region, aws_access_key_id, aws_secret_access_key)
 def __init__(self, queue_name, queue_region, aws_access_key_id, aws_secret_access_key):
     Staff.__init__(self, aws_access_key_id, aws_secret_access_key)     
     #Staff.deliver_queue_init(self, queue_name, queue_region, aws_access_key_id, aws_secret_access_key)     
     self.queue = SQSUtils(queue_name, queue_region, aws_access_key_id, aws_secret_access_key)
     self.priority = self._priority_init()
Exemple #33
0
 def __init__(self, aws_access_key_id, aws_secret_access_key, logger=None):
     Staff.__init__(self, aws_access_key_id, aws_secret_access_key)
     self.result_pool = list()