# 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
            raise LIBREValueError('no source named: %s' % source_slug)
        else:
            logger.debug('got new source named: %s' % source_slug)
            # Rebuild the parameters for this enclosed value, omitting the source slug
            new_string = u'&'.join(parts[1:])

            parameters = {}
            for part in new_string.split('&'):
                try:
                    key, value = part.split('=')
                except ValueError:
                    pass
                else:
                    parameters[key] = value

            return new_source.get_all(parameters=parameters)
    else:
        logger.debug('Is a number')
        try:
            return convert_to_number(string)
        except ValueError:
            logger.error('Invalid value or unknown source: %s' % string)
            raise LIBREValueError('Invalid value or unknown source: %s' % string)


def parse_as_geometry(string):
    geometry_name, value = string.split('(', 1)
    logger.debug('geometry name: %s' % geometry_name)

    # Get the geometry class from the 'shapely.geometry' module

# 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

            raise LIBREValueError('no source named: %s' % source_slug)
        else:
            logger.debug('got new source named: %s' % source_slug)
            # Rebuild the parameters for this enclosed value, omitting the source slug
            new_string = u'&'.join(parts[1:])

            parameters = {}
            for part in new_string.split('&'):
                try:
                    key, value = part.split('=')
                except ValueError:
                    pass
                else:
                    parameters[key] = value

            return new_source.get_all(parameters=parameters)
    else:
        logger.debug('Is a number')
        try:
            return convert_to_number(string)
        except ValueError:
            logger.error('Invalid value or unknown source: %s' % string)
            raise LIBREValueError('Invalid value or unknown source: %s' % string)


def parse_as_geometry(string):
    geometry_name, value = string.split('(', 1)
    logger.debug('geometry name: %s' % geometry_name)

    # Get the geometry class from the 'shapely.geometry' module

    geometry_class = getattr(geometry, geometry_name, geometry.shape)