This is the first portion of a project to build a clone of the AirBnB website. The first goal of this project is to create a program that serializes and deserializes objects into json files, and reloads them on startup for use between sessions, or in other words making the data persist between sessions.
The second goal of the project is to build a console to manage all this stored data. The console is made to update, delete, and create new instances of any class of data. It also keeps track of when the objects it has made were created, and updated.
b
Task | Files | Description |
---|---|---|
0: Authors/README File | AUTHORS | The authors for the project |
1: Pep8 | N/A | All the code in the repository is pep8 compliant |
2: Unit Testing | /tests | All the unit testing files for the program |
3. Make BaseModel | /models/base_model.py | The BaseModel class to be inherited by every model class in the project, containing a few useful methods. |
4. Update BaseModel w/ kwargs | /models/base_model.py | Add functionality to recreate an instance of a class using a dictionary passed with Kwargs |
5. Create FileStorage class | /models/engine/file_storage.py /models/_ init _.py /models/base_model.py | Class that handles the JSON serialization and deserialization of a file, and reloads the content of the file to be used within the program through multiple sessions |
6. Console 0.0.1 | console.py | Add basic functionality to a console program to quit, handle empty lines, and to handle the console encountering an EOF in the input field |
7. Console 0.1 | console.py | Update the console with multiple methods in order to create, destroy, show, and update the contents of individual objects that are stored within the file storage system. |
8. Create User class | console.py /models/engine/file_storage.py /models/user.py | Creates a user class and update the console and file storage system to work dynamically work with the user class. |
9. More Classes | /models/user.py /models/place.py /models/city.py /models/amenity.py /models/state.py /models/review.py | Add more classes to store various information through the file storage system, and to seperate similar types |
10. Console 1.0 | console.py /models/engine/file_storage.py | Updates the console to work dynamically with all the classes created through all the tasks, and update file storage to do the same |
- First clone this repository.
- Once the repository is cloned locate the "console.py" file and run it as follows
/AirBnB_clone$ ./console.py
- When this command is run the following prompt should appear:
(hbnb)
- This prompt designates you are in the "HBnB" console, there are a variety of commands available once the console program is run.
* create - Creates an instance based on given class
* destroy - Destroys an object based on class and UUID
* show - Shows an object based on class and UUID
* all - Shows all objects the program has access to, or all objects of a given class
* update - Updates existing attributes an object based on class name and UUID
* quit - Exits the program (EOF will as well)
- It is possible to call <class_name>.<command>(arguments) as well
Usage: create <class_name>
(hbnb) create BaseModel
(hbnb) create BaseModel
3aa5babc-efb6-4041-bfe9-3cc9727588f8
(hbnb)
Usage: show <class_name> <class_id>
(hbnb) show BaseModel 3aa5babc-efb6-4041-bfe9-3cc9727588f8
(hbnb) show BaseModel 3aa5babc-efb6-4041-bfe9-3cc9727588f8
[BaseModel] (3aa5babc-efb6-4041-bfe9-3cc9727588f8) {'id': '3aa5babc-efb6-4041-bfe9-3cc9727588f8', 'created_at': datetime.datetime(2020, 2, 18, 14, 21, 12, 96959),
'updated_at': datetime.datetime(2020, 2, 18, 14, 21, 12, 96971)}
(hbnb)
Usage: destroy <class_name> <class_id>
(hbnb) destroy BaseModel 3aa5babc-efb6-4041-bfe9-3cc9727588f8
(hbnb) destroy BaseModel 3aa5babc-efb6-4041-bfe9-3cc9727588f8
(hbnb) show BaseModel 3aa5babc-efb6-4041-bfe9-3cc9727588f8
** no instance found **
(hbnb)
Usage: update <class_name> <class_id>
(hbnb) update BaseModel b405fc64-9724-498f-b405-e4071c3d857f first_name "person"
(hbnb) update BaseModel b405fc64-9724-498f-b405-e4071c3d857f first_name "person"
(hbnb) show BaseModel b405fc64-9724-498f-b405-e4071c3d857f
[BaseModel] (b405fc64-9724-498f-b405-e4071c3d857f) {'id': 'b405fc64-9724-498f-b405-e4071c3d857f', 'created_at': datetime.datetime(2020, 2, 18, 14, 33, 45, 729889),
'updated_at': datetime.datetime(2020, 2, 18, 14, 33, 45, 729907), 'first_name': 'person'}
(hbnb)