Skip to content
Permalink
Browse files

add parameter filename to the function filtering out files when uploa…

…ding files through FTP
  • Loading branch information...
sdpython committed Oct 13, 2015
1 parent 313b832 commit 30f980672551e1f9fd623bd240f20d9b9d1ff15e
@@ -47,7 +47,7 @@ def test_folder_transfer(self):
fLOG=fLOG)
fftp = FolderTransferFTP(ftn, ftp, status,
footer_html="<b>footer</b>",
content_filter=lambda c: c)
content_filter=lambda c, f: c)

li = list(fftp.iter_eligible_files())
assert len(li) > 0
@@ -156,9 +156,13 @@ def __init__(self,
If *filter_out* is a function, the signature is::
def filter_out(full_file_name):
def filter_out(full_file_name, filename):
# ...
return True # if the file is filtered out, False otherwise
.. versionchanged:: 1.3
Function *filter_out* receives another parameter (filename)
to give more information when raising an exception.
"""
self._ftn = file_tree_node
self._ftp = ftp_transfer
@@ -260,7 +264,7 @@ def preprocess_before_transfering(self, path, force_binary=False):

# filter
try:
content = self._content_filter(content)
content = self._content_filter(content, path)
except Exception as e:
raise FolderTransferFTPException(
"File {0} cannot be transferred (exception)".format(path)) from e

0 comments on commit 30f9806

Please sign in to comment.
You can’t perform that action at this time.