# Path: firefly/util.py
# def last_dot_splitter(dotted_path):
# def import_module_class(dotted_path):
# def import_module(dotted_path):
# def setup_logging(config):
# def verify_access_token(token, key):
# def generate_access_token(key, duration=60):
# def generate_ds_key(ds):
# def b58encode(value):
# def b58decode(encoded):


from collections import defaultdict
from urllib import urlencode
from urllib2 import urlopen
from urllib2 import URLError
from firefly import util
import json
import firefly.data_source
            `data_source_name` is an internal hash of the data source name.
            Defaults to False.
    """

    DESC = "Aggregates other data sources"

    def __init__(self, *args, **kwargs):
        """Reads the configuration passed to it and holds on to the data
        sources that are available to this data source.
        """
        super(AggregatingDataSource, self).__init__(*args, **kwargs)

        self.data_sources = []

        self.DESC = kwargs.get('desc', self.DESC)

        # Keeps track of the first entry in a key, mapping it to a specific data
        # source. The first instance of a key is always authoritative.
        self.key_mapping_cache = {}

        data_sources = kwargs['data_sources']
        for data_source in data_sources:
            data_server_url = data_source['data_server_url']
            data_source_name = data_source['data_source_name']
            name_is_hash = data_source.get('name_is_hash', False)
            secret_key = data_source['secret_key']

            if name_is_hash:
                data_source_hash = data_source_name
            else:

# Path: firefly/util.py
# def last_dot_splitter(dotted_path):
# def import_module_class(dotted_path):
# def import_module(dotted_path):
# def setup_logging(config):
# def verify_access_token(token, key):
# def generate_access_token(key, duration=60):
# def generate_ds_key(ds):
# def b58encode(value):
# def b58decode(encoded):


# Path: firefly/data_sources/aggregating_data_source.py
from collections import defaultdict
from urllib import urlencode
from urllib2 import urlopen
from urllib2 import URLError
from firefly import util
import json
import firefly.data_source

            `data_source_name` is an internal hash of the data source name.
            Defaults to False.
    """

    DESC = "Aggregates other data sources"

    def __init__(self, *args, **kwargs):
        """Reads the configuration passed to it and holds on to the data
        sources that are available to this data source.
        """
        super(AggregatingDataSource, self).__init__(*args, **kwargs)

        self.data_sources = []

        self.DESC = kwargs.get('desc', self.DESC)

        # Keeps track of the first entry in a key, mapping it to a specific data
        # source. The first instance of a key is always authoritative.
        self.key_mapping_cache = {}

        data_sources = kwargs['data_sources']
        for data_source in data_sources:
            data_server_url = data_source['data_server_url']
            data_source_name = data_source['data_source_name']
            name_is_hash = data_source.get('name_is_hash', False)
            secret_key = data_source['secret_key']

            if name_is_hash:
                data_source_hash = data_source_name
            else:

                data_source_hash = util.generate_ds_key(data_source_name)