#NEWLINE# def _get_codeobj( pyfile ) : #NEWLINE# #INDENT# ' Returns the code object, given a python file ' #NEWLINE# from imp import PY_COMPILED , PY_SOURCE #NEWLINE# ( result , fileobj , fullpath ) = _check_if_pyc ( pyfile ) #NEWLINE# try : #NEWLINE# #INDENT# data = fileobj . read ( ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# fileobj . close ( ) #NEWLINE# #UNINDENT# if ( result is PY_COMPILED ) : #NEWLINE# #INDENT# import marshal #NEWLINE# code_obj = marshal . loads ( data [ 8 : ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( result is PY_SOURCE ) : #NEWLINE# #INDENT# code_obj = compile ( data , fullpath , 'exec' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise Exception ( 'Input file is unknown format: {0}' . format ( fullpath ) ) #NEWLINE# #UNINDENT# #UNINDENT# return code_obj