Exemple #1
0
    def do_all(self, line):
        """
        Prints all string representation of all
        instances based or not on the class name.
        """
        objs = FileStorage().all()

        if line:
            args = line.split(' ')

            if args[0] not in self.allowed_modules:
                print("** class doesn't exist **")
                return

            fill_list1 = []
            for k, v in objs.items():
                if args[0] in k:
                    fill_list1.append(str(v))
            print(fill_list1)

        else:
            fill_list2 = []
            for v in objs.values():
                fill_list2.append(str(v))
            print(fill_list2)
Exemple #2
0
 def cities(self):
     ''' Return the cities linkes to the current state '''
     dic = FileStorage().all()
     cities = []
     for key, value in dic.items():
         try:
             if value.state_id == self.id:
                 cities.append(value)
         except:
             pass
     return (cities)
Exemple #3
0
 def cities(self):
     """returns the list of City instances with state_id"""
     objDict = FileStorage().all()
     citiesList = []
     for key, value in objDict.items():
         try:
             if value.state_id == self.id:
                 citiesList.append(value)
         except:
             pass
     return (citiesList)