コード例 #1
0
    def fill(self, values):
        """Implementation of form filling.

        This method goes through all widgets defined on this view one by one and calls their
        ``fill`` methods appropriately.

        ``None`` values will be ignored.

        It will log any skipped fill items.
        It will log a warning if you pass any extra values for filling.

        It will store the fill value in :py:attr:`last_fill_data`. The data will be "deflattened" to
        ensure uniformity.

        Args:
            values: A dictionary of ``widget_name: value_to_fill``.

        Returns:
            :py:class:`bool` if the fill changed any value.
        """
        changed = []
        values = deflatten_dict(values)
        self.last_fill_data = values
        changed.append(self.before_fill(values))
        # there are some views like ConditionalView which are dynamically updated
        # it is necessary to pass current view at least for
        # name -> widget resolution right before fill and for logging
        self.fill_strategy.context = FillContext(parent=self)
        changed.append(self.fill_strategy.do_fill(values))
        a_fill = self.after_fill(any(changed))
        return a_fill if isinstance(a_fill, bool) else any(changed)
コード例 #2
0
    def fill(self, fill_data):
        values = deflatten_dict(fill_data)
        was_change = False
        self.before_fill(values)
        for key, value in values.items():
            widget = self.fields(key)
            if value is None:
                self.logger.debug('Skipping fill of %r because value was None', key)
                continue
            try:
                if widget.fill(value):
                    was_change = True
            except NotImplementedError:
                continue

        self.after_fill(was_change)
        return was_change
コード例 #3
0
ファイル: ui.py プロジェクト: akarol/cfme_tests
    def fill(self, fill_data):
        values = deflatten_dict(fill_data)
        was_change = False
        self.before_fill(values)
        for key, value in values.items():
            widget = self.fields(key)
            if value is None:
                self.logger.debug('Skipping fill of %r because value was None', key)
                continue
            try:
                if widget.fill(value):
                    was_change = True
            except NotImplementedError:
                continue

        self.after_fill(was_change)
        return was_change
コード例 #4
0
ファイル: base.py プロジェクト: izapolsk/widgetastic.core
    def fill(self, values):
        """Implementation of form filling.

        This method goes through all widgets defined on this view one by one and calls their
        ``fill`` methods appropriately.

        ``None`` values will be ignored.

        It will log any skipped fill items.
        It will log a warning if you pass any extra values for filling.

        It will store the fill value in :py:attr:`last_fill_data`. The data will be "deflattened" to
        ensure uniformity.

        Args:
            values: A dictionary of ``widget_name: value_to_fill``.

        Returns:
            :py:class:`bool` if the fill changed any value.
        """
        changed = []
        values = deflatten_dict(values)
        self.last_fill_data = values
        changed.append(self.before_fill(values))

        extra_keys = set(values.keys()) - set(self.widget_names)
        if extra_keys:
            self.logger.warning(
                'Extra values that have no corresponding fill fields passed: %s',
                ', '.join(extra_keys))
        to_fill = [(getattr(self, n), values[n]) for n in self.widget_names
                   if n in values and values[n] is not None]
        changed.append(self.fill_strategy.do_fill(to_fill))

        a_fill = self.after_fill(any(changed))
        return a_fill if isinstance(a_fill, bool) else any(changed)