CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
cacheconfigParser.py
Go to the documentation of this file.
1 from xml.dom.minidom import parse,parseString,getDOMImplementation,Node
2 
3 class cacheconfigParser(object):
4  def __init__(self):
5  self.__configstr=''
6  self.__configfile=''
7  ###parse result
9  def handleFrontierConnect(self,dom):
10  #print 'handleFrontierConnect'
11  nodelist=dom.getElementsByTagName('frontier-connect')[0].childNodes
12  #print nodelist
13  for node in nodelist:
14  if node.nodeType!=Node.TEXT_NODE and node.nodeType!=Node.COMMENT_NODE:
15  tagname=node.tagName
16  attrs=node.attributes
17  for attrName in attrs.keys():
18  attrNode=attrs.get(attrName)
19  attrValue=attrNode.nodeValue
20  if tagname in self.__parameterDict:
21  self.__parameterDict[tagname].append((attrName,attrValue))
22  else:
23  valuelist=[]
24  valuelist.append((attrName,attrValue))
25  self.__parameterDict[tagname]=valuelist
26  def parse(self,filename):
27  """
28  Parse an XML file by name
29  """
30  dom=parse(filename)
31  self.handleFrontierConnect(dom)
32  dom.unlink()
33  def parseString(self,strbuff):
34  dom=parseString(strbuff)
35  self.handleFrontierConnect(dom)
36  dom.unlink()
37  def proxylist(self):
38  return self.__parameterDict['proxy']
39  def serverlist(self):
40  return self.__parameterDict['server']
41  def parameterdict(self):
42  return self.__parameterDict
43 if __name__ == '__main__':
44  mydocstr="""<frontier-connect><proxy url="http://cmst0frontier.cern.ch:3128"/><proxy url="http://cmst0frontier.cern.ch:3128"/><proxy url="http://cmst0frontier1.cern.ch:3128"/><proxy url="http://cmst0frontier2.cern.ch:3128"/><server url="http://cmsfrontier.cern.ch:8000/FrontierInt"/><server url="http://cmsfrontier.cern.ch:8000/FrontierInt"/><server url="http://cmsfrontier1.cern.ch:8000/FrontierInt"/><server url="http://cmsfrontier2.cern.ch:8000/FrontierInt"/><server url="http://cmsfrontier3.cern.ch:8000/FrontierInt"/><server url="http://cmsfrontier4.cern.ch:8000/FrontierInt"/></frontier-connect>"""
46  p.parseString(mydocstr)
47  print 'proxies'
48  print p.proxylist()
49  print 'servers'
50  print p.serverlist()
51  print 'parameterdict'
52  print p.parameterdict()
53 
54  p.parse('/afs/cern.ch/user/x/xiezhen/w1/site-local-config.xml')
55  print 'proxies'
56  print p.proxylist()
57  print 'servers'
58  print p.serverlist()
59  print 'parameterdict'
60  print p.parameterdict()
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...