Added case insensitive option

This commit is contained in:
Dimitris Zlatanidis 2015-09-24 07:10:13 +03:00
parent 460c8c2e1f
commit 3d81797818
6 changed files with 51 additions and 14 deletions

View file

@ -1,6 +1,7 @@
2.9.3 - 23/09/2015
Added:
- Default repositories file to allow editing urls
- Additional option "--case-ins" case insensitive in "--tracking" option
Fixed:
- Matching packages with case insensitive option

View file

@ -445,8 +445,8 @@ Command Line Tool Usage
--resolve-off, --case-ins directly from remote repositories
with all dependencies.
-t, --tracking, [repository] [package], Tracking package dependencies and
--check-deps, --graph=[type] print package dependencies tree with
highlight if packages is installed.
--check-deps, --graph=[type], print package dependencies tree with
--case-ins highlight if packages is installed.
Also check if dependencies used or
drawing dependencies diagram.
-p, --desc, [repository] [package], Print description of a package

View file

@ -39,7 +39,8 @@ Usage: slpkg Commands:
[-c [repository], --upgrade, --skip=[...], --resolve-off,
--checklist]
[-s [repository] [package...], --resolve-off, --case-ins]
[-t [repository] [package], --check-deps, --graph=[type]]
[-t [repository] [package], --check-deps, --graph=[type],
--case-ins]
[-p [repository] [package], --color=[]]
[-n [SBo package], --checklist, --case-ins]
[-F [package...], --case-ins]
@ -221,7 +222,7 @@ Additional options:
\fB--case-ins\fP : Search package name in repository with case insensitive.
.SS -t, --tracking, tracking dependencies
\fBslpkg\fP \fB-t\fP <\fIrepository\fP> <\fIname of package\fP>, \fB--check-deps\fP, \fB--graph=[type]\fP
\fBslpkg\fP \fB-t\fP <\fIrepository\fP> <\fIname of package\fP>, \fB--check-deps\fP, \fB--graph=[type]\fP \fB--case-ins\fP
.PP
Tracking all dependencies of that package.
The sequence shown is that you must follow to correctly install package.
@ -232,6 +233,8 @@ Additional options:
\fB--check-deps\fP : Check if installed packages used by other packages.
.PP
\fB--graph=[type]\fP : Drawing dependencies graph. (example for type: ascii, image.x11, image.png etc. Require pygraphviz)
.PP
\fB--case-ins\fP : Search package name in repository with case insensitive.
.SS -p, --desk, print packages description
\fBslpkg\fP \fB-p\fP <\fIrepository\fP> <\fIname of package\fP>, \fB--color=[]\fP

View file

@ -95,8 +95,8 @@ Optional arguments:
--resolve-off, --case-ins directly from remote repositories
with all dependencies.
-t, --tracking, [repository] [package], Tracking package dependencies and
--check-deps, --graph=[type] print package dependencies tree with
highlight if packages is installed.
--check-deps, --graph=[type], print package dependencies tree with
--case-ins highlight if packages is installed.
Also check if dependencies used or
drawing dependencies diagram.
-p, --desc, [repository] [package], Print description of a package
@ -160,7 +160,8 @@ def usage(repo):
[-c [repository], --upgrade, --skip=[...], --resolve-off,
--checklist]
[-s [repository] [package...], --resolve-off, --case-ins]
[-t [repository] [package], --check-deps, --graph=[type]]
[-t [repository] [package], --check-deps, --graph=[type],
--case-ins]
[-p [repository] [package], --color=[]]
[-n [SBo package], --checklist, --case-ins]
[-F [package...], --case-ins]

View file

@ -355,7 +355,8 @@ class ArgParse(object):
]
additional_options = [
"--check-deps",
"--graph="
"--graph=",
"--case-ins"
]
if (len(self.args) >= 3 and len(self.args) < 6 and
self.args[0] in options):
@ -363,8 +364,12 @@ class ArgParse(object):
for arg in self.args[3:]:
if arg.startswith(additional_options[1]):
flag.append(arg)
arg = ""
if arg in additional_options:
flag.append(arg)
if arg and arg not in additional_options:
usage("")
raise SystemExit()
TrackingDeps(self.args[2], self.args[1], flag).run()
else:
usage(self.args[1])

View file

@ -30,6 +30,7 @@ from slpkg.__metadata__ import MetaData as _meta_
from slpkg.pkg.find import find_package
from slpkg.sbo.greps import SBoGrep
from slpkg.sbo.dependency import Requires
from slpkg.sbo.search import sbo_search_pkg
@ -125,16 +126,42 @@ class TrackingDeps(object):
"""Get dependencies by repositories
"""
if self.repo == "sbo":
self.dependencies_list = Requires(self.flag).sbo(self.name)
self.sbo_case_insensitive()
self.find_pkg = sbo_search_pkg(self.name)
if self.find_pkg:
self.dependencies_list = Requires(self.flag).sbo(self.name)
else:
PACKAGES_TXT = Utils().read_file(self.meta.lib_path + "{0}_repo/"
"PACKAGES.TXT".format(self.repo))
PACKAGES_TXT = Utils().read_file(
self.meta.lib_path + "{0}_repo/PACKAGES.TXT".format(self.repo))
self.names = Utils().package_name(PACKAGES_TXT)
self.bin_case_insensitive()
self.find_pkg = search_pkg(self.name, self.repo)
if self.find_pkg:
self.black = BlackList().packages(self.names, self.repo)
self.dependencies_list = Dependencies(
self.names, self.repo, self.black).binary(self.name, self.flag)
self.find_pkg = search_pkg(self.name, self.repo)
self.names, self.repo, self.black).binary(self.name,
self.flag)
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
def bin_case_insensitive(self):
"""Matching packages distinguish between uppercase and
lowercase
"""
if "--case-ins" in self.flag:
data_dict = Utils().case_sensitive(self.names)
for key, value in data_dict.iteritems():
if key == self.name.lower():
self.name = value
def graph(self):
"""Drawing image dependencies map