diff --git a/skill_generator.py b/skill_generator.py index de640f3..fc41006 100755 --- a/skill_generator.py +++ b/skill_generator.py @@ -4,6 +4,7 @@ # Not actually part of the project; just easier to maintain everything here import sys,os,traceback +import re try: import Blessings except: @@ -14,8 +15,8 @@ try: args=sys.argv[1:] command=sys.argv[1] except: - print("No command specified, just outputing the list") - command="print" + print("No command specified, just outputing the help") + command="help" """var d_vars={"nb_dices":0,"perfection":0,"defense_i_0":0,"defense_i_1":0,"defense_i_2":0,"rempart_p":0, @@ -127,18 +128,20 @@ class listWrapper(): ## Commands def initialise(args): + "Initialise the variables for the switch" text="var d_vars={" for line in list: text+='"{}":{},'.format(line[0],line[6]) text=text[:-1]+'};' - print(text) return text def pprint(args): + "Print the whole list of values" for i in list: print(i) def check_init(args): + "Check the initialisation message" try: test_values=args[1] except: @@ -188,34 +191,50 @@ def check_init(args): return fails def reroll(args): + "Generate the reroll inline message" + reroll="var msg_relance=\"Relancer ce jet";\'' + return reroll def check_reroll(args): - pass + "Check the reroll inline message" + model=""""Relancer ce jet";""" + var=re.compile('" .* ".*\+"') + print(var.search(model)) def check_wrapper(args): + "Test the wrapper, only useful internally" fails=0 s=len(hashedCategories) @@ -240,22 +259,31 @@ def check_wrapper(args): print("Wrapper: All test sucessful") return fails +def help(args): + "Help, print the following message" + print("List of availables commands") + for key in commands.keys(): + print(" {}: {}".format(key,commands[key].__doc__)) def test_all(args): + "Execute all tests" check_init(args) check_reroll(args) check_wrapper(args) commands={"init":initialise,"print":pprint,"reroll":reroll, "test_init":check_init,"test_wrapper":check_wrapper, -"test":test_all} +"test":test_all,"help":help} if __name__ == '__main__': wrapper=megaListWrapper() try: - commands[command](args) + ret=commands[command](args) + if ret: + print(ret) except KeyError: - print("Command {} doesn't exist, choose from {}".format(command,str(commands.keys()))) + print("Command {} doesn't exist".format(command)) + commands['help'](args) except Exception: print("Couldn't execute command "+command) print(" > {} ({})".format(sys.exc_info()[1],sys.exc_info()[0]))