remove the old search algorithm

This commit is contained in:
Zdenek Dohnal 2021-02-18 09:07:06 +01:00
parent b2f875a767
commit bfad24d925
2 changed files with 43 additions and 11 deletions

View File

@ -1,8 +1,8 @@
diff --git a/prnt/cups.py b/prnt/cups.py diff --git a/prnt/cups.py b/prnt/cups.py
index a9f410a..733891b 100644 index a9f410a..3783a60 100644
--- a/prnt/cups.py --- a/prnt/cups.py
+++ b/prnt/cups.py +++ b/prnt/cups.py
@@ -489,49 +489,72 @@ def getPPDFile2(mq,model, ppds): # New PPD find @@ -489,78 +489,77 @@ def getPPDFile2(mq,model, ppds): # New PPD find
#Check if common ppd name is already given in models.dat(This is needed because in case of devices having more than one derivatives #Check if common ppd name is already given in models.dat(This is needed because in case of devices having more than one derivatives
#will have diffrent model name strings in device ID, because of which we don't get the common ppd name for search) #will have diffrent model name strings in device ID, because of which we don't get the common ppd name for search)
family_check=isfamilydrv(ppds) family_check=isfamilydrv(ppds)
@ -55,6 +55,8 @@ index a9f410a..733891b 100644
- ((prop.hpijs_build and 'hpijs' in pdls) or (prop.hpcups_build and 'hpijs' not in pdls)) or \ - ((prop.hpijs_build and 'hpijs' in pdls) or (prop.hpcups_build and 'hpijs' not in pdls)) or \
- ('ps' in pdls) or ('pdf' in pdls): - ('ps' in pdls) or ('pdf' in pdls):
- matches.append((f, [p for p in pdls if p and p != 'hpijs'])) - matches.append((f, [p for p in pdls if p and p != 'hpijs']))
- log.debug(matches)
- num_matches = len(matches)
+ for f in ppds: + for f in ppds:
+ # ignore foomatic and gutenprint drivers + # ignore foomatic and gutenprint drivers
+ if 'foomatic' in f or 'gutenprint' in f: + if 'foomatic' in f or 'gutenprint' in f:
@ -89,7 +91,22 @@ index a9f410a..733891b 100644
+ if pdl in ['hpijs', 'hpcups']: + if pdl in ['hpijs', 'hpcups']:
+ ppd_model=ppd_model.replace('-{}'.format(pdl), '') + ppd_model=ppd_model.replace('-{}'.format(pdl), '')
+ continue + continue
+
- if num_matches == 0:
- log.debug("No PPD found for model %s using new algorithm. Trying old algorithm..." % stripped_model)
- #Using Old algo, ignores the series keyword in ppd searching.
- matches2 = list(getPPDFile(stripModel(stripped_model), ppds).items())
- log.debug(matches2)
- num_matches2 = len(matches2)
- if num_matches2:
- for f, d in matches2:
- match = ppd_pat.match(f)
- if match is not None:
- log.debug("Found match: %s" % f)
- try:
- pdls = match.group(2).split('-')
- except AttributeError:
- pdls = []
+ if not models.PDL_TYPES.get(pdl): + if not models.PDL_TYPES.get(pdl):
+ log.debug('Unknown PDL named \'{}\' - can be a new PDL or ' + log.debug('Unknown PDL named \'{}\' - can be a new PDL or '
+ 'just a part of device name. Assume it is ' + 'just a part of device name. Assume it is '
@ -102,17 +119,29 @@ index a9f410a..733891b 100644
+ continue + continue
+ +
+ log.debug("Found match: %s" % f) + log.debug("Found match: %s" % f)
+
- if (prop.hpcups_build and 'hpijs' not in f) or \
- ((prop.hpijs_build and 'hpijs' in pdls) or (prop.hpcups_build and 'hpijs' not in pdls)) or \
- ('ps' in pdls) or ('pdf' in pdls):
- matches.append((f, [p for p in pdls if p and p != 'hpijs']))
+ if (prop.hpcups_build and 'hpijs' not in f) or \ + if (prop.hpcups_build and 'hpijs' not in f) or \
+ ((prop.hpijs_build and 'hpijs' in driver_types) or (prop.hpcups_build and 'hpijs' not in driver_types)) or \ + ((prop.hpijs_build and 'hpijs' in driver_types) or (prop.hpcups_build and 'hpijs' not in driver_types)) or \
+ ('ps' in pdls) or ('pdf' in pdls): + ('ps' in pdls) or ('pdf' in pdls):
+ matches.append((f, pdls, [d for d in driver_types if d and d != 'hpijs'])) + matches.append((f, pdls, [d for d in driver_types if d and d != 'hpijs']))
+
+
log.debug(matches)
num_matches = len(matches)
@@ -570,7 +593,7 @@ def getPPDFile2(mq,model, ppds): # New PPD find - log.debug(matches)
- num_matches = len(matches)
+
+ log.debug(matches)
+ num_matches = len(matches)
if num_matches == 0:
- log.error("No PPD found for model %s using old algorithm." % stripModel(stripped_model))
+ log.error("No PPD found for model %s." % stripModel(stripped_model))
return None
elif num_matches == 1:
@@ -570,7 +569,7 @@ def getPPDFile2(mq,model, ppds): # New PPD find
# > 1 # > 1
log.debug("%d matches found. Searching based on PDL: Host > PS,PDF > PCL/Other" % num_matches) log.debug("%d matches found. Searching based on PDL: Host > PS,PDF > PCL/Other" % num_matches)
for p in [models.PDL_TYPE_HOST, models.PDL_TYPE_PS,models.PDL_TYPE_PDF, models.PDL_TYPE_PCL]: for p in [models.PDL_TYPE_HOST, models.PDL_TYPE_PS,models.PDL_TYPE_PDF, models.PDL_TYPE_PCL]:
@ -121,7 +150,7 @@ index a9f410a..733891b 100644
for x in pdl_list: for x in pdl_list:
# default to HOST-based PDLs, as newly supported PDLs will most likely be of this type # default to HOST-based PDLs, as newly supported PDLs will most likely be of this type
if models.PDL_TYPES.get(x, models.PDL_TYPE_HOST) == p: if models.PDL_TYPES.get(x, models.PDL_TYPE_HOST) == p:
@@ -579,8 +602,8 @@ def getPPDFile2(mq,model, ppds): # New PPD find @@ -579,8 +578,8 @@ def getPPDFile2(mq,model, ppds): # New PPD find
log.debug("%d matches found. Searching based on Filters: HPCUPS > HPIJS" % num_matches) log.debug("%d matches found. Searching based on Filters: HPCUPS > HPIJS" % num_matches)
for p in ["hpcups","hpijs"]: for p in ["hpcups","hpijs"]:

View File

@ -7,7 +7,7 @@
Summary: HP Linux Imaging and Printing Project Summary: HP Linux Imaging and Printing Project
Name: hplip Name: hplip
Version: 3.20.11 Version: 3.20.11
Release: 5%{?dist} Release: 6%{?dist}
License: GPLv2+ and MIT and BSD and IJG and Public Domain and GPLv2+ with exceptions and ISC License: GPLv2+ and MIT and BSD and IJG and Public Domain and GPLv2+ with exceptions and ISC
Url: https://developers.hp.com/hp-linux-imaging-and-printing Url: https://developers.hp.com/hp-linux-imaging-and-printing
@ -810,6 +810,9 @@ rm -f %{buildroot}%{_sysconfdir}/xdg/autostart/hplip-systray.desktop
%config(noreplace) %{_sysconfdir}/sane.d/dll.d/hpaio %config(noreplace) %{_sysconfdir}/sane.d/dll.d/hpaio
%changelog %changelog
* Thu Feb 18 2021 Zdenek Dohnal <zdohnal@redhat.com> - 3.20.11-6
- remove the old search algorithm
* Fri Feb 05 2021 Zdenek Dohnal <zdohnal@redhat.com> - 3.20.11-5 * Fri Feb 05 2021 Zdenek Dohnal <zdohnal@redhat.com> - 3.20.11-5
- 1925259 - %pre scriptlet enables and starts cups.service, which is unnecessary - 1925259 - %pre scriptlet enables and starts cups.service, which is unnecessary
- 1919556 - hp-fab crashed: QFileDialog.getOpenFileName is not used correctly - 1919556 - hp-fab crashed: QFileDialog.getOpenFileName is not used correctly