11# -*- coding: utf-8 -*-
22import argparse
3- from typing import Dict , List , Union
3+ from typing import Union
44
55from findex_dict import FindexDict
66from findex_redis import FindexRedis
77from findex_sqlite import FindexSQLite
88
9- from cloudproof_py .findex import MasterKey , Label , IndexedValue , Findex , utils
9+ from cloudproof_py .findex import Findex , Keyword , Label , Location , MasterKey , utils
10+ from cloudproof_py .findex .typing import IndexedValuesAndKeywords , ProgressResults
1011
1112# Simple database containing the firstname and lastname of each user.
1213# Each line has a corresponding UID: 1, 2 or 3.
@@ -36,10 +37,10 @@ def main(backend: str = "Dict"):
3637 findex_interface = FindexDict ()
3738
3839 # Create the index
39- indexed_values_and_keywords = {}
40+ indexed_values_and_keywords : IndexedValuesAndKeywords = {}
4041 for uid , keywords in data .items ():
4142 # Convert database UIDs to IndexedValue expected by Findex
42- location = IndexedValue . from_location (uid . encode ( "utf-8" ) )
43+ location = Location . from_string (uid )
4344 # This location has 2 keywords associated: the firstname and lastname
4445 indexed_values_and_keywords [location ] = keywords
4546
@@ -61,8 +62,8 @@ def main(backend: str = "Dict"):
6162 # Keywords can point to Locations but also to other Keywords, thus generating a graph.
6263
6364 # Create the alias `Joe` for `John`
64- alias_graph = {
65- IndexedValue . from_keyword ( b "John" ): ["Joe" ],
65+ alias_graph : IndexedValuesAndKeywords = {
66+ Keyword . from_string ( "John" ): ["Joe" ],
6667 }
6768 findex_interface .upsert (alias_graph , master_key , label )
6869
@@ -91,7 +92,7 @@ def main(backend: str = "Dict"):
9192
9293 print ("Search using the `progress_callback`: " )
9394
94- def echo_progress_callback (res : Dict [ str , List [ IndexedValue ]] ) -> bool :
95+ def echo_progress_callback (res : ProgressResults ) -> bool :
9596 print ("\t Partial results:" , res )
9697 return True
9798
0 commit comments