Giter Club home page Giter Club logo

airbnb_clone's Introduction

AirBnB clone - The console

Welcome to the AirBnB clone project!

Getting Started

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.

Description

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.

Environment

This project is interpreted/tested on Ubuntu 14.04 LTS using python3 (version 3.4.3)

Installation

Access AirBnb directory: cd AirBnB_clone Run hbnb(interactively): ./console and enter command

Functionalities of this command interpreter:

  • 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

File Storage

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.

Console

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.

Usage

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:

Interactive Mode

  • 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(, , "")

Non-interactive mode example

$ echo "help" | ./console.py (hbnb) Documented commands (type help ): ======================================== EOF all count create destroy help quit show update

Tests

All the code is tested with the unittest module. The test for the classes are in the test_models folder

Further information

For further information on python version, and documentation visit python.org

Authors

Emmanuel Oguntade

Nike Oni

License

Public Domain. No copy write protection

airbnb_clone's People

Contributors

boloo66 avatar ninikay avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.