From d3465166a8de3b957decdb41da49dfa64a1b55e4 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 9 Jan 2023 19:11:03 +0200 Subject: [PATCH] Switch to glob module --- slpkg/utilities.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/slpkg/utilities.py b/slpkg/utilities.py index 3401c004..5e5014ca 100644 --- a/slpkg/utilities.py +++ b/slpkg/utilities.py @@ -1,7 +1,7 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -import os +import glob import time import shutil import tarfile @@ -24,10 +24,16 @@ class Utilities: def is_installed(self, name: str) -> str: """ Returns the installed package name. """ - for package in os.listdir(self.configs.log_packages): + pattern = f'{str(self.configs.log_packages)}/*{self.configs.sbo_repo_tag}' + packages = glob.glob(pattern) + + for package in packages: + package = package.split('/')[-1] pkg = self.split_installed_pkg(package)[0] - if pkg == name and self.configs.sbo_repo_tag in package and pkg not in self.black.get(): + + if pkg == name and pkg not in self.black.get(): return package + return '' @staticmethod