@staticmethod<EOL><INDENT>def find_data_files(source,target,patterns,isiter=False):<DEDENT>
if glob.has_magic(source) or glob.has_magic(target):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>ret = {}<EOL>for pattern in patterns:<EOL><INDENT>pattern = os.path.join(source,pattern)<EOL>for filename in glob.glob(pattern):<EOL><INDENT>if os.path.isfile(filename):<EOL><INDENT>targetpath = os.path.join(target,os.path.relpath(filename,source))<EOL>path = os.path.dirname(targetpath)<EOL>ret.setdefault(path,[]).append(filename)<EOL><DEDENT>elif isiter and os.path.isdir(filename):<EOL><INDENT>source2 = os.path.join(source,filename)<EOL>targetpath2 = "<STR_LIT>" %(target,os.path.basename(filename))<EOL>ret.update(SetupUtils.find_data_files(source2,targetpath2,patterns,isiter))<EOL><DEDENT><DEDENT><DEDENT>return sorted(ret.items())<EOL>
Locates the specified data-files and returns the matches; 
            filesystem tree for setup's data_files in setup.py
            Usage:
                data_files = find_data_files(r"C:\Python27\Lib\site-packages\numpy\core","numpy/core",["*.dll","*.pyd"])
                data_files = find_data_files(r"d:\auto\buffer\test\test","buffer/test/test",["*"],True)
            :param source -a full path directory which you want to find data from
            :param target -a relative path directory which you want to pack data to
            :param patterns -glob patterns, such as "*dll", "*pyd"  etc.
            :param isiter - True/Fase, Will traverse path if True when patterns equal ["*"]