hbnb is a clone of the web application AirBnB. This project will be constructed in multiples phases. In this phase we created a command interpreter to manipulate data without a visual interface, like in a Shell (perfect for development and debugging).
- Allowed editors: vi, vim, emacs
- All your files will be interpreted/compiled on Ubuntu 14.04 LTS using python3 (version 3.4.3)
- All your files should end with a new line
- The first line of all your files should be exactly #!/usr/bin/python3
- A README.md file, at the root of the folder of the project, is mandatory
- Your code should use the PEP 8 style (version 1.7 or more)
- All your files must be executable
- The length of your files will be tested using wc
- All your modules should have a documentation (python3 -c 'print(import("my_module").doc)')
- All your classes should have a documentation (python3 -c 'print(import("my_module").MyClass.doc)')
- All your functions (inside and outside a class) should have a documentation (python3 -c 'print(import("my_module").my_function.doc)' and python3 -c 'print(import("my_module").MyClass.my_function.doc)')
- AUTHORS - list of contributor
- console.py - command interpreter
do_create
- create a new instance of a classdo_show
- prints string representation of an instance based on class name and iddo_all
- prints all string representation of all instances based or not on the class namedo_destroy
- deletes an instance based on the class name and iddo_update
- updates an instance based on the class name and id by adding or updating attributeemptyline
- ensures that hitting 'enter' will not remember the last commanddo_quit
- quit programdo_EOF
- exit at end of file
- file_storage.py - class FileStorage
all
- returns the dictionary __objectsnew
- sets in __objects the obj with key .idsave
- serializes __objects to the JSON file (path: __file_path)reload
- deserializes the JSON file to __objects
- base_model.py - defines all common attributes/methods for other classes
__init__
- initialize instance attributes__str__
- creates formatted string representation of instance__repr__
- returns string representation of instancesave
- updates public instance attribute updated_at with current datetimeto_dict
- creates a dictionary containing all keys/values of__dict__
of the instance
- user.py - class User
- city.py - class City
- state.py - class State
- place.py - class Place
- review.py - class Review
- amenity.py - class Amenity
__init__.py
- initialization code for Python package models- tests - unit test files
python3 -m unittest discover tests
$ ./console.py
(hbnb) help
Documented commands (type help <topic>):
========================================
EOF help quit
(hbnb)
(hbnb)
(hbnb) quit
$
$ echo "help" | ./console.py
(hbnb)
Documented commands (type help <topic>):
========================================
EOF help quit
(hbnb)
$
$ cat test_help
help
$
$ cat test_help | ./console.py
(hbnb)
Documented commands (type help <topic>):
========================================
EOF help quit
(hbnb)
$