# Path: ravel/app.py
# class AppConsole(cmd.Cmd):
#     "Superclass for an application's sub-shell"
# 
#     def __init__(self, db, env, components):
#         """db: a ravel.db.RavelDb instance
#            env: a ravel.env.Environment instance of the CLI's executing environment
#            components: list of the app's SQL components (tables, view, etc.)"""
#         self.db = db
#         self.env = env
#         self.components = components
#         self.logOn = False
#         cmd.Cmd.__init__(self)
# 
#     def emptyline(self):
#         "Don't repeat the last line when hitting return on empty line"
#         return
# 
#     def onecmd(self, line):
#         "Run command and report execution time for each execution line"  
#         if line:
#             if self.logOn:
#                 startTime = time.time()
#                 stop = cmd.Cmd.onecmd(self, line)
#                 endTime = time.time()
#                 elapsed = round((endTime - startTime)*1000, 3)
#                 cmdLogger.logline('cmd: '+line)
#                 logger.info("Execution time: {0}ms".format(elapsed))
#                 cmdLogger.logline('start time: {0}'.format(time.asctime(time.localtime(startTime))))
#                 cmdLogger.logline('time span: {0}ms'.format(elapsed))
#                 return stop
#             else:
#                 return cmd.Cmd.onecmd(self, line)
# 
#     def do_cmdlogger(self, line):
#         if str(line).lower() == 'on':
#             self.logOn = True
#             logger.info('Cmd logger on.')
#         elif str(line).lower() == 'off':
#             self.logOn = False
#             logger.info('Cmd logger off.')
#         else:
#             logger.info("Input 'on' to turn on cmd logger and 'off' to turn it off.")
# 
#     def do_list(self, line):
#         "List application components"
#         print self.name, "components:"
#         for comp in self.components:
#             print "   ", comp
# 
#     def do_watch(self, line):
#         "Watch application components"
#         w = [c.name for c in self.components if c.watchable]
#         cmd, cmdfile = mk_watchcmd(self.db, w)
#         self.env.mkterm(cmd, cmdfile)
# 
#     def do_EOF(self, line):
#         "Quit application console"
#         sys.stdout.write("\n")
#         return True
# 
#     def do_exit(self, line):
#         "Quit application console"
#         return True
# 
# Path: ravel/log.py
# LEVELS = { "debug" : logging.DEBUG,
#            "info" : logging.INFO,
#            "warning" : logging.WARNING,
#            "error" : logging.ERROR,
#            "critical" : logging.CRITICAL
#        }
# DEFAULT_LEVEL = logging.ERROR
# MSG_FORMAT = "%(levelname)s:%(funcName)s: %(message)s"
# class Singleton(type):
# class RavelLogger(Logger, object):
#     def __init__(cls, name, bases, dict_):
#     def __call__(cls, *args, **kw):
#     def __init__(self):
#     def setLogLevel(self, levelname=None):


from ravel.app import AppConsole
from ravel.log import logger
"""
Routing sub-shell.
"""


class RoutingConsole(AppConsole):
    def __init__(self, db, env, components):

# Path: ravel/app.py
# class AppConsole(cmd.Cmd):
#     "Superclass for an application's sub-shell"
# 
#     def __init__(self, db, env, components):
#         """db: a ravel.db.RavelDb instance
#            env: a ravel.env.Environment instance of the CLI's executing environment
#            components: list of the app's SQL components (tables, view, etc.)"""
#         self.db = db
#         self.env = env
#         self.components = components
#         self.logOn = False
#         cmd.Cmd.__init__(self)
# 
#     def emptyline(self):
#         "Don't repeat the last line when hitting return on empty line"
#         return
# 
#     def onecmd(self, line):
#         "Run command and report execution time for each execution line"  
#         if line:
#             if self.logOn:
#                 startTime = time.time()
#                 stop = cmd.Cmd.onecmd(self, line)
#                 endTime = time.time()
#                 elapsed = round((endTime - startTime)*1000, 3)
#                 cmdLogger.logline('cmd: '+line)
#                 logger.info("Execution time: {0}ms".format(elapsed))
#                 cmdLogger.logline('start time: {0}'.format(time.asctime(time.localtime(startTime))))
#                 cmdLogger.logline('time span: {0}ms'.format(elapsed))
#                 return stop
#             else:
#                 return cmd.Cmd.onecmd(self, line)
# 
#     def do_cmdlogger(self, line):
#         if str(line).lower() == 'on':
#             self.logOn = True
#             logger.info('Cmd logger on.')
#         elif str(line).lower() == 'off':
#             self.logOn = False
#             logger.info('Cmd logger off.')
#         else:
#             logger.info("Input 'on' to turn on cmd logger and 'off' to turn it off.")
# 
#     def do_list(self, line):
#         "List application components"
#         print self.name, "components:"
#         for comp in self.components:
#             print "   ", comp
# 
#     def do_watch(self, line):
#         "Watch application components"
#         w = [c.name for c in self.components if c.watchable]
#         cmd, cmdfile = mk_watchcmd(self.db, w)
#         self.env.mkterm(cmd, cmdfile)
# 
#     def do_EOF(self, line):
#         "Quit application console"
#         sys.stdout.write("\n")
#         return True
# 
#     def do_exit(self, line):
#         "Quit application console"
#         return True
# 
# Path: ravel/log.py
# LEVELS = { "debug" : logging.DEBUG,
#            "info" : logging.INFO,
#            "warning" : logging.WARNING,
#            "error" : logging.ERROR,
#            "critical" : logging.CRITICAL
#        }
# DEFAULT_LEVEL = logging.ERROR
# MSG_FORMAT = "%(levelname)s:%(funcName)s: %(message)s"
# class Singleton(type):
# class RavelLogger(Logger, object):
#     def __init__(cls, name, bases, dict_):
#     def __call__(cls, *args, **kw):
#     def __init__(self):
#     def setLogLevel(self, levelname=None):


# Path: apps/routing.py
from ravel.app import AppConsole
from ravel.log import logger

"""
Routing sub-shell.
"""


class RoutingConsole(AppConsole):
    def __init__(self, db, env, components):

        AppConsole.__init__(self, db, env, components)