ralsina/nikola — pull request #29 by quodlibetor (2012-05-12 03:20:31+00:00)
Title: Compile Posts based on file extension instead of project setting

First attempt at issue #22

Everything works correctly here, but I'm not sure about the implementation.

The first problem might have just come from the fact that I'm not familiar with the code base, but because of the way that global configuration is set up it seems like the only way to get access to a conf during a doit run is by adding code inside of `nikola.Nikola`.

So, originally I had a utility function inside of `Nikola`, but I would have needed to either never cache the results of figuring out what compiler a given file extension maps to, or create a cache and make it a class global property. Instead of that I just created a new class in utils that has a private cache variable (`inverse_post_compilers`) and every time we run into a new extension the compiler for it gets added.

The code is mostly ugly because of error checking, the api that it enables (see nikola/nikola.py:174, nikola/nikola.py:354, nikola/nikola.py:811) is exactly the same, and I think that this `post_compilers` format (i.e., `'language': ['list', 'of', 'extensions']`) is the most intuitive and least tedious for users.