import logging

from collections import OrderedDict
from egpackager.datasources import GspreadDataSource


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_gpsread_datasource(self, *args, **kwargs):
        self.logger.debug('Adding Google Sheets data source')
        self._data[kwargs['uri']] = GspreadDataSource(*args, **kwargs)

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

import logging

from collections import OrderedDict
from egpackager.datasources import GspreadDataSource


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':
            pass

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

Generalize adding a data source
Generalize adding a data source

Instead of using data source specific methods for DataManager, use
just one: add_datasource(). The type of data source is defined by
the keyword argument 'type'.
