# HG changeset patch # User Tom Fredrik Blenning Klaussen # Date 1347823901 -7200 # Node ID f65c2d63ab6636213b284ae410abf0565ced42bf # Parent 10f1d7de9bc34e15cb569cd560358281376ec128 Rename Options to Config diff -r 10f1d7de9bc3 -r f65c2d63ab66 Config.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Config.py Sun Sep 16 21:31:41 2012 +0200 @@ -0,0 +1,32 @@ +#!/usr/bin/env python -O + +import xml.dom.minidom, sys, re + +class Config: + def __init__(self, path): + self.document = xml.dom.minidom.parse(path) + + @staticmethod + def getOption(node, option, match): + for potentialMatch in node.childNodes: + if potentialMatch.nodeName == "option": + if potentialMatch.hasAttribute('match'): + matchstr = potentialMatch.getAttribute('match') + try: + prog = re.compile(matchstr) + except: + raise xml.dom.SyntaxErr(matchstr + + + " is not a valid value for attribute match") + if prog.match(match): + res = Config.getOption(potentialMatch, option, match) + if not res: + res = potentialMatch.getAttribute('cxxflags') + return res + return None + + def getCxxflags(self, name): + value = self.getOption(self.document.childNodes[0], 'Cxxflags', name) + if not value: + raise xml.dom.NotFoundErr() + return value diff -r 10f1d7de9bc3 -r f65c2d63ab66 Options.py --- a/Options.py Sun Sep 16 21:29:22 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -#!/usr/bin/env python -O - -import xml.dom.minidom, sys, re - -class Config: - def __init__(self, path): - self.document = xml.dom.minidom.parse(path) - - @staticmethod - def getOption(node, option, match): - for potentialMatch in node.childNodes: - if potentialMatch.nodeName == "option": - if potentialMatch.hasAttribute('match'): - matchstr = potentialMatch.getAttribute('match') - try: - prog = re.compile(matchstr) - except: - raise xml.dom.SyntaxErr(matchstr - + - " is not a valid value for attribute match") - if prog.match(match): - res = Config.getOption(potentialMatch, option, match) - if not res: - res = potentialMatch.getAttribute('cxxflags') - return res - return None - - def getCxxflags(self, name): - value = self.getOption(self.document.childNodes[0], 'Cxxflags', name) - if not value: - raise xml.dom.NotFoundErr() - return value diff -r 10f1d7de9bc3 -r f65c2d63ab66 codeOptimizer.py --- a/codeOptimizer.py Sun Sep 16 21:29:22 2012 +0200 +++ b/codeOptimizer.py Sun Sep 16 21:31:41 2012 +0200 @@ -4,7 +4,7 @@ from Compilable import Compilable from DepGraph import DepGraph -from Options import Config +from Config import Config