No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xepinfo.py 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. # File: xepinfo.py
  2. # Version: 0.2
  3. # Description: xepinfo class
  4. # Last Modified: 2009
  5. # Author: Tobias Markmann (tm@ayena.de)
  6. ## LICENSE ##
  7. #
  8. # Copyright (c) 1999 - 2009 XMPP Standards Foundation
  9. #
  10. # Permission is hereby granted, free of charge, to any person obtaining a copy
  11. # of this software and associated documentation files (the "Software"), to deal
  12. # in the Software without restriction, including without limitation the rights
  13. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14. # copies of the Software, and to permit persons to whom the Software is
  15. # furnished to do so, subject to the following conditions:
  16. #
  17. # The above copyright notice and this permission notice shall be included in
  18. # all copies or substantial portions of the Software.
  19. #
  20. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  23. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  25. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  26. # THE SOFTWARE.
  27. #
  28. ## END LICENSE ##
  29. from xml.dom.minidom import parse,parseString,Document,getDOMImplementation
  30. def getText(nodelist):
  31. thisText = ""
  32. for node in nodelist:
  33. if node.nodeType == node.TEXT_NODE:
  34. thisText = thisText + node.data
  35. return thisText
  36. class XEPInfo:
  37. def __init__(self, filename, parseStr):
  38. thexep = ""
  39. if parseStr:
  40. thexep = parseString(filename)
  41. else:
  42. thexep = parse(filename)
  43. xepNode = (thexep.getElementsByTagName("xep")[0])
  44. headerNode = (xepNode.getElementsByTagName("header")[0])
  45. titleNode = (headerNode.getElementsByTagName("title")[0])
  46. self.title = getText(titleNode.childNodes)
  47. self.nr = getText((headerNode.getElementsByTagName("number")[0]).childNodes)
  48. shortnameNode = headerNode.getElementsByTagName("shortname")
  49. if shortnameNode:
  50. self.shortname = getText((shortnameNode[0]).childNodes)
  51. else:
  52. self.shortname = "NOT YET ASSIGNED"
  53. abstractNode = (headerNode.getElementsByTagName("abstract")[0])
  54. self.abstract = getText(abstractNode.childNodes)
  55. statusNode = (headerNode.getElementsByTagName("status")[0])
  56. self.status = getText(statusNode.childNodes)
  57. self.type = getText((headerNode.getElementsByTagName("type")[0]).childNodes)
  58. revNode = (headerNode.getElementsByTagName("revision")[0])
  59. self.version = getText((revNode.getElementsByTagName("version")[0]).childNodes)
  60. self.date = getText((revNode.getElementsByTagName("date")[0]).childNodes)
  61. titleNode = (headerNode.getElementsByTagName("interim"))
  62. if titleNode:
  63. self.interim = True;
  64. else:
  65. self.interim = False;
  66. depNode = headerNode.getElementsByTagName("dependencies")
  67. self.depends = []
  68. if depNode:
  69. depNode = depNode[0]
  70. for dep in depNode.getElementsByTagName("spec"):
  71. self.depends.append(getText(dep.childNodes))
  72. def getInterim(self):
  73. return self.interim
  74. def getNr(self):
  75. return self.nr
  76. def getTitle(self):
  77. return self.title
  78. def getShortname(self):
  79. return self.shortname
  80. def getAbstract(self):
  81. return self.abstract
  82. def getStatus(self):
  83. return self.status
  84. def getVersion(self):
  85. return self.version
  86. def getType(self):
  87. return self.type
  88. def getDate(self):
  89. return self.date
  90. def getDepends(self):
  91. return self.depends