From d0ab7158eeb0b643e7cc022ef0cd4c66ce6c819d Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Sun, 16 Aug 2015 17:27:12 +0100 Subject: [PATCH] vim, templates, nb.py --- etc/vim/source/functions.vim | 14 +++++++------- etc/vim/templates/daemon.tt | 9 +++++---- lib/python/nb.py | 4 ++++ lib/python/nb.pyc | Bin 1823 -> 1980 bytes 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/etc/vim/source/functions.vim b/etc/vim/source/functions.vim index d190251b..c32fe7b3 100644 --- a/etc/vim/source/functions.vim +++ b/etc/vim/source/functions.vim @@ -1,6 +1,7 @@ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " " Functions +" See: http://learnvimscriptthehardway.stevelosh.com/chapters/27.html " """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" let $VIMHOME = $HOME.'/.vim' @@ -34,7 +35,11 @@ func! FileVimplate() setloc nomore setloc textwidth=0 - let fname = &filetype.'.tt' + let ftype = FileGet('type') + if $VIMFILE =~ 'init\.d' + let ftype = 'daemon' + endif + let fname = ftype.'.tt' let ffind = findfile(fname,$VIMPLATE_DIR) if ffind == '' " if ffind != $VIMPLATE_DIR . '/' . fname @@ -42,12 +47,7 @@ func! FileVimplate() return endif - let cmd = $VIMPLATE . ' -template '.&filetype -" NB 29.12.12 let cmd = cmd . ' -listtemplates' - " let cmd = 'vimplate -user nico -dir '.$VIMHOME.'/vimplaterc -template '.&filetype - " let cmd = 'vimplate -user nico' . -dir '.$VIMHOME.'/vimplaterc -template '.&filetype -" NB 29.12.12 echo '>>'.cmd -" NB 29.12.12 execute "!" . cmd . ' && echo OK' + let cmd = $VIMPLATE . ' -template '.ftype let bashenv = $BASH_ENV let $BASH_ENV = "" execute "r!" . cmd diff --git a/etc/vim/templates/daemon.tt b/etc/vim/templates/daemon.tt index 14515028..e355946f 100644 --- a/etc/vim/templates/daemon.tt +++ b/etc/vim/templates/daemon.tt @@ -9,10 +9,6 @@ # Short-Description: [% var.filename %] # Description: [% user.me_now %] - [% user.copyright %] ### END INIT INFO -################################################################################# -# -# -################################################################################# PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin @@ -27,11 +23,16 @@ test -x $DAEMON || exit 0 . /lib/lsb/init-functions +START="yes" # Source defaults file; edit that file to configure this script. if test -e /etc/default/$NAME ; then . /etc/default/$NAME fi +if [ "$START" != "yes" ]; then + echo "$NAME not configured to start, please edit /etc/default/$NAME to enable (START=yes)" +fi + case "$1" in start) log_daemon_msg "Starting" "${NAME}" diff --git a/lib/python/nb.py b/lib/python/nb.py index 222fbfe7..6c9161c4 100644 --- a/lib/python/nb.py +++ b/lib/python/nb.py @@ -2,9 +2,13 @@ import sys import os import re #INCLUDE_LINES = re.sub('\.py$','-lines.py',os.path.realpath(__file__)) +import pprint +PP = pprint.PrettyPrinter(indent=4) # Debug message def debug(msg): + if (type(msg)) != 'str': + msg = PP.pformat(msg) print >> sys.stderr, msg # Return first and last line from a file diff --git a/lib/python/nb.pyc b/lib/python/nb.pyc index c31091678297c3c8915ac43e09e24539dc6d2bb6..6f3d4bd2ae30d229d5990c31bd6b608db0269c4e 100644 GIT binary patch delta 573 zcmYjNJ4?e*6h0?6Nt4)zEyX8l!3S{_TwGMdK?eyDmx_q=MyQV(lDiZtMJu?tlnhSl z>fqMZ!Cn82n~R=vb?}D!-S0fVbMjPtElrBgf`@k>dky$Ig5EW{X{SHwcL5~AnSi>0 zNWh5+(f}!-2Uxd2ns5V9w?SH(uJ_ei1nO=m~hOj|N) zsisM^fdqVcknRRSx=f$|IsiT7@>2oH94Len((YNWw+Mj#6K@5%@FuJWLV4I?9uGNn(p!s zlFjt=FpZBI(F$2G9(@X||LqP%I#qY6ombNvL%k pE*W8%Vwh!^XILQc>1Ls|n0?vhu__rXl{fNO5w7i)UB~rY=Ld!)U#b8A delta 397 zcmYk1u}TCn5Qb+q$?j(Fyt~B}#61O%Ljr=OXeWrEf>%Ur6l^XQTHbCW2;yNaNNV*V zuCcJNvC(JnDeTpmXmJVi<kXHcF-o696!6gI3 z{cEnQF00ya;BJ=ihSM;)!!crGl8X*v*Z1T@W0umkV9fb{ztmbPSc8H@fk-aJ?*S+xj&ZH!T1hE1AAa|x$IgPI>VI