#NEWLINE# def resolve_pattern( self , dirname , pattern , globstar_with_root ) : #NEWLINE# #INDENT# "Apply ``pattern`` (contains no path elements) to the\n        literal directory`` in dirname``.\n\n        If pattern=='', this will filter for directories. This is\n        a special case that happens when the user's glob expression ends\n        with a slash (in which case we only want directories). It simpler\n        and faster to filter here than in :meth:`_iglob`.\n        " #NEWLINE# if ( sys . version_info [ 0 ] == 3 ) : #NEWLINE# #INDENT# if isinstance ( pattern , bytes ) : #NEWLINE# #INDENT# dirname = bytes ( self . curdir , 'ASCII' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( isinstance ( pattern , unicode ) and ( not isinstance ( dirname , unicode ) ) ) : #NEWLINE# #INDENT# dirname = unicode ( dirname , ( sys . getfilesystemencoding ( ) or sys . getdefaultencoding ( ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not has_magic ( pattern ) ) : #NEWLINE# #INDENT# if ( pattern == '' ) : #NEWLINE# #INDENT# if self . isdir ( dirname ) : #NEWLINE# #INDENT# return [ ( pattern , ( ) ) ] #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if self . exists ( os . path . join ( dirname , pattern ) ) : #NEWLINE# #INDENT# return [ ( pattern , ( ) ) ] #NEWLINE# #UNINDENT# #UNINDENT# return [ ] #NEWLINE# #UNINDENT# if ( not dirname ) : #NEWLINE# #INDENT# dirname = self . curdir #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# if ( pattern == '**' ) : #NEWLINE# #INDENT# names = ( [ '' ] if globstar_with_root else [ ] ) #NEWLINE# for ( top , entries ) in self . walk ( dirname ) : #NEWLINE# #INDENT# _mkabs = ( lambda s : os . path . join ( self . chop_dirname ( dirname , top ) , s ) ) #NEWLINE# names . extend ( map ( _mkabs , entries ) ) #NEWLINE# #UNINDENT# pattern = '*' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# names = self . listdir ( dirname , prefix = get_magic_prefix ( pattern ) ) #NEWLINE# #UNINDENT# #UNINDENT# except os . error : #NEWLINE# #INDENT# return [ ] #NEWLINE# #UNINDENT# if ( not _ishidden ( pattern ) ) : #NEWLINE# #INDENT# names = filter ( ( lambda x : ( ( not x ) or ( not _ishidden ( x ) ) ) ) , names ) #NEWLINE# #UNINDENT# return fnmatch . filter ( names , pattern )