Commit 35856e2d by Eric Coissac

Add a xml module priding basic function to write simple XML files

parent f16ddd53
......@@ -39,6 +39,7 @@ name of each reloaded module.
- **[clobber](#clobber)** : for managing the clobber/noclobber status
- **[download](#download)** : for managing download from FTP and Web including MD5 checks
- **[ifs](#ifs)** : for managing the *input field separator*
- **[irods](#irods)** : provide functions wrapping the iRods iget and iput icommands.
- **[lecaluke](#lecaluke)** : declare variable related for the LECA computers in LUKE
- **[logging](#logging)** : adds functionnalities for managing log files and log levels
- **[mutex](#mutex)** : manages concurent access to resources through locks and semaphores
......@@ -46,7 +47,7 @@ name of each reloaded module.
- **[stacks](#stacks)** : manages *stacks* of values
- **[tempdir](#tempdir)** : manages the creation of temporary directories and their erasements
- **[timeout](#timeout)** : provides a function for limiting the maximum execution time of a command
- **[irods](#irods)** : provide functions wrapping the iRods iget and iput icommands.
- **[xml](#xml)** : provides a set of functions to write basic XML files
----------------------------------------------------------
......@@ -488,13 +489,13 @@ Closes the current logfile and redirect the logging to stderr.
----------------------------------------------------------
## stack
## stacks
### Activating the module
```{shell}
> source $LECABASHHOME/utils.sh
> include stack
> include stacks
```
### Functions provided:
......@@ -679,3 +680,45 @@ The function download the file until the MD5 check is ok or the maximum retrial
count is reached.
`igetwithmd5` is not taking care of protecting is access by a lock or a semaphore.
## xml
### Activating the module
```{shell}
> source $LECABASHHOME/utils.sh
> include xml
```
### Functions provided:
#### XML_header
```{shell}
XML_header
```
#### XML_push
```{shell}
XML_push <TAG>
```
#### XML_pop
```{shell}
XML_pop
```
#### XML_tag_data
```{shell}
XML_tag_data <TAG> <VALUES>
```
#### XML_data
```{shell}
XML_data <VALUES>
```
#
# LECA Bash library
#
# The LECA bash library provides a set of function used for helping
# development of bash script mainly to write job script on the luke
# cluster
#
# The files from the LECA Bash library must be sourced from your main script
#
include logging
logdebug "Load XML package"
include stacks
######
#
# XML formating function
#
newstack __LECABASH__markup__
function __LECABASH__XML_pad__() {
local pad=$(printf '%0.1s' " "{1..60})
local padlength=$(( $1 * 2 ))
printf '%*.*s' 0 "$padlength" "$pad"
}
function XML_header() {
echo '<?xml version="1.0" encoding="UTF-8"?>'
}
function XML_push() {
local tag=$1
shift
local attribs="$*"
__LECABASH__XML_pad__ $(stacksize __LECABASH__markup__)
echo -n "<${tag}"
if [[ -z "${attribs}" ]] ; then
echo ">"
else
echo " ${attribs}>"
fi
pushvalue __LECABASH__markup__ "${tag}"
}
function XML_pop() {
local tag=""
popvalue __LECABASH__markup__ tag
__LECABASH__XML_pad__ $(stacksize __LECABASH__markup__)
echo "</${tag}>"
}
function XML_tag_data() {
local tag=$1
shift
__LECABASH__XML_pad__ $(stacksize __LECABASH__markup__)
echo "<${tag}>$*</${tag}>"
}
function XML_data() {
__LECABASH__XML_pad__ $(stacksize __LECABASH__markup__)
echo "$*"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment