pyppd creates double entries for many (all ?) standard PPDs #1

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants

OdyX commented Sep 4, 2013

Hi Vitor,

my use-case is the building of foomatic-db-compressed-ppds on Debian (similarly on Ubuntu). The end-result is the following:

$ /usr/lib/cups/driver/foomatic-db-compressed-ppds list | grep B6300-Postscript
"foomatic-db-compressed-ppds:0/ppd/foomatic-ppd/Oki-B6300-Postscript.ppd" en "Oki" "Oki B6300 Foomatic/Postscript (recommended)" "DRV:DPostscript,R1,M0,TP;"
"foomatic-db-compressed-ppds:1/ppd/foomatic-ppd/Oki-B6300-Postscript.ppd" en "Oki" "Oki B6300 Foomatic/Postscript (recommended)" "MFG:Oki;MDL:B6300;"

As you can see, this PPD file has two entries in the pyppd-compiled list. one DRV and one MFG/MDL pair.

This has the annoying side-effect to show these doubled entries in many (if not all) CUPS interfaces: localhost:631, system-config-printer-kde, etc.

What do you think, should these doubled entries for "single-printer, single-driver" be merged, and if so, how?

Cheers, OdyX

Owner

vitorbaptista commented Jun 30, 2013

@OdyX, sorry, I just saw your issue now. Do you still have this problem?

OdyX commented Jul 1, 2013

@vitorbaptista : Yes, that's still happening, and a fix would be worthwhile.

Owner

vitorbaptista commented Jul 1, 2013

@OdyX Cool, I'll just double check with Till Kamppeter, which mentored me in this, to be sure this isn't the expected behavior (I remember we talking about it a long time ago). I'll keep you updated.

Owner

vitorbaptista commented Jul 1, 2013

@OdyX You're right. I'll take a look at this in the next couple weeks. If you want to have a try in the mean time, please feel free. The bug should be around https://github.com/vitorbaptista/pyppd/blob/master/pyppd/ppd.py#L103-L107

Also, just for recording in this issue, this was Till's answer:

Yes, the duplicate results for one and the same PPD are really a bug,
but note that there are also cases where there really need to be more
than one result. This is if a PPD has more than one "Product" line,
meaning that it is for more than one printer model. Than each "Product"
line must generate one result for this PPD. If there is only one
"Product" line there should be only one result for this PPD.

AFAIR the bug is that there is one result line based on the "Product"
line and another based on the "NickName" (or "ModelName"?). The
"NickName"/"ModelName" should only be used if there is no "Product" line
at all, otherwise one result for each "Product" line. The "Product" line
(without parantheses) should be the MDL of the corresponding device ID,
the MFG should come from the "Manufacturer" line in the PPD.
Contributor

tillkamppeter commented Sep 2, 2013

I have a solution for the problem. my patch to pyppd/ppd.py introduces the following changes:

  • if a device ID has no MDL/MODEL field, it is not taken into account as an extra model
  • If in a device ID a DRV: field is found (Foomatic info) this is added to the device IDs of all model entries
  • Model names get normalized before comparing: all lowercase, leading and trailing white space stripped, manufacturer name in the beginning removed, then only really different models get an extra entry.
  • If a PPD contains one or more "_1284DeviceID:" lines and only one "_Product:" line, the model name of the "*Product:" line is ignored.

This removes tons of bogus lines, especially in foomatic-db-compressed-ppds, openprinting-ppds, and postscript-hp.

I send the patch to you by e-mail as this system does not allow attachments and so has no patch input channel.

Improved the checking of "*1284DeviceID:" and "*Product:" lines in th…
…e PPD files whether they are really for different models

- if a device ID has no MDL/MODEL field, it is not taken into account as an
  extra model
- If in a device ID a DRV: field is found (Foomatic info) this is added to the
  device IDs of all model entries.
- Model names get normalized before comparing: all lowercase, leading and
  trailing white space stripped, manufacturer name in the beginning removed,
  then only really different models get an extra entry.
- If a PPD contains one or more "*1284DeviceID:" lines and only one "*Product:"
  line, the model name of the "*Product:" line is ignored.

This removes tons of bogus lines, especially in the PPD from Foomatic (both
generated from XML and ready-made PPDs from printer manufacturers) and HPLIP.

OdyX commented Sep 4, 2013

Hi guys,

Without double-checking Till's code, I have attached his commit as pull-request to this issue to ease Vitor's integration job. :-)

Cheers,

OdyX

Owner

vitorbaptista commented Sep 5, 2013

Hi all,

I've just merged @tillkamppeter's commit and released version 1.0.1. @OdyX Could you please check that everything works as you expected? Reopen the issue if you find any problems :)

Thanks again for the patch, @tillkamppeter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment