#NEWLINE# def subpaths( path ) : #NEWLINE# #INDENT# 'List of all recursive parents of `path` in distance order' #NEWLINE# def append_deeper( acc , name ) : #NEWLINE# #INDENT# return ( acc + [ ( ( acc [ ( - 1 ) ] + os . sep ) + name ) ] ) #NEWLINE# #UNINDENT# ( drive , dirs ) = os . path . splitdrive ( path ) #NEWLINE# dirs = dirs . split ( os . sep ) #NEWLINE# if os . path . isfile ( path ) : #NEWLINE# #INDENT# dirs = dirs [ : ( - 1 ) ] #NEWLINE# #UNINDENT# paths = reduce ( d , dirs , [ '' ] ) [ 1 : ] #NEWLINE# paths = [ ( d [ 1 : ] if d . startswith ( ( os . sep + os . sep ) ) else d ) for d in paths ] #NEWLINE# paths = [ ( drive + d ) for d in paths ] #NEWLINE# paths . reverse ( ) #NEWLINE# return paths