Retrait de la PEP8 (mais je remet une fois que tu aura push
This commit is contained in:
parent
c4d3a98726
commit
3ac3e394b5
@ -1,13 +1,11 @@
|
|||||||
#dummy module
|
#dummy module
|
||||||
import os
|
import asyncio
|
||||||
import random
|
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
|
||||||
|
|
||||||
import discord
|
|
||||||
import fractale.source.main
|
import fractale.source.main
|
||||||
|
import random
|
||||||
|
import discord
|
||||||
|
import os
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
|
|
||||||
class MainClass():
|
class MainClass():
|
||||||
def __init__(self, client, modules, owners, prefix):
|
def __init__(self, client, modules, owners, prefix):
|
||||||
self.client = client
|
self.client = client
|
||||||
@ -22,32 +20,14 @@ class MainClass():
|
|||||||
self.interactive=True
|
self.interactive=True
|
||||||
self.color=0x78ffc3
|
self.color=0x78ffc3
|
||||||
self.fractals={
|
self.fractals={
|
||||||
"von_koch_curve_flake": {"Type": "Figures", "Max": ((5000, 5000), 5000, 10), "Min": ((0, 0), 0, 1),
|
"von_koch_curve_flake":{"Type":"Figures", "Max":((5000,5000), 5000, 10), "Min":((0,0),0,1), "Default":"(2500 2500) 2000 5 #ffffff 1", "Indication":"(départ) (arrivée) longueur iterations color bg stroke", "ParseData":"pfixi"},
|
||||||
"Default": "(2500 2500) 2000 5 #ffffff 1",
|
"von_koch_curve":{"Type":"Figures", "Max":((5000,5000),(5000,5000),10), "Min":((0,0),(0,0),1), "Default":"(0 2500) (5000 2500) 5 #ffffff 1", "Indication":"(départ) (arrivée) iterations color bg stroke", "ParseData":"ppixi"},
|
||||||
"Indication": "(départ) (arrivée) longueur iterations color bg stroke",
|
"blanc_manger":{"Type":"Figures", "Max":((5000,5000),(5000,5000),10), "Min":((0,0),(0,0),1), "Default":"(1000 1000) (4000 4000) 7 #ffffff 1", "Indication":"(départ) (arrivée) iterations color bg stroke", "ParseData":"ppixi"},
|
||||||
"ParseData": "pfixi"},
|
"dragon":{"Type":"Lsystem", "Max":((5000,5000), 2500,19), "Min":((0,0),1,1), "Default":"(2500 2500)", "Indication":"(origine) longueur iterations color bg stroke", "ParseData":"pfixi"},
|
||||||
"von_koch_curve": {"Type": "Figures", "Max": ((5000, 5000), (5000, 5000), 10), "Min": ((0, 0), (0, 0), 1),
|
"sierpinski_triangle":{"Type":"Lsystem", "Max":((5000,5000),2500,11), "Min":((0,0),0,1), "Default":"(0 0)", "Indication":"(origine) longueur iterations color bg stroke", "ParseData":"pfixi"},
|
||||||
"Default": "(0 2500) (5000 2500) 5 #ffffff 1",
|
"fractal_plant":{"Type":"Lsystem", "Max":((5000,5000),2500,8), "Min":((0,0),0,1), "Default":"(0 2500)", "Indication":"(origine) longueur iterations color bg stroke", "ParseData":"pfixi"},
|
||||||
"Indication": "(départ) (arrivée) iterations color bg stroke", "ParseData": "ppixi"},
|
"koch_curve_right_angle":{"Type":"Lsystem", "Max":((5000,5000),2500,9), "Min":((0,0),0,1), "Default":"(0 5000)", "Indication":"(origine) longueur iterations color bg stroke", "ParseData":"pfixi"},
|
||||||
"blanc_manger": {"Type": "Figures", "Max": ((5000, 5000), (5000, 5000), 10), "Min": ((0, 0), (0, 0), 1),
|
"fractal_binary_tree":{"Type":"Lsystem", "Max":((5000,5000),2500,15), "Min":((0,0),0,1), "Default":"(0 0)", "Indication":"(origine) longueur iterations color bg stroke", "ParseData":"pfixi"}
|
||||||
"Default": "(1000 1000) (4000 4000) 7 #ffffff 1",
|
|
||||||
"Indication": "(départ) (arrivée) iterations color bg stroke", "ParseData": "ppixi"},
|
|
||||||
"dragon": {"Type": "Lsystem", "Max": ((5000, 5000), 2500, 19), "Min": ((0, 0), 1, 1),
|
|
||||||
"Default": "(2500 2500)", "Indication": "(origine) longueur iterations color bg stroke",
|
|
||||||
"ParseData": "pfixi"},
|
|
||||||
"sierpinski_triangle": {"Type": "Lsystem", "Max": ((5000, 5000), 2500, 11), "Min": ((0, 0), 0, 1),
|
|
||||||
"Default": "(0 0)", "Indication": "(origine) longueur iterations color bg stroke",
|
|
||||||
"ParseData": "pfixi"},
|
|
||||||
"fractal_plant": {"Type": "Lsystem", "Max": ((5000, 5000), 2500, 8), "Min": ((0, 0), 0, 1),
|
|
||||||
"Default": "(0 2500)", "Indication": "(origine) longueur iterations color bg stroke",
|
|
||||||
"ParseData": "pfixi"},
|
|
||||||
"koch_curve_right_angle": {"Type": "Lsystem", "Max": ((5000, 5000), 2500, 9), "Min": ((0, 0), 0, 1),
|
|
||||||
"Default": "(0 5000)",
|
|
||||||
"Indication": "(origine) longueur iterations color bg stroke",
|
|
||||||
"ParseData": "pfixi"},
|
|
||||||
"fractal_binary_tree": {"Type": "Lsystem", "Max": ((5000, 5000), 2500, 15), "Min": ((0, 0), 0, 1),
|
|
||||||
"Default": "(0 0)", "Indication": "(origine) longueur iterations color bg stroke",
|
|
||||||
"ParseData": "pfixi"}
|
|
||||||
}
|
}
|
||||||
self.help="""\
|
self.help="""\
|
||||||
</prefix>fractale [fractale] [nombre d'itérations]
|
</prefix>fractale [fractale] [nombre d'itérations]
|
||||||
@ -57,6 +37,7 @@ class MainClass():
|
|||||||
```..: Toutes les fractales:
|
```..: Toutes les fractales:
|
||||||
%s```"""%'\n'.join(['......: %s'%t for t in self.fractals.keys()])
|
%s```"""%'\n'.join(['......: %s'%t for t in self.fractals.keys()])
|
||||||
|
|
||||||
|
|
||||||
def parse(self, inp):
|
def parse(self, inp):
|
||||||
retDic={"Success":False, "Message":"", "Result":()}
|
retDic={"Success":False, "Message":"", "Result":()}
|
||||||
#Parsing the fractal name and storing the corresponding dic into a variable
|
#Parsing the fractal name and storing the corresponding dic into a variable
|
||||||
@ -74,14 +55,12 @@ class MainClass():
|
|||||||
elif char==')':
|
elif char==')':
|
||||||
parentheses_count-=1
|
parentheses_count-=1
|
||||||
if not(-1<parentheses_count<2):
|
if not(-1<parentheses_count<2):
|
||||||
retDic.update({"Success": False,
|
retDic.update({"Success":False, "Message":"Usage invalide de parentheses au charactère numéro %s (à partir d'après le nom de la fractale)."%i})
|
||||||
"Message": "Usage invalide de parentheses au charactère numéro %s (à partir d'après le nom de la fractale)." % i})
|
|
||||||
return(retDic)
|
return(retDic)
|
||||||
|
|
||||||
#Here, we have a coherent parentheses usage
|
#Here, we have a coherent parentheses usage
|
||||||
if ',' in arg:
|
if ',' in arg:
|
||||||
retDic.update({"Success": False,
|
retDic.update({"Success":False, "Message":"Les virgules n'ont pas leur place dans les paramètres de génération. Il ne doit y avoir que des espaces uniques."})
|
||||||
"Message": "Les virgules n'ont pas leur place dans les paramètres de génération. Il ne doit y avoir que des espaces uniques."})
|
|
||||||
return(retDic)
|
return(retDic)
|
||||||
|
|
||||||
#parsing the fractal
|
#parsing the fractal
|
||||||
@ -95,14 +74,12 @@ class MainClass():
|
|||||||
int(args[i])
|
int(args[i])
|
||||||
int(args[i+1])
|
int(args[i+1])
|
||||||
except:
|
except:
|
||||||
retDic.update({"Success": False,
|
retDic.update({"Success":False, "Message":"Les valeurs ne sont pas du bon type. (nombre entiers attendus pour les coordonnées d'un point)"})
|
||||||
"Message": "Les valeurs ne sont pas du bon type. (nombre entiers attendus pour les coordonnées d'un point)"})
|
|
||||||
return(retDic)
|
return(retDic)
|
||||||
parsed_args.append((int(args[i]),int(args[i+1])))
|
parsed_args.append((int(args[i]),int(args[i+1])))
|
||||||
i+=2
|
i+=2
|
||||||
else:
|
else:
|
||||||
parsed_args.append(
|
parsed_args.append(self.parse(inp.split(' ')[0]+' '+fractal['Default'])['Result'][len(parsed_args)])
|
||||||
self.parse(inp.split(' ')[0] + ' ' + fractal['Default'])['Result'][len(parsed_args)])
|
|
||||||
i+=1
|
i+=1
|
||||||
|
|
||||||
elif parse=='f':
|
elif parse=='f':
|
||||||
@ -110,14 +87,12 @@ class MainClass():
|
|||||||
try:
|
try:
|
||||||
float(args[i])
|
float(args[i])
|
||||||
except:
|
except:
|
||||||
retDic.update({"Success": False,
|
retDic.update({"Success":False, "Message":"Les valeurs ne sont pas du bon type. (Nombre à virgule flottante attendu (mettre un point pour la virgule))"})
|
||||||
"Message": "Les valeurs ne sont pas du bon type. (Nombre à virgule flottante attendu (mettre un point pour la virgule))"})
|
|
||||||
return(retDic)
|
return(retDic)
|
||||||
parsed_args.append(float(args[i]))
|
parsed_args.append(float(args[i]))
|
||||||
i+=1
|
i+=1
|
||||||
else:
|
else:
|
||||||
parsed_args.append(
|
parsed_args.append(self.parse(inp.split(' ')[0]+' '+fractal['Default'])['Result'][len(parsed_args)])
|
||||||
self.parse(inp.split(' ')[0] + ' ' + fractal['Default'])['Result'][len(parsed_args)])
|
|
||||||
i+=1
|
i+=1
|
||||||
|
|
||||||
elif parse=='i':
|
elif parse=='i':
|
||||||
@ -127,14 +102,12 @@ class MainClass():
|
|||||||
except:
|
except:
|
||||||
print(args[i])
|
print(args[i])
|
||||||
print(i)
|
print(i)
|
||||||
retDic.update({"Success": False,
|
retDic.update({"Success":False, "Message":"Les valeurs ne sont pas du bon type. (Nombre entier attendu)"})
|
||||||
"Message": "Les valeurs ne sont pas du bon type. (Nombre entier attendu)"})
|
|
||||||
return(retDic)
|
return(retDic)
|
||||||
parsed_args.append(int(args[i]))
|
parsed_args.append(int(args[i]))
|
||||||
i+=1
|
i+=1
|
||||||
else:
|
else:
|
||||||
parsed_args.append(
|
parsed_args.append(self.parse(inp.split(' ')[0]+' '+fractal['Default'])['Result'][len(parsed_args)])
|
||||||
self.parse(inp.split(' ')[0] + ' ' + fractal['Default'])['Result'][len(parsed_args)])
|
|
||||||
i+=1
|
i+=1
|
||||||
|
|
||||||
elif parse=='x':
|
elif parse=='x':
|
||||||
@ -145,14 +118,12 @@ class MainClass():
|
|||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
except:
|
except:
|
||||||
retDic.update({"Success": False,
|
retDic.update({"Success":False, "Message":"Les valeurs ne sont pas du bon type. (Valeur hexadécimale attendue)"})
|
||||||
"Message": "Les valeurs ne sont pas du bon type. (Valeur hexadécimale attendue)"})
|
|
||||||
return(retDic)
|
return(retDic)
|
||||||
parsed_args.append(int(args[i].replace('#','0x'),16))
|
parsed_args.append(int(args[i].replace('#','0x'),16))
|
||||||
i+=1
|
i+=1
|
||||||
else:
|
else:
|
||||||
parsed_args.append(
|
parsed_args.append(self.parse(inp.split(' ')[0]+' '+fractal['Default'])['Result'][len(parsed_args)])
|
||||||
self.parse(inp.split(' ')[0] + ' ' + fractal['Default'])['Result'][len(parsed_args)])
|
|
||||||
i+=1
|
i+=1
|
||||||
retDic.update({"Success":True, "Result":parsed_args})
|
retDic.update({"Success":True, "Result":parsed_args})
|
||||||
return(retDic)
|
return(retDic)
|
||||||
@ -166,26 +137,22 @@ class MainClass():
|
|||||||
|
|
||||||
fig = fractale.source.main.Figures(im=im)#here
|
fig = fractale.source.main.Figures(im=im)#here
|
||||||
if len(args)==1 :
|
if len(args)==1 :
|
||||||
await self.client.loop.run_in_executor(ThreadPoolExecutor(), fig.von_koch_curve_flake,
|
await self.client.loop.run_in_executor(ThreadPoolExecutor(), fig.von_koch_curve_flake,*((2500, 2500), 2000, 5))
|
||||||
*((2500, 2500), 2000, 5))
|
|
||||||
elif args[1].lower()=="blanc_manger" :
|
elif args[1].lower()=="blanc_manger" :
|
||||||
iterations=7
|
iterations=7
|
||||||
if len(args)>2 and int(args[2])<=20:
|
if len(args)>2 and int(args[2])<=20:
|
||||||
iterations=int(args[2])
|
iterations=int(args[2])
|
||||||
await self.client.loop.run_in_executor(ThreadPoolExecutor(), fig.blanc_manger,
|
await self.client.loop.run_in_executor(ThreadPoolExecutor(), fig.blanc_manger,*((1000, 1000), (4000, 4000), iterations))
|
||||||
*((1000, 1000), (4000, 4000), iterations))
|
|
||||||
elif args[1].lower()=="von_koch_curve_flake" :
|
elif args[1].lower()=="von_koch_curve_flake" :
|
||||||
iterations=5
|
iterations=5
|
||||||
if len(args)>2 and int(args[2])<=7:
|
if len(args)>2 and int(args[2])<=7:
|
||||||
iterations=int(args[2])
|
iterations=int(args[2])
|
||||||
await self.client.loop.run_in_executor(ThreadPoolExecutor(), fig.von_koch_curve_flake,
|
await self.client.loop.run_in_executor(ThreadPoolExecutor(), fig.von_koch_curve_flake,*((2500, 2500), 2000, iterations))
|
||||||
*((2500, 2500), 2000, iterations))
|
|
||||||
elif args[1].lower()=="von_koch_curve" :
|
elif args[1].lower()=="von_koch_curve" :
|
||||||
iterations=5
|
iterations=5
|
||||||
if len(args)>2 and int(args[2])<=7:
|
if len(args)>2 and int(args[2])<=7:
|
||||||
iterations=int(args[2])
|
iterations=int(args[2])
|
||||||
await self.client.loop.run_in_executor(ThreadPoolExecutor(), fig.von_koch_curve,
|
await self.client.loop.run_in_executor(ThreadPoolExecutor(), fig.von_koch_curve,*((0, 2500), (5000,2500), iterations))
|
||||||
*((0, 2500), (5000, 2500), iterations))
|
|
||||||
else:
|
else:
|
||||||
await self.modules['help'][1].send_help(message.channel, self)
|
await self.modules['help'][1].send_help(message.channel, self)
|
||||||
return#here
|
return#here
|
||||||
|
Loading…
Reference in New Issue
Block a user