-
Notifications
You must be signed in to change notification settings - Fork 1
/
NSString.py
30 lines (22 loc) · 839 Bytes
/
NSString.py
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
29
30
from RVObject import *
import xml.etree.ElementTree as xmltree
import base64
class NSString(RVObject):
def __init__(self,xmlelement=None, datastring=""):
# Create instance variables.
self.data = datastring
self.rvXMLIvarName = ""
if xmlelement is not None:
self.data = xmlelement.text
self.rvXMLIvarName = xmlelement.get('rvXMLIvarName')
def __repr__(self):
return self.data
def getdecoded(self):
return base64.b64decode(self.data).decode("utf-8")
def setdecoded(self, s):
self.data = base64.b64encode(bytes(s, "utf-8")).decode("utf-8")
def serializexml(self):
xmlelement = xmltree.Element("NSString")
xmlelement.text = str(self)
xmlelement.set('rvXMLIvarName', self.rvXMLIvarName)
return xmlelement