diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b00f317c..7a3cb9bd 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,11 +5,13 @@ v3.2.1 ------ *Release date: In development* + - Allow negative indexes for list elements in context searches. Example: [CONTEXT:element.-1] - Add support for JSON strings to the `DICT` and `LIST`` replacement. Example: [DICT:{"key": true}], [LIST:[null]] - Add `REPLACE` replacement, to replace a substring with another. Example: [REPLACE:[CONTEXT:some_url]::https::http] - Add `TITLE` replacement, to apply Python's title() function. Example: [TITLE:the title] - Add `ROUND` replacement, float number to a string with the indicated number of decimals. Example: [ROUND:3.3333::2] +- Remove accents from generated file names to avoid errors in some filesystems v3.2.0 ------ diff --git a/toolium/test/utils/test_path_utils.py b/toolium/test/utils/test_path_utils.py index b3a8c820..b8149fa5 100644 --- a/toolium/test/utils/test_path_utils.py +++ b/toolium/test/utils/test_path_utils.py @@ -30,6 +30,7 @@ ('successful login -- @1.1 john.doe', 'successful_login_1_1_john_doe'), ('successful login -- @1.2 Mark options: {Length=10 Mark=mark File=file_name.jpg}', 'successful_login_1_2_Mark_options___Length_10_Mark_mark_File_file_name_jpg'), + ('successful login -- @1.3 acción', 'successful_login_1_3_accion'), ) diff --git a/toolium/utils/path_utils.py b/toolium/utils/path_utils.py index a6af05bb..010f3015 100644 --- a/toolium/utils/path_utils.py +++ b/toolium/utils/path_utils.py @@ -16,9 +16,10 @@ limitations under the License. """ -from os import makedirs import errno import re +import unicodedata +from os import makedirs FILENAME_MAX_LENGTH = 100 @@ -34,6 +35,9 @@ def get_valid_filename(s, max_length=FILENAME_MAX_LENGTH): """ s = str(s).strip().replace(' -- @', '_') s = re.sub(r'(?u)[^-\w]', '_', s).strip('_') + # Remove accents to avoid errors in some filesystems + nfkd_form = unicodedata.normalize('NFKD', s) + s = ''.join([c for c in nfkd_form if not unicodedata.combining(c)]) return s[:max_length]