Skip to content

Commit

Permalink
Merge 867f918 into 2ca9483
Browse files Browse the repository at this point in the history
  • Loading branch information
Nwuguru Sunday committed May 12, 2016
2 parents 2ca9483 + 867f918 commit 2042d7c
Show file tree
Hide file tree
Showing 60 changed files with 6,602 additions and 1 deletion.
1 change: 1 addition & 0 deletions .coverage
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!coverage.py: This is a private format, don't read it directly!{"lines": {"/Users/andela/Documents/projects/room-allocation/src/person.py": [1, 4, 5, 7, 8, 9, 10, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 25, 30, 31, 32, 34, 41, 45, 46, 47, 48, 49, 50, 51, 55, 68, 73, 76, 77, 78, 79, 81, 89, 92, 94, 96, 98, 99, 100, 102, 113, 114, 116, 117], "/Users/andela/Documents/projects/room-allocation/src/util.py": [1, 2, 3, 4, 5, 7, 8, 10, 11, 12, 14, 16, 18, 20, 21, 23, 29, 33, 37, 39, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 61, 62, 63], "/Users/andela/Documents/projects/room-allocation/src/room.py": [1, 2, 5, 6, 8, 9, 11, 12, 14, 15, 16, 17, 18, 20, 23, 24, 25, 27, 28, 30, 31, 32, 34, 35, 36, 38, 41, 42, 43, 44, 45, 46, 48, 49, 51, 53, 55, 61, 62, 63, 64, 65, 67, 69, 70, 72, 76, 79, 80, 83, 84, 86, 87, 89, 91, 94, 96], "/Users/andela/Documents/projects/room-allocation/test.py": [1, 3, 4], "/Users/andela/Documents/projects/room-allocation/src/amity.py": [1, 3, 4, 5, 6, 7, 8, 521, 522, 11, 524, 525, 526, 15, 528, 17, 18, 19, 20, 21, 22, 23, 24, 516, 538, 539, 28, 542, 517, 33, 34, 35, 37, 40, 41, 554, 44, 47, 48, 49, 530, 51, 513, 350, 56, 58, 573, 62, 64, 523, 68, 70, 275, 73, 74, 77, 78, 79, 592, 81, 82, 83, 84, 85, 86, 88, 89, 91, 92, 93, 95, 96, 97, 99, 100, 293, 102, 529, 616, 106, 107, 108, 109, 110, 112, 531, 116, 117, 118, 119, 120, 124, 125, 126, 533, 128, 131, 132, 133, 134, 135, 136, 138, 535, 141, 142, 143, 144, 657, 146, 148, 661, 662, 151, 152, 153, 155, 162, 163, 676, 165, 169, 170, 172, 173, 174, 175, 176, 177, 179, 692, 182, 183, 184, 185, 186, 188, 189, 190, 191, 192, 194, 195, 198, 199, 201, 204, 205, 206, 207, 208, 210, 211, 212, 213, 216, 217, 218, 219, 221, 223, 229, 536, 231, 232, 234, 235, 236, 238, 239, 240, 241, 243, 244, 248, 281, 42, 254, 255, 256, 640, 258, 259, 537, 261, 145, 267, 268, 269, 271, 272, 273, 643, 276, 277, 278, 280, 644, 285, 645, 291, 292, 646, 296, 297, 647, 300, 301, 302, 303, 307, 310, 311, 312, 527, 299, 660, 317, 318, 319, 321, 324, 325, 326, 328, 329, 331, 334, 335, 336, 337, 338, 339, 340, 341, 343, 344, 345, 347, 540, 351, 352, 353, 355, 356, 230, 359, 362, 363, 364, 365, 366, 368, 370, 373, 374, 375, 377, 382, 383, 385, 387, 392, 393, 394, 395, 397, 400, 401, 402, 403, 404, 408, 414, 419, 420, 424, 425, 433, 313, 435, 440, 441, 442, 443, 447, 451, 452, 453, 454, 460, 462, 465, 466, 467, 468, 472, 164, 476, 477, 478, 479, 481, 482, 484, 357, 490, 492, 495, 496, 497, 501, 504, 505, 506, 507, 508, 509], "/Users/andela/Documents/projects/room-allocation/tests/test_fileman.py": [1, 2, 3, 4, 6, 7, 9, 10, 11, 13, 14, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 28, 29, 30, 32, 33, 34, 35, 36, 38, 39, 40, 41, 44, 45, 46, 48, 49, 50, 52, 53, 54, 55, 56, 57, 59, 60, 61, 63, 64, 65, 66, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 82], "/Users/andela/Documents/projects/room-allocation/tests/test_db.py": [1, 2, 3, 4, 5, 6, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 26, 27, 28, 29, 31, 32, 33, 36, 37, 38, 40, 41, 42, 43, 44, 45, 47, 48, 49, 50, 51, 53, 54, 55, 56, 57, 59, 60, 61, 62, 63, 65, 66, 67, 69, 70, 71, 73, 74, 75, 77, 78, 80, 81, 82, 83, 84, 85, 86, 87, 88, 90, 91, 92, 93, 94, 95, 96, 97, 104], "/Users/andela/Documents/projects/room-allocation/src/livingspace.py": [8, 1, 4, 5, 7], "/Users/andela/Documents/projects/room-allocation/src/fileman.py": [1, 2, 3, 6, 7, 9, 10, 11, 13, 14, 17, 18, 21, 27, 28, 30, 31, 32, 33, 34, 36, 39, 40, 42, 43, 44, 46, 49, 50, 52, 53, 55, 58, 59, 61, 63, 66, 67, 68, 70, 73, 75, 78, 79, 80, 82, 85, 86, 88, 89], "/Users/andela/Documents/projects/room-allocation/tests/test_room.py": [1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 13, 14, 15, 17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 32, 33, 34, 35, 36, 38, 39, 40, 41, 42, 43, 44, 45, 48, 49, 50, 51, 52, 53, 55, 56, 57, 58, 59, 62, 65, 67, 70, 71, 72, 73, 75, 76, 77, 78, 80, 81, 82, 83, 84, 86], "/Users/andela/Documents/projects/room-allocation/src/staff.py": [8, 1, 4, 5, 7], "/Users/andela/Documents/projects/room-allocation/tests/test_person.py": [1, 2, 3, 4, 6, 7, 9, 10, 11, 12, 14, 15, 16, 18, 19, 20, 22, 25, 27, 28, 30, 31, 33], "/Users/andela/Documents/projects/room-allocation/src/db.py": [1, 2, 3, 6, 7, 9, 10, 11, 12, 13, 15, 18, 19, 21, 24, 26, 28, 31, 33, 36, 37, 38, 39, 40, 41, 42, 43, 44, 46, 49, 50, 51, 52, 54, 55, 56, 58, 61, 62, 63, 66, 67, 69, 72, 73, 74, 75, 78, 79, 81, 84, 85, 86, 87, 90, 93, 94, 95, 96, 97, 98, 99, 100, 101, 103, 106, 107, 108, 109, 111, 114, 115, 116, 118, 120, 122, 125, 128, 129, 131, 134, 135, 137, 138, 139, 140, 142, 148, 149, 150, 152, 153, 155, 156, 157, 159, 168, 171, 172, 173], "/Users/andela/Documents/projects/room-allocation/src/office.py": [8, 1, 4, 5, 7], "/Users/andela/Documents/projects/room-allocation/src/fellow.py": [1, 3, 4, 6], "/Users/andela/Documents/projects/room-allocation/tests/test_amity.py": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 29, 30, 31, 32, 33, 35, 36, 37, 39, 40, 41, 43, 44, 45, 46, 49, 50, 51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 91, 92, 93, 94, 95, 97, 98, 99, 100, 101, 102, 104, 105, 107, 108, 109, 110, 111, 113, 114, 115, 116, 117, 119, 120, 121, 122, 124, 125, 126, 127, 128, 129, 131, 132, 133, 134, 135, 136, 138, 139, 140, 141, 142, 144, 145, 146, 147, 148, 149, 150, 151, 152, 154, 155, 156, 157, 158, 159, 160, 163, 164, 165, 166, 167, 168, 169, 170, 173, 174, 175, 176, 177, 178, 180, 181, 182, 183, 184, 185, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 198, 201, 202, 203, 204, 206, 207, 208, 209, 210, 211, 213]}}
6 changes: 6 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[report]
omit =
*/python?.?/*
*/site-packages/nose/*
*__init__*
src/migration.py
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.pyc
*.db
src/*.pyc
data/*.pyc
data/*.pkl
data/*.txt
tests/htmlcov/*

10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: python
python:
- "2.7"
# command to install dependencies
install:
- pip install -r requirements.txt
script:
- nosetests --with-coverage
after_success:
- coveralls
65 changes: 64 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,64 @@
# room-allocation
Room Allocation
===============
[![Build Status](https://travis-ci.org/andela-snwuguru/room-allocation.svg?branch=master)](https://travis-ci.org/andela-snwuguru/room-allocation) [![Coverage Status](https://coveralls.io/repos/github/andela-snwuguru/room-allocation/badge.svg?branch=master)](https://coveralls.io/github/andela-snwuguru/room-allocation?branch=master)

Room Allocation is a checkpoint 1 project used to evaluate Fellow proviciency in Python programming. This is not a real solution for room allocation but it is a good start for python beginners.

### Features

- Create rooms
- Add Person
- Auto allocate person to a room when added
- Reallocate person
- remove person
- Manual allocation of person
- Display allocations
- Load people from text file (see sample text file format below)
- Display unallocated people and room
- Display rooms base on allocated or unallocated
- Display room details with list of members
- Save state to sqlite database
- Load state from sqlite database

### Dependecies

- Docopt `` pip install docopt ``
- Tabulate `` pip install tabulate ``
- Coverage `` pip install coverage ``
- Python 2.7.X and above

### How to use

- Clone project `` git clone git@github.com:andela-snwuguru/room-allocation.git ``
- Create a virtual environment `` mkvirtualenv ara ``
- Install dependecies `` pip install -r requirements.txt ``
- Navigate to project folder `` cd ~/room-allocation ``
- See list of available command `` python ara.py -h ``

### Sample Operations

- Create multiple rooms `` python ara.py create_room "room 1" "office" "room 2" "living" ``
- Add Person `` python ara.py add_person "Sunday" "Nwuguru" "fellow" -w ``
- Reallocate person `` python ara.py reallocate_person "SN3" "room 2" ``
- remove person `` python ara.py remove_person "SN3" "room 2" ``
- Allocate person `` python ara.py reallocate_person "SN3" "room 2" -w ``
- Load people from text file `` python ara.py load_people "people.txt" ``
- Display allocations `` python ara.py print_allocations ``
- Export allocations to file `` python ara.py print_allocations "allocation.txt" `` exported file will be located in data folder
- Display unallocated `` python ara.py print_unallocated ``
- Export unallocated to file `` python ara.py print_unallocated "unallocated.txt" `` exported file will be located in data folder
- Display room details `` python ara.py print_room "room 1" ``
- Display people `` python ara.py list_people ``
- Display unallocated people `` python ara.py list_people -u``
- Display rooms `` python ara.py list_rooms ``
- Display allocated rooms `` python ara.py list_rooms -a``
- Save current state to sqlite database `` python ara.py save_state "my_db" ``
- Load current state from sqlite database `` python ara.py load_state "my_db" ``
- Clear Records `` python ara.py clear ``

### How to Contribute

- Fork Repo
- Create new branch and add your contribution
- Push to your branch
- Raise a pull request
Binary file added amity.db
Binary file not shown.
Binary file added amity_test.db
Binary file not shown.
60 changes: 60 additions & 0 deletions ara.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
"""Amity Room Allocation
Usage:
ara create_room (<room_name> <room_type>)...
ara add_person (<firstname> <lastname> <person_type>) [-w]
ara reallocate_person <person_id> <new_room_name> [-l]
ara allocate_person <person_id> <new_room_name> [-w]
ara remove_person <person_id> <current_room_name>
ara load_people <file_location>
ara print_allocations [(-o <file_name>)]
ara print_unallocated [(-o <file_name>) -r]
ara print_room <name_of_room>
ara save_state [--db=sqlite_database -v]
ara load_state [--db=sqlite_database]
ara list_people [-u | -a]
ara list_rooms [-u | -a]
ara clear
Options:
-h --help Show this screen.
-w Wants accomodation
-u Unallocated
-r Rooms
-a Allocated
-o Output file name
-l Living Space
-v Show Logs
"""
from docopt import docopt
from src.amity import Amity


#function mapping to avoid long if else chain
func_map = [
'create_room',
'add_person',
'reallocate_person',
'load_people',
'print_allocations',
'print_unallocated',
'print_room',
'save_state',
'load_state',
'list_people',
'list_rooms',
'allocate_person',
'remove_person',
'clear',
]

if __name__ == '__main__':
arguments = docopt(__doc__)

for command in func_map:
if arguments[command]:
amity = Amity(command)
amity.run_command(arguments)
break
5 changes: 5 additions & 0 deletions data/config.pkl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(dp0
S'drop_db'
p1
I00
s.
93 changes: 93 additions & 0 deletions data/people.pkl
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
(lp0
ccopy_reg
_reconstructor
p1
(csrc.fellow
Fellow
p2
c__builtin__
object
p3
Ntp4
Rp5
(dp6
S'living_space'
p7
I00
sS'uid'
p8
S'TU2'
p9
sS'firstname'
p10
S'TEST'
p11
sS'lastname'
p12
S'USER'
p13
sS'is_allocated'
p14
I01
sS'util'
p15
g1
(csrc.util
Util
p16
g3
Ntp17
Rp18
(dp19
S'file_manager'
p20
g1
(csrc.fileman
FileMan
p21
g3
Ntp22
Rp23
(dp24
S'file_location'
p25
S'/Users/andela/Documents/projects/room-allocation/data/people.pkl'
p26
sS'base'
p27
S'/Users/andela/Documents/projects/room-allocation'
p28
sbsS'db'
p29
g1
(csrc.db
Db
p30
g3
Ntp31
Rp32
(dp33
S'db_location'
p34
S'/Users/andela/Documents/projects/room-allocation/amity.db'
p35
sS'table_name'
p36
S'table_name'
p37
sS'error_message'
p38
S''
p39
sS'name'
p40
S'amity'
p41
sbsbsS'assigned_room'
p42
(dp43
S'OFFICE'
p44
S'TESTROOM 2'
p45
ssba.
2 changes: 2 additions & 0 deletions data/people_test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
OLUWAFEMI SULE FELLOW Y
DOMINIC WALTERS STAFF
4 changes: 4 additions & 0 deletions data/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Data folder

This folder is very vital to the functionality of this project.
Don't delete it
Loading

0 comments on commit 2042d7c

Please sign in to comment.