[elbe-devel] [PATCH 3/6] soapclient: use splitext to split the extension instead of fixed length
Torben Hohn
torben.hohn at linutronix.de
Wed May 29 16:34:08 CEST 2019
relying on the fact that an extension is 3 characters long is broken.
Use os.path.splitext() to extract the filetype.
Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
elbepack/soapclient.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/elbepack/soapclient.py b/elbepack/soapclient.py
index 6ae1bd210..2a857f94a 100644
--- a/elbepack/soapclient.py
+++ b/elbepack/soapclient.py
@@ -940,11 +940,12 @@ class UploadPackageAction(RepoAction):
print("--------------------------")
print("Check files...")
+ filetype = os.path.splitext(filename)[1]
+
# Check filetype
- if filename[-3:] not in ['dsc', 'deb']:
+ if filetype not in ['.dsc', '.deb']:
print("Error: Only .dsc and .deb files allowed to upload.")
- else:
- filetype = filename[-4:]
+ sys.exit(20)
files = [filename] # list of all files which will be uploaded
--
2.11.0
More information about the elbe-devel
mailing list