#NEWLINE# @ classmethod #NEWLINE# def OpenFileObject( cls , path_spec , resolver_context = None ) : #NEWLINE# #INDENT# 'Opens a file-like object defined by path specification.\n\n    Args:\n      path_spec: the path specification (instance of PathSpec).\n      resolver_context: the optional resolver context (instance of\n                        resolver.Context). The default is None which will use\n                        the built in context which is not multi process safe.\n\n    Returns:\n      The file-like object (instance of file.FileIO) or None if the path\n      specification could not be resolved.\n\n    Raises:\n      KeyError: if resolver helper object is not set for the corresponding\n                type indicator.\n      PathSpecError: if the path specification is incorrect.\n    ' #NEWLINE# if ( resolver_context is None ) : #NEWLINE# #INDENT# resolver_context = cls . _resolver_context #NEWLINE# #UNINDENT# if ( path_spec . type_indicator == definitions . TYPE_INDICATOR_MOUNT ) : #NEWLINE# #INDENT# if path_spec . HasParent ( ) : #NEWLINE# #INDENT# raise errors . PathSpecError ( 'Unsupported mount path specification with parent.' ) #NEWLINE# #UNINDENT# mount_point = getattr ( path_spec , 'identifier' , None ) #NEWLINE# if ( not mount_point ) : #NEWLINE# #INDENT# raise errors . PathSpecError ( 'Unsupported path specification without mount point identifier.' ) #NEWLINE# #UNINDENT# path_spec = mount_manager . MountPointManager . GetMountPoint ( mount_point ) #NEWLINE# if ( not path_spec ) : #NEWLINE# #INDENT# raise errors . MountPointError ( 'No such mount point: {0:s}' . format ( mount_point ) ) #NEWLINE# #UNINDENT# #UNINDENT# file_object = resolver_context . GetFileObject ( path_spec ) #NEWLINE# if ( not file_object ) : #NEWLINE# #INDENT# if ( path_spec . type_indicator not in cls . _resolver_helpers ) : #NEWLINE# #INDENT# raise KeyError ( 'Resolver helper object not set for type indicator: {0:s}.' . format ( file_object . type_indicator ) ) #NEWLINE# #UNINDENT# resolver_helper = cls . _resolver_helpers [ path_spec . type_indicator ] #NEWLINE# file_object = resolver_helper . NewFileObject ( resolver_context ) #NEWLINE# #UNINDENT# file_object . open ( path_spec = path_spec ) #NEWLINE# return file_object