Esempio n. 1
0
	def _read_customers(self, path):
		""" read customer from path and add to self._customers """
		try:
			for cust_id, cust_name in file_reader(path, 2, sep=",", header=True):
				if cust_id in self._customers:
					print(f'customer id already there {cust_id}')
				else:
					self._customers[cust_id] = Customer(cust_id, cust_name)
		except ValueError as err:
			print(err)
Esempio n. 2
0
	def _read_products(self, path):
		"""read product file"""
		try:
			for prod_id, store_id, prod_name in file_reader(path, 3, sep="|", header=False):
				if prod_id in self._products:
					print(f"product id already exists {prod_id}")
				else:
					self._stores[store_id].add_productname(prod_id, prod_name)
		except ValueError as err:
			print(err)
Esempio n. 3
0
	def _read_stores(self, path):
		"""read store file"""
		try:
			for store_id, store_name in file_reader(path, 2, sep="*", header=True):
				if store_id in self._stores:
					print(f"Store id already there {store_id}")
				else:
					self._stores[store_id] = Store(store_id, store_name)
		except ValueError as err:
			print(err)
Esempio n. 4
0
	def _read_inventory(self, path):
		"""read inventory file"""
		try:
			for store_id, available_quantity, product_id in file_reader(path, 3, sep="|", header=True):
				if store_id in self._stores:
					self._stores[store_id].add_inventory(available_quantity, product_id)
				else:
					print(f"Warning: Store id does not exists {store_id}")
		except ValueError as err:
			print(err)
Esempio n. 5
0
 def read_instructors(self, path):
     try:
         for cwid, name, dept in file_reader(path,
                                             3,
                                             sep="\t",
                                             header=False):
             if cwid in self._instructors:
                 print(f"already exists {cwid}")
             else:
                 self._instructors[cwid] = Instructor(cwid, name, dept)
     except ValueError as err:
         print(err)
Esempio n. 6
0
 def read_students(self, path):
     try:
         for cwid, name, major in file_reader(path,
                                              3,
                                              sep="\t",
                                              header=False):
             if cwid in self._students:
                 print(f"ALready exists {cwid}")
             else:
                 self._students[cwid] = Student(cwid, name, major)
     except ValueError as err:
         print(err)
Esempio n. 7
0
 def read_majors(self, path):
     """read the majors from major.txt"""
     try:
         for major, flag, course in file_reader(path,
                                                3,
                                                sep='\t',
                                                header=False):
             if major in self._majors:
                 self._majors[major].add_course(flag, course)
             else:
                 self._majors[major] = Major(major)
                 self._majors[major].add_course(flag, course)
     except ValueError as err:
         print(err)
Esempio n. 8
0
 def read_students(self, path):
     """read the students.txt"""
     try:
         for cwid, name, major in file_reader(path,
                                              3,
                                              sep="\t",
                                              header=False):
             if cwid in self._students:
                 print(f"{cwid} is already there")
             else:
                 self._students[cwid] = Student(cwid, name, major,
                                                self._majors[major])
     except ValueError as err:
         print(err)
Esempio n. 9
0
	def _read_transactions(self, path):
		"""read transaction file"""
		try:
			for cust_id, quantity, prod_id, store_id in file_reader(path, 4, sep="|", header=True):
				if cust_id in self._customers:
					available_product = self._stores[store_id].available_product(prod_id)

					self._customers[cust_id].add_quantity(self._stores[store_id]._product_name[prod_id], quantity
					if int(quantity) < available_product else available_product)

				else:
					print(f"Warning: Customer Id {cust_id} does not exist")

				if store_id in self._stores:
					self._stores[store_id].update_inv(prod_id, quantity, self._customers[cust_id]._name)
				else:
					print(f"Warning: Store Id {store_id} does not exist")
		except ValueError as err:
			print(err)
Esempio n. 10
0
    def read_grades(self, path):
        """read the file grades.txt"""
        try:
            for student_cwid, course, grade, instructor_cwid in file_reader(
                    path, 4, sep='\t', header=False):
                if student_cwid in self._students:
                    self._students[student_cwid].add_course(course, grade)
                else:
                    print(
                        f"Warning: Student cwid {student_cwid} doesnt exist in students file"
                    )

                if instructor_cwid in self._instructors:
                    self._instructors[instructor_cwid].add_course(
                        course)  # using the instructor cwid as key
                else:
                    print(
                        f"Warning: instructor cwid {instructor_cwid} doesnt exist in instructor file"
                    )

        except ValueError as erf:
            print(erf)