fix Snowflake.to_b32l() for negative values

This commit is contained in:
Yusur 2025-06-18 09:35:09 +02:00
parent e615cbb628
commit a531ba0c37
2 changed files with 4 additions and 2 deletions

View file

@ -27,7 +27,7 @@ from .itertools import makelist, kwargs_prefix, ltuple, rtuple, additem
from .i18n import I18n, JsonI18n, TomlI18n from .i18n import I18n, JsonI18n, TomlI18n
from .snowflake import Snowflake, SnowflakeGen from .snowflake import Snowflake, SnowflakeGen
__version__ = "0.3.0" __version__ = "0.3.1"
__all__ = ( __all__ = (
'Siq', 'SiqCache', 'SiqType', 'SiqGen', 'StringCase', 'Siq', 'SiqCache', 'SiqType', 'SiqGen', 'StringCase',

View file

@ -131,7 +131,9 @@ class Snowflake(int):
def to_oct(self) -> str: def to_oct(self) -> str:
return f'{self:o}' return f'{self:o}'
def to_b32l(self) -> str: def to_b32l(self) -> str:
"""PSA Snowflake Base32 representations are padded to 10 bytes!""" # PSA Snowflake Base32 representations are padded to 10 bytes!
if self < 0:
return '_' + Snowflake.to_b32l(-self)
return b32lencode(self.to_bytes(10, 'big')).lstrip('a') return b32lencode(self.to_bytes(10, 'big')).lstrip('a')
@classmethod @classmethod