Skip to content

uzoawili/amity-room-allocation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Allocator Build Status

Python program to allocate people to rooms in Andela's Amity.

Installation

  1. Clone the repo to any directory on your PC from which you can run python (preferrably with a virtual environment).
  2. Run pip install -r requirements.txt to install all dependencies.
  3. Finally run python allocator.py and voila! Start allocating!

The program is should guide you from there but if not, feel free to use the help command anytime.

Testing

  1. Run the following command in the root program's root package: nosetests
  2. To test with coverage reports: nosetests --with-coverage --cover-package=allocator

Usage

This application runs as a command interpreter.

  1. Typically you start by loading or inputing data for teams and rooms. (NOTE: There are defaults for this, you only need call the bare minimum commands without any arguments).
  2. Next you run the 'allocate' command to allocate person to rooms.
  3. Finally you can query for room or team allocation data and 'print' it to the console or 'save' to a file.

Commands:

See below for the list of commands and their usage:

LOAD

Loads data from text files to populate either the 'team' or 'rooms'. Has the format:
load [<target>(team|rooms) ['<filepath>'] ] [<mode>(:o|:a)]

  • target:
    The target data to populate. Value can be either team or rooms. Note that although setting target is optional, the other options have no effect unless it is specified. Calling load without target loads both rooms and teams with the default filepath and mode settings.

  • filepath:
    Optional. Path to the input file wrapped in single-quotes ''. Can be absolute or relative. Defaults to '/data/input_persons_ext.txt' for team and '/data/input_rooms_ext.txt' for rooms.

  • mode:
    Optional. Specifies how the data is added to target.
    :o to overwrite previously loaded data.
    :a to append to previously loaded data.
    Defaults to :o.

    Examples:
    load team './data/input_persons_ext.txt' :a
    load rooms

INPUT

Collects data from command line to populate either the 'team' or 'rooms'. Has the format:
input <target>(team|rooms) '<cslist>' [<mode>(:o|:a)]

  • target:
    The target data to populate. Value can be either team or rooms. Note that although setting target is optional, the other options have no effect unless it is specified. Calling load without target loads both rooms and teams with the default filepath and mode settings.

  • cslist:
    Comma seperated list of input lines for persons or rooms wrapped in single-quotes ''.

  • mode:
    Optional. Specifies how the data is added to target.
    :o to overwrite previously loaded data.
    :a to append to previously loaded data.
    Defaults to :a.

    Examples:
    input team 'ANDREW PHILLIPS FELLOW Y M, MATTHEW O'CONNOR STAFF' :o
    input room 'HAMMER OFFICE STAFF, SAPELE LIVING F'

ALLOCATE

Allocates persons to rooms using optional or default constraints. Has the format:
allocate [<sep_gender>(g+|g-)] [<sep_roles>(r+|r-)]

  • sep_gender:
    Optional. Specifies whether genders should be separated when allocating fellows to living spaces.
    g+ to seperate genders.
    g- to allow different genders to share living spaces. lol...in your dreams ;)
    Defaults to g+.

  • sep_roles:
    Optional. Specifies whether roles (staff and fellows) should be separated when allocating persons to office spaces.
    r+ to seperate roles.
    r- to allow staff and fellows to share office spaces. Not bad huh?
    Defaults to r+.

    Examples:
    allocate g+ r-
    allocate

PRINT

Outputs team or room data to the console. Filter options are available. Has the format:
print <target>(team|room) [<filters>(see the filter tables below)]

  • target:
    Target data to output. Value can be either team or rooms.

  • filters:
    Optional. Filters the output using combinations of constraints:

    Room filters meaning
    os or ls office spaces or living spaces
    st or fw for staffor _for fellows
    ml or fm for males or for females
    oc+ or oc- has occupants or no occupants
    cf+ or cf- is full capacity or not full capacity
    Person filters meaning
    st or fw staff or fellows
    ml or fm male or female
    o+ or o- have office space or don't have office space
    l+ or l- have living space or don't have living space
    w+ or w- want living space or don't want living space

    NOTE: for rooms filters, any of the five pairs can be combined in the same command. The same hold true for person filteres.

    Examples:
    print rooms os fw c+ # prints office-spaces for fellows that are filled to capacity.
    print team fw fm w+ l- # prints female fellows that want but have not been allocated living spaces.

SAVE

Outputs team or room data to a file. Filter options are available. Use the format:
save <target>(team|room) [<filters>(any combination from the list below)] ['<filepath>'] [<mode>(:o|:a)]

  • target:
    Same as in 'print' command.

  • filters:
    Same as in 'print' command.

  • filepath:
    Optional path to the output file wrapped in single-quotes ''. Can be absolute or relative.
    Defaults to './data/output.txt'.

  • mode:
    Optional. Specifies how the data is written to file.
    :o to overwrite previous saved content.
    :a to append to previously saved content.
    Defaults to :o.

    Examples:
    save rooms os fw c- '/data/output.txt' :a
    save team fw ml l-

About

Room allocation system for Andela's Amity.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages