You've already forked JapariArchive
fresh start
This commit is contained in:
24
helpers.py
Normal file
24
helpers.py
Normal file
@@ -0,0 +1,24 @@
|
||||
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
|
||||
Reference in New Issue
Block a user