iupload: Raise exceptions instead of just returning None when errors occurs - transferwee - Download/upload file via wetransfer.com Err tccr.it 70 hgit clone https://github.com/iamleot/transferwee URL:https://github.com/iamleot/transferwee tccr.it 70 1Log /r/transferwee/log.gph tccr.it 70 1Files /r/transferwee/files.gph tccr.it 70 1Refs /r/transferwee/refs.gph tccr.it 70 1README /r/transferwee/file/README.md.gph tccr.it 70 i--- Err tccr.it 70 1commit 5d921f6b936a0ce688ee9301c0a567fbea8bc7c8 /r/transferwee/commit/5d921f6b936a0ce688ee9301c0a567fbea8bc7c8.gph tccr.it 70 1parent 234eec526ff552e0a7365b5c4330fee00d01846a /r/transferwee/commit/234eec526ff552e0a7365b5c4330fee00d01846a.gph tccr.it 70 hAuthor: Leonardo Taccari URL:mailto:iamleot@gmail.com tccr.it 70 iDate: Sun, 2 Jun 2019 15:03:10 +0200 Err tccr.it 70 i Err tccr.it 70 iupload: Raise exceptions instead of just returning None when errors occurs Err tccr.it 70 i Err tccr.it 70 iPreviously when trying to upload non-existing filenames or duplicate Err tccr.it 70 ifilenames None was returned and printed and transferwee exited with Err tccr.it 70 istatus 0 without providing useful information. Respectively raise Err tccr.it 70 iFileNotFoundError() and FileExistsError() exceptions when that happens. Err tccr.it 70 i Err tccr.it 70 iShould fix issue #5. Err tccr.it 70 i Err tccr.it 70 iDiffstat: Err tccr.it 70 i M transferwee.py | 4 ++-- Err tccr.it 70 i Err tccr.it 70 i1 file changed, 2 insertions(+), 2 deletions(-) Err tccr.it 70 i--- Err tccr.it 70 1diff --git a/transferwee.py b/transferwee.py /r/transferwee/file/transferwee.py.gph tccr.it 70 i@@ -260,13 +260,13 @@ def upload(files: List[str], message: str = '', sender: str = None, Err tccr.it 70 i # Check that all files exists Err tccr.it 70 i for f in files: Err tccr.it 70 i if not os.path.exists(f): Err tccr.it 70 i- return None Err tccr.it 70 i+ raise FileNotFoundError(f) Err tccr.it 70 i Err tccr.it 70 i # Check that there are no duplicates filenames Err tccr.it 70 i # (despite possible different dirname()) Err tccr.it 70 i filenames = [os.path.basename(f) for f in files] Err tccr.it 70 i if len(files) != len(set(filenames)): Err tccr.it 70 i- return None Err tccr.it 70 i+ raise FileExistsError('Duplicate filenames') Err tccr.it 70 i Err tccr.it 70 i transfer_id = None Err tccr.it 70 i if sender and recipients: Err tccr.it 70 .