# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2010-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2010-2021 CEA/DEN, EDF R&D, OPEN CASCADE
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
"_typemap",
"_rangemap",
"_defaultmap",
- "_voidmap"
+ "_voidmap",
]
## This class is a placeholder for modeling data. An object based on this class
# Default initialization (if any)
if defaultmap is not None:
self._defaultmap.update(defaultmap)
- for name in list(self._defaultmap.keys()):
+ for name in self._defaultmap:
self.__setattr__(name,self._defaultmap[name])
## %A None argument means that no entry is created in the associated maps.
- def addAttribute(self, name, type=None, range=None, default=None, void=None):
+ def addAttribute(self, name, a_type=None, a_range=None, default=None, void=None):
"""
A None argument means that no entry is created in the associated maps.
"""
- self._typemap[name] = type
+ self._typemap[name] = a_type
- if range is not None:
- self._rangemap[name] = range
+ if a_range is not None:
+ self._rangemap[name] = a_range
if void is not None:
self._voidmap[name] = void
def __setattr__(self, name, val):
if name in UNCHECKED_ATTRIBUTES:
- self.__dict__[name] = val
+ object.__setattr__(self, name, val)
return
#__GBO_DEBUG_
if name == "_typemap":
print("WARNING WARNING WARNING : changing value of _typemap by ",val)
- if name not in list(self._typemap.keys()):
+ if name not in self._typemap:
raise DevelException("The class "+str(self.__class__)+" has no attribute "+str(name))
if val is None:
def __getattribute__(self, name):
if name in UNCHECKED_ATTRIBUTES:
- return self.__dict__[name]
+ return object.__getattribute__(self, name)
- if name not in list(self._typemap.keys()):
- raise DevelException("The class "+str(self.__class__)+" has no attribute "+str(name))
+ if name in DataModeler.__dict__:
+ return object.__getattribute__(self, name)
+
+ if name not in self._typemap:
+ raise DevelException("The class has no attribute "+str(name))
# The attribute coulb be requested while it has not been created yet (for
# example if we did't call the setter before).
- if name not in self.__dict__:
+ if name not in self.__dict__.keys():
return None
-
- return self.__dict__[name]
+
+ return object.__getattribute__(self, name)
def __isNotValidType(self, name, val):
isNotValid = (
ref_value = 1.3
data.addAttribute(
name = "myAttr",
- type = TypeDouble,
- range = None,
+ a_type = TypeDouble,
+ a_range = None,
default = ref_value,
void = False)