add from_bytes function
This commit is contained in:
parent
df5f06f695
commit
3fc96ae61e
@ -44,6 +44,24 @@ class Guid:
|
|||||||
result = int(parseWhat, 16)
|
result = int(parseWhat, 16)
|
||||||
parsePos += requiredLength
|
parsePos += requiredLength
|
||||||
return (parsePos, result)
|
return (parsePos, result)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def from_bytes(b : bytes):
|
||||||
|
guid = Guid()
|
||||||
|
|
||||||
|
guid.__a = (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | b[0]
|
||||||
|
guid.__b = (b[5] << 8) | b[4]
|
||||||
|
guid.__c = ((b[7] << 8) | b[6])
|
||||||
|
guid.__d = b[8]
|
||||||
|
guid.__e = b[9]
|
||||||
|
guid.__f = b[10]
|
||||||
|
guid.__g = b[11]
|
||||||
|
guid.__h = b[12]
|
||||||
|
guid.__i = b[13]
|
||||||
|
guid.__j = b[14]
|
||||||
|
guid.__k = b[15]
|
||||||
|
|
||||||
|
return guid
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __tryParseGuidWithDashes(guidString : str) -> UUIDParseResult:
|
def __tryParseGuidWithDashes(guidString : str) -> UUIDParseResult:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user