def name(self, values): """Set name and isSetByUser property. Args: values: A name or a tuple as (name, isSetByUser) Usage: HBSrf.name = "surface_001" # or HBSrf.name = ("mySurfaceName", True) """ try: # check if user passed a tuple if isinstance(values, str): raise TypeError new_name, is_name_set_by_user = values except ValueError: # user is passing a list or tuple with one ValueError new_name = values[0] is_name_set_by_user = False # if not indicated assume it is not set by user. except TypeError: # user just passed a single value which is the name new_name = values is_name_set_by_user = False # if not indicated assume it is not set by user. finally: # set new name self._name = str(new_name) self._is_name_set_by_user = is_name_set_by_user util.check_name(self._name)
def name(self, new_name): """Set name and isSetByUser property. Args: new_name: A name. """ new_name = new_name or util.random_name() self._name = str(new_name) util.check_name(self._name)
def name(self, n): util.check_name(n) self._name = n