#NEWLINE# def path_completer( text , expected = None , classes = None , perm_level = None , include_current_proj = False , typespec = None , visibility = None ) : #NEWLINE# #INDENT# '\n    :param text: String to tab-complete to a path matching the syntax project-name:folder/entity_or_folder_name\n    :type text: string\n    :param expected: "folder", "entity", "project", or None (no restriction) as to the types of answers to look for\n    :type expected: string\n    :param classes: if expected="entity", the possible data object classes that are acceptable\n    :type classes: list of strings\n    :param perm_level: the minimum permissions level required, e.g. "VIEW" or "CONTRIBUTE"\n    :type perm_level: string\n    :param include_current_proj: Indicate whether the current project\'s name should be a potential result\n    :type include_current_proj: boolean\n    :param visibility: Visibility with which to restrict the completion (one of "either", "visible", or "hidden") (default behavior is dependent on *text*)\n\n    Returns a list of matches to the text and restricted by the\n    requested parameters.\n    ' #NEWLINE# colon_pos = get_last_pos_of_char ( ':' , text ) #NEWLINE# slash_pos = get_last_pos_of_char ( '/' , text ) #NEWLINE# delim_pos = max ( colon_pos , slash_pos ) #NEWLINE# matches = [ ] #NEWLINE# if ( ( expected == 'project' ) and ( colon_pos > 0 ) and ( colon_pos == ( len ( text ) - 1 ) ) ) : #NEWLINE# #INDENT# if ( dxpy . find_one_project ( zero_ok = True , name = text [ : colon_pos ] ) is not None ) : #NEWLINE# #INDENT# return [ ( text + ' ' ) ] #NEWLINE# #UNINDENT# #UNINDENT# if ( ( colon_pos < 0 ) and ( slash_pos < 0 ) ) : #NEWLINE# #INDENT# if ( ( text != '' ) or ( expected == 'project' ) ) : #NEWLINE# #INDENT# results = dxpy . find_projects ( describe = True , level = perm_level ) #NEWLINE# if ( not include_current_proj ) : #NEWLINE# #INDENT# results = [ r for r in results if ( r [ 'id' ] != dxpy . WORKSPACE_ID ) ] #NEWLINE# #UNINDENT# matches += [ ( escape_colon ( r [ 'describe' ] [ 'name' ] ) + ':' ) for r in results if r [ 'describe' ] [ 'name' ] . startswith ( text ) ] #NEWLINE# #UNINDENT# #UNINDENT# if ( expected == 'project' ) : #NEWLINE# #INDENT# return matches #NEWLINE# #UNINDENT# if ( ( colon_pos < 0 ) and ( slash_pos >= 0 ) ) : #NEWLINE# #INDENT# if ( dxpy . WORKSPACE_ID is not None ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# dxproj = dxpy . get_handler ( dxpy . WORKSPACE_ID ) #NEWLINE# ( folderpath , entity_name ) = clean_folder_path ( text ) #NEWLINE# matches += get_folder_matches ( text , slash_pos , dxproj , folderpath ) #NEWLINE# if ( expected != 'folder' ) : #NEWLINE# #INDENT# if ( classes is not None ) : #NEWLINE# #INDENT# for classname in classes : #NEWLINE# #INDENT# matches += get_data_matches ( text , slash_pos , dxproj , folderpath , classname = classname , typespec = typespec , visibility = visibility ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# matches += get_data_matches ( text , slash_pos , dxproj , folderpath , typespec = typespec , visibility = visibility ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# ( proj_ids , folderpath , entity_name ) = resolve_path ( text , multi_projects = True ) #NEWLINE# #UNINDENT# except ResolutionError as details : #NEWLINE# #INDENT# sys . stderr . write ( ( '\n' + fill ( str ( details ) ) ) ) #NEWLINE# return matches #NEWLINE# #UNINDENT# for proj in proj_ids : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# dxproj = dxpy . get_handler ( proj ) #NEWLINE# matches += get_folder_matches ( text , delim_pos , dxproj , folderpath ) #NEWLINE# if ( expected != 'folder' ) : #NEWLINE# #INDENT# if ( classes is not None ) : #NEWLINE# #INDENT# for classname in classes : #NEWLINE# #INDENT# matches += get_data_matches ( text , delim_pos , dxproj , folderpath , classname = classname , typespec = typespec , visibility = visibility ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# matches += get_data_matches ( text , delim_pos , dxproj , folderpath , typespec = typespec , visibility = visibility ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return matches