datastructures.py 742 B

1234567891011121314151617181920212223242526272829
  1. # -*- coding: utf-8 -*-
  2. """
  3. flaskbb.utils.datastructures
  4. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5. A few helpers that are used by flaskbb
  6. :copyright: (c) 2014 by the FlaskBB Team.
  7. :license: BSD, see LICENSE for more details.
  8. """
  9. import sys
  10. class TemplateEventResult(list):
  11. """A list subclass for results returned by the hook that
  12. concatenates the results if converted to string, otherwise it works
  13. exactly like any other list.
  14. """
  15. def __init__(self, items):
  16. list.__init__(self, items)
  17. def __unicode__(self):
  18. return u"".join(map(str, self))
  19. def __str__(self):
  20. if sys.version_info[0] >= 3:
  21. return self.__unicode__()
  22. return self.__unicode__().encode("utf-8")