[hplip: 1/2] When copying Device IDs from hpcups to hpijs, use ModelName as the key instead of ShortNickName (bug

Tim Waugh twaugh at fedoraproject.org
Wed Jan 11 13:28:55 UTC 2012


commit 9ae4f5d2e3f96547cfff55783cef8c69be24861a
Author: Tim Waugh <twaugh at redhat.com>
Date:   Wed Jan 11 13:09:14 2012 +0000

    When copying Device IDs from hpcups to hpijs, use ModelName as the key instead of ShortNickName (bug #651509 comment #7).

 copy-deviceids.py |   40 +++++++++++++++++++++-------------------
 hplip.spec        |    6 +++++-
 2 files changed, 26 insertions(+), 20 deletions(-)
---
diff --git a/copy-deviceids.py b/copy-deviceids.py
index 978b979..6be4a5f 100755
--- a/copy-deviceids.py
+++ b/copy-deviceids.py
@@ -9,9 +9,9 @@ if len (sys.argv) < 3:
 hpcups_drv = sys.argv[1]
 hpijs_drv = sys.argv[2]
 
-# Match e.g.      Attribute "ShortNickName" "" "blah"
-# and catch 'blah' in group 0
-snn_re = re.compile ('^\s*Attribute\s+"ShortNickName"\s+""\s+"(.*)"\s*$')
+# Match e.g.      Model "ModelName"
+# and catch 'ModelName' in group 0
+mn_re = re.compile ('^\s*ModelName\s+"(.*)"\s*$')
 
 # Match e.g.      Attribute "1284DeviceID" "" "blah"
 # and catch everything before 'blah' in group 0, 'blah' in group 1,
@@ -21,50 +21,52 @@ devid_re = re.compile ('^(\s*Attribute\s+"1284DeviceID"\s+""\s+")(.*)("\s*)$')
 # Match e.g.   }
 end_re = re.compile ('^\s*}')
 
-devid_by_snn = dict()
+devid_by_mn = dict()
 
 hpcups_lines = file (hpcups_drv, "r").readlines ()
-current_snn = None
+current_mn = None
 for line in hpcups_lines:
-    if current_snn == None:
-        match = snn_re.match (line)
+    if current_mn == None:
+        match = mn_re.match (line)
         if match == None:
             continue
 
-        current_snn = match.groups ()[0]
+        current_mn = match.groups ()[0]
     else:
         match = devid_re.match (line)
         if match:
-            devid_by_snn[current_snn] = match.groups ()[1]
+            devid_by_mn[current_mn] = match.groups ()[1]
             continue
 
     if end_re.match (line):
-        current_snn = None
+        current_mn = None
 
 print >>sys.stderr, \
-    "%d IEEE 1284 Device IDs loaded from %s" % (len (devid_by_snn),
+    "%d IEEE 1284 Device IDs loaded from %s" % (len (devid_by_mn),
                                                 os.path.basename (hpcups_drv))
 
 replaced = 0
 hpijs_lines = file (hpijs_drv, "r").readlines ()
-current_snn = None
+current_mn = None
 for line in hpijs_lines:
-    if current_snn == None:
-        match = snn_re.match (line)
+    if current_mn == None:
+        match = mn_re.match (line)
         if match:
-            current_snn = match.groups ()[0]
-            if current_snn.endswith (" hpijs"):
-                current_snn = current_snn[:-6]
+            current_mn = match.groups ()[0]
+            if current_mn.endswith (" hpijs"):
+                current_mn = current_mn[:-6]
     else:
         match = devid_re.match (line)
         if match:
-            devid = devid_by_snn.get (current_snn)
+            devid = devid_by_mn.get (current_mn)
             if devid:
                 line = (match.groups ()[0] + devid + match.groups ()[2])
                 replaced += 1
+            else:
+                print >>sys.stderr, "Not matched: %s" % current_mn
 
     if end_re.match (line):
-        current_snn = None
+        current_mn = None
 
     print line.rstrip ("\n")
 
diff --git a/hplip.spec b/hplip.spec
index 3c566b1..b0ca1d8 100644
--- a/hplip.spec
+++ b/hplip.spec
@@ -1,7 +1,7 @@
 Summary: HP Linux Imaging and Printing Project
 Name: hplip
 Version: 3.11.12
-Release: 1%{?dist}
+Release: 2%{?dist}
 License: GPLv2+ and MIT
 Group: System Environment/Daemons
 Conflicts: system-config-printer < 0.6.132
@@ -518,6 +518,10 @@ fi
 %postun libs -p /sbin/ldconfig
 
 %changelog
+* Wed Jan 11 2012 Tim Waugh <twaugh at redhat.com> 3.11.12-2
+- When copying Device IDs from hpcups to hpijs, use ModelName as the
+  key instead of ShortNickName (bug #651509 comment #7).
+
 * Mon Dec 19 2011 Jiri Popelka <jpopelka at redhat.com> 3.11.12-1
 - 3.11.12
 


More information about the scm-commits mailing list