# 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
            if DECIMAL_SYMBOL in data:
                # It is a decimal number
                return float(data)
            else:
                # Otherwise it is an integer
                return int(data)


def parse_value(string):
    # Hidden import to avoid circular imports between model.py <- query.py <- this module <- model.py

    string = html_parser.unescape(string).strip()

    logger.debug('parsing: %s' % string)
    if string[0] == '"' and string[-1] == '"':
        # Strip quotes
        return unicode(string[1:-1])

    elif string == 'True':
        return True

    elif string == 'False':
        return False

    elif any(map(string.startswith, ['Point', 'LineString', 'LinearRings', 'Polygon', 'MultiPoint', 'MultiLineString', 'MultiPolygon', 'Geometry'])):
        logger.debug('is a geometry')
        return parse_as_geometry(string)

    elif string[0] == '[' and string[-1] == ']':
        # Is a list of values

# 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

            if DECIMAL_SYMBOL in data:
                # It is a decimal number
                return float(data)
            else:
                # Otherwise it is an integer
                return int(data)


def parse_value(string):
    # Hidden import to avoid circular imports between model.py <- query.py <- this module <- model.py

    string = html_parser.unescape(string).strip()

    logger.debug('parsing: %s' % string)
    if string[0] == '"' and string[-1] == '"':
        # Strip quotes
        return unicode(string[1:-1])

    elif string == 'True':
        return True

    elif string == 'False':
        return False

    elif any(map(string.startswith, ['Point', 'LineString', 'LinearRings', 'Polygon', 'MultiPoint', 'MultiLineString', 'MultiPolygon', 'Geometry'])):
        logger.debug('is a geometry')
        return parse_as_geometry(string)

    elif string[0] == '[' and string[-1] == ']':
        # Is a list of values

        logger.debug('Is a list')