import logging

from collections import OrderedDict
from egpackager.datasources import GspreadDataSource, RasterDataSource


class DataManager(object):

    def __init__(self, debug=False):
        # Set up logging
        if debug:
            logging.basicConfig(level=logging.DEBUG)
        else:
            logging.basicConfig(level=logging.INFO)
        self.logger = logging.getLogger(__name__)

        self.logger.debug("Initializing new registry manager")
        self._data = OrderedDict()

    def add_datasource(self, *args, **kwargs):
        if 'type' not in kwargs:
            raise TypeError("Missing require keyword argument: 'type")

        if kwargs['type'] == 'gspread':
            # Remove keyword argument 'type' as it us not needed anymore
            del kwargs['type']
            self.logger.debug('Adding Google Sheets data source')
            self._data[kwargs['uri']] = GspreadDataSource(*args, **kwargs)
        elif kwargs['type'] == 'raster':
            del kwargs['type']
            self.logger.debug('Adding raster data source')
            self._data[kwargs['uri']] = RasterDataSource(*args, **kwargs)
        else:
            raise TypeError("Unknown data source type: {0}".format(kwargs['type']))

    @property
    def data(self):
        return self._data

@@ -876,37 +876,34 @@
  self._data%5B
-kwargs%5B'uri'%5D
+'metadata'
 %5D = GspreadD
@@ -1087,21 +1087,18 @@
 ata%5B
-kwargs%5B'uri'%5D
+'resource'
 %5D = 
@@ -1228,16 +1228,58 @@
 type'%5D))
+%0A        self._data%5B'uri'%5D = kwargs%5B'uri'%5D
 %0A%0A    @p
@@ -1332,8 +1332,391 @@
 f._data%0A
+%0A    def get_metadata_value(self, key, value):%0A        return self.data%5B'metadata'%5D.get_value(key, value)%0A%0A    def get_resource_value(self, key, value):%0A        return self.data%5B'resource'%5D.get_value(key, value)%0A%0A    @property%0A    def metadata(self):%0A        return self.data%5B'metadata'%5D.data%0A%0A    @property%0A    def resource_metadata(self):%0A        return self.data%5B'resource'%5D.data%0A

Add metadata and resource distinction in DataManager