# 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: ravel/cmdlog.py
# class CmdLog(object):
#     def __init__(self):
#     def logline(self, line):
#     def __del__(self):


import cmd
import importlib
import os
import re
import sys
import time
import tempfile
import psycopg2
import sqlparse
import ravel.util
from sqlparse.tokens import Keyword
from ravel.log import logger
from ravel.cmdlog import cmdLogger

    def do_EOF(self, line):
        "Quit application console"
        sys.stdout.write("\n")
        return True

    def do_exit(self, line):
        "Quit application console"
        return True

class AppComponent(object):
    """A component in an application's SQL implementation.  Any addition
       to the database is considered a 'component' that must be removed
       when the application is unloaded.  A component could be a table,
       view, function, etc."""

    def __init__(self, name, typ):
        """name: the name of the component
           typ: the type of component (table, view, function)"""
        self.name = name
        self.typ = typ

    def drop(self, db):
        """Drop the component from the specified database
           db: a ravel.db.RavelDb instance containing the component"""
        try:
            cmd = "DROP {0} IF EXISTS {1} CASCADE;".format(self.typ, self.name)
            db.cursor.execute(cmd)
            logger.debug("removing component: %s", cmd)
        except Exception, e:

# 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: ravel/cmdlog.py
# class CmdLog(object):
#     def __init__(self):
#     def logline(self, line):
#     def __del__(self):


# Path: ravel/app.py
import cmd
import importlib
import os
import re
import sys
import time
import tempfile
import psycopg2
import sqlparse
import ravel.util
from sqlparse.tokens import Keyword
from ravel.log import logger
from ravel.cmdlog import cmdLogger


    def do_EOF(self, line):
        "Quit application console"
        sys.stdout.write("\n")
        return True

    def do_exit(self, line):
        "Quit application console"
        return True

class AppComponent(object):
    """A component in an application's SQL implementation.  Any addition
       to the database is considered a 'component' that must be removed
       when the application is unloaded.  A component could be a table,
       view, function, etc."""

    def __init__(self, name, typ):
        """name: the name of the component
           typ: the type of component (table, view, function)"""
        self.name = name
        self.typ = typ

    def drop(self, db):
        """Drop the component from the specified database
           db: a ravel.db.RavelDb instance containing the component"""
        try:
            cmd = "DROP {0} IF EXISTS {1} CASCADE;".format(self.typ, self.name)
            db.cursor.execute(cmd)
            logger.debug("removing component: %s", cmd)
        except Exception, e:

            logger.error("error removing component {0}: {1}"