in pyiceberg/cli/console.py [0:0]
def describe(ctx: Context, entity: Literal["name", "namespace", "table"], identifier: str) -> None:
"""Describe a namespace or a table."""
catalog, output = _catalog_and_output(ctx)
identifier_tuple = Catalog.identifier_to_tuple(identifier)
is_namespace = False
if entity in {"namespace", "any"} and len(identifier_tuple) > 0:
try:
namespace_properties = catalog.load_namespace_properties(identifier_tuple)
output.describe_properties(namespace_properties)
is_namespace = True
except NoSuchNamespaceError as exc:
if entity != "any" or len(identifier_tuple) == 1: # type: ignore
raise exc
is_table = False
if entity in {"table", "any"} and len(identifier_tuple) > 1:
try:
catalog_table = catalog.load_table(identifier)
output.describe_table(catalog_table)
is_table = True
except NoSuchTableError as exc:
if entity != "any":
raise exc
if is_namespace is False and is_table is False:
raise NoSuchTableError(f"Table or namespace does not exist: {identifier}")