Inbetween commit

This commit is contained in:
Maximilien Rigaut 2019-07-13 03:57:16 +02:00
parent f957a66220
commit 408f87aa77
3 changed files with 54 additions and 12 deletions

View File

@ -4,5 +4,5 @@
description =
self =
others =
_vars
macro
_vars =
macro =

View File

@ -4,7 +4,7 @@
description = Description pour dev/balance/concept
self = Message complet pour l'utilisateur lors de l'utilisation
others = Message complet pour les autres lors de l'utilisation
_var = Valeur de la variable {{var}}
_var = Valeur de la variable {{var}} * 77
macro = Macro propre de la technique, avec tout les setvars
special = Détails a prendre en compte,
les variables importantes, les stacks. (Notes pour la balance)

View File

@ -1,26 +1,68 @@
import sys,os,traceback
import re,argparse
from os import listdir
from os.path import isfile, join
import blessings
term=blessings.Terminal()
parser = argparse.ArgumentParser(description='Macro generator')
parser.add_argument('command',choices=["macro","varnames","diff"],help="The selected command")
parser.add_argument('character',default="all",help="Name of the character, all by default",nargs="?")
parser.add_argument('characters',default=["all"],help="Name of the characters to list, all by default",nargs="*")
parser.add_argument("-o",metavar="output",default="tty",help="File for the output command, tty by default",nargs="?")
parser.add_argument("-v",default=False,action='store_true',help="Default")
parser.add_argument("version",default="last",help="The version to pick from or from wich to make the diff from",nargs="?")
parser.add_argument("--version",default="last",help="The version to pick from or from wich to make the diff from",nargs="?")
verbose=False
def dprint(text):
if verbose:
print(text)
reserved_chars=["exemple.ini","God.ini"]
errors={
"notfound":term.red("Couldn't find {char} in the Character directory")
}
try:
parser.parse_args(sys.argv[1:])
except:
parser.print_help()
commands={"macro":macro,"varnames":varnames,"diff":diff}
def macro(e):
pass
def varnames(e):
pass
def diff(e):
pass
def diff(characters,output,version):
import subprocess
chars=get_char(characters)
if len(chars)==0:
dprint(errors["notfound"].format(char="any character"))
return
if output=="tty":
dprint("Printing diff")
list=["git", "diff","HEAD","--word-diff=color","--function-context"]+chars
subprocess.call(list)
def get_char(names):
if names[0]=="all":
return get_all_chars()
char=[]
for n in names:
c=join("Characters", n+".ini")
if isfile(c):
char.append(c)
else:
dprint(errors["notfound"].format(char=c))
return char
def get_all_chars():
return [join("Characters", f) for f in listdir("Characters") if (f not in reserved_chars and isfile(join("Characters", f)))]
if __name__ == '__main__':
try:
args=parser.parse_args(sys.argv[1:])
verbose=args.v
except:
parser.print_help()
sys.exit()
#print(args)
commands={"macro":macro,"varnames":varnames,"diff":diff}
commands[args.command](args.characters,args.o,args.version)