File: Help.py

package info (click to toggle)
pybliographer 1.2.12-4squeeze1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 3,560 kB
  • ctags: 1,413
  • sloc: python: 9,817; xml: 2,560; sh: 813; makefile: 621
file content (65 lines) | stat: -rw-r--r-- 1,691 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# This file is part of pybliographer
# 
# Copyright (C) 1998-2004 Frederic GOBRY
# Email : gobry@pybliographer.org
# 	   
# This program 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.
#   
# 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.
# 
# 

import string
import sys

Topics = {}

# --------------------------------------------------
def register (topic, help):
	''' Register a new help topic '''
	
	Topics [topic] = help


	
# --------------------------------------------------
def help (argument):
	''' The help function, as called by the main program '''

	if argument == "":
		print "Type help <topic> for specific info. Topics are:\n"
		
		tcount = 0
		topics = Topics.keys ()
		topics.sort ()
		
		for topics in topics:
			sys.stdout.write (' ' + string.ljust (topics, 20))
			tcount = tcount + 1
			if tcount > 3:
				tcount = 0
				print
		if tcount > 0:
			print
				
	else:
		if Topics.has_key (argument):
			print '-' * 70
			print " Help topic : `%s'" % argument
			print '-' * 70

			print Topics [argument]
			print
		else:
			print "error: topic `%s' not documented" % argument