-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocument.py
More file actions
28 lines (21 loc) · 894 Bytes
/
document.py
File metadata and controls
28 lines (21 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import json
class document:
def __init__(self, jsonBlob):
self.jsonBlob = jsonBlob
self.jsonParse = json.load(self.jsonBlob)
def getdocumentLinks(self):
return len(self.jsonParse['links'])
def getdocumentLinksHref(self, linkId):
return self.jsonParse['links'][linkId]['href']
def getdocumentLinksRel(self, linkId):
return self.jsonParse['links'][linkId]['rel']
def getLinkWithRel(self, Rel):
for x in range(self.getdocumentLinks()):
if self.jsonParse['links'][x]['rel'] == Rel:
return self.jsonParse['links'][x]['href']
return None
def getLinkWithHref(self, Href):
for x in range(self.getdocumentLinks()):
if self.jsonParse['links'][x]['href'] == Href:
return self.jsonParse['links'][x]['rel']
return None