# Path: libs/utils.py
# def ensure_dir(f):
#     d = os.path.dirname(f)
#     if not os.path.exists(d):
#         os.makedirs(d)
# 
# def ensure_file(f):
#     if not os.path.isfile(f):
#         open(f, 'a').close()


import os
import sys
import copy
import inspect
import framework
from enum import Enum
from libs.utils import ensure_dir, ensure_file
# framework_folder = os.path.dirname(framework.__file__)
framework_folder  = '.' if framework_folder == '' else framework_folder

app_folder = os.path.dirname(framework_folder)
app_folder = '.' if app_folder == '' else app_folder
projects_folder = app_folder + os.sep + 'projects' + os.sep
data_models_folder = app_folder + os.sep + 'data_models' + os.sep

fuddly_data_folder = os.path.expanduser('~' + os.sep + 'fuddly_data' + os.sep)
if not os.path.exists(fuddly_data_folder):
    new_fuddly_data_folder = True
ensure_dir(fuddly_data_folder)

exported_data_folder = fuddly_data_folder + 'exported_data' + os.sep
ensure_dir(exported_data_folder)
imported_data_folder = fuddly_data_folder + 'imported_data' + os.sep
ensure_dir(imported_data_folder)
logs_folder = fuddly_data_folder + 'logs' + os.sep
ensure_dir(logs_folder)
workspace_folder = fuddly_data_folder + 'workspace' + os.sep
ensure_dir(workspace_folder)
external_libs_folder = fuddly_data_folder + 'external_libs' + os.sep
ensure_dir(external_libs_folder)
external_tools_folder = fuddly_data_folder + 'external_tools' + os.sep
ensure_dir(external_tools_folder)
config_folder = os.path.join(fuddly_data_folder, 'config') + os.sep
ensure_dir(config_folder)

user_projects_folder = fuddly_data_folder + 'user_projects' + os.sep
ensure_dir(user_projects_folder)

# Path: libs/utils.py
# def ensure_dir(f):
#     d = os.path.dirname(f)
#     if not os.path.exists(d):
#         os.makedirs(d)
# 
# def ensure_file(f):
#     if not os.path.isfile(f):
#         open(f, 'a').close()


# Path: framework/global_resources.py
import os
import sys
import copy
import inspect
import framework
from enum import Enum
from libs.utils import ensure_dir, ensure_file

# framework_folder = os.path.dirname(framework.__file__)
framework_folder  = '.' if framework_folder == '' else framework_folder

app_folder = os.path.dirname(framework_folder)
app_folder = '.' if app_folder == '' else app_folder
projects_folder = app_folder + os.sep + 'projects' + os.sep
data_models_folder = app_folder + os.sep + 'data_models' + os.sep

fuddly_data_folder = os.path.expanduser('~' + os.sep + 'fuddly_data' + os.sep)
if not os.path.exists(fuddly_data_folder):
    new_fuddly_data_folder = True
ensure_dir(fuddly_data_folder)

exported_data_folder = fuddly_data_folder + 'exported_data' + os.sep
ensure_dir(exported_data_folder)
imported_data_folder = fuddly_data_folder + 'imported_data' + os.sep
ensure_dir(imported_data_folder)
logs_folder = fuddly_data_folder + 'logs' + os.sep
ensure_dir(logs_folder)
workspace_folder = fuddly_data_folder + 'workspace' + os.sep
ensure_dir(workspace_folder)
external_libs_folder = fuddly_data_folder + 'external_libs' + os.sep
ensure_dir(external_libs_folder)
external_tools_folder = fuddly_data_folder + 'external_tools' + os.sep
ensure_dir(external_tools_folder)
config_folder = os.path.join(fuddly_data_folder, 'config') + os.sep
ensure_dir(config_folder)

user_projects_folder = fuddly_data_folder + 'user_projects' + os.sep
ensure_dir(user_projects_folder)

ensure_file(user_projects_folder + os.sep + '__init__.py')