from Outils.Directory import GenerateDirectory
from pathlib import Path

def createFileConfig(nom, specifique = ''):
    
    generateDirectory = GenerateDirectory(nom, '/Modules/'+nom+'/' if specifique==''else '', specifique)
    directory = generateDirectory.getDirectory()
    nom = generateDirectory.getNom(True)

    Path(directory).mkdir(parents=True, exist_ok=True)

    with open(directory+"config.php","x", encoding='utf-8') as file:
        file.write("<?php\n\n")
        file.write("return [\n")
        file.write("    '"+nom+".prefix' => '"+nom+"',\n")
        file.write("    'twig.extensions."+nom+"' => [\n")
        file.write("        DI\get(Modules\\"+nom+"\TwigExtension\Outil"+nom+"Extension::class)\n")
        file.write("    ],\n")
        file.write("];\n")
        file.close()

