diff options
Diffstat (limited to 'Lib/distutils/filelist.py')
-rw-r--r-- | Lib/distutils/filelist.py | 58 |
1 files changed, 24 insertions, 34 deletions
diff --git a/Lib/distutils/filelist.py b/Lib/distutils/filelist.py index f7222fd..d39c835 100644 --- a/Lib/distutils/filelist.py +++ b/Lib/distutils/filelist.py @@ -37,27 +37,19 @@ class FileList: def __init__(self, warn=None, debug_print=None): - # use standard warning and debug functions if no other given - self.warn = warn or self.__warn - self.debug_print = debug_print or self.__debug_print + # ignore argument to FileList, but keep them for backwards + # compatibility self.allfiles = None self.files = [] - def set_allfiles (self, allfiles): self.allfiles = allfiles def findall (self, dir=os.curdir): self.allfiles = findall(dir) - - # -- Fallback warning/debug functions ------------------------------ - - def __warn (self, msg): - sys.stderr.write("warning: %s\n" % msg) - - def __debug_print (self, msg): + def debug_print (self, msg): """Print 'msg' to stdout if the global DEBUG (taken from the DISTUTILS_DEBUG environment variable) flag is true. """ @@ -65,7 +57,6 @@ class FileList: if DEBUG: print msg - # -- List-like methods --------------------------------------------- def append (self, item): @@ -87,8 +78,8 @@ class FileList: def remove_duplicates (self): # Assumes list has been sorted! - for i in range(len(self.files)-1, 0, -1): - if self.files[i] == self.files[i-1]: + for i in range(len(self.files) - 1, 0, -1): + if self.files[i] == self.files[i - 1]: del self.files[i] @@ -147,61 +138,60 @@ class FileList: self.debug_print("include " + string.join(patterns)) for pattern in patterns: if not self.include_pattern(pattern, anchor=1): - self.warn("no files found matching '%s'" % pattern) + log.warn("warning: no files found matching '%s'", + pattern) elif action == 'exclude': self.debug_print("exclude " + string.join(patterns)) for pattern in patterns: if not self.exclude_pattern(pattern, anchor=1): - self.warn( - "no previously-included files found matching '%s'"% - pattern) + log.warn(("warning: no previously-included files " + "found matching '%s'"), pattern) elif action == 'global-include': self.debug_print("global-include " + string.join(patterns)) for pattern in patterns: if not self.include_pattern(pattern, anchor=0): - self.warn(("no files found matching '%s' " + - "anywhere in distribution") % - pattern) + log.warn(("warning: no files found matching '%s' " + + "anywhere in distribution"), pattern) elif action == 'global-exclude': self.debug_print("global-exclude " + string.join(patterns)) for pattern in patterns: if not self.exclude_pattern(pattern, anchor=0): - self.warn(("no previously-included files matching '%s' " + - "found anywhere in distribution") % - pattern) + log.warn(("warning: no previously-included files matching " + "'%s' found anywhere in distribution"), + pattern) elif action == 'recursive-include': self.debug_print("recursive-include %s %s" % (dir, string.join(patterns))) for pattern in patterns: if not self.include_pattern(pattern, prefix=dir): - self.warn(("no files found matching '%s' " + - "under directory '%s'") % - (pattern, dir)) + log.warn(("warngin: no files found matching '%s' " + + "under directory '%s'"), + pattern, dir) elif action == 'recursive-exclude': self.debug_print("recursive-exclude %s %s" % (dir, string.join(patterns))) for pattern in patterns: if not self.exclude_pattern(pattern, prefix=dir): - self.warn(("no previously-included files matching '%s' " + - "found under directory '%s'") % - (pattern, dir)) + log.warn(("warning: no previously-included files matching " + "'%s' found under directory '%s'"), + pattern, dir) elif action == 'graft': self.debug_print("graft " + dir_pattern) if not self.include_pattern(None, prefix=dir_pattern): - self.warn("no directories found matching '%s'" % dir_pattern) + log.warn("warning: no directories found matching '%s'", + dir_pattern) elif action == 'prune': self.debug_print("prune " + dir_pattern) if not self.exclude_pattern(None, prefix=dir_pattern): - self.warn(("no previously-included directories found " + - "matching '%s'") % - dir_pattern) + log.warn(("no previously-included directories found " + + "matching '%s'"), dir_pattern) else: raise DistutilsInternalError, \ "this cannot happen: invalid action '%s'" % action |