Snake eats moon

I’ve been working on my spare… spare time on some web software for my World of Warcraft guild, principally to offer DKP statistics and character profiles.

I originally anticipated to do that stuff in PHP, but I figured it would be nice to learn something new, so I finally settled on Django, the “Web framework for perfectionists with deadlines”. Django is written in Python, which is a really nice language, not to mention hip at geek parties.

In any case, it hit me last weekend I would have to load World of Warcraft saved variables files, which are just Lua files declaring variables in the global scope. I thought this would be an ordeal and didn’t look forward to writing parsing code, or worse, a formal grammar.

Turns out Lua is so similar to Python a few regular expressions did the trick. I have to admit, I was rather pleased by the simplicity of the solution :)

So there you have it: the wowsv Python module. It exports a single function, aptly named wowsv, to load World of Warcraft saved variables into Python. You can do whatever you want with it, I don’t really care. Just credit me if you’re going to use it, and of course I’d appreciate to know about any changes or improvements you might make to it.

Download wowsv (sha1: 4711ce5a69e774b973bc5de2975051e18da11ee5)

In case you were wondering about the compression, my server would try to execute a straight .py as a CGI script.

Just a quick note - wowsv throws a wobbly if the .lua file you feed it has windows rather than unix style line endings.

Change the line endings in the .lua file and it works fine.

Hope that helps

Forgot to say… nice work - been trying to write this myself and was struggling! Thank you.

Thank you for this. I was looking for a way to export the savedvariables data and been pounding my head against the wall trying to make a py script do just this thing but couldn’t wrap my brain around it.

This is awesome. Thanks you again.

Using Python 2.4.1 - there seems to be some extra white-space that causes a syntax error on the compile stage. When using my SV file raw from the WoW folder. I put lua_vars = lua_vars.strip() just after the read, and it clears right up.