#FLM: Export FontLab class kerning to UFO
import os
moduleFound = False

try:
    import kernExport
    from kernExport import *
    # reload(kernExport)
    moduleFound = True

except ImportError:
    modulePath = os.path.join(fl.userpath, 'Macros', 'System', 'Modules')
    url = 'https://github.com/adobe-type-tools/python-modules'
    print '''

    Please make sure you have placed the "kernExport.py" module in your Macros/System/Modules folder:
    %s
    Get the module here:
    %s 

    ''' % (modulePath, url)


if moduleFound:

    # three options are possible; for further details see kernExport.__doc__:
    # kernExport.ClassKerningToUFO(fl.font, prefixOption = 'MM')   # prefix kerning classes in MetricsMachine-style
    # kernExport.ClassKerningToUFO(fl.font, prefixOption = 'UFO3') # prefix kerning classes in UFO3-style
    # kernExport.ClassKerningToUFO(fl.font)                        # do not change the name of kerning classes (apart from side markers)

    kernExport.ClassKerningToUFO(fl.font, 'MM')

@@ -36,16 +36,18 @@
 to UFO%0D%0A
+%0D%0A
 import o
@@ -49,16 +49,18 @@
 ort os%0D%0A
+%0D%0A
 moduleFo
@@ -76,82 +76,295 @@
 se%0D%0A
-%0D%0Atry:%0D%0A    import kernExport%0D%0A    from kernExport import *%0D%0A    # reload(
+defconFound = False%0D%0A%0D%0Atry:%0D%0A    import defcon%0D%0A    defconFound = True%0D%0A%0D%0Aexcept ImportError:%0D%0A    url = 'https://github.com/typesupply/defcon/'%0D%0A    print '''%0D%0A    %22Defcon%22 is required, but not installed.%0D%0A    Get it here: %25s%0D%0A    ''' %25 url%0D%0A%0D%0Aif defconFound:%0D%0A    try:%0D%0A        import 
 kern
@@ -369,19 +369,22 @@
 rnExport
-)
 %0D%0A
+    
     modu
@@ -393,32 +393,36 @@
 Found = True%0D%0A%0D%0A
+    
 except ImportErr
@@ -422,24 +422,28 @@
 portError:%0D%0A
+    
     modulePa
@@ -505,16 +505,20 @@
 ules')%0D%0A
+    
     url 
@@ -573,24 +573,28 @@
 dules'%0D%0A    
+   
+ 
 print '''%0D%0A%0D
@@ -592,18 +592,16 @@
 nt '''%0D%0A
-%0D%0A
     Plea
@@ -738,18 +738,20 @@
    %25s %0D%0A
-%0D%0A
+    
     ''' 
@@ -775,16 +775,32 @@
 l)%0D%0A%0D%0A%0D%0A
+def run():%0D%0A    
 if modul
@@ -806,24 +806,28 @@
 leFound:%0D%0A%0D%0A
+    
     # three 
@@ -893,16 +893,20 @@
 doc__:%0D%0A
+    
     # ke
@@ -1006,32 +1006,36 @@
 sMachine-style%0D%0A
+    
     # kernExport
@@ -1121,24 +1121,28 @@
 UFO3-style%0D%0A
+    
     # kernEx
@@ -1273,16 +1273,20 @@
 %0D%0A%0D%0A    
+   
+ 
 kernExpo
@@ -1318,12 +1318,55 @@
 ont, 'MM')%0D%0A
+%0D%0A%0D%0Aif __name__ == '__main__':%0D%0A    run()%0D%0A

Clarify Defcon dependency; alert if Defcon is not installed. Thanks to Paul van der Laan for reporting this issue.