# Path: util/Log.py
# class Log(object):
#     """
#     Log class
#     """
#     class __impl(object):
#         """ Implementation of singleton interface"""
#         def __init__(self):
#             """
#             """
#             self.levMap = {"ERROR":(0, "\033[31m%s%s\033[0m"), "WARNING":(1, "\033[33m%s%s\033[0m"), \
#                             "INFO":(2, "\033[34m%s%s\033[0m"), "MSG":(3, "\033[32m%s%s\033[0m"), \
#                             "UNKNOW":(4, "\033[31m%s%s\033[0m")}
#             self.config_level = 5
# 
#         def setLogLevel(self, lev):
#             """
#             Description : set log file level.The log message lower than this level will not be printed.
#             Args : lev : log level will be set.Value is [0-5],0 will not print any log message, 5 will print all log message
#             Return : NULL 
#             """
#             self.config_level = lev
# 
#         def LevPrint(self, level, msg, prefix=True):
#             """
#             Description :  print log message which has higher level than config level
#             Args: 
#                 level : ["ERROR", "WARNING", "INFO", "MSG", "UNKNOW"]
#                 msg : string, log message
#                 prefix : True , print time information
#                          False , don't print time information
#             Return : None
#             """
#             if level in self.levMap and self.levMap[level][0] > self.config_level:
#                 return 
# 
#             now = ""
#             pmsg = ""
#             if prefix:
#                 now = "[" + time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) \
#                     + " " + str(threading.current_thread().ident) + "] "
#             if (level in self.levMap):
#                     pmsg = self.levMap[level][1] % (now, msg)
#             else:
#                     pmsg = "UNKNOW log level(%s)" % level 
#                     pmsg += self.levMap["UNKNOW"][1] % (now, msg)
#                 
#             print(pmsg)
#             sys.stdout.flush()
# 
#     
#     # class Log
#     __instance = None
#     def __init__(self):
#         """ Create singleton instance """
#         # Check whether we already have an instance
#         if Log.__instance is None:
#             # Create and remember instance
#             Log.__instance = Log.__impl()
# 
#         # Store instance reference as the only member in the handle
#         self.__dict__['_Log__instance'] = Log.__instance
# 
#     def __getattr__(self, attr):
#         """ Delegate access to implementation """
#         return getattr(self.__instance, attr)
# 
#     def __setattr__(self, attr, value):
#         """ Delegate access to implementation """
#         return setattr(self.__instance, attr, value)


import os
import sys
from util import Log

#ut bin
#UT_APPLICATION('name',
#               Sources("src/*.cpp", Include('a/b/c')),
#               LinkFlags("link flags"),
#               Libs("$OUT_ROOT/a/b/c/output/lib/libutil.a"),
#               UTArgs(""))

#static library file .a
#STATIC_LIBRARY('name',
#               Sources("src/*.cpp", Include('a/b/c')),
#               Libs("$OUT_ROOT/a/b/c/output/lib/libutil.a"))

#proto static library file .a
#PROTO_LIBRARY('name',
#              'proto/*.proto',
#               Proto_Flags(""),
#               Include(""),
#               CppFlags("debug flags", "release flags"),
#               CxxFlags("debug falgs","release flas"),
#               Libs("$OUT_ROOT/a/b/c/output/lib/libutil.a"))'''

def scratch(target_dir):
    """
    create a BCLOUD template
    Args:
        target_dir : the directory of BROC file
    """
    broc_file = os.path.join(target_dir, 'BROC') 
    if os.path.exists(broc_file):

# Path: util/Log.py
# class Log(object):
#     """
#     Log class
#     """
#     class __impl(object):
#         """ Implementation of singleton interface"""
#         def __init__(self):
#             """
#             """
#             self.levMap = {"ERROR":(0, "\033[31m%s%s\033[0m"), "WARNING":(1, "\033[33m%s%s\033[0m"), \
#                             "INFO":(2, "\033[34m%s%s\033[0m"), "MSG":(3, "\033[32m%s%s\033[0m"), \
#                             "UNKNOW":(4, "\033[31m%s%s\033[0m")}
#             self.config_level = 5
# 
#         def setLogLevel(self, lev):
#             """
#             Description : set log file level.The log message lower than this level will not be printed.
#             Args : lev : log level will be set.Value is [0-5],0 will not print any log message, 5 will print all log message
#             Return : NULL 
#             """
#             self.config_level = lev
# 
#         def LevPrint(self, level, msg, prefix=True):
#             """
#             Description :  print log message which has higher level than config level
#             Args: 
#                 level : ["ERROR", "WARNING", "INFO", "MSG", "UNKNOW"]
#                 msg : string, log message
#                 prefix : True , print time information
#                          False , don't print time information
#             Return : None
#             """
#             if level in self.levMap and self.levMap[level][0] > self.config_level:
#                 return 
# 
#             now = ""
#             pmsg = ""
#             if prefix:
#                 now = "[" + time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) \
#                     + " " + str(threading.current_thread().ident) + "] "
#             if (level in self.levMap):
#                     pmsg = self.levMap[level][1] % (now, msg)
#             else:
#                     pmsg = "UNKNOW log level(%s)" % level 
#                     pmsg += self.levMap["UNKNOW"][1] % (now, msg)
#                 
#             print(pmsg)
#             sys.stdout.flush()
# 
#     
#     # class Log
#     __instance = None
#     def __init__(self):
#         """ Create singleton instance """
#         # Check whether we already have an instance
#         if Log.__instance is None:
#             # Create and remember instance
#             Log.__instance = Log.__impl()
# 
#         # Store instance reference as the only member in the handle
#         self.__dict__['_Log__instance'] = Log.__instance
# 
#     def __getattr__(self, attr):
#         """ Delegate access to implementation """
#         return getattr(self.__instance, attr)
# 
#     def __setattr__(self, attr, value):
#         """ Delegate access to implementation """
#         return setattr(self.__instance, attr, value)


# Path: client/Scratch.py
import os
import sys
from util import Log


#ut bin
#UT_APPLICATION('name',
#               Sources("src/*.cpp", Include('a/b/c')),
#               LinkFlags("link flags"),
#               Libs("$OUT_ROOT/a/b/c/output/lib/libutil.a"),
#               UTArgs(""))

#static library file .a
#STATIC_LIBRARY('name',
#               Sources("src/*.cpp", Include('a/b/c')),
#               Libs("$OUT_ROOT/a/b/c/output/lib/libutil.a"))

#proto static library file .a
#PROTO_LIBRARY('name',
#              'proto/*.proto',
#               Proto_Flags(""),
#               Include(""),
#               CppFlags("debug flags", "release flags"),
#               CxxFlags("debug falgs","release flas"),
#               Libs("$OUT_ROOT/a/b/c/output/lib/libutil.a"))'''

def scratch(target_dir):
    """
    create a BCLOUD template
    Args:
        target_dir : the directory of BROC file
    """
    broc_file = os.path.join(target_dir, 'BROC') 
    if os.path.exists(broc_file):

        Log.Log().LevPrint("ERROR", "BROC already existed in %s, couldn't create it" % target_dir)