Patch from Andrew Kuchling: allow multiple include/exclude patterns

for all commands except 'prune' and 'graft'.
This commit is contained in:
Greg Ward 2000-04-21 04:31:10 +00:00
parent 58ec6ede20
commit 9d5afa9894
1 changed files with 55 additions and 48 deletions

View File

@ -310,24 +310,25 @@ class sdist (Command):
# for the given action (which is the first word) # for the given action (which is the first word)
if action in ('include','exclude', if action in ('include','exclude',
'global-include','global-exclude'): 'global-include','global-exclude'):
if len (words) != 2: if len (words) < 2:
template.warn \ template.warn \
("invalid manifest template line: " + ("invalid manifest template line: " +
"'%s' expects a single <pattern>" % "'%s' expects <pattern1> <pattern2> ..." %
action) action)
continue continue
pattern = native_path (words[1]) pattern_list = map(native_path, words[1:])
elif action in ('recursive-include','recursive-exclude'): elif action in ('recursive-include','recursive-exclude'):
if len (words) != 3: if len (words) < 3:
template.warn \ template.warn \
("invalid manifest template line: " + ("invalid manifest template line: " +
"'%s' expects <dir> <pattern>" % "'%s' expects <dir> <pattern1> <pattern2> ..." %
action) action)
continue continue
(dir, pattern) = map (native_path, words[1:3]) dir = native_path(words[1])
pattern_list = map (native_path, words[2:])
elif action in ('graft','prune'): elif action in ('graft','prune'):
if len (words) != 2: if len (words) != 2:
@ -352,58 +353,64 @@ class sdist (Command):
# digging stuff up out of 'words'. # digging stuff up out of 'words'.
if action == 'include': if action == 'include':
print "include", pattern print "include", string.join(pattern_list)
files = select_pattern (all_files, pattern, anchor=1) for pattern in pattern_list:
if not files: files = select_pattern (all_files, pattern, anchor=1)
template.warn ("no files found matching '%s'" % pattern) if not files:
else: template.warn ("no files found matching '%s'" % pattern)
self.files.extend (files) else:
self.files.extend (files)
elif action == 'exclude': elif action == 'exclude':
print "exclude", pattern print "exclude", string.join(pattern_list)
num = exclude_pattern (self.files, pattern, anchor=1) for pattern in pattern_list:
if num == 0: num = exclude_pattern (self.files, pattern, anchor=1)
template.warn \ if num == 0:
("no previously-included files found matching '%s'" % template.warn (
pattern) "no previously-included files found matching '%s'"%
pattern)
elif action == 'global-include': elif action == 'global-include':
print "global-include", pattern print "global-include", string.join(pattern_list)
files = select_pattern (all_files, pattern, anchor=0) for pattern in pattern_list:
if not files: files = select_pattern (all_files, pattern, anchor=0)
template.warn (("no files found matching '%s' " + if not files:
"anywhere in distribution") % template.warn (("no files found matching '%s' " +
pattern) "anywhere in distribution") %
else: pattern)
self.files.extend (files) else:
self.files.extend (files)
elif action == 'global-exclude': elif action == 'global-exclude':
print "global-exclude", pattern print "global-exclude", string.join(pattern_list)
num = exclude_pattern (self.files, pattern, anchor=0) for pattern in pattern_list:
if num == 0: num = exclude_pattern (self.files, pattern, anchor=0)
template.warn \ if num == 0:
(("no previously-included files matching '%s' " + template.warn \
"found anywhere in distribution") % (("no previously-included files matching '%s' " +
pattern) "found anywhere in distribution") %
pattern)
elif action == 'recursive-include': elif action == 'recursive-include':
print "recursive-include", dir, pattern print "recursive-include", dir, string.join(pattern_list)
files = select_pattern (all_files, pattern, prefix=dir) for pattern in pattern_list:
if not files: files = select_pattern (all_files, pattern, prefix=dir)
template.warn (("no files found matching '%s' " + if not files:
"under directory '%s'") % template.warn (("no files found matching '%s' " +
(pattern, dir)) "under directory '%s'") %
else: (pattern, dir))
self.files.extend (files) else:
self.files.extend (files)
elif action == 'recursive-exclude': elif action == 'recursive-exclude':
print "recursive-exclude", dir, pattern print "recursive-exclude", dir, string.join(pattern_list)
num = exclude_pattern (self.files, pattern, prefix=dir) for pattern in pattern_list:
if num == 0: num = exclude_pattern (self.files, pattern, prefix=dir)
template.warn \ if num == 0:
(("no previously-included files matching '%s' " + template.warn \
"found under directory '%s'") % (("no previously-included files matching '%s' " +
(pattern, dir)) "found under directory '%s'") %
(pattern, dir))
elif action == 'graft': elif action == 'graft':
print "graft", dir_pattern print "graft", dir_pattern