@@ -109,6 +109,7 @@ def format_output_result_search_content(
109109 search_term = search_term ,
110110 search_results_total = len (result ),
111111 search_results_displayed = count ,
112+ hint = "Astuce : ctrl+clic sur le titre pour ouvrir le contenu" ,
112113 )
113114
114115 table = Table (
@@ -149,6 +150,7 @@ def format_output_result_search_image(
149150 search_term : Optional [str ] = None ,
150151 format_type : Optional [str ] = None ,
151152 count : int = 5 ,
153+ search_filter_type : Optional [str ] = None ,
152154) -> Union [list [dict ], Table ]:
153155 """Format result according to output option.
154156
@@ -162,9 +164,17 @@ def format_output_result_search_image(
162164 str: formatted result ready to print
163165 """
164166 if format_type == "table" :
167+ titre = add_search_criteria_as_str (
168+ in_txt = "Recherche dans les images" ,
169+ search_term = search_term ,
170+ search_filter_type = search_filter_type ,
171+ search_results_total = len (result ),
172+ search_results_displayed = count ,
173+ hint = "Astuce : ctrl+clic sur le nom pour ouvrir l'image" ,
174+ )
175+
165176 table = Table (
166- title = f"Recherche d'images - { len (result )} résultats "
167- f"avec le terme : { search_term } \n (ctrl+clic sur le nom pour ouvrir l'image)" ,
177+ title = titre ,
168178 show_lines = True ,
169179 highlight = True ,
170180 caption = f"{ __title__ } { __version__ } " ,
@@ -204,21 +214,23 @@ def format_output_result_search_image(
204214@lru_cache
205215def add_search_criteria_as_str (
206216 in_txt : str ,
207- search_filter_dates : tuple ,
217+ search_filter_dates : Optional [ tuple ] = None ,
208218 search_results_total : Optional [int ] = None ,
209219 search_results_displayed : Optional [int ] = None ,
210220 search_term : Optional [str ] = None ,
211221 search_filter_type : Optional [str ] = None ,
222+ hint : Optional [str ] = None ,
212223) -> str :
213224 """Prettify a title with search criterias.
214225
215226 Args:
216227 in_txt: initial title text
217228 search_filter_dates: tuple of dates used to filter search
218229 search_results_total: total of results of search. Defaults to None.
219- search_results_displayed: totla of results to display. Defaults to None.
230+ search_results_displayed: total of results to display. Defaults to None.
220231 search_term: search terms. Defaults to None.
221232 search_filter_type: search filter type. Defaults to None.
233+ hint: optional short hint text to display before the table. Defaults to None.
222234
223235 Returns:
224236 formatted title
@@ -229,15 +241,24 @@ def add_search_criteria_as_str(
229241 if search_term :
230242 in_txt += f" avec le terme : { search_term } "
231243
232- if any ([search_filter_dates [0 ], search_filter_dates [1 ], search_filter_type ]):
244+ if any (
245+ [
246+ isinstance (search_filter_dates , tuple ) and search_filter_dates [0 ],
247+ isinstance (search_filter_dates , tuple ) and search_filter_dates [1 ],
248+ search_filter_type ,
249+ ],
250+ ):
233251 in_txt += "\n Filtres : "
234252 if search_filter_type :
235253 in_txt += f"de type { search_filter_type } , "
236- if search_filter_dates [0 ]:
254+ if isinstance ( search_filter_dates , tuple ) and search_filter_dates [0 ]:
237255 in_txt += f"plus récents que { search_filter_dates [0 ]:%d %B %Y} , "
238- if search_filter_dates [1 ]:
256+ if isinstance ( search_filter_dates , tuple ) and search_filter_dates [1 ]:
239257 in_txt += f"plus anciens que { search_filter_dates [1 ]:%d %B %Y} "
240258 else :
241- in_txt += "Aucun filtre de recherche appliqué."
259+ in_txt += "\n Aucun filtre de recherche appliqué."
260+
261+ if hint :
262+ in_txt += f"\n { hint } "
242263
243264 return in_txt
0 commit comments