"""System Configuration - For holding global system variables $Id$ """ # Copyright 2008-2011 eGovMon # This program is distributed under the terms of the GNU General # Public License. # # This file is part of the eGovernment Monitoring # (eGovMon) # # eGovMon is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # eGovMon is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with eGovMon; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, # MA 02110-1301 USA __author__ = "$Author$" __version__ = "$Revision$" __updated__ = "$LastChangedDate$" import os import sys from scerror import * import xml.sax from xml.sax.handler import * class InitialRdf(ContentHandler): def __init__(self): self.in_quote = 0 self.value = '' def startElement(self, name, attrs): self.value="" def endElement(self, name): if name.startswith("egovmon:"): setattr(InitialRdf,name[8:],self.value) elif name.startswith("eiao:"): setattr(InitialRdf,name[5:],self.value) def characters(self, ch): self.value=self.value+ch def SystemConfiguration(): parser = xml.sax.make_parser() handler = InitialRdf() parser.setContentHandler(handler) filetoparse = '' foundinitialfile = False for file in ['/etc/egovmon/initial.rdf','initial.rdf', os.path.abspath(sys.prefix + '/initial.rdf')]: if not foundinitialfile: try: f = open(file,'r') foundinitialfile = True if not filetoparse: filetoparse = file except IOError: pass if not foundinitialfile: raise InitialRDFNotFoundError(['initial.rdf',os.path.abspath(sys.prefix + '/initial.rdf')]) parser.parse(filetoparse) return handler if __name__ == '__main__': sc=SystemConfiguration() print dir(sc)