From f90780102f39aa7ad522ba4ece10be8f9767489f Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sun, 29 May 2022 20:18:59 +0300 Subject: [PATCH] Switched with sqlite --- slpkg/sbo/search.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/slpkg/sbo/search.py b/slpkg/sbo/search.py index a39b918d..f9c8f53a 100644 --- a/slpkg/sbo/search.py +++ b/slpkg/sbo/search.py @@ -22,7 +22,7 @@ # along with this program. If not, see . -from slpkg.utils import Utils +import sqlite3 from slpkg.repositories import Repo from slpkg.__metadata__ import MetaData as _meta_ @@ -33,16 +33,17 @@ def sbo_search_pkg(name): """Search for package path in SLACKBUILDS.TXT file and return url """ - url = "" - utils = Utils() + db = _meta_.db + lib_path = _meta_.lib_path + con = sqlite3.connect(f"{lib_path}{db}") + cur = con.cursor() + + loc = cur.execute("""SELECT location + FROM sbo + WHERE name = '{}'""".format(name)).fetchone() + repo = Repo() sbo = repo.default_repository()["sbo"] sbo_url = f"{sbo}{slack_ver()}/" - SLACKBUILDS_TXT = utils.read_file( - f"{_meta_.lib_path}sbo_repo/SLACKBUILDS.TXT") - for line in SLACKBUILDS_TXT.splitlines(): - if line.startswith("SLACKBUILD LOCATION"): - sbo_name = (line[23:].split("/")[-1].replace("\n", "")).strip() - if name == sbo_name: - url = f"{sbo_url}{line[23:].strip()}/" - return url + + return f"{sbo_url}{loc[0][2:]}/"