Bases: ABC
The main parent class for your (Tables, Columns, Measures, Partitions, etc.).
Notice the magic methods. __rich_repr__()
starts the baseline for displaying your model.
It uses the amazing rich
python package and
builds your display from the self._display
.
__getattr__()
will check in self._object
, if unable to find anything in self
.
This will let you pull properties from the main .Net class.
Source code in pytabular/object.py
| class PyObject(ABC):
"""The main parent class for your (Tables, Columns, Measures, Partitions, etc.).
Notice the magic methods. `__rich_repr__()` starts the baseline for displaying your model.
It uses the amazing `rich` python package and
builds your display from the `self._display`.
`__getattr__()` will check in `self._object`, if unable to find anything in `self`.
This will let you pull properties from the main .Net class.
"""
def __init__(self, object) -> None:
"""Init to create your PyObject.
This will take the `object` and
set as an attribute to the `self._object`.
You can use that if you want to interact directly with the .Net object.
It will also begin to build out a default `rich` table display.
Args:
object (.Net object): A .Net object.
"""
self._object = object
self._display = Table(title=self.Name)
self._display.add_column(
"Properties", justify="right", style="cyan", no_wrap=True
)
self._display.add_column("", justify="left", style="magenta", no_wrap=False)
self._display.add_row("Name", self.Name)
self._display.add_row("ObjectType", str(self.ObjectType))
if str(self.ObjectType) not in "Model":
self._display.add_row("ParentName", self.Parent.Name)
self._display.add_row(
"ParentObjectType",
str(self.Parent.ObjectType),
end_section=True,
)
def __rich_repr__(self) -> str:
"""See [Rich Repr](https://rich.readthedocs.io/en/stable/pretty.html#rich-repr-protocol)."""
Console().print(self._display)
def __getattr__(self, attr):
"""Searches in `self._object`."""
return getattr(self._object, attr)
|
__init__(object)
Init to create your PyObject.
This will take the object
and
set as an attribute to the self._object
.
You can use that if you want to interact directly with the .Net object.
It will also begin to build out a default rich
table display.
Parameters:
Name |
Type |
Description |
Default |
object |
.Net object
|
|
required
|
Source code in pytabular/object.py
| def __init__(self, object) -> None:
"""Init to create your PyObject.
This will take the `object` and
set as an attribute to the `self._object`.
You can use that if you want to interact directly with the .Net object.
It will also begin to build out a default `rich` table display.
Args:
object (.Net object): A .Net object.
"""
self._object = object
self._display = Table(title=self.Name)
self._display.add_column(
"Properties", justify="right", style="cyan", no_wrap=True
)
self._display.add_column("", justify="left", style="magenta", no_wrap=False)
self._display.add_row("Name", self.Name)
self._display.add_row("ObjectType", str(self.ObjectType))
if str(self.ObjectType) not in "Model":
self._display.add_row("ParentName", self.Parent.Name)
self._display.add_row(
"ParentObjectType",
str(self.Parent.ObjectType),
end_section=True,
)
|
__rich_repr__()
See Rich Repr.
Source code in pytabular/object.py
| def __rich_repr__(self) -> str:
"""See [Rich Repr](https://rich.readthedocs.io/en/stable/pretty.html#rich-repr-protocol)."""
Console().print(self._display)
|
__getattr__(attr)
Searches in self._object
.
Source code in pytabular/object.py
| def __getattr__(self, attr):
"""Searches in `self._object`."""
return getattr(self._object, attr)
|