def test_str(self): table = get_default_table(["Parameter", "Value"]) table.border = False table.add_row(["readonly", "1"]) table.add_row(["state", Device.NA]) compare(str(self.device), table.get_string())
def __str__(self): table = get_default_table(["Parameter", "Value"]) table.border = False readable = (param for param in self if param.is_readable()) for param in readable: table.add_row([param.name, str(param.get().result())]) return table.get_string(sortby="Parameter")
def pdoc(): """Render process documentation.""" field_names = ["Name", "Description"] table = get_default_table(field_names) for name, process in _current_instances(Process): table.add_row([name, inspect.getdoc(process)]) print(table.get_string())
def ddoc(): """Render device documentation.""" field_names = ["Name", "Description", "Parameters"] table = get_default_table(field_names) for name, device in _current_instances(Device): doc = _get_param_description_table(device) table.add_row([name, inspect.getdoc(device), doc]) print(table.get_string())
def dstate(): """Render device state in a table.""" field_names = ["Name", "Parameters"] table = get_default_table(field_names) for name, device in _current_instances(Device): values = _get_param_value_table(device) table.add_row([name, values]) print(table.get_string())
def _get_param_value_table(motor): field_names = ["Name", "Value"] table = get_default_table(field_names) table.border = False table.header = False for param in motor: if param.is_readable(): table.add_row([param.name, str(param.get().result())]) return table.get_string()
def _get_param_description_table(motor): field_names = ["Name", "Access", "Unit", "Description"] table = get_default_table(field_names) table.border = False table.header = True def _access(parameter): result = 'r' if parameter.is_readable() else '' result += 'w' if parameter.is_writable() else '' return result for param in motor: dims = param.unit.dimensionality.string if param.unit else None row = [param.name, _access(param), str(dims), inspect.getdoc(param)] table.add_row(row) return table.get_string()