This function takes the page name and section, builds a full absolute path name, and checks that the file exists.
# - - - f i n d M a n F i l e
def findManFile ( pageName, section, suffix ):
"""Locate the man page and verify its existence.
[ (pageName is a page name as a string) and
(section is a section number as a string) and
(suffix is a suffix string) ->
if that man page exists in that section ->
return the absolute path to the page
else ->
sys.stdout +:= an error message as HTML
stop execution ]
"""
First build the absolute pathname to the file.
Then see if the file exists. See Section 4.4.1, “MAN_BASE” for the constant that defines the
path to the top directory of the man page structure.
#-- 1 --
# [ manPath := path to the man file for page name
# (pageName), section (section), and suffix (suffix) ]
manPath = ( "%s%s/%s.%s%s.gz" %
(MAN_BASE, section, pageName, section, suffix) )
#-- 2 --
# [ if manPath names an existing file ->
# I
# else ->
# sys.stdout +:= an error message in HTML
# stop execution ]
if not os.path.exists ( manPath ):
errorPage ( "No such man page: %s" % manPath )
#-- 3 --
return manPath