Beispiel #1
0
 def __dir__(self):
     """
     >>> from hydpy import dummies
     >>> from hydpy import print_values
     >>> print_values(dir(dummies.v2af))
     eqb, eqd1, eqd2, eqi1, eqi2, file1, file2, filenames, get_filename,
     remove, types, variables
     """
     return (objecttools.dir_(self) + self.filenames +
             [objecttools.instancename(type_) for type_ in self.types])
Beispiel #2
0
 def __getitem__(self, key):
     _key = key
     try:
         if inspect.isclass(key):
             if issubclass(key, BaseMask):
                 key = objecttools.instancename(key)
         elif isinstance(key, BaseMask):
             if key in self:
                 return key
             raise RuntimeError(
                 'The key does not define an available mask.')
         if isinstance(key, str):
             try:
                 return getattr(self, key.lower())
             except AttributeError:
                 raise RuntimeError(
                     'The key does not define an available mask.')
         raise TypeError(
             'The given key is neither a `string` a `mask` type.')
     except BaseException:
         objecttools.augment_excmessage(
             f'While trying to retrieve a mask based on key `{repr(_key)}`')
Beispiel #3
0
def _objectname(self):
    return getattr(self, 'name', objecttools.instancename(self))
Beispiel #4
0
 def __iter__(self):
     for cls in self.CLASSES:
         name = objecttools.instancename(cls)
         yield getattr(self, name)
Beispiel #5
0
 def __init__(self, model):
     self.model = model
     for cls in self.CLASSES:
         setattr(self, objecttools.instancename(cls), cls)