def usage_msg(self):
        """Generate a help message using saved option info."""
        if self.__usage:
            return self.__usage
        app = self.__app
        if not app:
            app = sys.argv[0].split(os.sep)[-1]
        str = 'Usage: ' + app
        if len(self.__olist):
            str = str + ' [options]'
        if self.__args:
            str = str + ' ' + self.__args
        self.__usage = map(lambda s: s + '\n', str.split('\n'))
        if len(self.__olist):
            self.__usage = self.__usage + ['\n', 'Options:\n']
        # Loop over options
        for oinfo in self.__olist:
            lside = rside = ''
            # Left side is -x,--xthing xarg
            if oinfo['opt']:
                lside = lside + oinfo['opt']
            if oinfo['long']:
                if oinfo['opt']:
                    lside = lside + ','
                lside = lside + oinfo['long']
            if oinfo['arg']:
                lside = lside + ' ' + oinfo['arg']
            lside = [ string.ljust(lside, self.__usage_lwid) ]
            # Right side is usage, word wrapped to fit
            rside = word_wrap.wrap_list(oinfo['usage'], self.__usage_rwid)
            # Pad out extra blank lines on left side
            for i in range(len(rside) - 1):
                lside.append(string.ljust('', self.__usage_lwid))
            # Tack 'em together
            self.__usage = self.__usage +  map(lambda l, r: l + r + '\n',
                                               lside, rside)
        if self.__note:
            self.__usage.append('\n')
            tmp = map(lambda s: s + '\n',
                      word_wrap.wrap_str(self.__note, self.__usage_width, '\n\n'))
            self.__usage = self.__usage + tmp
        return self.__usage
Generate a help message using saved option info.
recipes/Python/80308_xgetopt_solutimanaging_commnad_line_args_usage/recipe-80308.py