Switch to glob module

This commit is contained in:
Dimitris Zlatanidis 2023-01-09 19:11:03 +02:00
parent 92730ac2cc
commit d3465166a8

View file

@ -1,7 +1,7 @@
#!/usr/bin/python3 #!/usr/bin/python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os import glob
import time import time
import shutil import shutil
import tarfile import tarfile
@ -24,10 +24,16 @@ class Utilities:
def is_installed(self, name: str) -> str: def is_installed(self, name: str) -> str:
""" Returns the installed package name. """ """ 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] 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 package
return '' return ''
@staticmethod @staticmethod