@@ -1897,13 +1897,12 @@ def list(self, verbose=True, *, members=None):
18971897 _safe_print ("link to " + tarinfo .linkname )
18981898 print ()
18991899
1900- def add (self , name , arcname = None , recursive = True , exclude = None , * , filter = None ):
1900+ def add (self , name , arcname = None , recursive = True , * , filter = None ):
19011901 """Add the file `name' to the archive. `name' may be any type of file
19021902 (directory, fifo, symbolic link, etc.). If given, `arcname'
19031903 specifies an alternative name for the file in the archive.
19041904 Directories are added recursively by default. This can be avoided by
1905- setting `recursive' to False. `exclude' is a function that should
1906- return True for each filename to be excluded. `filter' is a function
1905+ setting `recursive' to False. `filter' is a function
19071906 that expects a TarInfo object argument and returns the changed
19081907 TarInfo object, if it returns None the TarInfo object will be
19091908 excluded from the archive.
@@ -1913,15 +1912,6 @@ def add(self, name, arcname=None, recursive=True, exclude=None, *, filter=None):
19131912 if arcname is None :
19141913 arcname = name
19151914
1916- # Exclude pathnames.
1917- if exclude is not None :
1918- import warnings
1919- warnings .warn ("use the filter argument instead" ,
1920- DeprecationWarning , 2 )
1921- if exclude (name ):
1922- self ._dbg (2 , "tarfile: Excluded %r" % name )
1923- return
1924-
19251915 # Skip if somebody tries to archive the archive...
19261916 if self .name is not None and os .path .abspath (name ) == self .name :
19271917 self ._dbg (2 , "tarfile: Skipped %r" % name )
@@ -1953,7 +1943,7 @@ def add(self, name, arcname=None, recursive=True, exclude=None, *, filter=None):
19531943 if recursive :
19541944 for f in os .listdir (name ):
19551945 self .add (os .path .join (name , f ), os .path .join (arcname , f ),
1956- recursive , exclude , filter = filter )
1946+ recursive , filter = filter )
19571947
19581948 else :
19591949 self .addfile (tarinfo )
0 commit comments