Commits

ZyX_I  committed ad22ab9

@%aurum/drivers/*, @%aurum/drivers/common/utils:
Moved some common package importing code into @%aurum/drivers/common/utils

  • Participants
  • Parent commits 58604ae

Comments (0)

Files changed (4)

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=▶,▲

File autoload/aurum/drivers/git.vim

 "▶1
 scriptencoding utf-8
+let s:pp='aurum.augit'
 execute frawor#Setup('0.1', {'@%aurum/drivers/common/hypsites': '0.0',
             \                                   '@%aurum/repo': '5.0',
-            \                   '@%aurum/drivers/common/utils': '1.1',
+            \                   '@%aurum/drivers/common/utils': '1.2',
             \                                           '@/os': '0.1',
             \                                      '@/options': '0.0',})
-let s:usepythondriver=0
-if has('python')
-    let s:py='python'
-    let s:pp='aurum.augit'
-    let s:pya=s:py.' '.s:pp.'.'
-    try
-        execute s:py 'import '.s:pp
-        let s:usepythondriver=1
-    catch
-        " s:usepythondriver stays equal to 0, errors are ignored
-    endtry
-    if s:usepythondriver
-        " FIXME Does not work in python3.
-        execute s:py 'reload('.s:pp.')'
-    endif
-endif
 let s:_messages={
             \   'hexf': 'Failed to obtain hex string for revision %s '.
             \           'in the repository %s: %s',
 let s:logformat='%h-%H-%P-%at%n%an%n%ae%n%d%n%w(0,1,1)%B'
 let s:logkwargs={'format': s:logformat, 'encoding': 'utf-8', 'date-order': 1}
 function s:F.parsecs(csdata)
-    let cs={'branch': 'default', 'phase': 'unknown'}
+    let cs={'branch': 'default', 'phase': 'unknown', 'bookmarks': []}
     let [rev, hex, parents, time]=split(remove(a:csdata, 0), '-', 1)
     let cs.hex=hex
     let cs.parents=split(parents)
     let aemail=remove(a:csdata, 0)
     let cs.user=aname.' <'.aemail.'>'
     let cs.tags=split(remove(a:csdata, 0)[2:-2], ', ')
-    let cs.bookmarks=[]
     "▶2 get description
     let description=[]
     while !empty(a:csdata) && a:csdata[0][0] is# ' '

File autoload/aurum/drivers/mercurial.vim

 "▶1
 scriptencoding utf-8
+let s:pp='aurum.aumercurial'
 execute frawor#Setup('0.2', {'@%aurum/drivers/common/hypsites': '0.0',
             \                                   '@%aurum/repo': '5.0',
             \                   '@%aurum/drivers/common/utils': '1.0',
             \                                      '@/options': '0.0',})
 let s:hg={}
 let s:iterfuncs={}
-let s:usepythondriver=0
-if has('python')
-    let s:py='python'
-    let s:pp='aurum.aumercurial'
-    let s:pya=s:py.' '.s:pp.'.'
-    try
-        execute s:py 'import '.s:pp
-        let s:usepythondriver=1
-    catch
-        " s:usepythondriver stays equal to 0, errors are ignored
-    endtry
-    if s:usepythondriver
-        " FIXME Does not work in python3. Not very problematic as mercurial does 
-        "       not do this either, but it will be necessary to review these 
-        "       lines after python3 support in mercurial will be finished.
-        execute s:py 'reload('.s:pp.')'
-    endif
-endif
 let s:nullrev=repeat('0', 40)
 "▶1 Messages
 let s:_messages={

File doc/aurum.txt

          replaced _r.utils.kwargstostr with _r.utils.kwargstolst,
          made _r.utils.run return a pair (output, exit_code)
     1.1: Added _r.utils.pyeval and _r.utils.pystring
+    1.2: Added pyimport feature
 @%aurum/file:
     0.1: Added |:AuFile| prompt option.
 @%aurum/hyperlink: