# Path: app/lib/conf.py
# APP = meta.APP_NAME
# class MetaConf(object):
# class Config(object):
#     def __init__(self):
#     def resolveMacros(self):
#     def getConfRoot(self):
#     def getSnapPath(self):
#     def getConfPaths(self):
#     def __init__(self, **kwargs):
#     def load(self, conf_type, *file_path):
#     def get(self, section, key):
#     def set(self, section, key, value):
#     def show(self):
#     def save(self):
#     def envGet():
#     def envGet2(key):
#     def envSet(self, **kwargs):
#     def envShow(self):
#     def getConfig(self, file):
#     def parseConfig(file):
# 
# Path: app/lib/auth.py
# class User(object):
#     def __init__(self):
#     def load(self):
#     def save(self, data):
#     def get(self, username):
#     def sha_password(cls, password):
#     def bcrypt_password(cls, password):
#     def show(self):
#     def add(self, username, password):
#     def delete(self, username):
#     def update(self, username, password):
#     def authenticate(self, username, password):
# 
# Path: app/lib/cert.py
# class Certificate(object):
#     def __init__(self):
#     def create(self):
#     def save(file, data):
# 
# Path: app/__metadata__.py
# APP_NAME = 'LXDUI'
# APP_CLI_CMD = 'lxdui'
# VERSION = '2.2'
# GIT_URL = 'https://github.com/AdaptiveScale/lxdui.git'
# LXD_URL = 'http://localhost:8443'
# LICENSE = 'Apache 2.0'
# AUTHOR = 'AdaptiveScale, Inc.'
# AUTHOR_URL = 'http://www.adaptivescale.com'
# AUTHOR_EMAIL = 'info@adaptivescale.com'
# KEYWORDS = 'lxc lxc-containers lxd'
# IMAGE_HUB = 'http://hub.kuti.io'
# AUTO_LOAD_CONFIG = True
# DEFAULT_CONFIG_FORMAT = 'ini'


from app.lib import conf, auth, cert
from pathlib import Path
from app import __metadata__ as meta
import shutil
import os
import logging
            if file.is_file():
                if file.stat() != 0:
                    print('File already exists: {}'.format(file_path))
                    self.replace(file_type, file_path)
                else:
                    print("File already exists, but it's empty: {} .".format(file_path))
                    self.createFile(file_type)
            else:
                print('Filename {} is a directory!'.format(file_path))
                raise Exception('{} is a directory!'.format(file_path))
        else:
            self.createFile(file_type)

    def replace(self, file_type, file_path):
        # prompt the user if the file should be deleted
        reply = input("Do you want to delete it and create a new one? [[y]/n] ")
        if reply == 'y' or reply == '':
            # os.rename(file_path, file_path + '.bak')
            os.remove(file_path)
            self.createFile(file_type)
        else:
            print("Aborting...")
            exit()

    def createConfig(self):
        # if the config file doesn't exist create it from the metadata
        pass

    def createFile(self, file_type):
        if file_type == 'auth':

# Path: app/lib/conf.py
# APP = meta.APP_NAME
# class MetaConf(object):
# class Config(object):
#     def __init__(self):
#     def resolveMacros(self):
#     def getConfRoot(self):
#     def getSnapPath(self):
#     def getConfPaths(self):
#     def __init__(self, **kwargs):
#     def load(self, conf_type, *file_path):
#     def get(self, section, key):
#     def set(self, section, key, value):
#     def show(self):
#     def save(self):
#     def envGet():
#     def envGet2(key):
#     def envSet(self, **kwargs):
#     def envShow(self):
#     def getConfig(self, file):
#     def parseConfig(file):
# 
# Path: app/lib/auth.py
# class User(object):
#     def __init__(self):
#     def load(self):
#     def save(self, data):
#     def get(self, username):
#     def sha_password(cls, password):
#     def bcrypt_password(cls, password):
#     def show(self):
#     def add(self, username, password):
#     def delete(self, username):
#     def update(self, username, password):
#     def authenticate(self, username, password):
# 
# Path: app/lib/cert.py
# class Certificate(object):
#     def __init__(self):
#     def create(self):
#     def save(file, data):
# 
# Path: app/__metadata__.py
# APP_NAME = 'LXDUI'
# APP_CLI_CMD = 'lxdui'
# VERSION = '2.2'
# GIT_URL = 'https://github.com/AdaptiveScale/lxdui.git'
# LXD_URL = 'http://localhost:8443'
# LICENSE = 'Apache 2.0'
# AUTHOR = 'AdaptiveScale, Inc.'
# AUTHOR_URL = 'http://www.adaptivescale.com'
# AUTHOR_EMAIL = 'info@adaptivescale.com'
# KEYWORDS = 'lxc lxc-containers lxd'
# IMAGE_HUB = 'http://hub.kuti.io'
# AUTO_LOAD_CONFIG = True
# DEFAULT_CONFIG_FORMAT = 'ini'


# Path: app/cli/init.py
from app.lib import conf, auth, cert
from pathlib import Path
from app import __metadata__ as meta
import shutil
import os
import logging

            if file.is_file():
                if file.stat() != 0:
                    print('File already exists: {}'.format(file_path))
                    self.replace(file_type, file_path)
                else:
                    print("File already exists, but it's empty: {} .".format(file_path))
                    self.createFile(file_type)
            else:
                print('Filename {} is a directory!'.format(file_path))
                raise Exception('{} is a directory!'.format(file_path))
        else:
            self.createFile(file_type)

    def replace(self, file_type, file_path):
        # prompt the user if the file should be deleted
        reply = input("Do you want to delete it and create a new one? [[y]/n] ")
        if reply == 'y' or reply == '':
            # os.rename(file_path, file_path + '.bak')
            os.remove(file_path)
            self.createFile(file_type)
        else:
            print("Aborting...")
            exit()

    def createConfig(self):
        # if the config file doesn't exist create it from the metadata
        pass

    def createFile(self, file_type):
        if file_type == 'auth':

            auth.User().save(self.account)