Revert "search-file: use ResultTable adapter when provider registers adapter; build column-aware rows and selection args"
This reverts commit 60cc8e1261.
This commit is contained in:
@@ -330,78 +330,6 @@ class search_file(Cmdlet):
|
||||
db.update_worker_status(worker_id, "completed")
|
||||
return 0
|
||||
|
||||
# If a ResultTable adapter is registered for this provider, use it to
|
||||
# build a column-aware table view; fall back to legacy behavior otherwise.
|
||||
try:
|
||||
from SYS.result_table_adapters import get_provider as _get_rprov
|
||||
from SYS.result_table_renderers import render_to_console as _render_to_console
|
||||
|
||||
try:
|
||||
_rprov = _get_rprov(provider_lower)
|
||||
except Exception:
|
||||
_rprov = None
|
||||
except Exception:
|
||||
_rprov = None
|
||||
|
||||
if _rprov is not None:
|
||||
# Adapt provider-specific results into ResultModel instances.
|
||||
try:
|
||||
adapted_rows = list(_rprov.adapter(results))
|
||||
except Exception:
|
||||
adapted_rows = []
|
||||
|
||||
cols = _rprov.get_columns(adapted_rows)
|
||||
|
||||
# Build table rows from adapted models using ColumnSpec headers and extractor
|
||||
for rm in adapted_rows:
|
||||
# Build columns list as (header, value)
|
||||
columns_for_row = []
|
||||
for c in cols:
|
||||
try:
|
||||
raw = c.extractor(rm)
|
||||
except Exception:
|
||||
raw = None
|
||||
if c.format_fn:
|
||||
try:
|
||||
val = c.format_fn(raw)
|
||||
except Exception:
|
||||
val = raw
|
||||
else:
|
||||
val = raw
|
||||
columns_for_row.append((c.header, val))
|
||||
|
||||
item_dict = {
|
||||
"title": getattr(rm, "title", None) or "",
|
||||
"path": getattr(rm, "path", None),
|
||||
"ext": getattr(rm, "ext", None),
|
||||
"size_bytes": getattr(rm, "size_bytes", None),
|
||||
"metadata": getattr(rm, "metadata", None) or {},
|
||||
"source": getattr(rm, "source", None) or provider_name,
|
||||
"columns": columns_for_row,
|
||||
"_selection_args": list(_rprov.selection_args(rm) or []),
|
||||
"table": table_type,
|
||||
}
|
||||
|
||||
row_index = len(table.rows)
|
||||
table.add_result(item_dict)
|
||||
results_list.append(item_dict)
|
||||
ctx.emit(item_dict)
|
||||
|
||||
# Render via the normal ResultTable pipeline (legacy rendering will print columns)
|
||||
if refresh_mode:
|
||||
ctx.set_last_result_table_preserve_history(table, results_list)
|
||||
else:
|
||||
ctx.set_last_result_table(table, results_list)
|
||||
|
||||
ctx.set_current_stage_table(table)
|
||||
|
||||
if db is not None:
|
||||
db.append_worker_stdout(worker_id, json.dumps(results_list, indent=2))
|
||||
db.update_worker_status(worker_id, "completed")
|
||||
|
||||
return 0
|
||||
|
||||
# Fallback (legacy) behavior for providers without a ResultTable adapter
|
||||
for search_result in results:
|
||||
item_dict = (
|
||||
search_result.to_dict()
|
||||
|
||||
Reference in New Issue
Block a user