XorgParser

A simple X.Org parser
Download

XorgParser Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL
  • Price:
  • FREE
  • Publisher Name:
  • Alberto Milone
  • Publisher web site:
  • http://albertomilone.com/evolbck.html

XorgParser Tags


XorgParser Description

A simple X.Org parser XorgParser is a simple, transparent and easy to extend X.Org parser. It was written with the following aims in mind:* Simple API.* Easy to extend.* Dependent only on Python (no external libraries)X-Kit was designed to be distribution agnostic so as to provide a standard way to manipulate the content of the xorg.conf from different applications.StructureThe Parser class in xorgparser.py is the core of the project since it includes all the main methods for the manipulation and validation of the xorg.conf. The XUtils subclass in xutils.py contains some not fundamental but still quite useful methods mainly focussed on dealing with the several relationships between the different sections of the xorg.conf.The most important attribute of the Parser class is globaldict i.e. a dictionary which contains a structured representation of the content of the xorg.conf. The section types are its keys (see self.sections). "SubSection" is treated as a special section type.As regards normal sections, the value assigned to each key of globaldict is another dictionary which has the position of each section as a key.self.globaldict = { 'Device': { 0: , 1: , etc. }, 'Screen': { 0: , 1: , etc.}, etc. }For example self.globaldict corresponds to a list of the options available in the 1st "Device" section of the xorg.conf.SubSections are treated differently from sections:self.globaldict = { 'Device': { 0: , 1: , etc. }, 'Screen': { 0: , 1: , etc. }, 'SubSection': { 0: { 'section': 'Screen', 'identifier': 'Display', 'position': 0, 'options': }, 1: {...}, etc. }, }In this case they keys of self.globaldict (i.e. 0, 1, etc.) represent the position of the "Display" SubSection inside the "Screen" section. The following are the keys of self.globaldict, , etc.:- section = the section in which the SubSection is located (e.g. "Screen")- position = the position of the section (e.g. "Screen") in the xorg.conf e.g. position would be 0 if the SubSection was located in the 1st "Screen" section of the xorg.conf (whose options are stored in "self.globaldict")- identifier = the name of the SubSection (e.g. "Display")- options = a list with the options available in the SubSectionAnother important concept to consider is that each line in each section is considered as an option. No more than one instance of the same option should be found in the same section (e.g. Driver "nv" and Driver "vesa" cannot cohexist in the same Device section). References (e.g. Screen "Default Screen" in the Device section), however, are treated as a special kind of option and more than one reference of the same kind can be found in the same section (e.g. Screen "Screen 1" and Screen "Screen 2" in the same ServerLayout section)IMPORTANT NOTE ON CASE SENSITIVE SECTION NAMES: the parser will accept sections in either lowercase and uppercase when reading a configuration file. The same is not true when the methods are called and the name of the section is passed as a parameter, as in such case the names of the sections must be exactly as in "self.sections" i.e. the 1st letter of each word which is part of the name must be in uppercase:e.g. invalid: "screen", "serverlayout", "Serverlayout" valid: "Screen", "ServerLayout"If you don't respect this rule, a KeyError will be raised.For further information you can have a look at the documentation by typing:import XKithelp(XKit.xutils)How to install X-KitIf you use Ubuntu you should be able to find the source package on Launchpad (see the "Development" section of this file) and in the Ubuntu repository (starting from Ubuntu 8.10).The easiest way to install it is by typing the following command: # ./setup.py install (as root). Requirements: · Python What's New in This Release: xorgparser.py: · remove harmless but useless lines after an Exception in getValue() · make sure that if optiontype != None the option (differently from the value) is always put in quotation marks in addOption() 0-test.py: · add a test for the quotation marks check in addOption()


XorgParser Related Software