|
a |
|
b/OSSEval/OSSEval/utils.py |
|
|
1 |
from json import JSONEncoder
|
|
|
2 |
|
|
|
3 |
class TrivialJSONEncoder(JSONEncoder):
|
|
|
4 |
def default(self, o):
|
|
|
5 |
return o.__dict__
|
|
|
6 |
|
|
|
7 |
class xmlMinidom():
|
|
|
8 |
@staticmethod
|
|
|
9 |
def getString(xmldoc, tag):
|
|
|
10 |
try:
|
|
|
11 |
return xmldoc.getElementsByTagName(tag)[0].firstChild.data
|
|
|
12 |
except:
|
|
|
13 |
return ""
|
|
|
14 |
|
|
|
15 |
@staticmethod
|
|
|
16 |
def getStringAttribute(xmldoc, tag):
|
|
|
17 |
try:
|
|
|
18 |
return xmldoc.attributes[tag].firstChild.data
|
|
|
19 |
except:
|
|
|
20 |
return ""
|
|
|
21 |
|
|
|
22 |
@staticmethod
|
|
|
23 |
def getNaturalAttribute(xmldoc, tag):
|
|
|
24 |
'''
|
|
|
25 |
a natural number; if it's not there -1 is returned
|
|
|
26 |
'''
|
|
|
27 |
try:
|
|
|
28 |
return int(xmldoc.attributes[tag].firstChild.data)
|
|
|
29 |
except:
|
|
|
30 |
return -1
|
|
|
31 |
|