# 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
      delete_ld(graphs,subject)
   else:
      request_type = content_type()
      if request_type[0]=='application/ld+json':
         if graphs is not None and len(graphs)>1:
            abort(400,'Only one graph may be specified on update/append.')
         json = request.get_json(force=True)
         ld = jsonld.compact(json,current_app.config.get('LD_CONTEXT'))
         if request.method=='POST':
            append_ld(ld,graphs=graphs[0] if graphs is not None and len(graphs)>0 else None,subjects=subjects)
         else:
            update_ld(ld,graph=graphs[0] if graphs is not None and len(graphs)>0 else None,subjects=subjects)
         return ('',201)
      elif request_type[0]=='application/sparql-update':
         if request.method=='POST':
            abort(400,'Invalid method POST with SPARQL update.')
         if len(graphs)>0:
            abort(400,'The graph parameter may not be specified via update - incorporate into the SPARQL update statement.')
         if len(subjects)>0:
            abort(400,'The subject parameter may not be specified via update - incorporate into the SPARQL update statement.')

         ld = query_ld(request.data.decode(encoding=request_type[1]),limit=request.args.get('limit'))
         return jsonld_response(ld)
      elif request_type[0]=='application/sparql-query':
         if request.method=='PUT':
            abort(400,'Invalid method PUT with SPARQL query.')
         if len(graphs)>0:
            abort(400,'The graph parameter may not be specified via query - incorporate into the SPARQL update statement.')
         if len(subjects)>0:
            abort(400,'The subject parameter may not be specified via query - incorporate into the SPARQL update statement.')

# 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

      delete_ld(graphs,subject)
   else:
      request_type = content_type()
      if request_type[0]=='application/ld+json':
         if graphs is not None and len(graphs)>1:
            abort(400,'Only one graph may be specified on update/append.')
         json = request.get_json(force=True)
         ld = jsonld.compact(json,current_app.config.get('LD_CONTEXT'))
         if request.method=='POST':
            append_ld(ld,graphs=graphs[0] if graphs is not None and len(graphs)>0 else None,subjects=subjects)
         else:
            update_ld(ld,graph=graphs[0] if graphs is not None and len(graphs)>0 else None,subjects=subjects)
         return ('',201)
      elif request_type[0]=='application/sparql-update':
         if request.method=='POST':
            abort(400,'Invalid method POST with SPARQL update.')
         if len(graphs)>0:
            abort(400,'The graph parameter may not be specified via update - incorporate into the SPARQL update statement.')
         if len(subjects)>0:
            abort(400,'The subject parameter may not be specified via update - incorporate into the SPARQL update statement.')

         ld = query_ld(request.data.decode(encoding=request_type[1]),limit=request.args.get('limit'))
         return jsonld_response(ld)
      elif request_type[0]=='application/sparql-query':
         if request.method=='PUT':
            abort(400,'Invalid method PUT with SPARQL query.')
         if len(graphs)>0:
            abort(400,'The graph parameter may not be specified via query - incorporate into the SPARQL update statement.')
         if len(subjects)>0:
            abort(400,'The subject parameter may not be specified via query - incorporate into the SPARQL update statement.')

         ld = query_ld(request.data.decode(encoding=request_type[1]),limit=request.args.get('limit'))