refs #1101 add ogGetParentPath()

pull/1/head
Natalia Serrano 2024-11-11 16:54:25 +01:00
parent 4342a5c27e
commit d49e01f9e2
1 changed files with 18 additions and 17 deletions

View File

@ -224,26 +224,27 @@ def ogGetPath (src=None, file=None):
#print (f'f ({f}) prevfile ({prevfile})')
return filepath
def ogGetParentPath(*args):
# Variables locales.
PARENT = None
if "help" in args:
FileSystemLib.ogHelp("$FUNCNAME", "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_filepath", "$FUNCNAME \"/mnt/sda1/windows/system32\" ==> /mnt/sda1/WINDOWS", "$FUNCNAME REPO /etc/fstab ==> /opt/opengnsys/images/etc", "$FUNCNAME 1 1 \"/windows/system32\" ==> /mnt/sda1/WINDOWS")
#/**
# ogGetParentPath [ str_repo | int_ndisk int_npartition ] path_filepath
#@brief Metafunción que devuelve el camino del directorio padre.
#@see ogGetPath
#*/ ##
#ogGetParentPath ([ str_repo | int_ndisk int_npartition ] path_filepath
#ogGetParentPath ('/mnt/sda1/windows/system32') ==> '/mnt/sda1/WINDOWS'
#ogGetParentPath ('REPO', '/etc/fstab') ==> '/opt/opengnsys/images/etc'
#ogGetParentPath ('1 1', '/windows/system32') ==> '/mnt/sda1/WINDOWS'
def ogGetParentPath (src=None, file=None):
if file is None:
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, '')
return
# Procesar camino según el número de parámetros.
if len(args) == 1:
PARENT = os.path.dirname(args[0])
elif len(args) == 2:
PARENT = f"{args[0]} {os.path.dirname(f'/{args[1]}')}"
elif len(args) == 3:
PARENT = f"{args[0]} {args[1]} {os.path.dirname(f'/{args[2]}')}"
if src is None:
return ogGetPath (file=os.path.dirname (file))
else:
SystemLib.ogRaiseError(OG_ERR_FORMAT)
return
return ogGetPath(PARENT)
return ogGetPath (src=src, file=os.path.dirname('/'+file))
def ogIsNewerFile(*args):
# Variables locales.