PyNDN: A couple of bug fixes in Name and Data classes
diff --git a/PyNDN/Data.py b/PyNDN/Data.py
index 48c54da..7e8dd56 100644
--- a/PyNDN/Data.py
+++ b/PyNDN/Data.py
@@ -35,13 +35,14 @@
self._data = data._data
elif isinstance (data, ns.ndnSIM.ndn.Data):
self._data = data
- self.signedInfo = SignedInfo ()
- # timestamp
- self.signedInfo.freshnessSeconds = self._data.GetFreshness ().ToDouble (ns.core.Time.S)
- if self._data.GetKeyLocator ():
- self.signedInfo.keyLocator = Name (name = self._data.GetKeyLocator ())
else:
raise TypeError ("Invalid type supplied for 'data' parameter [%s]" % type (data))
+
+ self.signedInfo = SignedInfo ()
+ # timestamp
+ self.signedInfo.freshnessSeconds = self._data.GetFreshness ().ToDouble (ns.core.Time.S)
+ if self._data.GetKeyLocator ():
+ self.signedInfo.keyLocator = Name (name = self._data.GetKeyLocator ())
else:
self._data = ns.ndnSIM.ndn.Data ()
diff --git a/PyNDN/Name.py b/PyNDN/Name.py
index b760213..628b843 100644
--- a/PyNDN/Name.py
+++ b/PyNDN/Name.py
@@ -36,12 +36,8 @@
if value is not None:
if isinstance (value, Name):
self._name = ns.ndnSIM.ndn.Name (value._name)
- elif isinstance (value, ns.ndnSIM.ndn.Name):
- self._name = ns.ndnSIM.ndn.Name (value)
- elif isinstance (value, str):
- self._name = ns.ndnSIM.ndn.Name (value)
else:
- raise TypeError ("Not support tyupe [%s]" % type (value))
+ self._name = ns.ndnSIM.ndn.Name (value)
else:
self._name = ns.ndnSIM.ndn.Name ()
@@ -53,7 +49,10 @@
return ns.ndnSIM.ndn.Wire.FromName (self._name)
def append (self, value):
- self._name.append (value)
+ if isinstance (value, Name):
+ self._name.append (value._name)
+ else:
+ self._name.append (value)
return self
def __getattr__ (self, name):
@@ -85,6 +84,9 @@
def __str__ (self):
return self._name.toUri ()
+ def __eq__ (self, other):
+ return self._name == other._name
+
def isPrefixOf (self, other):
return self[:] == other[:len(self)]