wmflib: add ensure_final_newline()

If the argument is a string, ensure it ends with a final newline.
If it is not a string, pass it through unmodified.

This function is designed to make it easier to write custom Puppet
resource types that delegate to file resources and that take
either a "content" or a "source" parameter.

Change-Id: Ib1f88b11b6308900a0bf0279eaca863793f614cd