{ "info": { "author": "wmj", "author_email": "wmj.py@gmx.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Topic :: Utilities" ], "description": "\nwikiexpand\n==========\n\nExpansion engine for pages written using MediaWiki syntax, based on\nmwparserfromhell_.\n\n*Wikiexpand* tries to mimic the expansion of transcluded text (templates) and\nmagic words (parser functions and variables).\n\n.. _mwparserfromhell: https://github.com/earwig/mwparserfromhell\n\nUsage\n-----\n\nFirst, we need to create an expansion context (``wikiexpand.expand.ExpansionContext``),\nand provide a place where to look for our templates (``wikiexpand.expand.templates.TemplateStore``):\n\n.. code-block:: python\n\n # expansion context\n from wikiexpand.expand import ExpansionContext\n # a template store using `dict` as storage\n from wikiexpand.expand.templates import TemplateDict\n\n tpl = TemplateDict()\n\n # define a simple template\n tpl[\"helloworld\"] = \"Hello World\"\n\n # create the expansion context\n ctx = ExpansionContext(templates=tpl)\n\n # expand text transcluding our template\n ctx.expand(\"Lorem {{helloworld}}! Ipsum\")\n 'Lorem Hello World! Ipsum'\n\n\nParser functions and magic words\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nMost common used parser functions and magic words can also be expanded:\n\n.. code-block:: python\n\n # expand text using a parser functions\n ctx.expand(\"{{#if:x|1|0}} {{#if:|1|0}}\")\n '1 0'\n\n\nMany magic words provide contextual data which are defined for a site (namespaces,\nserver time, etc.) or a given page (title, url, etc.). In order to be able to\nexpand those magic words, providing site (``wikiexpand.expand.context.SiteContext``)\nand page context (``wikiexpand.expand.context.PageContext``) is required.\n\n.. code-block:: python\n\n # implementation using pywikibot to retrieve info from a Wikimedia site\n import pywikibot as pw\n from wikiexpand.wiki.context import Wiki\n\n # site context for es.wiktionary.org\n eswikt = Wiki(pw.Site(\"es\", \"wiktionary\"))\n\n # set page context for a page named \"hello\"\n ctx.set_context(eswikt.page_context(\"hello\"))\n\n ctx.expand(\"Using page context: {{PAGENAME}}, {{TALKSPACE}}. Using site context: [{{fullurl:hello}}], {{NAMESPACE:Template:helloworld}}\")\n 'Using page context: hello, Discusi\u00f3n. Using site context: [https://es.wiktionary.org/wiki/hello], Plantilla'\n\n\nImplemented parser functions\n++++++++++++++++++++++++++++\n\n``#expr``*, ``#if``, ``#ifeq``, ``#ifexist``, ``#rel2abs``, ``#switch``, ``#tag``,\n``#time``*, ``#timel``, ``#titleparts``, ``anchorencode``, ``articlepagename``,\n``articlepagenamee``, ``articlespace``, ``articlespacee``, ``basepagename``,\n``basepagenamee``, ``defaultsort``, ``fullpagename``, ``fullpagenamee``, ``fullurl``,\n``lc``, ``lcfirst``, ``namespace``, ``namespacee``, ``ns``, ``padleft``, ``padright``,\n``pagename``, ``pagenamee``, ``rootpagename``, ``rootpagenamee``, ``subjectpagename``,\n``subjectpagenamee``, ``subjectspace``, ``subjectspacee``, ``subpagename``,\n``subpagenamee``, ``talkpagename``, ``talkpagenamee``, ``talkspace``, ``talkspacee``,\n``uc``, ``ucfirst``, ``urlencode``.\n\nImplemented behaviour of the functions marked with * differs from the reference.\n\nImplemented variables\n+++++++++++++++++++++\n\n``!``, ``ARTICLEPAGENAME``, ``ARTICLEPAGENAMEE``, ``ARTICLESPACE``, ``ARTICLESPACEE``,\n``BASEPAGENAME``, ``BASEPAGENAMEE``, ``CURRENTDAY``, ``CURRENTDAY2``,\n``CURRENTDAYNAME``, ``CURRENTDOW``, ``CURRENTHOUR``, ``CURRENTMONTH``,\n``CURRENTMONTH1``, ``CURRENTMONTHABBREV``, ``CURRENTMONTHNAME``, ``CURRENTTIME``,\n``CURRENTTIMESTAMP``, ``CURRENTWEEK``, ``CURRENTYEAR``, ``FULLPAGENAME``,\n``FULLPAGENAMEE``, ``LOCALDAY``, ``LOCALDAY2``, ``LOCALDAYNAME``, ``LOCALDOW``,\n``LOCALHOUR``, ``LOCALMONTH``, ``LOCALMONTH1``, ``LOCALMONTHABBREV``,\n``LOCALMONTHNAME``, ``LOCALTIME``, ``LOCALTIMESTAMP``, ``LOCALWEEK``, ``LOCALYEAR``,\n``NAMESPACE``, ``NAMESPACEE``, ``PAGENAME``, ``PAGENAMEE``, ``ROOTPAGENAME``,\n``ROOTPAGENAMEE``, ``SUBJECTPAGENAME``, ``SUBJECTPAGENAMEE``, ``SUBJECTSPACE``,\n``SUBJECTSPACEE``, ``SUBPAGENAME``, ``SUBPAGENAMEE``, ``TALKPAGENAME``,\n``TALKPAGENAMEE``, ``TALKSPACE``, ``TALKSPACEE``.\n\nLua modules\n~~~~~~~~~~~\n\nModules written in Lua and executed using ``{{#invoke:}}`` are not recognised, but\ncan be replaced by implementing callable templates (that is, functions that\nrender Wikicode). See the doc in\n``wikiexpand.expand.templates.TemplateStore.callable_templates``.\n\n\nChangelog\n---------\n\n0.2\n===\n\n* new parser function & variable ARTICLEPAGENAME, ARTICLEPAGENAMEE\n* new parser function & variable SUBPAGENAME, SUBPAGENAMEE\n* new parser function & variable ROOTPAGENAME, ROOTPAGENAMEE\n* new parser function & variable BASEPAGENAME, BASEPAGENAMEE\n* new parser function #titleparts\n* site context: clean and canonical title perform previous space cleaning and unescaping of html entities.\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/wmj/wikiexpand", "keywords": "mediawiki templates expansion", "license": "LGPLv3", "maintainer": "", "maintainer_email": "", "name": "wikiexpand", "package_url": "https://pypi.org/project/wikiexpand/", "platform": "", "project_url": "https://pypi.org/project/wikiexpand/", "project_urls": { "Homepage": "https://bitbucket.org/wmj/wikiexpand" }, "release_url": "https://pypi.org/project/wikiexpand/0.2/", "requires_dist": [ "pywikibot (>=2.0rc3)", "mwparserfromhell (>=0.4.3)" ], "requires_python": "", "summary": "Expansion engine for MediaWiki wiki pages based on mwparserfromhell", "version": "0.2" }, "last_serial": 3368691, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "6b81456df8867f2aa2ef4a83b5f96517", "sha256": "30e6bc5d78316317a1310cf4d330a879f6abf1357f8446aa7769d99a0170092f" }, "downloads": -1, "filename": "wikiexpand-0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "6b81456df8867f2aa2ef4a83b5f96517", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 32322, "upload_time": "2017-10-28T14:29:50", "url": "https://files.pythonhosted.org/packages/b8/a7/cee14a98b36cbd232e85c54c2e325be187414493b452f29e26fbc8d39944/wikiexpand-0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "44cf9ac4ae91c51753392d252a186e5b", "sha256": "f3870d125810fa5348cd13f16d26ae6d23df4e293c1640735b6453ca935a2a5c" }, "downloads": -1, "filename": "wikiexpand-0.1.tar.gz", "has_sig": false, "md5_digest": "44cf9ac4ae91c51753392d252a186e5b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26280, "upload_time": "2017-10-28T14:29:52", "url": "https://files.pythonhosted.org/packages/9c/f5/eef28da609323821a7da84ddceedb1332214d91e44926339f893365e0a44/wikiexpand-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "8dcd4f188926a68aff5747118443191e", "sha256": "b54ce59ef44e236b8061d4f551920064bb62417f86860fb10f6dbcaa71c58033" }, "downloads": -1, "filename": "wikiexpand-0.2.linux-x86_64.tar.gz", "has_sig": false, "md5_digest": "8dcd4f188926a68aff5747118443191e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 71439, "upload_time": "2017-11-27T17:58:36", "url": "https://files.pythonhosted.org/packages/6f/52/cb48ea781a222122122a9a1158bc1eba615f7f732d30b66cfac3049fe6eb/wikiexpand-0.2.linux-x86_64.tar.gz" }, { "comment_text": "", "digests": { "md5": "d52b90601debe27f5329ba9fcfa2b4c8", "sha256": "b1f61f5be413f2be77cfe4c999c6ecf2fa7fa2640be9c8fc7c1f648fd628bc5a" }, "downloads": -1, "filename": "wikiexpand-0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d52b90601debe27f5329ba9fcfa2b4c8", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 35910, "upload_time": "2017-11-27T17:58:30", "url": "https://files.pythonhosted.org/packages/e4/b9/25fd7032af744ea2488a519ec2bd3cf7d758148154f566ac7ff9da099983/wikiexpand-0.2-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8dcd4f188926a68aff5747118443191e", "sha256": "b54ce59ef44e236b8061d4f551920064bb62417f86860fb10f6dbcaa71c58033" }, "downloads": -1, "filename": "wikiexpand-0.2.linux-x86_64.tar.gz", "has_sig": false, "md5_digest": "8dcd4f188926a68aff5747118443191e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 71439, "upload_time": "2017-11-27T17:58:36", "url": "https://files.pythonhosted.org/packages/6f/52/cb48ea781a222122122a9a1158bc1eba615f7f732d30b66cfac3049fe6eb/wikiexpand-0.2.linux-x86_64.tar.gz" }, { "comment_text": "", "digests": { "md5": "d52b90601debe27f5329ba9fcfa2b4c8", "sha256": "b1f61f5be413f2be77cfe4c999c6ecf2fa7fa2640be9c8fc7c1f648fd628bc5a" }, "downloads": -1, "filename": "wikiexpand-0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d52b90601debe27f5329ba9fcfa2b4c8", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 35910, "upload_time": "2017-11-27T17:58:30", "url": "https://files.pythonhosted.org/packages/e4/b9/25fd7032af744ea2488a519ec2bd3cf7d758148154f566ac7ff9da099983/wikiexpand-0.2-py2.py3-none-any.whl" } ] }