#
# This file is part of Documancer (http://documancer.sf.net)
#
# Copyright (C) 2002-2005 Vaclav Slavik
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id: provider.py,v 1.7 2005/01/30 19:46:31 vaclavslavik Exp $
#
# Info pages documentation provider (Unix)
#
import sys
if sys.platform == 'win32':
raise ImportError('Info provider is for Unix only')
from gettext import gettext as _
import providers
import os.path, commands, string, urllib
infopagesList = None
def getInfopagesList():
global infopagesList
if infopagesList == None:
l = commands.getoutput("helpers/info2html/infocat 2>/dev/null").splitlines()
infopagesList = []
url = None
for i in l:
if i == '':
url = None
continue
if url == None:
url = i
else:
key = i[:i.find(':')]
infopagesList.append((key, i, url))
return infopagesList
class InfoProvider(providers.DocumentationProvider):
def getID(self):
return 'info'
def getName(self):
return _('Info pages')
def getDescription(self):
return _("""Unix info pages.
This plugin is based on
info2html
by Karl Guggisberg.""")
def serve(self, book, url):
if url == "" or url == "index.html": url = "INFOCAT"
if url[-5:] == ".html": url = url[:-5]
urls = url.split("/")
if len(urls) == 1:
urls.append("Top")
root_url = "."
else:
root_url = ".."
catalog = urllib.quote(urls[0])
page = urllib.quote(string.join(urls[1:], "/"))
if catalog == "INFOCAT":
txt = """