diff --git a/src/caosdb/common/models.py b/src/caosdb/common/models.py index 5ab31f482454a408c8b692e24adea4099a28f6cc..adbd9dc3a9039999f0124f0a6fe046ee2a9dd44f 100644 --- a/src/caosdb/common/models.py +++ b/src/caosdb/common/models.py @@ -517,6 +517,22 @@ class Entity(object): w_parent._get_parent_recursively(all_parents) def get_parent(self, key): + """Return the first parent matching the key or None if no match exists. + + Parameters + --------- + key : int or Enity or str + The id, Entity, or name of the parent that should be + returned. If an Entity is given, its id or its name is + used to find a matching parent. + + Returns + ------- + parent : Entity + The first parent of this entity that matches the given id, + entity, or name. + + """ if isinstance(key, int): for p in self.parents: if p.id is not None and int(p.id) == int(key): @@ -2780,7 +2796,8 @@ class Container(list): for f in listdir(x): if isdir(x + '/' + f): - part = MultipartParam(name=hex(randint(0, sys.maxsize)), value="") + part = MultipartParam( + name=hex(randint(0, sys.maxsize)), value="") part.filename = upload + \ ('/' + d + '/' if d is not None else '/') + f + '/' ret.extend(Container._dir_to_http_parts(