#!/usr/bin/python

import cupshelpers.ppds as ppd
import cupshelpers.cupshelpers as cupshelpers
import cups
import sys

picklefile="pickled-ppds"
import pickle
try:
	f = open (picklefile, "r")
	cupsppds = pickle.load (f) 
except IOError:
	f = open (picklefile, "w")
	c = cups.Connection ()
	cupsppds = c.getPPDs ()
	pickle.dump (cupsppds, f)

ppds = ppd.PPDs (cupsppds)

id_dict = cupshelpers.parseDeviceID (sys.argv[1])
(status, ppdname) = ppds.getPPDNameFromDeviceID (id_dict["MFG"],
		id_dict["MDL"],
		id_dict["DES"],
		id_dict["CMD"])

#print status
print ppdname
