A Python parser for MediaWiki wikicode https://mwparserfromhell.readthedocs.io/
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 12 Jahren
vor 11 Jahren
vor 12 Jahren
vor 12 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #! /usr/bin/env python
  2. #
  3. # Copyright (C) 2012-2021 Ben Kurtovic <ben.kurtovic@gmail.com>
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a copy
  6. # of this software and associated documentation files (the "Software"), to deal
  7. # in the Software without restriction, including without limitation the rights
  8. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. # copies of the Software, and to permit persons to whom the Software is
  10. # furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included in
  13. # all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. # SOFTWARE.
  22. from glob import glob
  23. import os
  24. import sys
  25. from setuptools import find_packages, setup, Extension
  26. from setuptools.command.build_ext import build_ext
  27. sys.path.insert(0, os.path.join(os.path.dirname(__file__), "src"))
  28. from mwparserfromhell import __version__
  29. with open("README.rst") as fp:
  30. long_docs = fp.read()
  31. use_extension = True
  32. fallback = True
  33. # Allow env var WITHOUT_EXTENSION and args --with[out]-extension:
  34. env_var = os.environ.get("WITHOUT_EXTENSION")
  35. if "--without-extension" in sys.argv:
  36. use_extension = False
  37. elif "--with-extension" in sys.argv:
  38. fallback = False
  39. elif env_var is not None:
  40. if env_var == "1":
  41. use_extension = False
  42. elif env_var == "0":
  43. fallback = False
  44. # Remove the command line argument as it isn't understood by setuptools:
  45. sys.argv = [
  46. arg for arg in sys.argv if arg not in ("--without-extension", "--with-extension")
  47. ]
  48. def build_ext_patched(self):
  49. try:
  50. build_ext_original(self)
  51. except Exception as exc:
  52. print("error: " + str(exc))
  53. print("Falling back to pure Python mode.")
  54. del self.extensions[:]
  55. if fallback:
  56. build_ext.run, build_ext_original = build_ext_patched, build_ext.run
  57. # Project-specific part begins here:
  58. tokenizer = Extension(
  59. "mwparserfromhell.parser._tokenizer",
  60. sources=sorted(glob("src/mwparserfromhell/parser/ctokenizer/*.c")),
  61. depends=sorted(glob("src/mwparserfromhell/parser/ctokenizer/*.h")),
  62. )
  63. setup(
  64. name="mwparserfromhell",
  65. packages=find_packages("src"),
  66. package_dir={"": "src"},
  67. ext_modules=[tokenizer] if use_extension else [],
  68. setup_requires=["pytest-runner"]
  69. if "test" in sys.argv or "pytest" in sys.argv
  70. else [],
  71. tests_require=["pytest"],
  72. version=__version__,
  73. python_requires=">= 3.6",
  74. author="Ben Kurtovic",
  75. author_email="ben.kurtovic@gmail.com",
  76. url="https://github.com/earwig/mwparserfromhell",
  77. description="MWParserFromHell is a parser for MediaWiki wikicode.",
  78. long_description=long_docs,
  79. download_url="https://github.com/earwig/mwparserfromhell/tarball/v{}".format(
  80. __version__
  81. ),
  82. keywords="earwig mwparserfromhell wikipedia wiki mediawiki wikicode template parsing",
  83. license="MIT License",
  84. classifiers=[
  85. "Development Status :: 4 - Beta",
  86. "Environment :: Console",
  87. "Intended Audience :: Developers",
  88. "License :: OSI Approved :: MIT License",
  89. "Operating System :: OS Independent",
  90. "Programming Language :: Python :: 3",
  91. "Programming Language :: Python :: 3.6",
  92. "Programming Language :: Python :: 3.7",
  93. "Programming Language :: Python :: 3.8",
  94. "Programming Language :: Python :: 3.9",
  95. "Programming Language :: Python :: 3.10",
  96. "Topic :: Text Processing :: Markup",
  97. ],
  98. )