# Path: libre/apps/data_drivers/literals.py
# DATA_TYPE_DATE = 4
# 
# DATA_TYPE_DATETIME = 3
# 
# DATA_TYPE_NUMBER = 2
# 
# DATA_TYPE_STRING = 1
# 
# DATA_TYPE_TIME = 5
# 
# THOUSAND_SYMBOL = ','
# 
# DECIMAL_SYMBOL = '.'


from HTMLParser import HTMLParser
from operator import itemgetter
from urllib import unquote_plus
from dateutil.parser import parse
from shapely import geometry
from .literals import (
    DATA_TYPE_DATE, DATA_TYPE_DATETIME, DATA_TYPE_NUMBER, DATA_TYPE_STRING,
    DATA_TYPE_TIME, THOUSAND_SYMBOL, DECIMAL_SYMBOL)
from .exceptions import LIBREValueError
    from .models import Source
import logging
import types
import pyparsing
from __future__ import absolute_import




logger = logging.getLogger(__name__)

enclosed_parser = pyparsing.Forward()
nestedBrackets = pyparsing.nestedExpr('[', ']', content=enclosed_parser)
enclosed_parser << (pyparsing.Word(pyparsing.alphanums + '-' + '.' + '(' + ')') | ',' | nestedBrackets)

DATA_TYPE_FUNCTIONS = {
    DATA_TYPE_STRING: lambda x: unicode(x).strip(),
    DATA_TYPE_NUMBER: lambda x: convert_to_number(x),
    DATA_TYPE_DATETIME: lambda x: parse(x),
    DATA_TYPE_DATE: lambda x: parse(x).date(),

# Path: libre/apps/data_drivers/literals.py
# DATA_TYPE_DATE = 4
# 
# DATA_TYPE_DATETIME = 3
# 
# DATA_TYPE_NUMBER = 2
# 
# DATA_TYPE_STRING = 1
# 
# DATA_TYPE_TIME = 5
# 
# THOUSAND_SYMBOL = ','
# 
# DECIMAL_SYMBOL = '.'


# Path: libre/apps/data_drivers/utils.py
from HTMLParser import HTMLParser
from operator import itemgetter
from urllib import unquote_plus
from dateutil.parser import parse
from shapely import geometry
from .literals import (
    DATA_TYPE_DATE, DATA_TYPE_DATETIME, DATA_TYPE_NUMBER, DATA_TYPE_STRING,
    DATA_TYPE_TIME, THOUSAND_SYMBOL, DECIMAL_SYMBOL)
from .exceptions import LIBREValueError
    from .models import Source
import logging
import types
import pyparsing

from __future__ import absolute_import




logger = logging.getLogger(__name__)

enclosed_parser = pyparsing.Forward()
nestedBrackets = pyparsing.nestedExpr('[', ']', content=enclosed_parser)
enclosed_parser << (pyparsing.Word(pyparsing.alphanums + '-' + '.' + '(' + ')') | ',' | nestedBrackets)

DATA_TYPE_FUNCTIONS = {
    DATA_TYPE_STRING: lambda x: unicode(x).strip(),
    DATA_TYPE_NUMBER: lambda x: convert_to_number(x),
    DATA_TYPE_DATETIME: lambda x: parse(x),
    DATA_TYPE_DATE: lambda x: parse(x).date(),

    DATA_TYPE_TIME: lambda x: parse(x).time(),