#NEWLINE# def get_pack_resource_file_abs_path( pack_name , resource_type , file_path ) : #NEWLINE# #INDENT# '\n    Retrieve full absolute path to the pack resource file.\n\n    Note: This function also takes care of sanitizing ``file_name`` argument\n          preventing directory traversal and similar attacks.\n\n    :param pack_name: Pack name.\n    :type pack_name: ``str``\n\n    :param resource_type: Pack resource type (e.g. action, sensor, etc.).\n    :type resource_type: ``str``\n\n    :pack file_path: Resource file path relative to the pack directory (e.g. my_file.py or\n                     directory/my_file.py)\n    :type file_path: ``str``\n\n    :rtype: ``str``\n    ' #NEWLINE# path_components = [ ] #NEWLINE# if ( resource_type == 'action' ) : #NEWLINE# #INDENT# path_components . append ( 'actions/' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( resource_type == 'sensor' ) : #NEWLINE# #INDENT# path_components . append ( 'sensors/' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( resource_type == 'rule' ) : #NEWLINE# #INDENT# path_components . append ( 'rules/' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( ( 'Invalid resource type: %s' % resource_type ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# path_components . append ( file_path ) #NEWLINE# file_path = os . path . join ( * path_components ) #NEWLINE# result = get_pack_file_abs_path ( pack_name = pack_name , file_path = file_path ) #NEWLINE# return result