Small refactoring & user feed API WIP
This commit is contained in:
35
twExtract/twUtils.py
Normal file
35
twExtract/twUtils.py
Normal file
@ -0,0 +1,35 @@
|
||||
import math
|
||||
import hashlib
|
||||
import base64
|
||||
import uuid
|
||||
digits = "0123456789abcdefghijklmnopqrstuvwxyz"
|
||||
|
||||
def baseConversion(x, base):
|
||||
result = ''
|
||||
i = int(x)
|
||||
while i > 0:
|
||||
result = digits[i % base] + result
|
||||
i = i // base
|
||||
if int(x) != x:
|
||||
result += '.'
|
||||
i = x - int(x)
|
||||
d = 0
|
||||
while i != int(i):
|
||||
result += digits[int(i * base % base)]
|
||||
i = i * base
|
||||
d += 1
|
||||
if d >= 8:
|
||||
break
|
||||
return result
|
||||
|
||||
|
||||
def calcSyndicationToken(idStr):
|
||||
id = int(idStr) / 1000000000000000 * math.pi
|
||||
o = baseConversion(x=id, base=int(math.pow(6, 2)))
|
||||
c = o.replace('0', '').replace('.', '')
|
||||
if c == '':
|
||||
c = '0'
|
||||
return c
|
||||
|
||||
def generate_transaction_id(method: str, path: str) -> str:
|
||||
return "?" # not implemented
|
Reference in New Issue
Block a user