It is a python based program used to make the task of converting numbers and units simpler in galaxy.
- Python 2.7 is used here.
- Program has been tested with sufficient unittest test cases.
python galaxy_guide.py <input_file>
** input_file = file to read input from, (default is input.txt) **
- All data read from input file are case-sensitive
- Input can read only in the specified format as given below:
- (unit in lower case) is ( symbols from I,V,X,L,C,D,M )
- (unit1 unit2 unit3 .. unitn) (metal name with first alphabet capital) is (price) Credits
- how much is (unit1 unit2 unit3 .. unitn) ?
- how many Credits is (unit1 unit2 unit3 .. unitn) (metal name with first alphabet capital) ?
- ** The sequence in which input are passed also matters. ** Input file should contain Input type 1 (as given above) followed by type2, the question (type 3 and 4) can be in any order but should be only after type1 and type2. Refer to input.txt to get a clear idea.
- If any input question is invalid it will generate a error statement in output.
- If the conversion input is wrong, it will exit the program by printing the line which has error.
- Default input file input.txt has been attached.
- Module roman_to_number contains the logic to convert input roman number to base 10 english number.
- mapping dictionary contain the mapping of symbols to numbers.
- roman_to_number method takes a roman string, validates it by calling is_valid method and converts it into appropriate number.
- is_valid method contains the logic to check if the input roman string is valid or not. It uses various regular expression to check the input step-by-step.
- galaxy_guide module reads the input file line-by-line, checks it using the regular expression constructed dynamically
and creates a list of output.
- This module contains a class GalaxyGuide, while instantiating this class, name of input file can be passed or the default input.txt file will be used.
- The index method reads input file line-by-line, make use of current_type property to call the appropiate the method.
- _input_type1 and _input_type2 are used to validate and extract information from type1 and type1 line
- _question_type1 and _question_type2 are used to validate and generate output from question1 and question2 line
- KISS (keep it smart and simple) & DRY (Do not repeat yourself) principle has been tried to followed through out the program to keep the logic simple and at one place
- PEP 0008 -- Style Guide for Python Code has been used to maintain the coding convention consistent.
- Python unittest module has been used for testing.
- Unit test for module roman_to_number has been include in file test_r_to_n.py . Care has been taken place to check again different conditions. It can be runned using below command line statement. python test_r_to_n.py
- Unit test for module galaxy_guide has been include in test_galaxy_guide.py . All different input files are present in test_inputs file. It can be runned using below command line statement. python test_galaxy_guide.py
Thanks for using it.