Commit 1bb9dce0 authored by Wim Van de Meerssche's avatar Wim Van de Meerssche
Browse files

added __lt__ and others to URN

parent d4dbf0bc
......@@ -5,7 +5,7 @@ with open("", "r", encoding="utf-8") as fh:
description="A collection of useful functions",
......@@ -25,10 +25,12 @@ URN creation and verification utilities.
import re
from functools import total_ordering
from typing import Union, Optional
URN_PREFIX = "urn:publicid:IDN"
class URN(object):
A class that creates and extracts values from URNs
......@@ -103,6 +105,11 @@ class URN(object):
return self.urn_string() == other.urn_string()
return NotImplemented
def __lt__(self, other):
if not isinstance(other, URN):
return NotImplemented
return self.urn_string() < other.urn_string()
def __hash__(self):
"""Overrides the default implementation"""
return hash(self.urn_string())
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