Commit 9324c916 authored by Nic's avatar Nic
Browse files

[units] getunits: allow empty key

parent 25a89709
......@@ -504,11 +504,20 @@ class ValidatorMixin:
"""called by Base class __init__()"""
self._schemas = {}
def getunits(self, tabname, key):
def getunits(self, tabname, key=None):
"""retrieve from schema the working units. Raise KeyError the the
column is not units-aware
column is not units-aware.
if `key` is provided, the relevant units is returned (eg. "length" -> "mm")
otherwise, the whole dict is returned
return self.get(tabname, "schemas").build()["properties"][key]["units"]
props = self.get(tabname, "schemas").build()["properties"]
units = {
dim: units for dim, data in props.items() if (units := data.get("units"))
if key:
return units[key]
return units
def getrow(self, tabname, key, search_by=None):
"""retrieve a row from any tabname, eventually sorting by `search_by`"""
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment