3 # This file is under GNU General Public License 3.0
7 from sqlite3 import connect
9 from argparse import ArgumentParser
13 environ["ALLUSERSPROFILE"]
15 db_file = "/usr/local/share/pEp/system.db"
17 db_file = environ["ALLUSERSPROFILE"] + r"\pEp\system.db"
19 p = ArgumentParser(description="show trustwords instead of hex fingerprint")
20 p.add_argument('--db-path', '-d', type=str, default=db_file,
21 help='path to pEp system db (default: ' + db_file + ')')
22 p.add_argument('--lang', '-l', type=str, default="en",
23 help='use dictionary for language LANG (default: en)')
24 p.add_argument('--short', '-s', action='store_true',
25 help='display the first 5 of the trustwords')
26 p.add_argument('hex', metavar="hex", type=str, nargs='+',
27 help='hex values of fingerprint')
31 c = connect(args.db_path).cursor()
32 hex_string = sub(r"\W", "", "".join(args.hex))
35 n = min(20, len(s)) if args.short else len(s)
36 for i in range(0, n, 4):
41 for arg in hex_word(hex_string):
42 c.execute("select word from wordlist where id = {} and lang = lower('{}')".format(
43 str(int(arg, 16)), args.lang))
44 r.append(c.fetchall()[0][0])