From 724b1a76dd9a9c92d549038f32b388a863cf71aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Tue, 8 Oct 2019 08:44:47 +0200 Subject: [PATCH] Fixed issue with malformed packages (close #25) --- CB/Core.py | 4 +++- CB/CurseForge.py | 4 ++-- CB/GitLab.py | 3 ++- CB/Tukui.py | 4 ++-- CB/WoWInterface.py | 4 ++-- CB/__init__.py | 2 +- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/CB/Core.py b/CB/Core.py index 1fc5773..5d6290f 100644 --- a/CB/Core.py +++ b/CB/Core.py @@ -78,6 +78,8 @@ def update_config(self): if addon['Name'] == 'TukUI': addon['Name'] = 'Tukui' addon['URL'] = 'Tukui' + # 2.7.3 + addon['Directories'] = list(filter(None, set(addon['Directories']))) # 1.3.0 if 'URLCache' in self.config.keys(): self.config.pop('URLCache', None) @@ -112,7 +114,7 @@ def check_if_dev(self, url): return False def cleanup(self, directories): - if len(directories) > 0 and directories != ['']: + if len(directories) > 0: for directory in directories: shutil.rmtree(self.path / directory, ignore_errors=True) diff --git a/CB/CurseForge.py b/CB/CurseForge.py index 68af9ea..35e7dc5 100644 --- a/CB/CurseForge.py +++ b/CB/CurseForge.py @@ -45,8 +45,8 @@ def get_addon(self): for file in self.archive.namelist(): if '/' not in os.path.dirname(file): self.directories.append(os.path.dirname(file)) - self.directories = list(set(self.directories)) - if len(self.directories) == 0 or self.directories == ['']: + self.directories = list(filter(None, set(self.directories))) + if len(self.directories) == 0: raise RuntimeError(f'{self.name}.\nProject package is corrupted or incorrectly packaged.') def install(self, path): diff --git a/CB/GitLab.py b/CB/GitLab.py index d2b69b5..561fce2 100644 --- a/CB/GitLab.py +++ b/CB/GitLab.py @@ -27,7 +27,8 @@ def get_addon(self): file_info = self.archive.getinfo(file) if file_info.is_dir() and file_info.filename.count('/') == 2 and '.gitlab' not in file_info.filename: self.directories.append(file_info.filename.split('/')[1]) - if len(self.directories) == 0 or self.directories == ['']: + self.directories = list(filter(None, set(self.directories))) + if len(self.directories) == 0: raise RuntimeError(f'{self.name}.\nProject package is corrupted or incorrectly packaged.') def install(self, path): diff --git a/CB/Tukui.py b/CB/Tukui.py index 63354de..8441c53 100644 --- a/CB/Tukui.py +++ b/CB/Tukui.py @@ -26,8 +26,8 @@ def get_addon(self): for file in self.archive.namelist(): if '/' not in os.path.dirname(file): self.directories.append(os.path.dirname(file)) - self.directories = list(set(self.directories)) - if len(self.directories) == 0 or self.directories == ['']: + self.directories = list(filter(None, set(self.directories))) + if len(self.directories) == 0: raise RuntimeError(f'{self.name}.\nProject package is corrupted or incorrectly packaged.') def install(self, path): diff --git a/CB/WoWInterface.py b/CB/WoWInterface.py index a51080e..f30aeed 100644 --- a/CB/WoWInterface.py +++ b/CB/WoWInterface.py @@ -29,8 +29,8 @@ def get_addon(self): for file in self.archive.namelist(): if '/' not in os.path.dirname(file): self.directories.append(os.path.dirname(file)) - self.directories = list(set(self.directories)) - if len(self.directories) == 0 or self.directories == ['']: + self.directories = list(filter(None, set(self.directories))) + if len(self.directories) == 0: raise RuntimeError(f'{self.name}.\nProject package is corrupted or incorrectly packaged.') def install(self, path): diff --git a/CB/__init__.py b/CB/__init__.py index b0aba3a..2e4a2af 100644 --- a/CB/__init__.py +++ b/CB/__init__.py @@ -1,7 +1,7 @@ import string import random -__version__ = '2.7.2' +__version__ = '2.7.3' __license__ = 'GPLv3' __copyright__ = '2019, Paweł Jastrzębski ' __docformat__ = 'restructuredtext en'