# Path: duckpond/apps/jsonld/endpoint.py
# def get_ld(graphs=[],subjects=[],connection=None):
#    if connection is None:
#       connection = get_connection()
# 
#    ld = connection.get(graphs,subjects)
#    return jsonld.compact(ld,connection.context)
# 
# def query_ld(q,limit=None,connection=None):
#    if connection is None:
#       connection = get_connection()
# 
#    ld = connection.query(q,limit=limit)
#    return ld if ld.get('names') is not None and ld.get('values') is not None else jsonld.compact(ld,connection.context)
# 
# def update_ld(data,graph=None,subjects=[],connection=None):
#    if connection is None:
#       connection = get_connection()
# 
#    return connection.replace(data,graph,subjects)
# 
# def delete_ld(graphs=[],subjects=[],connection=None):
#    if connection is None:
#       connection = get_connection()
# 
#    connection.delete(graphs,subjects)
# 
# def append_ld(data,graph=None,connection=None):
#    if connection is None:
#       connection = get_connection()
# 
#    return connection.append(data,graph)


from flask import Blueprint, request, abort, make_response, jsonify, current_app
from duckpond.apps.jsonld.endpoint import get_ld, query_ld, update_ld, delete_ld, append_ld
import logging
import requests
import json

prefix = 'duckpond_service_jsonld'
data = Blueprint(prefix+'_data',__name__,template_folder='templates')

logger = logging.getLogger('webapp')

def content_type():
   contentType = request.headers.get('Content-Type')
   if contentType is None:
      return ('application/octet-stream',None)
   parts = contentType.split(';')
   charset = 'UTF-8'
   for part in parts[1:]:
      part = part.strip()
      param = part.split('=')
      if param[0].strip()=='charset':
         charset = param[1].strip()
   return (parts[0],charset)

def jsonld_response(data):
   if data is None:
      data = {}
   if type(data)==dict or type(data)==list:

# Path: duckpond/apps/jsonld/endpoint.py
# def get_ld(graphs=[],subjects=[],connection=None):
#    if connection is None:
#       connection = get_connection()
# 
#    ld = connection.get(graphs,subjects)
#    return jsonld.compact(ld,connection.context)
# 
# def query_ld(q,limit=None,connection=None):
#    if connection is None:
#       connection = get_connection()
# 
#    ld = connection.query(q,limit=limit)
#    return ld if ld.get('names') is not None and ld.get('values') is not None else jsonld.compact(ld,connection.context)
# 
# def update_ld(data,graph=None,subjects=[],connection=None):
#    if connection is None:
#       connection = get_connection()
# 
#    return connection.replace(data,graph,subjects)
# 
# def delete_ld(graphs=[],subjects=[],connection=None):
#    if connection is None:
#       connection = get_connection()
# 
#    connection.delete(graphs,subjects)
# 
# def append_ld(data,graph=None,connection=None):
#    if connection is None:
#       connection = get_connection()
# 
#    return connection.append(data,graph)


# Path: duckpond/apps/jsonld/service.py
from flask import Blueprint, request, abort, make_response, jsonify, current_app
from duckpond.apps.jsonld.endpoint import get_ld, query_ld, update_ld, delete_ld, append_ld
import logging
import requests
import json


prefix = 'duckpond_service_jsonld'
data = Blueprint(prefix+'_data',__name__,template_folder='templates')

logger = logging.getLogger('webapp')

def content_type():
   contentType = request.headers.get('Content-Type')
   if contentType is None:
      return ('application/octet-stream',None)
   parts = contentType.split(';')
   charset = 'UTF-8'
   for part in parts[1:]:
      part = part.strip()
      param = part.split('=')
      if param[0].strip()=='charset':
         charset = param[1].strip()
   return (parts[0],charset)

def jsonld_response(data):
   if data is None:
      data = {}
   if type(data)==dict or type(data)==list:

      data = json.dumps(data)