# 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
Contain the field types for SeSQL
We cannot reuse Django types because what we need is too specific
"""



log = logging.getLogger('sesql')


class Field(object):
    """
    This represent an abstract field
    """
    primary = False
    slqtype = None
    indexfunction = ""
    placeholder = "%s"

    def __init__(self, name, source = None, sql_default = None):
        """
        Constructor
        name = name for the field in our database
        sources = list of names used in input
        """
        self.name = name
        self.index_column = name
        self.sql_default = sql_default
        self.data_column = name
        if not source:
            source = name

# 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

Contain the field types for SeSQL
We cannot reuse Django types because what we need is too specific
"""



log = logging.getLogger('sesql')


class Field(object):
    """
    This represent an abstract field
    """
    primary = False
    slqtype = None
    indexfunction = ""
    placeholder = "%s"

    def __init__(self, name, source = None, sql_default = None):
        """
        Constructor
        name = name for the field in our database
        sources = list of names used in input
        """
        self.name = name
        self.index_column = name
        self.sql_default = sql_default
        self.data_column = name
        if not source:
            source = name

        self.source = guess_source(source)