refs #1059 add ogHelp
parent
c3a0e8db1c
commit
2d02f00766
|
@ -8,6 +8,10 @@ import stat
|
|||
#def ogGetOsUuid():
|
||||
#def ogGetSerialNumber():
|
||||
|
||||
#/**
|
||||
# ogIsEfiActive
|
||||
#@brief Comprueba si el sistema tiene activo el arranque EFI.
|
||||
#*/ ##
|
||||
def ogIsEfiActive():
|
||||
try:
|
||||
return stat.S_ISDIR (os.stat ('/sys/firmware/efi').st_mode)
|
||||
|
|
|
@ -155,45 +155,19 @@ import inspect
|
|||
#@note Si no se indican parámetros, la función se toma de la variable \c $FUNCNAME
|
||||
#@note La descripción de la función se toma de la variable compuesta por \c MSG_FUNC_$función incluida en el fichero de idiomas.
|
||||
#@note Pueden especificarse varios mensajes con ejemplos.
|
||||
#@version 0.9 - Primera versión para OpenGnSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2009-07-27
|
||||
#*/
|
||||
def ogHelp (fname, fmt, msg):
|
||||
func = fname or inspect.stack()[1][3]
|
||||
MSG = f'MSG_HELP_{func}'
|
||||
# Variables locales
|
||||
FUNC = ""
|
||||
MSG = ""
|
||||
FUNCNAME = ogHelp.__name__
|
||||
def ogHelp (fname, fmt=None, examples=[]):
|
||||
FUNC = fname or inspect.stack()[1][3]
|
||||
MSG = f'ogGlobals.MSG_HELP_{FUNC}'
|
||||
ogEcho ([], "help", f"{ogGlobals.MSG_FUNCTION} {FUNC}: {eval (MSG)}")
|
||||
if fmt:
|
||||
ogEcho([], "help", f" {ogGlobals.MSG_FORMAT}: {fmt}")
|
||||
|
||||
# Mostrar función, descripción y formato.
|
||||
FUNC = args[0] if len(args) > 0 else FUNCNAME[-1]
|
||||
MSG = f"MSG_HELP_{FUNC}"
|
||||
ogEcho("help", f"{MSG_FUNCTION} {FUNC}: {globals()[MSG]}")
|
||||
if len(args) > 1:
|
||||
ogEcho("help", f" {MSG_FORMAT}: {args[1]}")
|
||||
|
||||
# Mostrar ejemplos (si existen).
|
||||
for example in args[2:]:
|
||||
ogEcho("help", f" {MSG_EXAMPLE}: {example}")
|
||||
#function ogHelp () {
|
||||
#
|
||||
## Variables locales.
|
||||
#local FUNC MSG
|
||||
#
|
||||
## Mostrar función, descripción y formato.
|
||||
#FUNC="${1:-${FUNCNAME[${#FUNCNAME[*]}-1]}}"
|
||||
#MSG="MSG_HELP_$FUNC"
|
||||
#ogEcho help "$MSG_FUNCTION $FUNC: ${!MSG}"
|
||||
#[ -n "$2" ] && ogEcho help " $MSG_FORMAT: $2"
|
||||
## Mostrar ejemplos (si existen).
|
||||
#shift 2
|
||||
#while [ $# -gt 0 ]; do
|
||||
# ogEcho help " $MSG_EXAMPLE: $1"
|
||||
# shift
|
||||
#done
|
||||
#}
|
||||
if type (examples) is list:
|
||||
for example in examples:
|
||||
ogEcho([], "help", f" {ogGlobals.MSG_EXAMPLE}: {example}")
|
||||
else: ## string
|
||||
ogEcho([], "help", f" {ogGlobals.MSG_EXAMPLE}: {examples}")
|
||||
|
||||
def ogRaiseError(*args):
|
||||
# Variables locales
|
||||
|
|
|
@ -8,4 +8,10 @@ OGLOGCOMMAND='/tmp/command.log'
|
|||
OGLOGSESSION='/tmp/session.log'
|
||||
DEBUG='yes'
|
||||
|
||||
## languages
|
||||
MSG_EXAMPLE='Example'
|
||||
MSG_FORMAT='Format'
|
||||
MSG_FUNCTION='Function'
|
||||
## /languages
|
||||
|
||||
TZ='Europe/Madrid'
|
||||
|
|
Loading…
Reference in New Issue