Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if isinstance(v, pq.Quantity):
if len(v.shape):
section.create_property(name, tuple(v.magnitude))
else:
section.create_property(name, v.magnitude.item())
section.props[name].unit = str(v.dimensionality)
elif isinstance(v, datetime_types):
value, annotype = dt_to_nix(v)
prop = section.create_property(name, value)
prop.definition = annotype
elif isinstance(v, string_types):
if len(v):
section.create_property(name, v)
else:
section.create_property(name, nix.DataType.String)
elif isinstance(v, bytes):
section.create_property(name, v.decode())
elif isinstance(v, Iterable):
values = []
unit = None
definition = None
if len(v) == 0:
# NIX supports empty properties but dtype must be specified
# Defaulting to String and using definition to signify empty
# iterable as opposed to empty string
values = nix.DataType.String
definition = EMPTYANNOTATION
elif hasattr(v, "ndim") and v.ndim == 0:
values = v.item()
if isinstance(v, pq.Quantity):
unit = str(v.dimensionality)