From 64776a87147e6f1aff3a91773cc16d0332c3cf6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Sun, 19 Apr 2020 09:17:10 +0200 Subject: [PATCH] check zipextensions as one string or list --- workdirfs.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/workdirfs.py b/workdirfs.py index 476baed..55f7b23 100755 --- a/workdirfs.py +++ b/workdirfs.py @@ -152,11 +152,20 @@ class WorkdirFS(Operations): return path + def _check_fileext(self, filename, zipext): + if type(zipext) is str: + return zipext in filename + elif type(zipext) is list: + for e in arr: + if (lambda x: x in filename)(e): + return True + return False def _cleanup_dirs(self): print("Cleanup dir", self.yesterdaypath) - zip_fileext=".gz" + #zip_fileext=".gz" + zip_fileext=[".gz","tgz",".gz.tar"] zip_compressionlevel=5 #for root, dirs, files in os.walk(self.yesterdaypath, topdown=False): print("Archivepath",self.archivpathbase) @@ -170,7 +179,8 @@ class WorkdirFS(Operations): if self.args.compress: for f in files: print("compress", os.path.join(root, f)) - if zip_fileext not in f: + #if zip_fileext not in f: + if not _check_fileext(f,zip_fileext): try: with open(os.path.join(root, f), 'rb') as f_in: with gzip.open(