Add YAPF style + ignore, and format tracked Python files
This commit is contained in:
@@ -88,7 +88,8 @@ class Get_Metadata(Cmdlet):
|
||||
url: list[str],
|
||||
hash_value: Optional[str],
|
||||
pages: Optional[int] = None,
|
||||
) -> Dict[str, Any]:
|
||||
) -> Dict[str,
|
||||
Any]:
|
||||
"""Build a table row dict with metadata fields."""
|
||||
size_mb = None
|
||||
size_int: Optional[int] = None
|
||||
@@ -114,13 +115,20 @@ class Get_Metadata(Cmdlet):
|
||||
duration_value = str(pages_int) if pages_int is not None else ""
|
||||
|
||||
columns = [
|
||||
("Title", title or ""),
|
||||
("Hash", hash_value or ""),
|
||||
("MIME", mime or ""),
|
||||
("Size(MB)", str(size_mb) if size_mb is not None else ""),
|
||||
(duration_label, duration_value),
|
||||
("Imported", imported_label),
|
||||
("Store", store or ""),
|
||||
("Title",
|
||||
title or ""),
|
||||
("Hash",
|
||||
hash_value or ""),
|
||||
("MIME",
|
||||
mime or ""),
|
||||
("Size(MB)",
|
||||
str(size_mb) if size_mb is not None else ""),
|
||||
(duration_label,
|
||||
duration_value),
|
||||
("Imported",
|
||||
imported_label),
|
||||
("Store",
|
||||
store or ""),
|
||||
]
|
||||
|
||||
return {
|
||||
@@ -142,7 +150,8 @@ class Get_Metadata(Cmdlet):
|
||||
def _add_table_body_row(table: ResultTable, row: Dict[str, Any]) -> None:
|
||||
"""Add a single row to the ResultTable using the prepared columns."""
|
||||
columns = row.get("columns") if isinstance(row, dict) else None
|
||||
lookup: Dict[str, Any] = {}
|
||||
lookup: Dict[str,
|
||||
Any] = {}
|
||||
if isinstance(columns, list):
|
||||
for col in columns:
|
||||
if isinstance(col, tuple) and len(col) == 2:
|
||||
@@ -220,7 +229,9 @@ class Get_Metadata(Cmdlet):
|
||||
duration_seconds = metadata.get("duration_seconds")
|
||||
if duration_seconds is None:
|
||||
duration_seconds = metadata.get("length")
|
||||
if duration_seconds is None and isinstance(metadata.get("duration_ms"), (int, float)):
|
||||
if duration_seconds is None and isinstance(metadata.get("duration_ms"),
|
||||
(int,
|
||||
float)):
|
||||
try:
|
||||
duration_seconds = float(metadata["duration_ms"]) / 1000.0
|
||||
except Exception:
|
||||
@@ -234,7 +245,8 @@ class Get_Metadata(Cmdlet):
|
||||
except ValueError:
|
||||
if ":" in s:
|
||||
parts = [p.strip() for p in s.split(":") if p.strip()]
|
||||
if len(parts) in {2, 3} and all(p.isdigit() for p in parts):
|
||||
if len(parts) in {2,
|
||||
3} and all(p.isdigit() for p in parts):
|
||||
nums = [int(p) for p in parts]
|
||||
if len(nums) == 2:
|
||||
duration_seconds = float(nums[0] * 60 + nums[1])
|
||||
@@ -261,7 +273,8 @@ class Get_Metadata(Cmdlet):
|
||||
row = self._build_table_row(
|
||||
title=title,
|
||||
store=storage_source,
|
||||
path=metadata.get("path", ""),
|
||||
path=metadata.get("path",
|
||||
""),
|
||||
mime=mime_type,
|
||||
size_bytes=file_size,
|
||||
dur_seconds=duration_seconds,
|
||||
@@ -272,7 +285,10 @@ class Get_Metadata(Cmdlet):
|
||||
)
|
||||
|
||||
table_title = f"get-metadata: {title}" if title else "get-metadata"
|
||||
table = ResultTable(table_title).init_command(table_title, "get-metadata", list(args))
|
||||
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