# Path: ckanext/ioos_theme/blueprint.py
# def feedback(data=None, errors=None, error_summary=None,
#              package_name=None):
# def _post_feedback(self):
# def _clear_pycsw(config_path):
# def _sync_pycsw(config_path):
# def csw_index():
# def csw_clear():
# def csw_sync(self):
#     def feedback_form(errors=None, error_summary=None,
#                       package_name=None):


import ckan.plugins as p
import json
import logging
import copy
import pendulum
import datetime
import six
import re
from ckan.lib.search import SearchError
from ckan.plugins import toolkit
from collections import OrderedDict
from ckan.logic.validators import int_validator, email_validator
from ckanext.spatial.interfaces import ISpatialHarvester
from itertools import chain
from six.moves import urllib
from lxml import etree
from collections import OrderedDict
from sortedcontainers import SortedDict
from ckanext.ioos_theme import blueprint
def get_pkg_extra(pkg, key):
    try:
        pkg_item = next((extra['value'] for extra in pkg['extras'] if extra['key'] == key))
    except StopIteration:
        return None
    return pkg_item


def jsonpath(obj, path):
    for key in path.split('.'):
        if not isinstance(obj, dict):
            return {}
        obj = obj.get(key, {})
        log.info("OBJ: %s", obj)
    return obj

class Ioos_ThemePlugin(p.SingletonPlugin):
    '''
    Plugin definition for the IOOS Theme
    '''

    p.implements(p.IConfigurer)
    p.implements(p.ITemplateHelpers)
    p.implements(p.IBlueprint)
    p.implements(p.IPackageController, inherit=True)
    p.implements(ISpatialHarvester, inherit=True)
    p.implements(p.IFacets, inherit=True)

    # IBlueprint
    def get_blueprint(self):

# Path: ckanext/ioos_theme/blueprint.py
# def feedback(data=None, errors=None, error_summary=None,
#              package_name=None):
# def _post_feedback(self):
# def _clear_pycsw(config_path):
# def _sync_pycsw(config_path):
# def csw_index():
# def csw_clear():
# def csw_sync(self):
#     def feedback_form(errors=None, error_summary=None,
#                       package_name=None):


# Path: ckanext/ioos_theme/plugin.py
import ckan.plugins as p
import json
import logging
import copy
import pendulum
import datetime
import six
import re
from ckan.lib.search import SearchError
from ckan.plugins import toolkit
from collections import OrderedDict
from ckan.logic.validators import int_validator, email_validator
from ckanext.spatial.interfaces import ISpatialHarvester
from itertools import chain
from six.moves import urllib
from lxml import etree
from collections import OrderedDict
from sortedcontainers import SortedDict
from ckanext.ioos_theme import blueprint

def get_pkg_extra(pkg, key):
    try:
        pkg_item = next((extra['value'] for extra in pkg['extras'] if extra['key'] == key))
    except StopIteration:
        return None
    return pkg_item


def jsonpath(obj, path):
    for key in path.split('.'):
        if not isinstance(obj, dict):
            return {}
        obj = obj.get(key, {})
        log.info("OBJ: %s", obj)
    return obj

class Ioos_ThemePlugin(p.SingletonPlugin):
    '''
    Plugin definition for the IOOS Theme
    '''

    p.implements(p.IConfigurer)
    p.implements(p.ITemplateHelpers)
    p.implements(p.IBlueprint)
    p.implements(p.IPackageController, inherit=True)
    p.implements(ISpatialHarvester, inherit=True)
    p.implements(p.IFacets, inherit=True)

    # IBlueprint
    def get_blueprint(self):

        blueprints = [blueprint.ioos_bp]