base.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. # -*- coding: utf-8 -*-
  2. # Copyright (C) 2020 Red Hat, Inc.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  13. # implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. import abc
  17. class FormatterBase(metaclass=abc.ABCMeta):
  18. """Base class for example plugin used in the tutorial.
  19. """
  20. def __init__(self, max_width=60):
  21. self.max_width = max_width
  22. @abc.abstractmethod
  23. def format(self, data):
  24. """Format the data and return unicode text.
  25. :param data: A dictionary with string keys and simple types as
  26. values.
  27. :type data: dict(str:?)
  28. :returns: Iterable producing the formatted text.
  29. """