#NEWLINE# def glob( repo , tree , pathname ) : #NEWLINE# #INDENT# "\n    Return an iterator which yields the paths matching a pathname pattern.\n\n    This is identical to python's glob.iglob() function, but works on the\n    given git tree object instead of the filesystem.\n    " #NEWLINE# if isinstance ( tree , pygit2 . Oid ) : #NEWLINE# #INDENT# tree = repo [ tree ] #NEWLINE# #UNINDENT# pathname = pathname . strip ( '/' ) #NEWLINE# if ( not has_magic ( repo ) ) : #NEWLINE# #INDENT# if path_exists ( tree , pathname ) : #NEWLINE# #INDENT# ( yield pathname ) #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# ( dirname , basename ) = os . path . split ( pathname ) #NEWLINE# if ( not dirname ) : #NEWLINE# #INDENT# for name in glob1 ( repo , tree , os . curdir , basename ) : #NEWLINE# #INDENT# ( yield name ) #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# if ( ( dirname != pathname ) and has_magic ( dirname ) ) : #NEWLINE# #INDENT# dirs = glob ( repo , tree , dirname ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# dirs = [ dirname ] #NEWLINE# #UNINDENT# if has_magic ( basename ) : #NEWLINE# #INDENT# glob_in_dir = glob1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# glob_in_dir = glob0 #NEWLINE# #UNINDENT# for dirname in dirs : #NEWLINE# #INDENT# for name in glob_in_dir ( repo , tree , dirname , basename ) : #NEWLINE# #INDENT# ( yield os . path . join ( dirname , name ) )