From 3d79bb5131b62ee08eb71fec61cc021ffe17c325 Mon Sep 17 00:00:00 2001 From: vermeul <swen@ethz.ch> Date: Wed, 23 Oct 2019 17:27:43 +0200 Subject: [PATCH] improved __dir__ for entityTypes. validationPlugin no longer returns an object, instead, the get_validationPlugin() should be used --- pybis/src/python/pybis/entity_type.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pybis/src/python/pybis/entity_type.py b/pybis/src/python/pybis/entity_type.py index 4c0328f52f5..33088a301ad 100644 --- a/pybis/src/python/pybis/entity_type.py +++ b/pybis/src/python/pybis/entity_type.py @@ -4,7 +4,7 @@ from pandas import DataFrame from .openbis_object import OpenBisObject from .things import Things from .utils import check_datatype, split_identifier, format_timestamp, is_identifier, is_permid, nvl, extract_permid, extract_code, extract_name, VERBOSE -from .definitions import get_method_for_entity, get_type_for_entity +from .definitions import get_method_for_entity, get_type_for_entity, get_definition_for_entity class EntityType: """ EntityTypes define a variety of an entity, eg. sample, dataSet, experiment @@ -37,13 +37,21 @@ class EntityType: ] def __dir__(self): - return self._attrs() + [ + defs = get_definition_for_entity(self.entity) + attrs = [ 'get_property_assignments()', 'assign_property()', 'revoke_property()', 'move_property_to_top()', 'move_property_after()', + 'get_validationPlugin()', + 'save()', + 'delete()', ] + if self.is_new: + return attrs + defs['attrs_new'] + else: + return attrs + list(set(defs['attrs'] + defs['attrs_up'])) def __getattr__(self, name): if name in self._attrs(): @@ -177,7 +185,7 @@ class EntityType: @property - def validationPlugin(self): + def get_validationPlugin(self): """Returns a validation plugin object when called. Returns None when no validation plugin is defined. """ -- GitLab