2018-03-21 06:50:40 -04:00
|
|
|
from baseconv import BaseConverter
|
|
|
|
from string import ascii_lowercase, ascii_uppercase
|
|
|
|
|
|
|
|
# We have to create this collection ourselves because we want uppercase then
|
|
|
|
# lowercase, and string.ascii_letters is lowercase then uppercase.
|
|
|
|
chars = ascii_uppercase + ascii_lowercase
|
|
|
|
conv = BaseConverter(chars)
|
|
|
|
|
2022-03-11 23:04:05 -05:00
|
|
|
class AbcIdConverter:
|
|
|
|
regex = '[a-zA-Z]+'
|
2018-03-21 06:50:40 -04:00
|
|
|
|
2022-03-11 23:04:05 -05:00
|
|
|
def to_python(self, value: str) -> int:
|
|
|
|
return int(conv.decode(value))
|
2018-03-21 06:50:40 -04:00
|
|
|
|
2022-03-11 23:04:05 -05:00
|
|
|
def to_url(self, value: int) -> str:
|
|
|
|
return conv.encode(value)
|