Source

aurum / autoload / aurum / drivers / common / utils.vim

Diff from to

File autoload/aurum/drivers/common/utils.vim

 "▶1
 scriptencoding utf-8
-execute frawor#Setup('1.1', {'@/resources': '0.0',
+execute frawor#Setup('1.2', {'@/resources': '0.0',
             \                       '@/os': '0.2'})
 let s:utils={}
 "▶1 _unload
 endfunction
 "▶1 post resource
 call s:_f.postresource('utils', s:utils)
+"▶1 pyimport feature
+if has('python')
+    " TODO Add python3 support
+    function s:F.pyimport(plugdict, fdict)
+        let g=a:plugdict.g
+        if !has_key(g, 'pp')
+            return
+        endif
+        let g.py='python'
+        let g.pya=g.py.' '.g.pp.'.'
+        try
+            execute g.py 'import' g.pp
+            let g.usepythondriver=1
+        catch
+            let g.usepythondriver=0
+        endtry
+        let a:fdict.reloadcmd=(g.py.' reload('.g.pp.')')
+    endfunction
+else
+    function s:F.pyimport(plugdict, fdict, pkg)
+        let a:plugdict.g.usepythondriver=0
+    endfunction
+endif
+function s:F.pyreload(plugdict, fdict)
+    if has_key(a:fdict, 'reloadcmd')
+        execute a:fdict.reloadcmd
+    endif
+endfunction
+call s:_f.newfeature('pyimport', {  'load': s:F.pyimport,
+            \                     'unload': s:F.pyreload})
 "▶1
 call frawor#Lockvar(s:, '')
 " vim: ft=vim ts=4 sts=4 et fmr=▶,▲