def main(): """where it all gets done """ from optparse import OptionParser parser = OptionParser() parser.add_option("-q", "--quiet", help="quiet mode. Just display APL", action="store_false", dest="verbose", default=True) parser.add_option("-v", "--verbose", help="verbose mode. Display how APL was calculated", action="store_true", dest="verbose", default=False) parser.add_option("-f", "--file", help="path to file in configparser INI format", dest="input_file", default="") parser.add_option("-d", "--directory", help="path to directory containing files ending in .pcg", dest="input_directory", default="") parser.add_option("-r", "--range", help="display range of challenges from Easy to Epic", action="store_true", dest="range", default=False) parser.add_option("-c", "--challenge-rating", help="display CR of party (not same as APL, varies by count)", action="store_true", dest="cr", default=False) (options, args) = parser.parse_args() result = 0 cr = "" if options.input_file: (apl, count) = nots.calculate_apl_from_file(options.input_file, options.verbose) if options.input_directory: (apl, count) = nots.calculate_apl_from_dir(options.input_directory, options.verbose) if options.cr: cr = nots.calculate_cr(apl, count) cr = nots.cr_int_to_cr_display(cr) if cr: result = cr else: result = apl if options.range: nots.print_range(result, options.verbose) else: if options.cr: type="Challenge Rating" else: type="Average Party Level" nots.print_result(result, options.verbose, type)
def test_return_correct_string_for_cr_int_2(self): """CR 2 returns a string of 2""" expect= '2' result = 0 result = nots.cr_int_to_cr_display(2) self.assertEqual(expect, result)
def test_return_correct_string_for_cr_int_neg_4(self): """CR -4 returns a string of 1/8""" expect= '1/8' result = 0 result = nots.cr_int_to_cr_display(-4) self.assertEqual(expect, result)
def test_return_correct_string_for_cr_int_0(self): """CR 0 returns a string of 1/2""" expect= '1/2' result = 0 result = nots.cr_int_to_cr_display(0)
def test_return_correct_string_for_cr_int_3(self): """CR 3 returns a string of 3""" expect= '3' result = 0 result = nots.cr_int_to_cr_display(3) self.assertEqual(expect, result)