r661 - in /trunk/utils/addons: ./ registry-samples/ src/ src/vim/
src/vim/addons/
zack at users.alioth.debian.org
zack at users.alioth.debian.org
Thu May 11 18:16:17 UTC 2006
Author: zack
Date: Thu May 11 18:16:11 2006
New Revision: 661
URL: http://svn.debian.org/wsvn/?sc=1&rev=661
Log:
first snapshot of vim-addons implementation
Added:
trunk/utils/addons/
trunk/utils/addons/addons-proposal.txt
trunk/utils/addons/registry-format.txt
trunk/utils/addons/registry-samples/
trunk/utils/addons/registry-samples/alternate
trunk/utils/addons/registry-samples/calendar
trunk/utils/addons/registry-samples/gnupg
trunk/utils/addons/registry-samples/latexsuite
trunk/utils/addons/registry-samples/matchit
trunk/utils/addons/registry-samples/utl
trunk/utils/addons/src/
trunk/utils/addons/src/vim/
trunk/utils/addons/src/vim/__init__.py
trunk/utils/addons/src/vim/addons/
trunk/utils/addons/src/vim/addons/__init__.py
trunk/utils/addons/src/vim/addons/constants.py
trunk/utils/addons/src/vim/addons/errors.py
trunk/utils/addons/src/vim/addons/registry.py
trunk/utils/addons/src/vim/addons/utils.py
trunk/utils/addons/src/vim/addons/vim-addons (with props)
Added: trunk/utils/addons/addons-proposal.txt
URL: http://svn.debian.org/wsvn/trunk/utils/addons/addons-proposal.txt?rev=661&op=file
==============================================================================
--- trunk/utils/addons/addons-proposal.txt (added)
+++ trunk/utils/addons/addons-proposal.txt Thu May 11 18:16:11 2006
@@ -1,0 +1,89 @@
+
+handling of vim add-ons
+=======================
+
+vim add-ons
+-----------
+
+with "add-on" I refer to every additional (set of) feature that can be added to
+vim using its extension mechanisms (color schemes, syntaxes, indentation,
+plugin, ...)
+
+current issues
+--------------
+
+every vim add-on is currently installed in /usr/share/vim/addons/, directory
+which is in the runtimepath. As a consequence every installed add-on is always
+enabled. The only way to choose which ones to load is to override the
+runtimepath so that /usr/share/vim/addons/ is not listed and manually load the
+desired one
+
+proposed solution
+-----------------
+
+keep on installing add-ons under /usr/share/vim/addons/ (no changes are needed
+for all packages which ship add-ons), but remove this directory from the
+runtimepath. Adds a directory /var/vim/addons/ to the runtimepath and implement
+a flexible symlink mechanism (a-la /etc/init.d/) to selectively enable add-ons.
+
+implementation
+--------------
+
+1 registry, 1 tool.
+
+The registry keep track of all installed vim add-ons, associating to each add-on
+name a list of files that should be in the runtimepath to enable the add-on.
+E.g., an entry in the registry can be:
+
+ Add-on: utl
+ Files: doc/utl_usr.txt, doc/utl_ref.txt, plugin/utl_rc.vim, plugin/utl.vim,
+ plugin/utl_scm.vim, plugin/utl_arr.vim, plugin/utl_uri.vim
+
+A single package can ship more than one add-on. Still, it is recommended that
+each package named vim-<name> installs a single add-on called <name> so that its
+easier for the user to know the canonical name of add-ons.
+
+The tool 'vim-addons' enables/disables plugins (in the same spirit as
+apache-modconf does for apache modules).
+
+When invoked as 'vim-addons update' (by sysadms), it reads as input
+/etc/vim/addons which lists names of enables add-ons, one per line. After
+invoking it, the symlinks under /var/vim/addons/ are all and only those
+corresponding to the addons listed /etc/vim/addons. This kind of invocation is
+idempotent.
+
+Other 'vim-addons' actions are meant to be used both by sysadms and users.
+Besides providing some query mechanisms (e.g. 'vim-addons list'), 'vim-addons'
+can be invoked to either "enable" or "enable" add-ons. When invoked by the
+sysadm to enable/disable add-ons it basically change /etc/vim/addons and re-run
+'update-vim-addons' (the actual implementation can be smarter than that and only
+change the needed symlinks). When invoked by the user it enables/disables
+add-ons acting on symlinks in the user directory ~/.vim/
+
+registry format
+---------------
+
+the registry can be as simple as a set of files installed under
+/usr/share/vim/registry/. We can think about providing a debhelper that looks
+for all files installed under /usr/share/vim/addons/ and create the
+corresponding registry entry installing it in the package or something similar.
+
+miscellanea
+-----------
+
+* Automatic enabling of fresh installed add-on
+
+ It is a debian de-facto policy that installing a package just "makes it work".
+ To implement this, postinst scripts of vim addons should invoke 'vim-addons
+ enable <name>'
+
+* Disabling a system-wide enabled plugin
+
+ In order to support users willing to disable in their configuration add-ons
+ which are system-wide enabled an extra field could be added to the registry
+ listing a line that need to be added to ~/.vimrc to disable an add-on (e.g.
+ 'let did_something = 1'). When invoked by users to disable a plugin such a
+ line will be added to some file automatically sourced by vim on startup.
+
+--
+Thu, 11 May 2006 12:55:15 -0500 zack
Added: trunk/utils/addons/registry-format.txt
URL: http://svn.debian.org/wsvn/trunk/utils/addons/registry-format.txt?rev=661&op=file
==============================================================================
--- trunk/utils/addons/registry-format.txt (added)
+++ trunk/utils/addons/registry-format.txt Thu May 11 18:16:11 2006
@@ -1,0 +1,28 @@
+
+Format of Vim add-ons registry
+==============================
+
+The registry is stored as a directory containing one file per add-on. Each file
+name corresponds to the add-on name.
+
+Each add-on is an RFC822 compliant file (the same format used by debian/control
+files) with the following fields (mandatory unless otherwise specified):
+
+- Add-On
+ name of the add-on, must be the same as the filename
+- Files
+ list of the files that should be present in one of the directories in the
+ vim runtimepath for the add-on to be enabled. Files are specified relative
+ to one of those dirs
+- Description
+ (optional, though highly recommended)
+ short, human understandable description of the add-on
+- Source
+ (optional, defaults to "/usr/share/vim/addons/")
+ where to find the files listed in the "Files" field. Used to provide add-on
+ descriptions of add-ons installed in non conventional ways (e.g. under
+ /usr/share/vim-scripts or provided by upstream e.g.
+ /usr/share/vim/vimcurrent/macros/)
+
+--
+Thu, 11 May 2006 12:55:24 -0500 zack
Added: trunk/utils/addons/registry-samples/alternate
URL: http://svn.debian.org/wsvn/trunk/utils/addons/registry-samples/alternate?rev=661&op=file
==============================================================================
--- trunk/utils/addons/registry-samples/alternate (added)
+++ trunk/utils/addons/registry-samples/alternate Thu May 11 18:16:11 2006
@@ -1,0 +1,4 @@
+Add-On: alternate
+Description: alternate pairing files (e.g. .c/.h) with short ex-commands
+Source: /usr/share/vim-scripts/
+Files: plugin/a.vim
Added: trunk/utils/addons/registry-samples/calendar
URL: http://svn.debian.org/wsvn/trunk/utils/addons/registry-samples/calendar?rev=661&op=file
==============================================================================
--- trunk/utils/addons/registry-samples/calendar (added)
+++ trunk/utils/addons/registry-samples/calendar Thu May 11 18:16:11 2006
@@ -1,0 +1,4 @@
+Add-On: calendar
+Description: show various kind of calendars in a separate window
+Source: /usr/share/vim-scripts/
+Files: plugin/calendar.vim
Added: trunk/utils/addons/registry-samples/gnupg
URL: http://svn.debian.org/wsvn/trunk/utils/addons/registry-samples/gnupg?rev=661&op=file
==============================================================================
--- trunk/utils/addons/registry-samples/gnupg (added)
+++ trunk/utils/addons/registry-samples/gnupg Thu May 11 18:16:11 2006
@@ -1,0 +1,4 @@
+Add-On: gnupg
+Description: plugin for transparent editing of GnuPG encrypted files.
+Source: /usr/share/vim-scripts/
+Files: plugin/gnupg.vim
Added: trunk/utils/addons/registry-samples/latexsuite
URL: http://svn.debian.org/wsvn/trunk/utils/addons/registry-samples/latexsuite?rev=661&op=file
==============================================================================
--- trunk/utils/addons/registry-samples/latexsuite (added)
+++ trunk/utils/addons/registry-samples/latexsuite Thu May 11 18:16:11 2006
@@ -1,0 +1,69 @@
+Add-On: latexsuite
+Description: comprehensive set of tools to view, edit and compile LaTeX documents.
+Files: compiler/tex.vim, doc/imaps.txt.gz, doc/latexhelp.txt.gz,
+ doc/latex-suite-quickstart.txt.gz, doc/latex-suite.txt.gz,
+ ftplugin/bib_latexSuite.vim, ftplugin/latex-suite/bibtex.vim,
+ ftplugin/latex-suite/bibtools.py, ftplugin/latex-suite/brackets.vim,
+ ftplugin/latex-suite/compiler.vim, ftplugin/latex-suite/custommacros.vim,
+ ftplugin/latex-suite/diacritics.vim,
+ ftplugin/latex-suite/dictionaries/dictionary,
+ ftplugin/latex-suite/dictionaries/SIunits,
+ ftplugin/latex-suite/elementmacros.vim, ftplugin/latex-suite/envmacros.vim,
+ ftplugin/latex-suite/folding.vim, ftplugin/latex-suite/macros/example,
+ ftplugin/latex-suite/main.vim, ftplugin/latex-suite/mathmacros-utf.vim,
+ ftplugin/latex-suite/mathmacros.vim, ftplugin/latex-suite/multicompile.vim,
+ ftplugin/latex-suite/outline.py, ftplugin/latex-suite/packages/accents,
+ ftplugin/latex-suite/packages/acromake,
+ ftplugin/latex-suite/packages/afterpage, ftplugin/latex-suite/packages/alltt,
+ ftplugin/latex-suite/packages/amsmath, ftplugin/latex-suite/packages/amsthm,
+ ftplugin/latex-suite/packages/amsxtra, ftplugin/latex-suite/packages/arabic,
+ ftplugin/latex-suite/packages/array, ftplugin/latex-suite/packages/babel,
+ ftplugin/latex-suite/packages/bar, ftplugin/latex-suite/packages/bm,
+ ftplugin/latex-suite/packages/bophook,
+ ftplugin/latex-suite/packages/boxedminipage,
+ ftplugin/latex-suite/packages/caption2, ftplugin/latex-suite/packages/cases,
+ ftplugin/latex-suite/packages/ccaption,
+ ftplugin/latex-suite/packages/changebar,
+ ftplugin/latex-suite/packages/chapterbib, ftplugin/latex-suite/packages/cite,
+ ftplugin/latex-suite/packages/color, ftplugin/latex-suite/packages/comma,
+ ftplugin/latex-suite/packages/deleq, ftplugin/latex-suite/packages/drftcite,
+ ftplugin/latex-suite/packages/dropping,
+ ftplugin/latex-suite/packages/enumerate, ftplugin/latex-suite/packages/eqlist,
+ ftplugin/latex-suite/packages/eqparbox, ftplugin/latex-suite/packages/everyshi,
+ ftplugin/latex-suite/packages/exmpl, ftplugin/latex-suite/packages/flafter,
+ ftplugin/latex-suite/packages/float, ftplugin/latex-suite/packages/floatflt,
+ ftplugin/latex-suite/packages/fn2end, ftplugin/latex-suite/packages/footmisc,
+ ftplugin/latex-suite/packages/geometry, ftplugin/latex-suite/packages/german,
+ ftplugin/latex-suite/packages/graphicx, ftplugin/latex-suite/packages/graphpap,
+ ftplugin/latex-suite/packages/harpoon, ftplugin/latex-suite/packages/hhline,
+ ftplugin/latex-suite/packages/histogram,
+ ftplugin/latex-suite/packages/hyperref, ftplugin/latex-suite/packages/ifthen,
+ ftplugin/latex-suite/packages/inputenc,
+ ftplugin/latex-suite/packages/letterspace,
+ ftplugin/latex-suite/packages/lineno, ftplugin/latex-suite/packages/longtable,
+ ftplugin/latex-suite/packages/lscape, ftplugin/latex-suite/packages/manyfoot,
+ ftplugin/latex-suite/packages/moreverb, ftplugin/latex-suite/packages/multibox,
+ ftplugin/latex-suite/packages/multicol, ftplugin/latex-suite/packages/newalg,
+ ftplugin/latex-suite/packages/ngerman, ftplugin/latex-suite/packages/numprint,
+ ftplugin/latex-suite/packages/oldstyle, ftplugin/latex-suite/packages/outliner,
+ ftplugin/latex-suite/packages/overcite, ftplugin/latex-suite/packages/parallel,
+ ftplugin/latex-suite/packages/plain, ftplugin/latex-suite/packages/plates,
+ ftplugin/latex-suite/packages/polski, ftplugin/latex-suite/packages/psgo,
+ ftplugin/latex-suite/packages/schedule, ftplugin/latex-suite/packages/SIunits,
+ ftplugin/latex-suite/packages/textfit, ftplugin/latex-suite/packages/times,
+ ftplugin/latex-suite/packages/tipa, ftplugin/latex-suite/packages/ulem,
+ ftplugin/latex-suite/packages/url, ftplugin/latex-suite/packages/verbatim,
+ ftplugin/latex-suite/packages/version, ftplugin/latex-suite/packages.vim,
+ ftplugin/latex-suite/projecttemplate.vim, ftplugin/latex-suite/pytools.py,
+ ftplugin/latex-suite/smartspace.vim,
+ ftplugin/latex-suite/templates/article.tex,
+ ftplugin/latex-suite/templates/IEEEtran.tex,
+ ftplugin/latex-suite/templates/report.tex,
+ ftplugin/latex-suite/templates/report_two_column.tex,
+ ftplugin/latex-suite/templates.vim, ftplugin/latex-suite/texmenuconf.vim,
+ ftplugin/latex-suite/texproject.vim, ftplugin/latex-suite/texrc,
+ ftplugin/latex-suite/texviewer.vim, ftplugin/latex-suite/version.vim,
+ ftplugin/latex-suite/wizardfuncs.vim, ftplugin/tex/brackets.vim,
+ ftplugin/tex_latexSuite.vim, ftplugin/tex/texviewer.vim, indent/tex.vim,
+ plugin/filebrowser.vim, plugin/imaps.vim, plugin/libList.vim,
+ plugin/remoteOpen.vim, plugin/SyntaxFolds.vim
Added: trunk/utils/addons/registry-samples/matchit
URL: http://svn.debian.org/wsvn/trunk/utils/addons/registry-samples/matchit?rev=661&op=file
==============================================================================
--- trunk/utils/addons/registry-samples/matchit (added)
+++ trunk/utils/addons/registry-samples/matchit Thu May 11 18:16:11 2006
@@ -1,0 +1,3 @@
+Add-On: matchit
+Description: extended matching with "%" (e.g. if ... then ... else)
+Files: plugin/matchit.vim, doc/matchit.txt
Added: trunk/utils/addons/registry-samples/utl
URL: http://svn.debian.org/wsvn/trunk/utils/addons/registry-samples/utl?rev=661&op=file
==============================================================================
--- trunk/utils/addons/registry-samples/utl (added)
+++ trunk/utils/addons/registry-samples/utl Thu May 11 18:16:11 2006
@@ -1,0 +1,4 @@
+Add-On: utl
+Source: /usr/share/vim-scripts/
+Files: doc/utl_usr.txt, doc/utl_ref.txt, plugin/utl_rc.vim, plugin/utl.vim,
+ plugin/utl_scm.vim, plugin/utl_arr.vim, plugin/utl_uri.vim
Added: trunk/utils/addons/src/vim/__init__.py
URL: http://svn.debian.org/wsvn/trunk/utils/addons/src/vim/__init__.py?rev=661&op=file
==============================================================================
--- trunk/utils/addons/src/vim/__init__.py (added)
+++ trunk/utils/addons/src/vim/__init__.py Thu May 11 18:16:11 2006
@@ -1,0 +1,20 @@
+# Copyright (C) 2006, Stefano Zacchiroli <zack at debian.org>
+#
+# This file is part of vim-addons, a tool for managing Vim add-ons on Debian
+# GNU/Linux systems.
+#
+# vim-addons is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# vim-addons is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 51
+# Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import addons
+
Added: trunk/utils/addons/src/vim/addons/__init__.py
URL: http://svn.debian.org/wsvn/trunk/utils/addons/src/vim/addons/__init__.py?rev=661&op=file
==============================================================================
--- trunk/utils/addons/src/vim/addons/__init__.py (added)
+++ trunk/utils/addons/src/vim/addons/__init__.py Thu May 11 18:16:11 2006
@@ -1,0 +1,23 @@
+# Copyright (C) 2006, Stefano Zacchiroli <zack at debian.org>
+#
+# This file is part of vim-addons, a tool for managing Vim add-ons on Debian
+# GNU/Linux systems.
+#
+# vim-addons is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# vim-addons is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 51
+# Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import constants
+import errors
+import registry
+import utils
+
Added: trunk/utils/addons/src/vim/addons/constants.py
URL: http://svn.debian.org/wsvn/trunk/utils/addons/src/vim/addons/constants.py?rev=661&op=file
==============================================================================
--- trunk/utils/addons/src/vim/addons/constants.py (added)
+++ trunk/utils/addons/src/vim/addons/constants.py Thu May 11 18:16:11 2006
@@ -1,0 +1,28 @@
+# Copyright (C) 2006, Stefano Zacchiroli <zack at debian.org>
+#
+# This file is part of vim-addons, a tool for managing Vim add-ons on Debian
+# GNU/Linux systems.
+#
+# vim-addons is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# vim-addons is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 51
+# Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+"""default values and other constants"""
+
+personal_dest_dir = '~/.vim'
+system_src_dir = '/usr/share/vim/addons'
+system_dest_dir = '/var/lib/vim/addons'
+
+name_field_w = 25
+personal_field_w = 10
+system_field_w = 10
+
Added: trunk/utils/addons/src/vim/addons/errors.py
URL: http://svn.debian.org/wsvn/trunk/utils/addons/src/vim/addons/errors.py?rev=661&op=file
==============================================================================
--- trunk/utils/addons/src/vim/addons/errors.py (added)
+++ trunk/utils/addons/src/vim/addons/errors.py Thu May 11 18:16:11 2006
@@ -1,0 +1,29 @@
+# Copyright (C) 2006, Stefano Zacchiroli <zack at debian.org>
+#
+# This file is part of vim-addons, a tool for managing Vim add-ons on Debian
+# GNU/Linux systems.
+#
+# vim-addons is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# vim-addons is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 51
+# Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+"""exceptions for the vim add-ons registry package"""
+
+class RegistryError(Exception):
+ """base classe for errors in the vim add-ons registry package"""
+
+class MalformedRegistry(RegistryError):
+ """syntactically and/or semantically malformed registry"""
+
+class BadInvocation(Exception):
+ """some action of vim-addons has been invoked in an unappropriate manner"""
+
Added: trunk/utils/addons/src/vim/addons/registry.py
URL: http://svn.debian.org/wsvn/trunk/utils/addons/src/vim/addons/registry.py?rev=661&op=file
==============================================================================
--- trunk/utils/addons/src/vim/addons/registry.py (added)
+++ trunk/utils/addons/src/vim/addons/registry.py Thu May 11 18:16:11 2006
@@ -1,0 +1,108 @@
+# Copyright (C) 2006, Stefano Zacchiroli <zack at debian.org>
+#
+# This file is part of vim-addons, a tool for managing Vim add-ons on Debian
+# GNU/Linux systems.
+#
+# vim-addons is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# vim-addons is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 51
+# Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import email
+import os
+import stat
+import string
+
+from vim.addons.constants import system_src_dir
+from vim.addons import errors
+
+def is_registry_file(fname):
+ return (not fname[0] == '.')
+
+class Registry:
+ """registry of Vim add-ons installed in a Debian GNU/Linux system"""
+
+ def __init__(self, dir='/usr/share/vim/registry'):
+ """create a registry from a set of files located (non recursively) in
+ the given directory
+ """
+ self.__addons = {}
+ if not os.path.isdir(dir):
+ raise errors.MalformedRegistry, \
+ ("can't read directory %s" % dir)
+ _,_,files = os.walk(dir).next()
+ for f in files:
+ if not is_registry_file(f):
+ continue
+ msg = email.message_from_file(open(os.path.join(dir, f)))
+ if not msg.has_key('add-on'):
+ raise errors.MalformedRegistry, \
+ ("'add-on' field not found in file %s" % f)
+ name = msg['add-on']
+ if msg['add-on'] != f: # file name vs add-on name mismatch
+ raise errors.MalformedRegistry, \
+ ("file %s has add-on name %s, they should be equal" %
+ (os.path.join(dir, f), msg['add-on']))
+ self.__addons[name] = AddOn(msg)
+
+ def get(self,name):
+ """add-on lookup by name"""
+ return self.__addons[name]
+
+ def has_addon(self,name):
+ return self.__addons.has_key(name)
+
+ def list(self):
+ """list the available add-ons"""
+ names = self.__addons.keys()
+ names.sort()
+ return names
+
+ def __getitem__(self, name):
+ """add-on lookup by name"""
+ return self.get(name)
+
+class AddOn:
+ """encode a single Vim add-on"""
+
+ def __init__(self, msg):
+ """build an add-on from its RFC822 message representation"""
+ if not isinstance(msg, email.Message.Message):
+ raise TypeError, msg
+ if not msg.has_key('add-on'):
+ raise ValueError, "'add-on' field not found"
+ if not msg.has_key('files'):
+ raise ValueError, "'files' field not found"
+ self.__name = msg['add-on']
+ self.__files = map(string.strip, msg['files'].split(','))
+ if self.__files == []:
+ raise ValueError, 'an add-on should list at least 1 file'
+ self.__description = msg['description']
+ self.__source = msg['source']
+ if not self.__source:
+ self.__source = system_src_dir
+
+ def name(self):
+ """Add-on name (required field) """
+ return self.__name
+
+ def files(self):
+ """Add-on files (required field) """
+ return self.__files
+
+ def description(self):
+ """Add-on description (optional field) """
+ return self.__description
+
+ def source(self):
+ """Add-on source directory (optional field) """
+ return self.__source
+
Added: trunk/utils/addons/src/vim/addons/utils.py
URL: http://svn.debian.org/wsvn/trunk/utils/addons/src/vim/addons/utils.py?rev=661&op=file
==============================================================================
--- trunk/utils/addons/src/vim/addons/utils.py (added)
+++ trunk/utils/addons/src/vim/addons/utils.py Thu May 11 18:16:11 2006
@@ -1,0 +1,34 @@
+# Copyright (C) 2006, Stefano Zacchiroli <zack at debian.org>
+#
+# This file is part of vim-addons, a tool for managing Vim add-ons on Debian
+# GNU/Linux systems.
+#
+# vim-addons is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# vim-addons is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 51
+# Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+"""utility functions"""
+
+import sys
+
+def info(msg):
+ sys.stderr.write('I: ' + msg + '\n')
+ sys.stderr.flush()
+
+def warn(msg):
+ sys.stderr.write('W: ' + msg + '\n')
+ sys.stderr.flush()
+
+def error(msg):
+ sys.stderr.write('E: ' + msg + '\n')
+ sys.stderr.flush()
+
Added: trunk/utils/addons/src/vim/addons/vim-addons
URL: http://svn.debian.org/wsvn/trunk/utils/addons/src/vim/addons/vim-addons?rev=661&op=file
==============================================================================
--- trunk/utils/addons/src/vim/addons/vim-addons (added)
+++ trunk/utils/addons/src/vim/addons/vim-addons Thu May 11 18:16:11 2006
@@ -1,0 +1,228 @@
+#!/usr/bin/python
+
+# Copyright (C) 2006, Stefano Zacchiroli <zack at debian.org>
+#
+# This file is part of vim-addons, a tool for managing Vim add-ons on Debian
+# GNU/Linux systems.
+#
+# vim-addons is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# vim-addons is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 51
+# Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+from optparse import OptionParser
+import os
+import string
+import sys
+import textwrap
+
+# XXX temp, remove-me
+sys.path.insert(0, '/home/zack/pkg-vim/trunk/utils/addons/src')
+
+from vim.addons.constants import *
+from vim.addons import errors
+import vim.addons.registry
+from vim.addons import utils
+
+__registry_instance = None
+
+def get_registry():
+ """access to a singleton instance of the add-ons registry"""
+ global __registry_instance
+ if not __registry_instance:
+ __registry_instance = vim.addons.registry.Registry()
+ return __registry_instance
+
+def find_end_points(file, srcdir, destdir):
+ src = os.path.join(srcdir, file)
+ dest = os.path.join(destdir, file)
+ return (src, dest)
+
+def is_enabled(addon, destdir):
+ """check if an add-on is enabled in a given destination directory"""
+ # XXX simple implementation ATM, only the first of the several file
+ # pertaining to an add-on is checked (i.e. we assume: "if one file is
+ # linked then everyone is")
+
+ file = addon.files()[0]
+
+ (src, dest) = find_end_points(file, addon.source(), destdir)
+ return (os.path.islink(dest) and os.readlink(dest) == src)
+
+def list_action(args, options):
+ def pp(b):
+ if b:
+ return 'enabled'
+ else:
+ return 'disabled'
+
+ r = get_registry()
+ if not options.quiet:
+ print string.ljust(' Name', name_field_w), \
+ '|', string.ljust('Personal', personal_field_w), \
+ '|', string.ljust('System', system_field_w)
+ print '-' * (name_field_w + 1) + '+' + '-' * (personal_field_w + 2) \
+ + '+' + '-' * system_field_w
+ for name in r.list():
+ system_enabled = is_enabled(r[name], system_dest_dir)
+ personal_enabled = is_enabled(r[name],
+ os.path.expanduser(personal_dest_dir))
+ print string.ljust(' ' + name, name_field_w), \
+ '|', string.ljust(pp(personal_enabled), personal_field_w),\
+ '|', string.ljust(pp(system_enabled), system_field_w)
+ else:
+ for name in r.list():
+ print name
+
+def symlink(files, srcdir, destdir):
+ for f in files:
+ (src, dest) = find_end_points(f, srcdir, destdir)
+ if not os.path.isfile(src):
+ utils.warn("file '%s' does not exists, skipping its linking" % src)
+ continue
+ dirpart = os.path.dirname(dest) # in general: dirpart != destdir
+ if not os.path.isdir(dirpart):
+ # ensure actual destdir exists
+ utils.info("destination dir '%s' does not exist, creating it" %
+ dirpart)
+ os.makedirs(dirpart)
+ # do linking
+ if os.path.islink(dest):
+ if os.readlink(dest) != src:
+ os.unlink(dest)
+ os.symlink(src, dest)
+ elif os.path.isfile(dest):
+ utils.error("file '%s' exists and is not a symlink, "\
+ 'skipping its linking; please remove it and try again' %
+ dest)
+ continue
+ else:
+ os.symlink(src, dest)
+
+def unsymlink(files, destdir):
+ for f in files:
+ link = os.path.join(destdir, f)
+ if os.path.islink(link):
+ os.unlink(link)
+ curdir = os.path.dirname(link)
+ _,subdirs,subfiles = os.walk(curdir).next()
+ if subdirs == [] and subfiles == []: # curdir is empty, remove it
+ os.removedirs(os.path.dirname(link))
+ else:
+ utils.warn("file '%s' is not a symlink or does not exist, " \
+ 'skipping its removal' % link)
+ continue
+
+def expand_wildcard_addon(addons):
+ r = get_registry()
+ if addons == ['ALL']:
+ return r.list()
+ return addons
+
+def enable_action(args, options):
+ if not args:
+ raise errors.BadInvocation( \
+ 'you should specify one or more add-ons to enable')
+ r = get_registry()
+
+ for name in expand_wildcard_addon(args):
+ if not r.has_addon(name):
+ utils.warn("add-on '%s' not found, skipping it" % name)
+ continue
+ addon = r[name]
+ if is_enabled(addon, options.destdir) and not options.force:
+ if not options.quiet:
+ utils.warn("add-on '%s' is enabled, skipping it " \
+ "(forgot '--force'?)" % name)
+ continue
+ symlink(addon.files(), addon.source(), options.destdir)
+
+def disable_action(args, options):
+ if not args:
+ raise errors.BadInvocation( \
+ 'you should specify one or more add-ons to disable')
+ r = get_registry()
+
+ for name in expand_wildcard_addon(args):
+ if not r.has_addon(name):
+ utils.warn("add-on '%s' not found, skipping it" % name)
+ continue
+ addon = r[name]
+ if not is_enabled(addon, options.destdir) and not options.force:
+ if not options.quiet:
+ utils.warn("add-on '%s' is disabled, skipping it " \
+ "(forgot '--force'?)" % name)
+ continue
+ unsymlink(addon.files(), options.destdir)
+
+def main():
+ actions = {} # set up available actions
+ actions['list'] = (list_action, 'list available add-ons')
+ actions['enable'] = (enable_action, \
+ 'enables a list of add-on names given as arguments.' \
+ " 'ALL' alone can be given to act on all available add-ons")
+ actions['disable'] = (disable_action, \
+ 'disables a list of add-on names given as arguments.' \
+ " 'ALL' alone can be given to act on all available add-ons")
+
+ # help and command line parsing
+ actions_description = ''
+ names = actions.keys()
+ names.sort()
+ for name in names:
+ (_, dsc) = actions[name]
+ if actions_description != '':
+ actions_description += '\n'
+ actions_description += textwrap.fill(name + ': ' + dsc, \
+ initial_indent=' ', subsequent_indent=' ')
+ usage='%prog [options] <action> [arg ...]\n\n' \
+ 'actions:\n' + actions_description + \
+ "\n\ntry 'vim-addons' --help for more info"
+ parser = OptionParser(usage=usage)
+ parser.add_option('-d', '--destdir', action='store',
+ dest='destdir', default=personal_dest_dir,
+ metavar='DIR', help='specify destination directory')
+ parser.add_option('-p', '--personal', action='store_const',
+ dest='destdir', const=personal_dest_dir,
+ help='act on current user %s configuration directory' \
+ ' (same as -d %s)' \
+ % (personal_dest_dir, personal_dest_dir))
+ parser.add_option('-w', '--systemwide', action='store_const',
+ dest='destdir', const=system_dest_dir,
+ help='act on system wide configuration directory' \
+ ' (same as -d %s)' % system_dest_dir)
+ parser.add_option('-q', '--quiet', action='store_true',
+ dest='quiet', default=False,
+ help='decrease verbosity')
+ parser.add_option('-v', '--verbose', action='store_true',
+ dest='verbose', default=False,
+ help='increase verbosity')
+ parser.add_option('-f', '--force', action='store_true',
+ dest='force', default=False,
+ help='force actions (e.g. enabling of an enabled add-on)')
+ (options, args) = parser.parse_args()
+ if not args:
+ parser.error('you should specify an action')
+ options.destdir = os.path.expanduser(options.destdir)
+
+ # invoke the required action
+ action_name = args[0]
+ if not actions.has_key(action_name):
+ parser.error("unrecognized action '%s'" % action_name)
+ try:
+ action, _ = actions[action_name]
+ action(args[1:], options)
+ except errors.BadInvocation, msg:
+ parser.error(msg)
+
+if __name__ == '__main__':
+ main()
+
Propchange: trunk/utils/addons/src/vim/addons/vim-addons
------------------------------------------------------------------------------
svn:executable = *
More information about the pkg-vim-maintainers
mailing list