jkj
This commit is contained in:
@@ -7,7 +7,13 @@ import sys
|
||||
from SYS.logger import log
|
||||
from pathlib import Path
|
||||
|
||||
from ._shared import Cmdlet, CmdletArg, SharedArgs, parse_cmdlet_args, get_field
|
||||
from . import _shared as sh
|
||||
|
||||
Cmdlet = sh.Cmdlet
|
||||
CmdletArg = sh.CmdletArg
|
||||
SharedArgs = sh.SharedArgs
|
||||
parse_cmdlet_args = sh.parse_cmdlet_args
|
||||
get_field = sh.get_field
|
||||
import pipeline as ctx
|
||||
from result_table import ResultTable
|
||||
|
||||
@@ -74,9 +80,15 @@ class Get_Metadata(Cmdlet):
|
||||
hash_value: Optional[str], pages: Optional[int] = None) -> Dict[str, Any]:
|
||||
"""Build a table row dict with metadata fields."""
|
||||
size_mb = None
|
||||
if isinstance(size_bytes, int):
|
||||
size_int: Optional[int] = None
|
||||
if size_bytes is not None:
|
||||
try:
|
||||
size_mb = int(size_bytes / (1024 * 1024))
|
||||
size_int = int(size_bytes)
|
||||
except Exception:
|
||||
size_int = None
|
||||
if isinstance(size_int, int):
|
||||
try:
|
||||
size_mb = int(size_int / (1024 * 1024))
|
||||
except Exception:
|
||||
size_mb = None
|
||||
|
||||
@@ -105,7 +117,7 @@ class Get_Metadata(Cmdlet):
|
||||
"path": path,
|
||||
"store": store,
|
||||
"mime": mime,
|
||||
"size_bytes": size_bytes,
|
||||
"size_bytes": size_int,
|
||||
"duration_seconds": dur_int,
|
||||
"pages": pages_int,
|
||||
"imported_ts": imported_ts,
|
||||
@@ -237,8 +249,8 @@ class Get_Metadata(Cmdlet):
|
||||
pages=pages,
|
||||
)
|
||||
|
||||
table_title = title
|
||||
table = ResultTable(table_title).init_command("get-metadata", list(args))
|
||||
table_title = f"get-metadata: {title}" if title else "get-metadata"
|
||||
table = ResultTable(table_title).init_command(table_title, "get-metadata", list(args))
|
||||
self._add_table_body_row(table, row)
|
||||
ctx.set_last_result_table_overlay(table, [row], row)
|
||||
ctx.emit(row)
|
||||
|
||||
Reference in New Issue
Block a user