diff options
author | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-08-21 13:08:53 +0200 |
---|---|---|
committer | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-08-21 13:08:53 +0200 |
commit | faebdd5a0daa5fa3dd4b75ac1b341e79d26c83d8 (patch) | |
tree | d096fee92614ab5cba729b378b65747cb11ee869 | |
parent | 5226226ab2f46acef4d80130ee3546e7be21b7a6 (diff) |
cli: remove accents in image namev0.3.3-10
Remove accents in the --name argument of the create image command.
-rw-r--r-- | cli/objects/images.py | 3 | ||||
-rw-r--r-- | cli/utils.py | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/cli/objects/images.py b/cli/objects/images.py index 21f727c..dff2f9c 100644 --- a/cli/objects/images.py +++ b/cli/objects/images.py @@ -165,8 +165,9 @@ class OgImage(): return fs_code = list(part_info)[0]['code'] + image_name = remove_accents(parsed_args.name) payload = {'clients': parsed_args.client_ip, 'disk': parsed_args.disk, 'center_id': center_id, - 'partition': parsed_args.part, 'code': str(fs_code), 'name': parsed_args.name, + 'partition': parsed_args.part, 'code': str(fs_code), 'name': image_name, 'id': '0', 'repository_id': repo_id} if parsed_args.desc: payload['description'] = parsed_args.desc diff --git a/cli/utils.py b/cli/utils.py index 9831d4b..3825583 100644 --- a/cli/utils.py +++ b/cli/utils.py @@ -5,6 +5,7 @@ # Free Software Foundation; either version 3 of the License, or # (at your option) any later version. +import unicodedata import json import ipaddress import re @@ -65,3 +66,6 @@ def check_mac_address(addr): print(addr.lower()) return False +def remove_accents(text): + normalized_text = unicodedata.normalize('NFD', text) + return ''.join(c for c in normalized_text if unicodedata.category(c) != 'Mn') |