# Path: antioch/util/ason.py
# def loads(j, exchange=None):
#     def to_entity(d):
# def dumps(obj):
#     def from_entity(o):
# 
# Path: antioch/core/parser.py
# URL_REGEXP = r'(?P<scheme>[+a-z0-9]+)\:(\/\/)?'
# URL_RE = re.compile(URL_REGEXP, re.IGNORECASE)
# PREP_SRC = r'(?:\b)(?P<prep>' + prepstring + r')(?:\b)'
# SPEC = r"(?P<spec_str>my|the|a|an|\S+(?:\'s|s\'))"
# PHRASE_SRC = r'(?:' + SPEC + r'\s)?(?P<obj_str>.+)'
# PREP = re.compile(PREP_SRC)
# PHRASE = re.compile(PHRASE_SRC)
# POBJ_TEST = re.compile(PREP_SRC + "\s" + PHRASE_SRC)
# MULTI_WORD = re.compile(r'((\"|\').+?(?!\\).\2)|(\S+)')
# class URL(dict):
# class Lexer(object):
# class TransactionParser(object):
#     def __init__(self, source):
#     def __str__(self):
# def parse(caller, sentence, debug=False):
#     def _profile(name):
# def get_default_parser(v):
#     def __init__(self, command):
#         def nonoverlap(item):
#     def get_details(self):
#     def __init__(self, lexer, caller, exchange):
#     def get_environment(self):
#     def find_object(self, specifier, name, return_list=False):
#     def get_verb(self):
#     def filter_matches(self, possible):
#     def get_pronoun_object(self, pronoun):
#     def get_dobj(self):
#     def get_pobj(self, prep):
#     def get_dobj_str(self):
#     def get_pobj_str(self, prep, return_list=False):
#     def get_pobj_spec_str(self, prep, return_list=False):
#     def has_dobj(self):
#     def has_pobj(self, prep):
#     def has_dobj_str(self):
#     def has_pobj_str(self, prep):
# 
# Path: antioch/core/tasks.py
# def get_exchange(ctx=None):
# def authenticate(username, password, ip_address):
# def deploy(user_id, source):
# def login(user_id, session_id, ip_address):
# def logout(user_id):
# def parse(user_id, sentence):
# def registertask(user_id, delay, origin_id, verb_name, args, kwargs):
# def runtask(user_id, task_id):
# def iteratetasks():


import logging
from celery import shared_task
from antioch.util import ason
from antioch.core import parser, tasks
        from antioch.plugins import editors
        from antioch.plugins import editors



log = logging.getLogger(__name__)

@shared_task
def openeditor(user_id, object_id, type, name):
    with tasks.get_exchange(user_id) as x:
        if(type == 'object'):
            item = x.get_object(object_id)
        else:
            item = getattr(x, 'get_' + type)(object_id, name)
            if(item is None):
                item = x.instantiate(type, owner_id=user_id, origin_id=object_id, name=name)
        caller = x.get_object(user_id)
        p = parser.TransactionParser(parser.Lexer(''), caller, x)
        editors.edit(p, item)
    
    return {'response': True}

@shared_task
def openaccess(user_id, object_id, type, name):
    with tasks.get_exchange(user_id) as x:
        origin = x.get_object(object_id)
        caller = x.get_object(user_id)
        if(type == 'object'):
            item = origin
        else:
            item = getattr(origin, 'get_' + type)(name)
        

# Path: antioch/util/ason.py
# def loads(j, exchange=None):
#     def to_entity(d):
# def dumps(obj):
#     def from_entity(o):
# 
# Path: antioch/core/parser.py
# URL_REGEXP = r'(?P<scheme>[+a-z0-9]+)\:(\/\/)?'
# URL_RE = re.compile(URL_REGEXP, re.IGNORECASE)
# PREP_SRC = r'(?:\b)(?P<prep>' + prepstring + r')(?:\b)'
# SPEC = r"(?P<spec_str>my|the|a|an|\S+(?:\'s|s\'))"
# PHRASE_SRC = r'(?:' + SPEC + r'\s)?(?P<obj_str>.+)'
# PREP = re.compile(PREP_SRC)
# PHRASE = re.compile(PHRASE_SRC)
# POBJ_TEST = re.compile(PREP_SRC + "\s" + PHRASE_SRC)
# MULTI_WORD = re.compile(r'((\"|\').+?(?!\\).\2)|(\S+)')
# class URL(dict):
# class Lexer(object):
# class TransactionParser(object):
#     def __init__(self, source):
#     def __str__(self):
# def parse(caller, sentence, debug=False):
#     def _profile(name):
# def get_default_parser(v):
#     def __init__(self, command):
#         def nonoverlap(item):
#     def get_details(self):
#     def __init__(self, lexer, caller, exchange):
#     def get_environment(self):
#     def find_object(self, specifier, name, return_list=False):
#     def get_verb(self):
#     def filter_matches(self, possible):
#     def get_pronoun_object(self, pronoun):
#     def get_dobj(self):
#     def get_pobj(self, prep):
#     def get_dobj_str(self):
#     def get_pobj_str(self, prep, return_list=False):
#     def get_pobj_spec_str(self, prep, return_list=False):
#     def has_dobj(self):
#     def has_pobj(self, prep):
#     def has_dobj_str(self):
#     def has_pobj_str(self, prep):
# 
# Path: antioch/core/tasks.py
# def get_exchange(ctx=None):
# def authenticate(username, password, ip_address):
# def deploy(user_id, source):
# def login(user_id, session_id, ip_address):
# def logout(user_id):
# def parse(user_id, sentence):
# def registertask(user_id, delay, origin_id, verb_name, args, kwargs):
# def runtask(user_id, task_id):
# def iteratetasks():


# Path: antioch/plugins/editors/tasks.py
import logging
from celery import shared_task
from antioch.util import ason
from antioch.core import parser, tasks
        from antioch.plugins import editors
        from antioch.plugins import editors




log = logging.getLogger(__name__)

@shared_task
def openeditor(user_id, object_id, type, name):
    with tasks.get_exchange(user_id) as x:
        if(type == 'object'):
            item = x.get_object(object_id)
        else:
            item = getattr(x, 'get_' + type)(object_id, name)
            if(item is None):
                item = x.instantiate(type, owner_id=user_id, origin_id=object_id, name=name)
        caller = x.get_object(user_id)
        p = parser.TransactionParser(parser.Lexer(''), caller, x)
        editors.edit(p, item)
    
    return {'response': True}

@shared_task
def openaccess(user_id, object_id, type, name):
    with tasks.get_exchange(user_id) as x:
        origin = x.get_object(object_id)
        caller = x.get_object(user_id)
        if(type == 'object'):
            item = origin
        else:
            item = getattr(origin, 'get_' + type)(name)
        

        p = parser.TransactionParser(parser.Lexer(''), caller, x)