Commit 8c6233df authored by Wim Van de Meerssche's avatar Wim Van de Meerssche
Browse files

added __repr__, __eq__ and __hash__ to URN

parent 8d0549d3
......@@ -54,7 +54,7 @@ class URN(object):
Looks like urn:publicid:IDN+gcf:gpo:bbn:site1+node+LinuxBox23
"""
def __init__(self, *, authority=None, type=None, name=None, urn=None):
def __init__(self, urn=None, *, authority=None, type=None, name=None):
if not urn is None:
if not is_valid_urn(urn):
raise ValueError("Invalid URN %s" % urn)
......@@ -94,6 +94,19 @@ class URN(object):
def __str__(self):
return self.urn_string()
def __repr__(self):
return 'URN("'+self.urn_string()+'")'
def __eq__(self, other):
"""Overrides the default implementation"""
if isinstance(other, URN):
return self.urn_string() == other.urn_string()
return NotImplemented
def __hash__(self):
"""Overrides the default implementation"""
return hash(self.urn_string())
def urn_string(self):
return self.urn
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment