A Command Interpreter to Manage AirBnb objects.
Files interpreted/run on Ubuntu 14.04 LTS with Python 3
All code is written in accordance with Pep8 https://www.python.org/dev/peps/pep-0008/
- Interactive mode,
$ ./console.py
, and you will prompted with(hbnb)
*Non-interactive mode,$ echo "help" | ./console.py
- Type either
EOF
orquit
help
- Usage:
help
- Documentation/help provided
- Usage:
create
- Usage:
create BaseModel
- Creates a new instance of a class, saves it (to the JSON file) and prints the
id
- Usage:
show
- Usage:
show BaseModel 1234-5847-3912
- Prints the string representation of an instance based on the class name and
id
- Usage:
destroy
- Usage:
destroy BaseModel 1234-5847-3912
- Deletes an instance based on the class name and
id
(save the change into the JSON file).
- Usage:
all
- Usage:
all
- Prints all string representation of all instances based or not on the class name.
- Usage:
update
- Usage:
update User 1234-5678-9101 email 115@holbertonschool.com
- Updates an instance based on the class name and id by adding or updating attribute (save the change into the JSON file)
- Usage:
Module for Main Console
class HBNBCommand(cmd.Cmd)
includes:def emptyline(self)
: method to handle empty linedef do_quit(self, line)
: quit command method to exit consoledef do_create(self, arg)
: method to make new instance, saves it, and print iddef do_show(self, arg)
: method to print string representation of an instance based on class name/iddef do_destroy(self, arg)
: method to deletes instance based on class name/iddef do_all(self, arg)
: prints string representation of all instances or all instances of a classdef do_update(self, arg)
: method to update instance based on class name/id by adding/updating attribute
Module for Base Model
class BaseModel
includes:def __init__(self, *args, **kwargs)
: method to initialize instancedef save(self)
: method to update attributesupdated_at
with current datetime.def to_json(self)
: method to return dictionary of all key/values of instance and teh class namedef __str__(self)
: method to print dictionary of attributes of the instance.
Module for Amenity Model
class Amenity
includes:- `def init(self, *args, **kwargs) : method to make an instance of amenity
Module for City Model
class City
includes:- `def init(self, *args, **kwargs) : method to make instance of amenity
Module for Place Model
class Place
includes:- `def init(self, *args, **kwargs) : method to make an instance of place
Module for Review Model
class Review
includes:- `def init(self, *args, **kwargs) : method to initialize instance of review
Module for State Model
class State
includes:- `def init(self, *args, **kwargs) : method to make an instance of state
Module for User Model
class User
includes:- `def init(self, *args, **kwargs) : method to make instance of user
- initializes package
Module for serializing and deserializing instances and JSON
class FileStorage
includes:def all(self)
: methods to return __objectsdef new(self, obj)
: method to set obj in __objects with key/value pairdef save(self)
: method to serialize __objects to JSON filedef reload(self)
: method to deserialize the JSON to __objects
Public Domain, no copywrite protection