Skip to content
Snippets Groups Projects
Commit 75541103 authored by KERDREUX Jerome's avatar KERDREUX Jerome
Browse files

Format

parent 27cff7fa
No related branches found
No related tags found
1 merge request!1First try of type hints
...@@ -2,12 +2,13 @@ import uuid ...@@ -2,12 +2,13 @@ import uuid
from .exceptions import UUIDError from .exceptions import UUIDError
class UUID: class UUID:
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.__uuid = uuid.UUID(*args, **kwargs) self.__uuid = uuid.UUID(*args, **kwargs)
@staticmethod @staticmethod
def random_base(digit=2) -> 'UUID': def random_base(digit=2) -> "UUID":
"""zeros the last digits of a random uuid, usefull w/ you want to forge some addresses """zeros the last digits of a random uuid, usefull w/ you want to forge some addresses
two digit is great. two digit is great.
""" """
...@@ -19,15 +20,15 @@ class UUID: ...@@ -19,15 +20,15 @@ class UUID:
raise UUIDError raise UUIDError
@staticmethod @staticmethod
def random() -> 'UUID': def random() -> "UUID":
tmp = uuid.uuid1().int tmp = uuid.uuid1().int
return UUID(int=tmp) return UUID(int=tmp)
def __add__(self, value:int) -> 'UUID': def __add__(self, value: int) -> "UUID":
tmp = self.__uuid.int + value tmp = self.__uuid.int + value
return UUID(int=tmp) return UUID(int=tmp)
def __sub__(self, value:int) -> 'UUID': def __sub__(self, value: int) -> "UUID":
tmp = self.__uuid.int - value tmp = self.__uuid.int - value
return UUID(int=tmp) return UUID(int=tmp)
...@@ -52,7 +53,7 @@ class UUID: ...@@ -52,7 +53,7 @@ class UUID:
def get(self) -> uuid.UUID: def get(self) -> uuid.UUID:
return self.__uuid return self.__uuid
def set(self, value:uuid.UUID): def set(self, value: uuid.UUID):
self.__uuid = value self.__uuid = value
@property @property
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment