Description of problem: When trying to create a queue for an Epson Stylus D78 (which is not in the foomatic database yet), the close-match logic in foomatic.py ends up choosing Epson Stylus Pro 10000 because a) when scanning through the list, it isn't sorted in model order, and b) the 'how many characters match' logic is slightly wrong Version-Release number of selected component (if applicable): system-config-printer-0.7.50-1.fc6 How reproducible: 100% Steps to Reproduce: 1. Run this Python program: #!/usr/bin/python import sys sys.path.append ('/usr/share/system-config-printer') import foomatic f=foomatic.Foomatic() mfg='EPSON' mdl='Stylus D78' cmd=['ESCPL2','BDC','D4','D4PX'] print f.getPrinterFromDeviceID(mfg,mdl,commandsets=cmd) Actual results: Writing new pickle Please report a bug in Bugzilla against 'foomatic': https://bugzilla.redhat.com/bugzilla Include this complete message. Guessing Epson-Stylus_Pro_10000 from IEEE 1284 ID: <manufacturer>EPSON</manufacturer> <model>Stylus D78</model> <description></description> <commandset>ESCPL2,BDC,D4,D4PX</commandset> Epson-Stylus_Pro_10000 Expected results: Writing new pickle Please report a bug in Bugzilla against 'foomatic': https://bugzilla.redhat.com/bugzilla Include this complete message. Guessing Epson-Stylus_D68 from IEEE 1284 ID: <manufacturer>EPSON</manufacturer> <model>Stylus D78</model> <description></description> <commandset>ESCPL2,BDC,D4,D4PX</commandset> Epson-Stylus_D68 Additional info: Fix is: Index: foomatic.py =================================================================== RCS file: /usr/local/CVS/system-config-printer/foomatic.py,v retrieving revision 1.52 diff -d -u -r1.52 foomatic.py --- foomatic.py 8 Jan 2007 15:59:52 -0000 1.52 +++ foomatic.py 13 Feb 2007 12:49:17 -0000 @@ -776,12 +776,17 @@ # Try to find the best match (case-insensitive) best_matchlen = 0 mdll = mdl.lower () - for (name, id) in mdls.iteritems(): - name = name.lower () + mdlnames = mdls.keys () + mdlnames.sort (cups.modelSort) + mdlitems = map (lambda x: (x.lower (), mdls[x]), mdlnames) + for (name, id) in mdlitems: if mdll[:1 + best_matchlen] == name[:1 + best_matchlen]: - extra = 2 - while (mdll[1 + best_matchlen:extra + best_matchlen] == - name[1 + best_matchlen:extra + best_matchlen]): + # We know we've got one more character matching. + # Can we match any more on this entry? + extra = 1 + while (mdll[1 + best_matchlen:1 + best_matchlen + extra] == + name[1 + best_matchlen:1 + best_matchlen + extra]): + # Yes! Try another! extra += 1 if extra + best_matchlen >= len (name): break
Fixed in CVS.
FC6 test update: 0.7.52-1.fc6.
Fix verified.
Fixed in update: system-config-printer-0.7.52-1.fc6