Added module

This commit is contained in:
Dimitris Zlatanidis 2015-06-22 20:54:31 +03:00
parent 03dbad954c
commit 8539a8f15f

93
slpkg/load.py Normal file
View file

@ -0,0 +1,93 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# load.py file is part of slpkg.
# Copyright 2014-2015 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
# All rights reserved.
# Slpkg is a user-friendly package manager for Slackware installations
# https://github.com/dslackw/slpkg
# Slpkg is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
from utils import Utils
from splitting import split_package
from __metadata__ import MetaData as _meta_
from pkg.find import find_package
def library(repo):
"""Load packages from slpkg library and from local
"""
pkg_list, packages = [], ""
if repo == "sbo":
if (os.path.isfile(
_meta_.lib_path + "{0}_repo/SLACKBUILDS.TXT".format(repo))):
packages = Utils().read_file(_meta_.lib_path + "{0}_repo/"
"SLACKBUILDS.TXT".format(repo))
else:
if (os.path.isfile(
_meta_.lib_path + "{0}_repo/PACKAGES.TXT".format(repo))):
packages = Utils().read_file(_meta_.lib_path + "{0}_repo/"
"PACKAGES.TXT".format(repo))
for line in packages.splitlines():
if repo == "sbo":
if line.startswith("SLACKBUILD NAME: "):
pkg_list.append(line[17:].strip())
elif "local" not in repo:
if line.startswith("PACKAGE NAME: "):
pkg_list.append(line[15:].strip())
if repo == "local":
pkg_list = find_package("", _meta_.pkg_path)
return pkg_list
def skiped(pkgs):
"""Grap packages and added in skip
"""
skip, data = [], []
for pkg in pkgs.split(","):
pr = pkg.split(":")
data = library(pr[0])
if len(pr) > 1:
for d in data:
if pr[1].startswith("*") and pr[1].endswith("*"):
if pr[1][1:-1] in d:
if pr[0] == "sbo":
skip.append(d)
else:
skip.append(split_package(d)[0])
elif pr[1].endswith("*"):
if d.startswith(pr[1][:-1]):
if pr[0] == "sbo":
skip.append(d)
else:
skip.append(split_package(d)[0])
elif pr[1].startswith("*"):
if d.endswith(pr[1][1:]):
if pr[0] == "sbo":
skip.append(d)
else:
skip.append(split_package(d)[0])
else:
if pr[0] == "sbo":
skip.append(d)
else:
skip.append(split_package(d)[0])
else:
skip += pkg.split()
return skip