A Python parser for MediaWiki wikicode https://mwparserfromhell.readthedocs.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

31 lines
766 B

  1. # -*- coding: utf-8 -*-
  2. """
  3. Implements support for both Python 2 and Python 3 by defining common types in
  4. terms of their Python 2/3 variants. For example, :py:class:`str` is set to
  5. :py:class:`unicode` on Python 2 but :py:class:`str` on Python 3; likewise,
  6. :py:class:`bytes` is :py:class:`str` on 2 but :py:class:`bytes` on 3. These
  7. types are meant to be imported directly from within the parser's modules.
  8. """
  9. import sys
  10. py3k = sys.version_info.major == 3
  11. py32 = py3k and sys.version_info.minor == 2
  12. if py3k:
  13. bytes = bytes
  14. str = str
  15. range = xrange
  16. maxsize = sys.maxsize
  17. import html.entities as htmlentities
  18. else:
  19. bytes = str
  20. str = unicode
  21. range = range
  22. maxsize = sys.maxint
  23. import htmlentitydefs as htmlentities
  24. del sys