# Path: sesql/utils.py
# def strip_ligatures(value):
#     """
#     Convert the ligatures (œ, æ, ß, ...) into their compound value (oe, ae, ss)
#     Take **unicode** as input and output, not string
#     """
#     charmap = {
#         u'\N{Latin capital letter AE}': 'AE',
#         u'\N{Latin small letter ae}': 'ae',
#         u'\N{Latin capital letter Eth}': 'Dh',
#         u'\N{Latin small letter eth}': 'dh',
#         u'\N{Latin capital letter O with stroke}': 'Oe',
#         u'\N{Latin small letter o with stroke}': 'oe',
#         u'\N{Latin capital letter Thorn}': 'Th',
#         u'\N{Latin small letter thorn}': 'th',
#         u'\N{Latin small letter sharp s}': 'ss',
#         u'\N{Latin capital letter D with stroke}': 'Dj',
#         u'\N{Latin small letter d with stroke}': 'dj',
#         u'\N{Latin capital letter H with stroke}': 'H',
#         u'\N{Latin small letter h with stroke}': 'h',
#         u'\N{Latin small letter dotless i}': 'i',
#         u'\N{Latin small letter kra}': 'q',
#         u'\N{Latin capital letter L with stroke}': 'L',
#         u'\N{Latin small letter l with stroke}': 'l',
#         u'\N{Latin capital letter Eng}': 'Ng',
#         u'\N{Latin small letter eng}': 'ng',
#         u'\N{Latin capital ligature OE}': 'Oe',
#         u'\N{Latin small ligature oe}': 'oe',
#         u'\N{Latin capital letter T with stroke}': 'Th',
#         u'\N{Latin small letter t with stroke}': 'th',
#     }
# 
#     value = ''.join([ charmap.get(c,c) for c in value ])    
#     return value
# 
# Path: sesql/sources.py
# def guess_source(what):
#     """
#     Guess what is this source
# 
#     - AbstractSource will stay as it is
#     - a list or tuple will become TextAggregate
#     - a name with () in it will be a MethodCaller
#     - a name with . in it will be a SubField
#     - everything else will be a SimpleField
#     """
#     if isinstance(what, AbstractSource):
#         return what
#     if isinstance(what, (list, tuple)):
#         return TextAggregate(*what)
#     if isinstance(what, dict):
#         return WeightedAggregate(what)
#     if not isinstance(what, str):
#         raise ValueError, "what is neither AbstractSource, list, dict nor string"
#     if "." in what:
#         what = what.strip(".")
#         return SubField(*(what.split(".", 1)))
#     if what.endswith('()'):
#         return MethodCaller(what[:-2])
#     return SimpleField(what)
# 
# class ClassSource(AbstractSource):
#     """
#     Get the class of the object
#     """
#     def __init__(self, dereference_proxy = False):
#         """
#         Constructor
#         If dereference_proxy is set to True, proxy models will be
#         considered as their base classe - this is only for Django ORM
#         """
#         self.dereference_proxy = dereference_proxy
# 
#     def load_data(self, obj):
#         """
#         Load data from a Django object
#         """
#         klass = obj.__class__
#         if self.dereference_proxy:
#             if hasattr(obj, '_meta'):
#                 if getattr(obj._meta, 'proxy', False):
#                     klass = getattr(obj._meta, 'proxy_for_model', klass)
#         return klass.__name__


import logging
import unicodedata
from sesql.utils import strip_ligatures
from sesql.sources import guess_source, ClassSource
            from sesql import config
            from sesql import config
        from sesql import config
class LongIntField(IntField):
    """
    This is a bigint field
    """
    sqltype = "bigint"

class StrField(Field):
    """
    This is a simple string field, with specified length
    """
    def __init__(self, name, source = None, size = 255):
        """
        Constructor
        Takes one extra paramater: the field size
        """
        super(StrField, self).__init__(name, source)
        self.size = size
        self.sqltype = "varchar(%d)" % size

class ClassField(Field):
    """
    This is a field storing the class of the object
    """
    sqltype = "varchar(255)"

    def __init__(self, name, dereference_proxy = False):
        """
        Constructor
        """
        super(ClassField, self).__init__(name, None)

# Path: sesql/utils.py
# def strip_ligatures(value):
#     """
#     Convert the ligatures (œ, æ, ß, ...) into their compound value (oe, ae, ss)
#     Take **unicode** as input and output, not string
#     """
#     charmap = {
#         u'\N{Latin capital letter AE}': 'AE',
#         u'\N{Latin small letter ae}': 'ae',
#         u'\N{Latin capital letter Eth}': 'Dh',
#         u'\N{Latin small letter eth}': 'dh',
#         u'\N{Latin capital letter O with stroke}': 'Oe',
#         u'\N{Latin small letter o with stroke}': 'oe',
#         u'\N{Latin capital letter Thorn}': 'Th',
#         u'\N{Latin small letter thorn}': 'th',
#         u'\N{Latin small letter sharp s}': 'ss',
#         u'\N{Latin capital letter D with stroke}': 'Dj',
#         u'\N{Latin small letter d with stroke}': 'dj',
#         u'\N{Latin capital letter H with stroke}': 'H',
#         u'\N{Latin small letter h with stroke}': 'h',
#         u'\N{Latin small letter dotless i}': 'i',
#         u'\N{Latin small letter kra}': 'q',
#         u'\N{Latin capital letter L with stroke}': 'L',
#         u'\N{Latin small letter l with stroke}': 'l',
#         u'\N{Latin capital letter Eng}': 'Ng',
#         u'\N{Latin small letter eng}': 'ng',
#         u'\N{Latin capital ligature OE}': 'Oe',
#         u'\N{Latin small ligature oe}': 'oe',
#         u'\N{Latin capital letter T with stroke}': 'Th',
#         u'\N{Latin small letter t with stroke}': 'th',
#     }
# 
#     value = ''.join([ charmap.get(c,c) for c in value ])    
#     return value
# 
# Path: sesql/sources.py
# def guess_source(what):
#     """
#     Guess what is this source
# 
#     - AbstractSource will stay as it is
#     - a list or tuple will become TextAggregate
#     - a name with () in it will be a MethodCaller
#     - a name with . in it will be a SubField
#     - everything else will be a SimpleField
#     """
#     if isinstance(what, AbstractSource):
#         return what
#     if isinstance(what, (list, tuple)):
#         return TextAggregate(*what)
#     if isinstance(what, dict):
#         return WeightedAggregate(what)
#     if not isinstance(what, str):
#         raise ValueError, "what is neither AbstractSource, list, dict nor string"
#     if "." in what:
#         what = what.strip(".")
#         return SubField(*(what.split(".", 1)))
#     if what.endswith('()'):
#         return MethodCaller(what[:-2])
#     return SimpleField(what)
# 
# class ClassSource(AbstractSource):
#     """
#     Get the class of the object
#     """
#     def __init__(self, dereference_proxy = False):
#         """
#         Constructor
#         If dereference_proxy is set to True, proxy models will be
#         considered as their base classe - this is only for Django ORM
#         """
#         self.dereference_proxy = dereference_proxy
# 
#     def load_data(self, obj):
#         """
#         Load data from a Django object
#         """
#         klass = obj.__class__
#         if self.dereference_proxy:
#             if hasattr(obj, '_meta'):
#                 if getattr(obj._meta, 'proxy', False):
#                     klass = getattr(obj._meta, 'proxy_for_model', klass)
#         return klass.__name__


# Path: sesql/fields.py
import logging
import unicodedata
from sesql.utils import strip_ligatures
from sesql.sources import guess_source, ClassSource
            from sesql import config
            from sesql import config
        from sesql import config

class LongIntField(IntField):
    """
    This is a bigint field
    """
    sqltype = "bigint"

class StrField(Field):
    """
    This is a simple string field, with specified length
    """
    def __init__(self, name, source = None, size = 255):
        """
        Constructor
        Takes one extra paramater: the field size
        """
        super(StrField, self).__init__(name, source)
        self.size = size
        self.sqltype = "varchar(%d)" % size

class ClassField(Field):
    """
    This is a field storing the class of the object
    """
    sqltype = "varchar(255)"

    def __init__(self, name, dereference_proxy = False):
        """
        Constructor
        """
        super(ClassField, self).__init__(name, None)

        self.source = ClassSource(dereference_proxy = dereference_proxy)