def get_py_source ( file ) : try : response = None pysource = "" if regexp_py . search ( file ) is None : response = { "error" : "Only Python source files are allowed. (*.py)" } else : with open ( file , 'r' ) as pyfile : pysource = pyfile . read ( ) response = { "data" : pysource } except Exception as e : response = { "error" : str ( e ) } finally : return response
python source is not defined
Retrieves and returns the source code for any Python files requested by the UI via the host agent
def get_py_source(file):
    """
    Retrieves and returns the source code for any Python
    files requested by the UI via the host agent

    @param file [String] The fully qualified path to a file
    """
    try:
        response = None
        pysource = ""

        if regexp_py.search(file) is None:
            response = {"error": "Only Python source files are allowed. (*.py)"}
        else:
            with open(file, 'r') as pyfile:
                pysource = pyfile.read()

            response = {"data": pysource}

    except Exception as e:
        response = {"error": str(e)}
    finally:
        return response