Mark token source of truth in scan output
This commit is contained in:
@@ -693,14 +693,22 @@ def fit_cell(value: str, width: int) -> str:
|
||||
|
||||
def print_token_item_table(rows: list[dict[str, str]]) -> None:
|
||||
print("items")
|
||||
print(" ".join(fit_cell(name, width) for name, width in TOKEN_ITEM_COLUMNS))
|
||||
print(" ".join("-" * width for _, width in TOKEN_ITEM_COLUMNS))
|
||||
print(" ".join(fit_cell(name, width) for name, width in TOKEN_ITEM_COLUMNS).rstrip())
|
||||
print(" ".join("-" * width for _, width in TOKEN_ITEM_COLUMNS).rstrip())
|
||||
for row in rows:
|
||||
print(" ".join(fit_cell(row.get(name, ""), width) for name, width in TOKEN_ITEM_COLUMNS))
|
||||
print(" ".join(fit_cell(row.get(name, ""), width) for name, width in TOKEN_ITEM_COLUMNS).rstrip())
|
||||
|
||||
|
||||
def sync_flag(status_name: str) -> str:
|
||||
return "yes" if status_name == "in_sync" else "no"
|
||||
def sync_mark(status_name: str, source: str) -> str:
|
||||
if status_name == "diverged":
|
||||
return "!"
|
||||
if status_name in {"in_sync", "store_only", "store_ahead"}:
|
||||
truth_source = "tokens.json"
|
||||
elif status_name in {"repo_only", "repo_ahead"}:
|
||||
truth_source = "repo"
|
||||
else:
|
||||
truth_source = ""
|
||||
return "*" if source == truth_source else ""
|
||||
|
||||
|
||||
def users_label(server_entry: dict | None) -> str:
|
||||
@@ -758,7 +766,6 @@ def print_token_item_rows(
|
||||
endpoint_values = endpoint_column_values(endpoint, repo_entry, store_entry)
|
||||
repo_users_label = users_label(repo_entry)
|
||||
store_users_label = users_label(store_entry)
|
||||
sync_value = sync_flag(status_name)
|
||||
|
||||
repo_rows = scan_rows_by_endpoint.get(endpoint, [])
|
||||
if repo_rows:
|
||||
@@ -774,7 +781,7 @@ def print_token_item_rows(
|
||||
"repo_user": row["user"],
|
||||
"store_user": store_users_label,
|
||||
"token": "yes" if token_label else "no",
|
||||
"sync": sync_value,
|
||||
"sync": sync_mark(status_name, "repo"),
|
||||
}
|
||||
)
|
||||
elif repo_entry is None:
|
||||
@@ -786,7 +793,7 @@ def print_token_item_rows(
|
||||
"credential": "missing",
|
||||
"store_user": store_users_label,
|
||||
"token": "no",
|
||||
"sync": sync_value,
|
||||
"sync": sync_mark(status_name, "repo"),
|
||||
}
|
||||
)
|
||||
else:
|
||||
@@ -806,7 +813,7 @@ def print_token_item_rows(
|
||||
"repo_user": user_name,
|
||||
"store_user": store_users_label,
|
||||
"token": "yes" if token_label else "no",
|
||||
"sync": sync_value,
|
||||
"sync": sync_mark(status_name, "repo"),
|
||||
}
|
||||
)
|
||||
else:
|
||||
@@ -819,7 +826,7 @@ def print_token_item_rows(
|
||||
"credential": repo_kind,
|
||||
"store_user": store_users_label,
|
||||
"token": "yes" if repo_result == "present" else "no",
|
||||
"sync": sync_value,
|
||||
"sync": sync_mark(status_name, "repo"),
|
||||
}
|
||||
)
|
||||
|
||||
@@ -832,7 +839,7 @@ def print_token_item_rows(
|
||||
"credential": "missing",
|
||||
"repo_user": repo_users_label,
|
||||
"token": "no",
|
||||
"sync": sync_value,
|
||||
"sync": sync_mark(status_name, "tokens.json"),
|
||||
}
|
||||
)
|
||||
continue
|
||||
@@ -847,7 +854,7 @@ def print_token_item_rows(
|
||||
"credential": "store",
|
||||
"repo_user": repo_users_label,
|
||||
"token": "no",
|
||||
"sync": sync_value,
|
||||
"sync": sync_mark(status_name, "tokens.json"),
|
||||
}
|
||||
)
|
||||
continue
|
||||
@@ -863,7 +870,7 @@ def print_token_item_rows(
|
||||
"repo_user": repo_users_label,
|
||||
"store_user": user_name,
|
||||
"token": "yes" if token_name else "no",
|
||||
"sync": sync_value,
|
||||
"sync": sync_mark(status_name, "tokens.json"),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user