[elbe-devel] [PATCH v3 07/52] soapclient: use splitext to split the extension instead of fixed length

dion at linutronix.de dion at linutronix.de
Thu Jun 27 14:44:21 CEST 2019


From: Torben Hohn <torben.hohn at linutronix.de>

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>
Reviewed-by: Kurt Kanzenbach <kurt 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 6ae1bd21..2a857f94 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