refs #1059 add ogHelp

pull/1/head
Natalia Serrano 2024-10-29 16:19:51 +01:00
parent c3a0e8db1c
commit 2d02f00766
3 changed files with 21 additions and 37 deletions

View File

@ -8,6 +8,10 @@ import stat
#def ogGetOsUuid(): #def ogGetOsUuid():
#def ogGetSerialNumber(): #def ogGetSerialNumber():
#/**
# ogIsEfiActive
#@brief Comprueba si el sistema tiene activo el arranque EFI.
#*/ ##
def ogIsEfiActive(): def ogIsEfiActive():
try: try:
return stat.S_ISDIR (os.stat ('/sys/firmware/efi').st_mode) return stat.S_ISDIR (os.stat ('/sys/firmware/efi').st_mode)

View File

@ -155,45 +155,19 @@ import inspect
#@note Si no se indican parámetros, la función se toma de la variable \c $FUNCNAME #@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 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. #@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): def ogHelp (fname, fmt=None, examples=[]):
func = fname or inspect.stack()[1][3] FUNC = fname or inspect.stack()[1][3]
MSG = f'MSG_HELP_{func}' MSG = f'ogGlobals.MSG_HELP_{FUNC}'
# Variables locales ogEcho ([], "help", f"{ogGlobals.MSG_FUNCTION} {FUNC}: {eval (MSG)}")
FUNC = "" if fmt:
MSG = "" ogEcho([], "help", f" {ogGlobals.MSG_FORMAT}: {fmt}")
FUNCNAME = ogHelp.__name__
# Mostrar función, descripción y formato. if type (examples) is list:
FUNC = args[0] if len(args) > 0 else FUNCNAME[-1] for example in examples:
MSG = f"MSG_HELP_{FUNC}" ogEcho([], "help", f" {ogGlobals.MSG_EXAMPLE}: {example}")
ogEcho("help", f"{MSG_FUNCTION} {FUNC}: {globals()[MSG]}") else: ## string
if len(args) > 1: ogEcho([], "help", f" {ogGlobals.MSG_EXAMPLE}: {examples}")
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
#}
def ogRaiseError(*args): def ogRaiseError(*args):
# Variables locales # Variables locales

View File

@ -8,4 +8,10 @@ OGLOGCOMMAND='/tmp/command.log'
OGLOGSESSION='/tmp/session.log' OGLOGSESSION='/tmp/session.log'
DEBUG='yes' DEBUG='yes'
## languages
MSG_EXAMPLE='Example'
MSG_FORMAT='Format'
MSG_FUNCTION='Function'
## /languages
TZ='Europe/Madrid' TZ='Europe/Madrid'