Hallo, dies ist ein Test.
PWD: /www/data-lst1/unixsoft/unixsoft/kaempfer/.public_html
Running in File Mode
Relative path: ./../.././.././../../../bin/odoctool
Real path: /usr/bin/odoctool
Zurück
#!/usr/bin/python3.11 -Es import solaris.no_site_packages # # Copyright (c) 2016, 2021, Oracle and/or its affiliates. # import os import sys import gettext import logging from odoc import __version__ TEXT_DOMAIN = 'solaris_app_odoc' _ = gettext.translation(TEXT_DOMAIN, '/usr/lib/locale', fallback=True).gettext # Populated once ODOCDIR is found and actions are scanned _ACTION_HELP = '' def print_version(exit_code=None): """Print program version and exit with given exit_code.""" print('odoctool - online documentation tool\n' 'version: {}\n'.format(__version__)) sys.exit(exit_code) def print_help(exit_code=None): """Print short help message and exit with given exit_code.""" print(_('odoctool - online documentation tool\n' 'Usage: odoctool [opts]\n' ' odoctool [opts] <action> [action_opts] [arg1,arg2...]\n' '\n' 'Available options (also for all subcommands):\n' '-D, --debug enable debug messages\n' ' --log=FILE log messages to given file\n' '-V, --version print program version and exit\n' '-h, --help print this message and exit\n' '\n' 'Available actions:\n' '{}' '\n' 'Environment:\n' 'ODOC_CONF_<variable> override configuration variables - e.g.:\n' 'ODOC_CONF_SHARE_DIR path to directory with odoc assets\n' 'ODOC_CONF_BUNDLE_DIR path to directory with bundles\n' '\n' 'To pass a global option use `odoctool [opts] <action>`.\n' 'To see available action options use `odoctool <action> --help`.\n' '\n' 'For more information see: `man odoctool`.').format(_ACTION_HELP)) sys.exit(exit_code) if __name__ == '__main__': """Detect the program directory. Odoctool can be run either from workspace clone (for development purposes mostly) and from system-wide installation. Based on ability to import `odoc' module we need to setup certain parameters (mostly paths to resources) and modify sys.path in case odoctool is run from the workspace. """ # Determine program directory (to allow running from source clone) odoc_dir = os.getenv('ODOCDIR', None) if odoc_dir: if not os.path.exists(odoc_dir): print('error: ODOCDIR must be a valid directory', file=sys.stderr) print_help(1) odoc_dir = os.path.realpath(odoc_dir) sys.path.insert(1, odoc_dir) # Application imports and initialization actions = [] err_msg = None try: import odoc except ImportError: if odoc_dir: err_msg = 'invalid ODOCDIR setting' else: # Before giving up try Python package source-layout (run from # source repository) bin_dir = os.path.dirname(os.path.realpath(__file__)) odoc_dir = os.path.realpath(os.path.join(bin_dir, '..')) try: sys.path.insert(1, odoc_dir) import odoc except ImportError: err_msg = 'odoc is not installed correctly' if err_msg: print('error: {0}'.format(err_msg), file=sys.stderr) print_help(1) # Compare version of executable and odoc module to warn user about # importing non-matching components (e.g. vendor-packages version) if __version__ != odoc.__version__: print('warning: odoc module version differs from executable') from odoc import conf from odoc import util action = None action_args = [] logging_opts = {} print_help_switch = False # Global options array opts_def = [('h', 'help', False), ('V', 'version', False), ('D', 'debug', False), (None, 'logfile', True)] # Chomp global options. First non-option is taken as an action and all # other arguments are passed to that action run() as action- argv. opts, args = util.process_args(opts_def, help_func=print_help) # Handle opts for opt, arg in opts.items(): if opt == ('D', 'debug'): conf.DEBUG = 1 logging_opts['level'] = logging.DEBUG elif opt == (None, 'logfile'): logging_opts['file'] = arg elif opt == ('V', 'version'): print_version() elif opt == ('h', 'help'): # We don't want to print help directly as message contains # information gathered AFTER action introspection print_help_switch = True # Pass args if args: action = args[0] action_args = args[1:] # Setup logging facility util.init_logging(logging_opts) logging.debug('--- log started ---') logging.debug('odoc version: {}'.format(odoc.__version__)) # Setup directories (handles ODOC_CONF_<variable> override) util.init_conf(prog_dir=odoc_dir) # Import available actions # NOTE: We can't do this early as logging is used in actions __init__() from odoc import actions if not actions.ACTIONS: print('error: no actions available\n', file=sys.stderr) print_help(1) for k in actions.ACTIONS.keys(): if not actions.ACTIONS[k].is_hidden: _ACTION_HELP += '{:<23}{}\n'.format(k, actions.ACTIONS[k].desc) if print_help_switch: print_help() if not action: print('error: no action specified\n', file=sys.stderr) print_help(1) # Execute action if valid if action not in actions.ACTIONS: print('error: invalid action\n', file=sys.stderr) print_help(1) try: logging.debug('executing action {}'.format(action)) actions.ACTIONS[action].run(action_args) except Exception as err: logging.debug(err) if int(conf.DEBUG) > 1: import traceback traceback.print_exc() sys.exit('error: {} failed: {}'.format(action, err))