caellion-python-commons
caellion.pycommons.encoding.base36.Base36Coder Class Reference

This class provides methods allowing conversion between integer, hexadecimal integer and base36 strings. More...

Public Member Functions

def __init__ (self, custom_charset="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")
 Initialize coder. More...
 
def to_standard_charset (self, unformatted)
 Converts custom charset to standard charset. More...
 
def to_custom_charset (self, unformatted)
 Converts standard charset to custom charset. More...
 
def bytes_to_b36 (self, bytes_in)
 Converts bytes to base36 string in custom charset encoding. More...
 
def int_to_b36 (self, integer)
 Converts int to base36 string in custom charset encoding. More...
 
def b36_to_bytes (self, b36)
 Converts base36 string in custom encoding charset to bytes. More...
 
def b36_to_int (self, b36)
 Converts base36 string in custom encoding charset to integer. More...
 

Static Public Attributes

 custom_charset = None
 

Detailed Description

This class provides methods allowing conversion between integer, hexadecimal integer and base36 strings.

Definition at line 46 of file base36.py.

Constructor & Destructor Documentation

◆ __init__()

def caellion.pycommons.encoding.base36.Base36Coder.__init__ (   self,
  custom_charset = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" 
)

Initialize coder.

Parameters
custom_charsetcustom character set to use with the coder
Exceptions
InvalidCustomCharsetLengthException
InvalidCustomCharsetException

Definition at line 54 of file base36.py.

Member Function Documentation

◆ b36_to_bytes()

def caellion.pycommons.encoding.base36.Base36Coder.b36_to_bytes (   self,
  b36 
)

Converts base36 string in custom encoding charset to bytes.

Parameters
b36string in custom encoding charset
Returns
decoded bytes
Exceptions
InvalidInputStringException
ValueTooLargeException

Definition at line 171 of file base36.py.

◆ b36_to_int()

def caellion.pycommons.encoding.base36.Base36Coder.b36_to_int (   self,
  b36 
)

Converts base36 string in custom encoding charset to integer.

Parameters
b36base36 string in custom encoding charset
Returns
decoded integer
Exceptions
InvalidInputStringException

Definition at line 196 of file base36.py.

◆ bytes_to_b36()

def caellion.pycommons.encoding.base36.Base36Coder.bytes_to_b36 (   self,
  bytes_in 
)

Converts bytes to base36 string in custom charset encoding.

Parameters
bytes_ina bytes object to encode
Returns
Base36 string in custom format

Definition at line 128 of file base36.py.

◆ int_to_b36()

def caellion.pycommons.encoding.base36.Base36Coder.int_to_b36 (   self,
  integer 
)

Converts int to base36 string in custom charset encoding.

Parameters
integeran int to encode
Returns
Base36 string in custom format
Exceptions
NumberNotPositiveOrZeroException

Definition at line 147 of file base36.py.

◆ to_custom_charset()

def caellion.pycommons.encoding.base36.Base36Coder.to_custom_charset (   self,
  unformatted 
)

Converts standard charset to custom charset.

Parameters
unformattedBase36 string in standard charset encoding
Returns
Base36 string in custom format
Exceptions
InvalidInputStringException

Definition at line 104 of file base36.py.

◆ to_standard_charset()

def caellion.pycommons.encoding.base36.Base36Coder.to_standard_charset (   self,
  unformatted 
)

Converts custom charset to standard charset.

Parameters
unformattedBase36 string in custom charset encoding
Returns
Base36 string in standardized format
Exceptions
InvalidInputStringException

Definition at line 80 of file base36.py.

Member Data Documentation

◆ custom_charset

caellion.pycommons.encoding.base36.Base36Coder.custom_charset = None
static

Definition at line 52 of file base36.py.


The documentation for this class was generated from the following file: