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("README.md", "r", encoding="utf-8") as fh:
setup(
name="wvdemeer-utils",
version="1.2.0",
version="1.3.0",
description="A collection of useful functions",
long_description=long_description,
......
......@@ -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"
@total_ordering
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