Esempio n. 1
0
 def to_pf_name(self, parent_namespace, key):
     """Helper method returning the key to use for Parflow on
     a given field key. This allows handling of differences
     between what can be defined in Python vs Parflow key.
     """
     start = f'{parent_namespace}.' if parent_namespace else ''
     return start + remove_prefix(key, self._prefix_)
Esempio n. 2
0
    def to_pf_name(self, parent_namespace, key):
        """
        Helper method returning the key to use for Parflow on a given
        field key. This allows us to handle differences between what
        can be defined in Python vs Parflow key.
        """
        value = self.__dict__[key]
        prefix = ''
        if isinstance(value, PFDBObj):
            if value._prefix_ and key.startswith(value._prefix_):
                prefix = value._prefix_
        elif key in self._details_:
            detail = self._details_[key]
            if '_prefix_' in detail:
                prefix = detail['_prefix_']

        start = f'{parent_namespace}.' if parent_namespace else ''
        return start + remove_prefix(key, prefix)
Esempio n. 3
0
    def full_name(self):
        """
        Helper method returning the full name of a given ParFlow key.
        """
        full_path = []
        current_location = self
        count = 0
        while current_location._parent_ is not None:
            count += 1
            parent = current_location._parent_
            for name in parent.__dict__:
                value = parent.__dict__[name]
                if value is current_location:
                    prefix = current_location._prefix_
                    full_path.append(remove_prefix(name, prefix))
            current_location = parent
            if count > len(full_path):
                return f'not found {count}: {".".join(full_path)}'

        full_path.reverse()
        return '.'.join(full_path)