# Path: pyxc/util.py
# def usingPython3():
#     return sys.version_info[0] == 3
# 
# def parentOf(path):
#     return '/'.join(path.rstrip('/').split('/')[:-1])
# 
# Path: pyxc/pyxc_exceptions.py
# class PyxcError(Exception): pass
# class NoTransformationForNode(PyxcError): pass


import subprocess, os, json
        import pj.api_internal
from pyxc.util import usingPython3, parentOf
from pyxc import pyxc_exceptions
        if os.environ.get('PYTHONPATH'):
            pythonPath += ':' + os.environ.get('PYTHONPATH')
        
        subprocessArgs = ['/usr/bin/env',
                                    'PYTHONPATH=%s' % pythonPath,
                                    'python3.1',
                                    parentOf(os.path.abspath(__file__)) + '/pj',
                                    ] + subprocessArgs
        
        if input is None:
            p = subprocess.Popen(subprocessArgs, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            out, err = p.communicate()
        else:
            p = subprocess.Popen(subprocessArgs, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
            out, err = p.communicate(input=input)
        
        if p.returncode == 0:
            result = unicode(out, 'utf-8')
            if parseJson:
                result = json.loads(result)
            return result
        else:
            try:
                errInfo = json.loads(err)
            except ValueError:
                errInfo = {
                    'name': 'Exception',
                    'message': unicode(err, 'utf-8'),
                }
            if hasattr(pyxc_exceptions, errInfo['name']):

# Path: pyxc/util.py
# def usingPython3():
#     return sys.version_info[0] == 3
# 
# def parentOf(path):
#     return '/'.join(path.rstrip('/').split('/')[:-1])
# 
# Path: pyxc/pyxc_exceptions.py
# class PyxcError(Exception): pass
# class NoTransformationForNode(PyxcError): pass


# Path: pj/api.py
import subprocess, os, json
        import pj.api_internal
from pyxc.util import usingPython3, parentOf
from pyxc import pyxc_exceptions

        if os.environ.get('PYTHONPATH'):
            pythonPath += ':' + os.environ.get('PYTHONPATH')
        
        subprocessArgs = ['/usr/bin/env',
                                    'PYTHONPATH=%s' % pythonPath,
                                    'python3.1',
                                    parentOf(os.path.abspath(__file__)) + '/pj',
                                    ] + subprocessArgs
        
        if input is None:
            p = subprocess.Popen(subprocessArgs, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            out, err = p.communicate()
        else:
            p = subprocess.Popen(subprocessArgs, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
            out, err = p.communicate(input=input)
        
        if p.returncode == 0:
            result = unicode(out, 'utf-8')
            if parseJson:
                result = json.loads(result)
            return result
        else:
            try:
                errInfo = json.loads(err)
            except ValueError:
                errInfo = {
                    'name': 'Exception',
                    'message': unicode(err, 'utf-8'),
                }
            if hasattr(pyxc_exceptions, errInfo['name']):

                exceptionClass = getattr(pyxc_exceptions, errInfo['name'])