Hi,
if you just want to change the link addresses, this will probably work:
- Put custom_nfo.py and mwrender.nfo.py into the same directory.
- Put nfo.json to the directory where the wikiconf.txt is.
- Open nfo.json with a text editor and change the address.
- Set the executable flag for mwrender.nfo.py
- Set “lang = en” in your wikiconf.txt
- Do the rendering using mwrender.nfo.py instead of mw-render with the
same parameters.
Best wishes,
Timo
Am Montag, den 01.08.2011, 13:44 +0100 schrieb Alberto Simões:
> Hello
>
> Further developments:
>
> edited mwlib/apps/__init__.py and mwlib/cdbwiki.py and replaced en
> by pt. Redo the database, same behavior...
>
> On Mon, Aug 1, 2011 at 12:27 PM, ambs <[email protected]> wrote:
> > Hello
> >
> > I am in a kind of hurry to have this working. We are preparing an
> > information extraction task from Portuguese wikipedia and we need a
> > XHTML version of it :S
> >
> > Well, on to my problem.
> >
> > Used mw-buildcdb -i ptdump.xml -o cdb
> >
> > The cdb/wikiconf.txt file says: lang = en
> >
> > If I keep it that way, most pages are converted correctly.
> > If I change the 'en' to 'pt' (to get links rendered correctly) I have
> > a lot of pages failing (see error bellow).
> >
> > Any hint on what might be going on?
> >
> > Thank you
> > Alberto
> >
> >
> > Traceback (most recent call last):
> > File "/opt/python/bin/mw-render", line 8, in <module>
> > load_entry_point('mwlib==0.12.14', 'console_scripts', 'mw-render')
> > ()
> > File "/opt/python/lib/python2.7/site-packages/mwlib-0.12.14-py2.7-
> > linux-x86_64
> > .egg/mwlib/apps/render.py", line 214, in main
> > return Main()()
> > File "/opt/python/lib/python2.7/site-packages/mwlib-0.12.14-py2.7-
> > linux-x86_64
> > .egg/mwlib/apps/render.py", line 177, in __call__
> > writer(env, output=tmpout, status_callback=self.status,
> > **writer_options)
> > File "/opt/python/lib/python2.7/site-packages/mwlib-0.12.14-py2.7-
> > linux-x86_64
> > .egg/mwlib/xhtmlwriter.py", line 707, in xhtmlwriter
> > book = writerbase.build_book(env,
> > status_callback=buildbook_status)
> > File "/opt/python/lib/python2.7/site-packages/mwlib-0.12.14-py2.7-
> > linux-x86_64
> > .egg/mwlib/writerbase.py", line 43, in build_book
> > a = wiki.getParsedArticle(title=item.title,
> > revision=item.revision)
> > File "/opt/python/lib/python2.7/site-packages/mwlib-0.12.14-py2.7-
> > linux-x86_64
> > .egg/mwlib/nuwiki.py", line 342, in getParsedArticle
> > return uparser.parseString(title=title, raw=raw, wikidb=self,
> > lang=self.site
> > info["general"]["lang"])
> > File "/opt/python/lib/python2.7/site-packages/mwlib-0.12.14-py2.7-
> > linux-x86_64
> > .egg/mwlib/refine/uparser.py", line 34, in parseString
> > input = te.expandTemplates(True)
> > File "evaluate.py", line 291, in
> > mwlib.templ.evaluate.Expander.expandTemplates
> > (mwlib/templ/evaluate.c:5656)
> > File "evaluate.py", line 278, in
> > mwlib.templ.evaluate.Expander._expand (mwlib/
> > templ/evaluate.c:5301)
> > File "evaluate.py", line 28, in mwlib.templ.evaluate.flatten (mwlib/
> > templ/eval
> > uate.c:1024)
> > File "evaluate.py", line 30, in mwlib.templ.evaluate.flatten (mwlib/
> > templ/eval
> > uate.c:1055)
> > File "nodes.py", line 205, in mwlib.templ.nodes.Template.flatten
> > (mwlib/templ/
> > nodes.c:4315)
> > File "nodes.py", line 282, in mwlib.templ.nodes.Template._flatten
> > (mwlib/templ
> > /nodes.c:5601)
> > File "evaluate.py", line 30, in mwlib.templ.evaluate.flatten (mwlib/
> > templ/eval
> > uate.c:1055)
> > File "nodes.py", line 205, in mwlib.templ.nodes.Template.flatten
> > (mwlib/templ/
> > nodes.c:4315)
> > File "nodes.py", line 282, in mwlib.templ.nodes.Template._flatten
> > (mwlib/templ
> > /nodes.c:5601)
> > File "evaluate.py", line 28, in mwlib.templ.evaluate.flatten (mwlib/
> > templ/eval
> > uate.c:1024)
> > File "evaluate.py", line 30, in mwlib.templ.evaluate.flatten (mwlib/
> > templ/eval
> > uate.c:1055)
> > File "nodes.py", line 205, in mwlib.templ.nodes.Template.flatten
> > (mwlib/templ/
> > nodes.c:4315)
> > File "nodes.py", line 282, in mwlib.templ.nodes.Template._flatten
> > (mwlib/templ
> > /nodes.c:5601)
> > File "evaluate.py", line 28, in mwlib.templ.evaluate.flatten (mwlib/
> > templ/eval
> > uate.c:1024)
> > File "evaluate.py", line 30, in mwlib.templ.evaluate.flatten (mwlib/
> > templ/evaluate.c:1055)
> > File "nodes.py", line 30, in mwlib.templ.nodes.IfNode.flatten (mwlib/
> > templ/nodes.c:1391)
> > File "evaluate.py", line 28, in mwlib.templ.evaluate.flatten (mwlib/
> > templ/evaluate.c:1024)
> > File "evaluate.py", line 30, in mwlib.templ.evaluate.flatten (mwlib/
> > templ/evaluate.c:1055)
> > File "nodes.py", line 191, in mwlib.templ.nodes.Variable.flatten
> > (mwlib/templ/nodes.c:4075)
> > File "evaluate.py", line 152, in
> > mwlib.templ.evaluate.ArgumentList.get (mwlib/templ/evaluate.c:3202)
> > File "evaluate.py", line 28, in mwlib.templ.evaluate.flatten (mwlib/
> > templ/evaluate.c:1024)
> > File "evaluate.py", line 30, in mwlib.templ.evaluate.flatten (mwlib/
> > templ/evaluate.c:1055)
> > File "nodes.py", line 205, in mwlib.templ.nodes.Template.flatten
> > (mwlib/templ/nodes.c:4315)
> > File "nodes.py", line 268, in mwlib.templ.nodes.Template._flatten
> > (mwlib/templ/nodes.c:5399)
> > File "/opt/python/lib/python2.7/site-packages/mwlib-0.12.14-py2.7-
> > linux-x86_64.egg/mwlib/templ/magics.py", line 559, in __call__
> > res = m(args) or '' # FIXME: catch TypeErros
> > File "/opt/python/lib/python2.7/site-packages/mwlib-0.12.14-py2.7-
> > linux-x86_64.egg/mwlib/templ/magics.py", line 440, in IFEXIST
> > exists =
> > bool(self.wikidb.normalize_and_get_image_path(name.split(":")[1]))
> > File "/opt/python/lib/python2.7/site-packages/mwlib-0.12.14-py2.7-
> > linux-x86_64.egg/mwlib/nuwiki.py", line 268, in __getattr__
> > raise AttributeError()
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "mwlib" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> > http://groups.google.com/group/mwlib?hl=en.
> >
> >
>
>
>
> --
> Alberto Simões
>
--
You received this message because you are subscribed to the Google Groups
"mwlib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/mwlib?hl=en.
{
"base_url": "http://en.wikipedia.org/w/",
"format": "nuwiki",
"script_extension": ".php"
}"""
Enable looking for a custom nfo.json and siteinfo.json
Author: Timo Richter
"""
import mwlib.cdbwiki
class WikiDB(mwlib.cdbwiki.WikiDB):
def __init__(self, dir, prefix='wiki', lang="en"):
try:
super(WikiDB,self).__init__(dir,prefix,lang)
except(RuntimeError):
print("Warning: "+"could not get siteinfo for language %r" % (lang,))
print("Please set up a custom siteinfo and nfo.")
print "Mod: WikiDB"
self.nfo = self.get_data("nfo") or self.nfo
self.siteinfo = self.get_data("siteinfo") or self.siteinfo
mwlib.cdbwiki.WikiDB=WikiDB
#!/usr/bin/env python
import mwlib.apps.render
import custom_nfo
mwlib.apps.render.Main()()