I don't know how useful this is for the regular game, it was made for a very specific mod, still I figured some people would like it or at least salvage some code from it:
Relatively self-explanatory, I think.
This really isn't meant to be used stand-alone but for modders who want to include new traits outside the traditional XML bonuses.
All the python is labeled and searching for 'Sea trait' should find the changes. Remember to add the 25% caravel production bonus which is done in the UnitInfos XML file.
I recommend downloading and using Winmerge to combine python.
Seafaring Trait (XML+Python) 2016-10-05
Seafaring Trait (XML+Python)