Add more comment about list conversion

This commit is contained in:
Josué Tille 2020-04-28 22:30:35 +02:00
parent 06bc5ba16f
commit fd967e0879
No known key found for this signature in database
GPG key ID: 716A6C99B04194EF

View file

@ -170,7 +170,7 @@ ynh_webpath_register () {
# | arg: -a, allowed= - (optional) A list of group/user to allow for the permission # | arg: -a, allowed= - (optional) A list of group/user to allow for the permission
# | arg: -l, label= - (optional) Define a name for the permission. This label will be shown on the SSO and in the admin. # | arg: -l, label= - (optional) Define a name for the permission. This label will be shown on the SSO and in the admin.
# | Default is "APP_LABEL (permission name)". # | Default is "APP_LABEL (permission name)".
# | arg: -t, show_tile= - (optional) Define if a tile will be shown in the SSO # | arg: -t, show_tile= - (optional) Define if a tile will be shown in the SSO. Default is false (for the permission different than 'main').
# | arg: -P, protected= - (optional) Define if this permission is protected. If it is protected the administrator # | arg: -P, protected= - (optional) Define if this permission is protected. If it is protected the administrator
# | won't be able to add or remove the visitors group of this permission. # | won't be able to add or remove the visitors group of this permission.
# | By default it's 'true' (for the permission different than 'main'). # | By default it's 'true' (for the permission different than 'main').
@ -215,7 +215,13 @@ ynh_permission_create() {
if [[ -n $additional_urls ]] if [[ -n $additional_urls ]]
then then
additional_urls=",additional_urls=['${additional_urls//';'/"','"}']" # Convert a list from getopts to python list
# Note that getopts separate the args with ';'
# By example:
# --additional_urls /urlA /urlB
# will be:
# additional_urls=['/urlA', '/urlB']
additional_urls=",additional_urls=['${additional_urls//;/\',\'}']"
fi fi
if [[ -n $auth_header ]] if [[ -n $auth_header ]]
@ -228,8 +234,15 @@ ynh_permission_create() {
fi fi
fi fi
if [[ -n $allowed ]]; then if [[ -n $allowed ]]
allowed=",allowed=['${allowed//';'/"','"}']" then
# Convert a list from getopts to python list
# Note that getopts separate the args with ';'
# By example:
# --additional_urls /urlA /urlB
# will be:
# additional_urls=['/urlA', '/urlB']
allowed=",allowed=['${allowed//;/\',\'}']"
fi fi
if [[ -n ${label:-} ]]; then if [[ -n ${label:-} ]]; then
@ -238,16 +251,20 @@ ynh_permission_create() {
label=",label='$YNH_APP_LABEL ($permission)'" label=",label='$YNH_APP_LABEL ($permission)'"
fi fi
if [[ -n ${show_tile:-} ]]; then if [[ -n ${show_tile:-} ]]
if [ $show_tile == "true" ]; then then
if [ $show_tile == "true" ]
then
show_tile=",show_tile=True" show_tile=",show_tile=True"
else else
show_tile=",show_tile=False" show_tile=",show_tile=False"
fi fi
fi fi
if [[ -n ${protected:-} ]]; then if [[ -n ${protected:-} ]]
if [ $protected == "true" ]; then then
if [ $protected == "true" ]
then
protected=",protected=True" protected=",protected=True"
else else
protected=",protected=False" protected=",protected=False"
@ -329,15 +346,30 @@ ynh_permission_url() {
if [[ -n $add_url ]] if [[ -n $add_url ]]
then then
add_url=",add_url=['${add_url//';'/"','"}']" # Convert a list from getopts to python list
# Note that getopts separate the args with ';'
# By example:
# --additional_urls /urlA /urlB
# will be:
# additional_urls=['/urlA', '/urlB']
add_url=",add_url=['${add_url//;/\',\'}']"
fi fi
if [[ -n $remove_url ]]; then if [[ -n $remove_url ]]
remove_url=",remove_url=['${remove_url//';'/"','"}']" then
# Convert a list from getopts to python list
# Note that getopts separate the args with ';'
# By example:
# --additional_urls /urlA /urlB
# will be:
# additional_urls=['/urlA', '/urlB']
remove_url=",remove_url=['${remove_url//;/\',\'}']"
fi fi
if [[ -n $auth_header ]]; then if [[ -n $auth_header ]]
if [ $auth_header == "true" ]; then then
if [ $auth_header == "true" ]
then
auth_header=",auth_header=True" auth_header=",auth_header=True"
else else
auth_header=",auth_header=False" auth_header=",auth_header=False"
@ -385,10 +417,22 @@ ynh_permission_update() {
if [[ -n $add ]] if [[ -n $add ]]
then then
# Convert a list from getopts to python list
# Note that getopts separate the args with ';'
# By example:
# --additional_urls /urlA /urlB
# will be:
# additional_urls=['/urlA', '/urlB']
add=",add=['${add//';'/"','"}']" add=",add=['${add//';'/"','"}']"
fi fi
if [[ -n $remove ]] if [[ -n $remove ]]
then then
# Convert a list from getopts to python list
# Note that getopts separate the args with ';'
# By example:
# --additional_urls /urlA /urlB
# will be:
# additional_urls=['/urlA', '/urlB']
remove=",remove=['${remove//';'/"','"}']" remove=",remove=['${remove//';'/"','"}']"
fi fi
@ -397,8 +441,10 @@ ynh_permission_update() {
label=",label='$label'" label=",label='$label'"
fi fi
if [[ -n $show_tile ]]; then if [[ -n $show_tile ]]
if [ $show_tile == "true" ]; then then
if [ $show_tile == "true" ]
then
show_tile=",show_tile=True" show_tile=",show_tile=True"
else else
show_tile=",show_tile=False" show_tile=",show_tile=False"
@ -406,7 +452,8 @@ ynh_permission_update() {
fi fi
if [[ -n $protected ]]; then if [[ -n $protected ]]; then
if [ $protected == "true" ]; then if [ $protected == "true" ]
then
protected=",protected=True" protected=",protected=True"
else else
protected=",protected=False" protected=",protected=False"