Ejemplo n.º 1
0
def read_manifest_in(reporter,
                     filelist=None, dirname=os.getcwd(),
                     filename="MANIFEST.in",
                     exclude_patterns=(r'/(RCS|CVS|\.svn|\.hg)/.*',)):
    """return a list of files matching the MANIFEST.in"""
    absfile = join(dirname, filename)
    if not exists(absfile):
        return []
    orig_dir = os.getcwd()
    os.chdir(dirname)
    if filelist is None:
        filelist = FileList()

    def warn(msg, *args):
        if args:
            try:
                msg %= args
            except TypeError as ex:
                raise TypeError(str((ex, msg, args)))
        #reporter.warning(absfile,None,msg)
    filelist.warn = warn
    __warn = distutils.log.warn
    distutils.log.warn = warn

    try:
        template = TextFile(filename, strip_comments=1,
                            skip_blanks=1, join_lines=1,
                            lstrip_ws=1, rstrip_ws=1,
                            collapse_join=1)
        while 1:
            line = template.readline()
            if line is None:            # end of file
                break
            try:
                filelist.process_template_line(line)
            except DistutilsTemplateError:
                #reporter.error(absfile, template.current_line, msg)
                pass
        filelist.sort()
        filelist.remove_duplicates()
        for pattern in exclude_patterns:
            filelist.exclude_pattern(pattern, is_regex=1)
        return [path.replace('./', '') for path in filelist.files]
    finally:
        distutils.log.warn = __warn
        os.chdir(orig_dir)