Welcome to the AirBnB clone project!
This team project is part of the ALX Software Engineer program. It is an educational purpose clone project from [AirBnB] and it is the first step towards building a first full web application. This first step consists of a custom command-line interface for data management, and the base classes for the storage of this data.
For this task a basic console was created using the Cmd Python module, to manage the objects of the whole project, being able to implement the methods create, show, update, all, and destroy to the existing classes and subclasses.
This project is interpreted/tested on Ubuntu 14.04 LTS using python3 (version 3.4.3)
Access AirBnb directory: cd AirBnB_clone Run hbnb(interactively): ./console and enter command
- Create a new object (ex: a new User or a new Place)
- Retrieve an object from a file, a database etc...
- Do operations on objects (count, compute stats, etc...)
- Update attributes of an object
- Destroy an object
The presented classes are stored in FileStorage class file. When the console is initialized, the console redirects an instance of FileStorage named storage. #Storage object is loaded or reloaded from any class instances stored in the JSON file file.json. Class instances are created, updated, or deleted and storage object registers changes intofile.json.
A FileStorage class is defined in file_storage.py with methods to follow this flow: -> to_dict() -> -> JSON dump -> -> FILE -> -> JSON load -> ->
The init.py file contains the instantiation of the FileStorage class called storage, followed by a call to the method reload() on that instance. This allows the storage to be reloaded automatically at initialization, which recovers the serialized data.
The console is a CLI that allows the use of data as backend tool. It can be used to handle all classes predefined previously called into storage object.
The console works both in interactive mode and non-interactive mode, much like a Unix shell. It prints a prompt and waits for the user for input:
- Run the console --> ./console.py
- Quit the console -->(hbnb) quit
- Display the help for a command -->(hbnb) help
- Create an object (prints its id) -->(hbnb) create
- Show an object -->(hbnb) show or (hbnb) .show()
- Destroy an object -->(hbnb) destroy or (hbnb) .destroy()
- Show all objects, or all instances of a class -->(hbnb) all or (hbnb) all
- Update an attribute of an object -->(hbnb) update "" or (hbnb) .update(, , "")
$ echo "help" | ./console.py (hbnb) Documented commands (type help ): ======================================== EOF all count create destroy help quit show update
All the code is tested with the unittest module. The test for the classes are in the test_models folder
For further information on python version, and documentation visit python.org
Emmanuel Oguntade
Nike Oni
Public Domain. No copy write protection