When copying Device IDs from hpcups to hpijs, use ModelName as the key instead of ShortNickName (bug #651509 comment #7).
This commit is contained in:
parent
5b6365d52f
commit
9ae4f5d2e3
@ -9,9 +9,9 @@ if len (sys.argv) < 3:
|
|||||||
hpcups_drv = sys.argv[1]
|
hpcups_drv = sys.argv[1]
|
||||||
hpijs_drv = sys.argv[2]
|
hpijs_drv = sys.argv[2]
|
||||||
|
|
||||||
# Match e.g. Attribute "ShortNickName" "" "blah"
|
# Match e.g. Model "ModelName"
|
||||||
# and catch 'blah' in group 0
|
# and catch 'ModelName' in group 0
|
||||||
snn_re = re.compile ('^\s*Attribute\s+"ShortNickName"\s+""\s+"(.*)"\s*$')
|
mn_re = re.compile ('^\s*ModelName\s+"(.*)"\s*$')
|
||||||
|
|
||||||
# Match e.g. Attribute "1284DeviceID" "" "blah"
|
# Match e.g. Attribute "1284DeviceID" "" "blah"
|
||||||
# and catch everything before 'blah' in group 0, 'blah' in group 1,
|
# 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. }
|
# Match e.g. }
|
||||||
end_re = re.compile ('^\s*}')
|
end_re = re.compile ('^\s*}')
|
||||||
|
|
||||||
devid_by_snn = dict()
|
devid_by_mn = dict()
|
||||||
|
|
||||||
hpcups_lines = file (hpcups_drv, "r").readlines ()
|
hpcups_lines = file (hpcups_drv, "r").readlines ()
|
||||||
current_snn = None
|
current_mn = None
|
||||||
for line in hpcups_lines:
|
for line in hpcups_lines:
|
||||||
if current_snn == None:
|
if current_mn == None:
|
||||||
match = snn_re.match (line)
|
match = mn_re.match (line)
|
||||||
if match == None:
|
if match == None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
current_snn = match.groups ()[0]
|
current_mn = match.groups ()[0]
|
||||||
else:
|
else:
|
||||||
match = devid_re.match (line)
|
match = devid_re.match (line)
|
||||||
if match:
|
if match:
|
||||||
devid_by_snn[current_snn] = match.groups ()[1]
|
devid_by_mn[current_mn] = match.groups ()[1]
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if end_re.match (line):
|
if end_re.match (line):
|
||||||
current_snn = None
|
current_mn = None
|
||||||
|
|
||||||
print >>sys.stderr, \
|
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))
|
os.path.basename (hpcups_drv))
|
||||||
|
|
||||||
replaced = 0
|
replaced = 0
|
||||||
hpijs_lines = file (hpijs_drv, "r").readlines ()
|
hpijs_lines = file (hpijs_drv, "r").readlines ()
|
||||||
current_snn = None
|
current_mn = None
|
||||||
for line in hpijs_lines:
|
for line in hpijs_lines:
|
||||||
if current_snn == None:
|
if current_mn == None:
|
||||||
match = snn_re.match (line)
|
match = mn_re.match (line)
|
||||||
if match:
|
if match:
|
||||||
current_snn = match.groups ()[0]
|
current_mn = match.groups ()[0]
|
||||||
if current_snn.endswith (" hpijs"):
|
if current_mn.endswith (" hpijs"):
|
||||||
current_snn = current_snn[:-6]
|
current_mn = current_mn[:-6]
|
||||||
else:
|
else:
|
||||||
match = devid_re.match (line)
|
match = devid_re.match (line)
|
||||||
if match:
|
if match:
|
||||||
devid = devid_by_snn.get (current_snn)
|
devid = devid_by_mn.get (current_mn)
|
||||||
if devid:
|
if devid:
|
||||||
line = (match.groups ()[0] + devid + match.groups ()[2])
|
line = (match.groups ()[0] + devid + match.groups ()[2])
|
||||||
replaced += 1
|
replaced += 1
|
||||||
|
else:
|
||||||
|
print >>sys.stderr, "Not matched: %s" % current_mn
|
||||||
|
|
||||||
if end_re.match (line):
|
if end_re.match (line):
|
||||||
current_snn = None
|
current_mn = None
|
||||||
|
|
||||||
print line.rstrip ("\n")
|
print line.rstrip ("\n")
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
Summary: HP Linux Imaging and Printing Project
|
Summary: HP Linux Imaging and Printing Project
|
||||||
Name: hplip
|
Name: hplip
|
||||||
Version: 3.11.12
|
Version: 3.11.12
|
||||||
Release: 1%{?dist}
|
Release: 2%{?dist}
|
||||||
License: GPLv2+ and MIT
|
License: GPLv2+ and MIT
|
||||||
Group: System Environment/Daemons
|
Group: System Environment/Daemons
|
||||||
Conflicts: system-config-printer < 0.6.132
|
Conflicts: system-config-printer < 0.6.132
|
||||||
@ -518,6 +518,10 @@ fi
|
|||||||
%postun libs -p /sbin/ldconfig
|
%postun libs -p /sbin/ldconfig
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Jan 11 2012 Tim Waugh <twaugh@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@redhat.com> 3.11.12-1
|
* Mon Dec 19 2011 Jiri Popelka <jpopelka@redhat.com> 3.11.12-1
|
||||||
- 3.11.12
|
- 3.11.12
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user