From 056d15af93a3fd3caa7b2d3f67a74cc9a5dc5599 Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Fri, 26 Jun 2020 13:58:14 +0200
Subject: [PATCH] CLEANUP

---
 src/caosdb/common/models.py | 63 ++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 40 deletions(-)

diff --git a/src/caosdb/common/models.py b/src/caosdb/common/models.py
index 2dc864cb..4a40e8cf 100644
--- a/src/caosdb/common/models.py
+++ b/src/caosdb/common/models.py
@@ -609,59 +609,48 @@ class Entity(object):
 
         Parameters
         ----------
-        properties : str or tuple of str
+        *properties : str or tuple of str
             A list of property names, e.g. `"height", "width"` or a list of
             tuples of properties, e.g. `("window", "height"), ("window",
             "width")`.
 
-        Raises
-        ------
-        TypeError :
-            If the properties parameter contains anything else than str or
-            tuple of str elements.
-
         Returns
         -------
         row : tuple
-            A row-like representation of the entities properties.
+            A row-like representation of the entity's properties.
         """
-        selectors = properties
+        properties = properties
         row = tuple()
-        for sel in selectors:
+        for selector in properties:
             val = None
-            if isinstance(sel, str):
-                if hasattr(self, sel.lower()):
-                    val = getattr(self, sel.lower())
-                else:
-                    prop = self.get_property(sel)
-                    if prop is not None:
-                        val = prop.value
-
-            elif isinstance(sel, (tuple, list)) and len(sel) > 0:
+            if isinstance(selector, (tuple, list)) and len(selector) > 0:
                 val = None
                 ref = self
 
                 # the while loop walks through the re
-                while len(sel) > 1 and isinstance(ref, Entity):
-                    prop = ref.get_property(sel[0])
+                while len(selector) > 1 and isinstance(ref, Entity):
+                    prop = ref.get_property(selector[0])
                     if prop is not None and isinstance(prop.value, Entity):
                         ref = prop.value
                     else:
                         # non-entity value -
                         ref = prop
-                    sel = sel[1:]
-                if len(sel) == 1 and isinstance(ref, Entity):
-                    if (hasattr(sel[0], "lower")
-                            and hasattr(ref, sel[0].lower())):
-                        val = getattr(ref, sel[0].lower())
+                    selector = selector[1:]
+                if len(selector) == 1 and isinstance(ref, Entity):
+                    if (hasattr(selector[0], "lower")
+                            and hasattr(ref, selector[0].lower())):
+                        val = getattr(ref, selector[0].lower())
                     else:
-                        prop = ref.get_property(sel[0])
+                        prop = ref.get_property(selector[0])
                         if prop is not None:
                             val = prop.value
             else:
-                raise TypeError("The elements of the parameter `properties` "
-                                "must contain str or non-empty tuples of str."
-                                " Was {}.".format(sel))
+                if hasattr(self, selector.lower()):
+                    val = getattr(self, selector.lower())
+                else:
+                    prop = self.get_property(selector)
+                    if prop is not None:
+                        val = prop.value
             if isinstance(val, Entity):
                 val = val.id if val.id is not None else val.name
             row += (val,)
@@ -3202,16 +3191,10 @@ class Container(list):
 
         Parameters
         ----------
-        properties : list
-            A list of property names, e.g. `["height", "width"]` or a list of
-            tuples of properties, e.g. `[("window", "height"), ("window",
-            "width")]`.
-
-        Raises
-        ------
-        TypeError :
-            If the properties parameter contains anything else than str or
-            tuple of str elements.
+        *properties : str or tuple of str
+            A list of property names, e.g. `"height", "width"` or a list of
+            tuples of properties, e.g. `("window", "height"), ("window",
+            "width")`.
 
         Returns
         -------
-- 
GitLab