Refactor python/tidy.py to not use globals. Fixes #3242
Cleaned up python/licenseck.py

- Moved logic into tidy.py
- Removed explicit BSD license exceptions, they are already ignored by
  being inside the codegen directory.
Use os.path.join instead of manually inserting slashes.
Merge pull request #3263 from duncankl/refactor-test-tidy

Refactor python/tidy.py (updated post-cargoify)