Move printerdata dictionary object into it's own file.
[samba.git] / source / python / samba / printerdata.py
1 #
2 # A python module that maps printerdata to a dictionary.  We define
3 # two classes.  The printerdata class maps to Get/Set/Enum/DeletePrinterData
4 # and the printerdata_ex class maps to Get/Set/Enum/DeletePrinterDataEx
5 #
6
7 import spoolss
8
9 class printerdata:
10     def __init__(self, host, creds = {}):
11         self.hnd = spoolss.openprinter(host, creds = creds)
12
13     def keys(self):
14         return self.hnd.enumprinterdata().keys()
15
16     def __getitem__(self, key):
17         return self.hnd.getprinterdata(key)['data']
18
19     def __setitem__(self, key, value):
20         # Store as REG_BINARY for now
21         self.hnd.setprinterdata({"key": "", "value": key, "type": 3,
22                                  "data": value})
23