本文整理汇总了Python中slpkg.utils.Utils类的典型用法代码示例。如果您正苦于以下问题:Python Utils类的具体用法?Python Utils怎么用?Python Utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Utils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: view
def view(self):
"""View slpkg config file
"""
print("") # new line at start
conf_args = [
"RELEASE",
"BUILD_PATH",
"PACKAGES",
"PATCHES",
"CHECKMD5",
"DEL_ALL",
"DEL_BUILD",
"SBO_BUILD_LOG",
"MAKEFLAGS",
"DEFAULT_ANSWER",
"REMOVE_DEPS_ANSWER",
"SKIP_UNST",
"RSL_DEPS",
"DEL_DEPS",
"USE_COLORS",
"DOWNDER",
"DOWNDER_OPTIONS",
"SLACKPKG_LOG",
"ONLY_INSTALLED",
"PRG_BAR",
"EDITOR"
]
read_conf = Utils().read_file(self.config_file)
for line in read_conf.splitlines():
if not line.startswith("#") and line.split("=")[0] in conf_args:
print("{0}".format(line))
else:
print("{0}{1}{2}".format(self.meta.color["CYAN"], line,
self.meta.color["ENDC"]))
print("") # new line at end
示例2: find
def find(self):
"""Find installed Slackware packages
"""
matching = size = 0
print("\nPackages with matching name [ {0}{1}{2} ]\n".format(
self.meta.color["CYAN"], ", ".join(self.binary),
self.meta.color["ENDC"]))
for pkg in self.binary:
for match in find_package("", self.meta.pkg_path):
if pkg in match:
matching += 1
print("[ {0}installed{1} ] - {2}".format(
self.meta.color["GREEN"], self.meta.color["ENDC"],
match))
data = Utils().read_file(self.meta.pkg_path + match)
for line in data.splitlines():
if line.startswith("UNCOMPRESSED PACKAGE SIZE:"):
if "M" in line[26:]:
size += float(line[26:-1]) * 1024
else:
size += float(line[26:-1])
break
if matching == 0:
message = "Can't find"
Msg().pkg_not_found("", ", ".join(self.binary), message, "\n")
else:
print("\n{0}Total found {1} matching packages.{2}".format(
self.meta.color["GREY"], matching, self.meta.color["ENDC"]))
unit = "Kb"
if size > 1024:
unit = "Mb"
size = (size / 1024)
print("{0}Size of installed packages {1} {2}.{3}\n".format(
self.meta.color["GREY"], round(size, 2), unit,
self.meta.color["ENDC"]))
示例3: _check_if_used
def _check_if_used(self, removes):
"""Check package if dependencies for another package
before removed"""
if self.extra == "--check-deps":
print("")
view = False
package, dependency = [], []
for pkg in find_package("", self.dep_path):
deps = Utils().read_file(self.dep_path + pkg)
for rmv in removes:
if rmv in deps.split():
view = True
package.append(pkg)
dependency.append(rmv)
if view:
Msg().template(78)
print("| {0}{1}{2}".format(
self.meta.color["RED"], " " * 30 + "!!! WARNING !!!",
self.meta.color["ENDC"]))
Msg().template(78)
for p, d in zip(package, dependency):
print("| {0}{1}{2} is dependency of the package --> "
"{3}{4}{5}".format(self.meta.color["YELLOW"], d,
self.meta.color["ENDC"],
self.meta.color["GREEN"], p,
self.meta.color["ENDC"]))
Msg().template(78)
self._skip_remove()
示例4: get_deps
def get_deps(self):
"""Grap package requirements from repositories
"""
if self.repo == "rlw":
# Robby"s repository dependencies as shown in the central page
# http://rlworkman.net/pkgs/
dependencies = {
"abiword": "wv",
"claws-mail": "libetpan",
"inkscape": "gtkmm atkmm pangomm cairomm mm-common libsigc++ "
"libwpg lxml gsl numpy BeautifulSoup",
"texlive": "libsigsegv texi2html",
"xfburn": "libburn libisofs"
}
if self.name in dependencies.keys():
return dependencies[self.name].split()
else:
return ""
else:
PACKAGES_TXT = Utils().read_file("{0}{1}_repo/PACKAGES.TXT".format(
_meta_.lib_path, self.repo))
for line in PACKAGES_TXT.splitlines():
if line.startswith("PACKAGE NAME:"):
pkg_name = split_package(line[14:].strip())[0]
if line.startswith("PACKAGE REQUIRED:"):
if pkg_name == self.name:
if line[18:].strip():
return self._req_fix(line)
示例5: __init__
def __init__(self):
self.meta = _meta_
self.DEFAULT_REPOS_NAMES = self.meta.default_repositories
self.custom_repo_file = "/etc/slpkg/custom-repositories"
self.default_repo_file = "/etc/slpkg/default-repositories"
self.custom_repositories_list = Utils().read_file(self.custom_repo_file)
self.default_repositories_list = Utils().read_file(
self.default_repo_file)
self.default_repository()
示例6: case_insensitive
def case_insensitive(self):
"""Matching packages distinguish between uppercase and
lowercase
"""
if "--case-ins" in self.flag:
data_dict = Utils().case_sensitive(self.data)
for key, value in data_dict.iteritems():
if key == self.name.lower():
self.name = value
示例7: sbo_case_insensitive
def sbo_case_insensitive(self):
"""Matching packages distinguish between uppercase and
lowercase for sbo repository
"""
if "--case-ins" in self.flag:
data = SBoGrep(name="").names()
data_dict = Utils().case_sensitive(data)
for key, value in data_dict.iteritems():
if key == self.name.lower():
self.name = value
示例8: case_insensitive
def case_insensitive(self):
"""Matching packages distinguish between uppercase and
lowercase
"""
if "--case-ins" in self.flag:
data_dict = Utils().case_sensitive(self.data)
for name in self.slackbuilds:
for key, value in data_dict.iteritems():
if key == name.lower():
index = self.slackbuilds.index(name)
self.slackbuilds[index] = value
示例9: _sizes
def _sizes(self, package):
"""Package size summary
"""
data = Utils().read_file(self.meta.pkg_path + package)
for line in data.splitlines():
if line.startswith("UNCOMPRESSED PACKAGE SIZE:"):
if "M" in line[26:]:
self.size += float(line[26:-1]) * 1024
else:
self.size += float(line[26:-1])
break
示例10: check_used
def check_used(self, pkg):
"""Check if dependencies used
"""
used = []
dep_path = self.meta.log_path + "dep/"
logs = find_package("", dep_path)
for log in logs:
deps = Utils().read_file(dep_path + log)
for dep in deps.splitlines():
if pkg == dep:
used.append(log)
return used
示例11: view
def view(self, repo):
"""
View repository information
"""
status = "{0}disabled{1}".format(self.meta.color["RED"],
self.meta.color["ENDC"])
self.form["Status:"] = status
self.form["Default:"] = "no"
if repo in self.meta.default_repositories:
self.form["Default:"] = "yes"
if (repo in self.meta.repositories and
os.path.isfile(self.meta.lib_path + "{0}_repo/PACKAGES."
"TXT".format(repo))):
status = "{0}enabled{1}".format(self.meta.color["GREEN"],
self.meta.color["ENDC"])
if repo != "sbo":
data = self.repository_data(repo)
size = units(data[1], data[2])
self.form["Repo id:"] = repo
self.form["Repo url:"] = self.all_repos[repo]
self.form["Total compressed packages:"] = "{0} {1}".format(
str(size[1][0]), str(size[0][0]))
self.form["Total uncompressed packages:"] = "{0} {1}".format(
str(size[1][1]), str(size[0][1]))
self.form["Number of packages:"] = data[0]
self.form["Status:"] = status
self.form["Last updated:"] = data[3]
elif (repo == "sbo" and os.path.isfile(self.meta.lib_path + "{0}_repo/"
"SLACKBUILDS.TXT".format(repo))):
status = "{0}enabled{1}".format(self.meta.color["GREEN"],
self.meta.color["ENDC"])
sum_sbo_pkgs = 0
for line in (Utils().read_file(
self.meta.lib_path + "sbo_repo/SLACKBUILDS."
"TXT").splitlines()):
if line.startswith("SLACKBUILD NAME: "):
sum_sbo_pkgs += 1
changelog_txt = Utils().read_file(
self.meta.log_path + "sbo/ChangeLog.txt")
last_upd = changelog_txt.split("\n", 1)[0]
self.form["Repo id:"] = repo
self.form["Repo url:"] = self.all_repos[repo]
self.form["Total compressed packages:"] = ""
self.form["Total uncompressed packages:"] = ""
self.form["Number of packages:"] = sum_sbo_pkgs
self.form["Status:"] = status
self.form["Last updated:"] = last_upd
print("")
for key, value in sorted(self.form.iteritems()):
print self.meta.color["GREY"] + key + self.meta.color["ENDC"], value
print("")
raise SystemExit()
示例12: _view_deps
def _view_deps(self, path, package):
"""View dependencies for before remove
"""
dependencies = Utils().read_file(path + package)
print("") # new line at start
Msg().template(78)
print("| Found dependencies for package {0}:".format(package))
Msg().template(78)
for dep in dependencies.splitlines():
print("| {0}{1}{2}".format(self.meta.color["RED"], dep,
self.meta.color["ENDC"]))
Msg().template(78)
return dependencies
示例13: case_insensitive
def case_insensitive(self):
"""Matching packages distinguish between uppercase and
lowercase
"""
if "--case-ins" in self.flag:
data = []
data = Utils().package_name(self.PACKAGES_TXT)
data_dict = Utils().case_sensitive(data)
for pkg in self.packages:
index = self.packages.index(pkg)
for key, value in data_dict.iteritems():
if key == pkg.lower():
self.packages[index] = value
示例14: _sizes
def _sizes(self, package):
"""Package size summary
"""
data = Utils().read_file(self.meta.pkg_path + package)
for line in data.splitlines():
if line.startswith("UNCOMPRESSED PACKAGE SIZE:"):
digit = float((''.join(re.findall(
"[-+]?\d+[\.]?\d*[eE]?[-+]?\d*", line[26:]))))
self.file_size = line[26:].strip()
if "M" in line[26:]:
self.size += digit * 1024
else:
self.size += digit
break
示例15: case_insensitive
def case_insensitive(self):
"""Matching packages distinguish between uppercase and
lowercase
"""
if "--case-ins" in self.flag:
data = []
for name in self.data[0]:
data.append(split_package(name)[0])
data_dict = Utils().case_sensitive(data)
for pkg in self.packages:
for key, value in data_dict.iteritems():
if key == pkg.lower():
index = self.packages.index(pkg)
self.packages[index] = value