home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- from xorgparser import *
- import sys
-
- class XUtils(Parser):
- '''
- Subclass with higher-level methods
-
- See xorgparser.Parser for the low-level methods
- '''
-
- def __init__(self, source = None):
- Parser.__init__(self, source)
-
-
- def checkNFixSection(self):
- '''
- Gathers information on one or more sections and try to fix
- broken references to other sections.
- '''
- brokenReferences = self.getBrokenReferences()
- for section in brokenReferences:
- for reference in brokenReferences[section]:
- self.makeSection(section, identifier = reference)
-
-
-
-
- def getDriver(self, section, position):
- '''
- Get the driver in use in a section. If none is found it will return
- false.
-
- For further information see getValue
- '''
- option = 'Driver'
- return self.getValue(section, option, position)
-
-
- def setDriver(self, section, driver, position):
- '''
- Set the driver in use in a section.
- '''
- option = 'Driver'
- self.addOption(section, option, driver, position = position)
-
-
- def isDriverInSection(self, driver, sectionsList = None):
- '''
- Look for the driver in the Device sections.
- Return True if the driver is found, otherwise return False.
-
- if sectionsList == None check all the Device sections
- '''
- if sectionsList == None:
- sectionsList = self.globaldict['Device'].keys()
-
- for section in sectionsList:
-
- try:
- if self.getDriver('Device', section) == driver:
- return True
- continue
- except OptionException:
- continue
-
-
-
- return False
-
-
- def getDevicesFromServerLayout(self, position):
- '''
- Look for references to Device sections in the Screen sections referred
- to in the ServerLayout[position] section.
-
- Return a list of references to the relevant Device sections
- '''
- devicesToCheck = []
- references = self.getReferences('ServerLayout', position, [
- 'Screen'])
- if len(references['Screen']) > 0:
- for reference in references['Screen']:
-
- try:
- screenPosition = self.getPosition('Screen', reference)
- except IdentifierException:
- continue
-
-
- try:
- deviceReferences = self.getReferences('Screen', screenPosition, [
- 'Device'])
- for device in deviceReferences['Device']:
- devicePosition = self.getPosition('Device', device)
- devicesToCheck.append(devicePosition)
- continue
- except OptionException:
- continue
-
-
-
-
- return devicesToCheck
-
-
- def getDevicesInUse(self):
- '''
- If possible, return only the Device sections in use, otherwise return
- all the Device sections.
-
- This method supports old Xinerama setups and therefore looks for
- references to Device sections in the ServerLayout section(s) and checks
- only the default ServerLayout section provided than one is set in the
- ServerFlags section.
- '''
- devicesToCheck = []
- driverEnabled = False
- serverLayout = self.globaldict['ServerLayout']
- serverFlags = self.globaldict['ServerFlags']
- serverLayoutLength = len(serverLayout)
- serverFlagsLength = len(serverFlags)
- if serverLayoutLength > 0:
- if serverLayoutLength > 1:
- if serverFlagsLength > 0:
- default = self.getDefaultServerLayout()
- if len(default) == 1:
- devicesToCheck = self.getDevicesFromServerLayout(default[0])
- else:
- for layout in serverLayout:
- devicesToCheck += self.getDevicesFromServerLayout(layout)
-
- else:
- for layout in serverLayout:
- devicesToCheck += self.getDevicesFromServerLayout(layout)
-
- else:
- devicesToCheck = self.getDevicesFromServerLayout(0)
-
- if len(devicesToCheck) == 0:
- devicesToCheck = self.globaldict['Device'].keys()
-
- return devicesToCheck
-
-
- def isDriverEnabled(self, driver):
- '''
- If possible, check only the Device sections in use, otherwise check
- all the Device sections and see if a driver is enabled.
-
- This method supports old Xinerama setups and therefore looks for
- references to Device sections in the ServerLayout section(s) and checks
- only the default ServerLayout section provided than one is set in the
- ServerFlags section.
- '''
- devicesToCheck = self.getDevicesInUse()
- driverEnabled = self.isDriverInSection(driver, sectionsList = devicesToCheck)
- return driverEnabled
-
-
- def getScreenDeviceRelationships(self):
- '''
- See which Screen sections are related to which Device sections
- '''
- relationships = { }
- it = 0
- for screen in self.globaldict['Screen']:
- references = self.getReferences('Screen', it, reflist = [
- 'Device'])
- device = references['Device'][0]
- device = self.getPosition('Device', device)
- relationships.setdefault(device)
- relationships[device] = { }
- relationships[device]['Screen'] = it
- it += 1
-
- return relationships
-
-
-