Browse Source

rename replace_invalid_filename_char to escape_filename

quarrying 2 years ago
parent
commit
4f7b0f7f9d
1 changed files with 7 additions and 1 deletions
  1. 7 1
      khandy/utils_fs.py

+ 7 - 1
khandy/utils_fs.py

@@ -1,6 +1,7 @@
 import os
 import re
 import shutil
+import warnings
 
 
 def get_path_stem(path):
@@ -174,13 +175,18 @@ def get_folder_size(dirname):
     return total_size
 
     
-def replace_invalid_filename_char(filename, new_char='_'):
+def escape_filename(filename, new_char='_'):
     assert isinstance(new_char, str)
     control_chars = ''.join((map(chr, range(0x00, 0x20))))
     pattern = r'[\\/*?:"<>|{}]'.format(control_chars)
     return re.sub(pattern, new_char, filename)
 
 
+def replace_invalid_filename_char(filename, new_char='_'):
+    warnings.warn('replace_invalid_filename_char will be deprecated, use escape_filename instead!')
+    return escape_filename(filename, new_char)
+
+
 def copy_file(src, dst_dir, action_if_exist='rename'):
     """
     Args: