termux-websms/update.py

19 lines
490 B
Python

#!/data/data/com.termux/files/usr/bin/python3
from json import loads as json_read, dumps as json_write
from sys import argv
from os.path import isfile
from sms import SMS_Service
output = argv [1]
if isfile (output):
database = json_read (open (output).read ())
s = SMS_Service (sms_list = database)
s.update_database ()
open (output, 'w').write (json_write (s.sorted_list ()))
else:
s = SMS_Service ()
s.build_database ()
open (output, 'w').write (json_write (s.sorted_list ()))