Newer
Older
class ZcliConfig:
filename = '.zephir-config.yaml'
config_file = Path.home() / filename
def __init__(self):
if not ZcliConfig.config_file.exists():
print("""Attention, le fichier de configuration de zephir-cli est inexistant !""")
url = input("Entrez l'adresse du serveur Zephir : ")
version = input("Entrez la version du zephir (defaut: 'v1') : ")
if not version:
version = "v1"
yaml_template = f"""url: {url}
with ZcliConfig.config_file.open("w", encoding ="utf-8") as fh:
fh.write(yaml_template)
print("Le fichier de configuration '.zephir-config.yaml' a été généré dans votre répertoire home. ")
with open(ZcliConfig.config_file, 'r') as stream:
try:
config = yaml.load(stream)
except yaml.YAMLError as exc:
print("Erreur au moment du chargement du fichier de configuration", exc)
config = {}
self.url = config.get('url')
self.version = config.get('version')