home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / share / hal / device-manager / Device.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2007-05-11  |  2.2 KB  |  76 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.5)
  3.  
  4. '''This file contains the Device class.'''
  5. import Const
  6.  
  7. class Device:
  8.     
  9.     def __init__(self, device_name, parent_name, properties):
  10.         self.device_name = device_name
  11.         self.parent_name = parent_name
  12.         self.parent_device = None
  13.         self.properties = properties
  14.         self.children = []
  15.  
  16.     
  17.     def print_tree(self, indent):
  18.         if indent == 0:
  19.             print ' ' * indent + self.device_name
  20.         else:
  21.             print ' ' * indent + '- ' + self.device_name
  22.         for c in self.children:
  23.             c.print_tree(indent + 4)
  24.         
  25.  
  26.     
  27.     def populate_gtk_tree(self, tree_model, dont_show_virtual, representation):
  28.         if dont_show_virtual:
  29.             
  30.             try:
  31.                 if self.properties['info.virtual']:
  32.                     if self.properties['info.subsystem'] not in ('block', 'ide_host'):
  33.                         self.row = self.parent_device.row
  34.                         for c in self.children:
  35.                             c.populate_gtk_tree(tree_model, dont_show_virtual, representation)
  36.                         
  37.                         return None
  38.                     
  39.  
  40.         
  41.         if self.parent_device == None:
  42.             self.row = None
  43.         else:
  44.             self.row = tree_model.append(self.parent_device.row)
  45.         if self.row != None:
  46.             icon = representation.get_icon(self)
  47.             tree_model.set_value(self.row, Const.PIXBUF_COLUMN, icon)
  48.             
  49.             try:
  50.                 title_name = self.properties['info.product']
  51.             except KeyError:
  52.                 title_name = 'Unknown Device'
  53.             except TypeError:
  54.                 title_name = 'Unknown Device'
  55.  
  56.             tree_model.set_value(self.row, Const.TITLE_COLUMN, title_name)
  57.             tree_model.set_value(self.row, Const.UDI_COLUMN, self.device_name)
  58.         
  59.         for c in self.children:
  60.             c.populate_gtk_tree(tree_model, dont_show_virtual, representation)
  61.         
  62.  
  63.     
  64.     def find_by_udi(self, device_udi):
  65.         if self.device_name == device_udi:
  66.             return self
  67.         
  68.         for c in self.children:
  69.             rc = c.find_by_udi(device_udi)
  70.             if rc != None:
  71.                 return rc
  72.                 continue
  73.         
  74.  
  75.  
  76.