home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import re
- from checkbox.lib.cache import cache
- from checkbox.lib.update import recursive_update
- from checkbox.properties import String
- from checkbox.registries.command import CommandRegistry
- from checkbox.registries.data import DataRegistry
- from checkbox.registries.map import MapRegistry
-
- class DeviceRegistry(DataRegistry):
- '''Registry for HAL device information.
-
- Each item contained in this registry consists of the properties of
- the corresponding HAL device.
- '''
-
- def items(self):
- all = { }
- current = None
- for line in self.split('\n'):
- match = re.match(' (.*) = (.*) \\((.*?)\\)', line)
- if match:
- keys = match.group(1).split('.')
- value = match.group(2).strip()
- type_name = match.group(3)
- if type_name == 'bool':
- value = bool(value == 'true')
- elif type_name == 'double':
- value = float(value.split()[0])
- elif type_name == 'int' or type_name == 'uint64':
- value = int(value.split()[0])
- elif type_name == 'string':
- value = str(value.strip("'"))
- elif type_name == 'string list':
- value = [ v.strip("'") for v in value.strip('{}').split(', ') ]
- else:
- raise Exception, 'Unknown type: %s' % type_name
- recursive_update(all, value)
- match
-
- items = []
- for key, value in all.items():
- value = MapRegistry(value)
- items.append((key, value))
-
- return items
-
- items = cache(items)
-
-
- class HalRegistry(CommandRegistry):
- '''Registry for HAL information.
-
- Each item contained in this registry consists of the udi as key and
- the corresponding device registry as value.
- '''
- command = String(default = 'lshal')
-
- def items(self):
- items = []
- for block in self.split('\n\n'):
- lines = block.split('\n')
- while lines:
- line = lines.pop(0)
- match = re.match("udi = '(.*)'", line)
- if match:
- udi = match.group(1)
- key = udi.split('/')[-1]
- break
- continue
- if lines:
- value = DeviceRegistry('\n'.join(lines))
- items.append((key, value))
- continue
-
- return items
-
- items = cache(items)
-
- factory = HalRegistry
-