import sys

table={}
table['overwrite']={'en': 'If you continue, you will overwrite the file : '}

table['cantwrite']={'en': "You can't write the file : "}




class Message:
    "Class to manage the message"
    def __init__(self,lang='en'):
        self.lang=lang


    def help(self):
        if self.lang=='en':
            print("NAME : \n\
	dim_frac\n\
\n\
SYNOPSIS :\n\
	dim_frac argument [options]\n\
\n\
\n\
DESCRIPTION :\n\
	dim_frac is a free software under GPL licence for fractal dimension computation. dim_frac can also generate the graph to see if the regression is correct.\n\
	\n\
\n\
ARGUMENT :\n\
	It must be an image supported by the ImageMagic Package (It includes png, bmp, tiff, jpeg, ...)\n\
\n\
OPTIONS :\n\
	-f, --force : don't ask before overwriting a file\n\
	-h, --help : print this help\n\
	-o, --output : This option allows to choose the type of the output. The default value is 'text'. \n\
		       The different parameters are :\n\
			all : all the available exportation\n\
			text : it only print the result\n\
			window : it open a Window with the graph\n\
			png : it exports the graph in png file\n\
			jpeg : it exports the graph in jpeg file\n\
			svg : it exports the graph in svg file (vectorial format)\n\
			fig : it exports the graph in fig file (for xfig)\n\
	--output2 : It's like the option --output except all : it's usefull, if you want export to more than one format.\n\
	--output3 : ...\n\
\n\
	--output_name : This option allows to define the name of the output without the extension which you can not define. By this way you can choose the directory where you want to save the files.\n\
\n\
	-m, --method : This option allows to choose the method for the box size sampling. The default method is pair\n\
			The different methods are :\n\
			all : We sample all the size, (good, but very long)\n\
			pair : We sample only the pair size.\n\
			exponential : We sample the power of the precision.\n\
\n\
\n\
\n\
	-p,--precision : Define the precision (a float strictly between 1 and 2). The default value is 1.2.\n\
\n\
EXEMPLES :\n\
\n\
frac_dim my_picture.png\n\
\n\
frac_dim my_picture.png -o text --output2 window --output3 svg --output_name my_export  -m all\n\
\n\
frac_dim my_picture.png -o all -m exponential --precision=1.1 --force\n\
")

                       
        else:
            self.Inexistante_language()
        



    def invalid_output(self, argument=""):
        if self.lang=='en':
            print("Invalid output : "+argument)
        else:
            self.Inexistante_language()



    def invalid_precision(self):
        if self.lang=='en':
            print("Invalid precision")
        else:
            self.Inexistante_language()



    def invalid_algo(self):
        if self.lang=='en':
            print("Invalid algorithm")
        else:
            self.Inexistante_language()



    def failed(self,output_name,output):
        if self.lang=='en':
            print("The exportation of "+output_name+'.'+output+ " failed!" )
        else:
            self.Inexistante_language()



    def invalid_method(self):
        if self.lang=='en':
            print("Invalid method")
        else:
            self.Inexistante_language()


    def doyouwanttocontinu(self,message="",file_name=""):
        
        try:
            print table[message][self.lang] + file_name
        except :
            'do nothing'
            
        if self.lang=='en':
            
            print("Do you want to continue?[y,n]")
            keyboard=raw_input()

            if keyboard in ['y','Y']:
                print "let's go"
            elif keyboard in ['n','N']:
                print "Good bye"
                sys.exit()
            else:
                self.doyouwanttocontinu()
            
        else:
            self.Inexistante_language()



    def non_valid_argument(self):
        if self.lang=='en':
            print("Non valid image!")
        else:
            self.Inexistante_language()
        sys.exit()



        
    def Inexistante_language(self):
        print("Inexistante language")
    
    
        

