You've already forked JapariArchive
24 lines
629 B
Python
24 lines
629 B
Python
from Database.x_classes import PostRating
|
|
|
|
|
|
def twos_complement(hexstr, bits):
|
|
value = int(hexstr,16) #convert hexadecimal to integer
|
|
|
|
#convert from unsigned number to signed number with "bits" bits
|
|
if value & (1 << (bits-1)):
|
|
value -= 1 << bits
|
|
return value
|
|
|
|
def get_rating_value(rating):
|
|
"for deciding final post rating"
|
|
match rating:
|
|
case PostRating.Explicit:
|
|
return 4
|
|
case PostRating.Questionable:
|
|
return 3
|
|
case PostRating.Sensitive:
|
|
return 2
|
|
case PostRating.General:
|
|
return 1
|
|
case _:
|
|
return 0 |