9
9
import os
10
10
import datetime
11
11
from collections import defaultdict , OrderedDict
12
- import re
13
12
import random
14
13
from urllib .error import HTTPError
14
+
15
+ import regex
15
16
import yaml
16
17
17
18
import urllib3
@@ -460,7 +461,7 @@ def is_integer(string_to_test: str) -> bool:
460
461
('\\ ]' , ']' ),
461
462
))
462
463
463
- escaped_glob_replacement = re .compile ('(%s)' % '|' .join (escaped_glob_tokens_to_re ).replace ('\\ ' , '\\ \\ \\ ' ))
464
+ escaped_glob_replacement = regex .compile ('(%s)' % '|' .join (escaped_glob_tokens_to_re ).replace ('\\ ' , '\\ \\ \\ ' ))
464
465
465
466
def glob_to_re (pattern : str ) -> str :
466
467
"""
@@ -475,7 +476,7 @@ def glob_to_re(pattern: str) -> str:
475
476
---------
476
477
A regular expression matching the same strings as the provided GLOB pattern
477
478
"""
478
- return escaped_glob_replacement .sub (lambda match : escaped_glob_tokens_to_re [match .group (0 )], re .escape (pattern ))
479
+ return escaped_glob_replacement .sub (lambda match : escaped_glob_tokens_to_re [match .group (0 )], regex .escape (pattern ))
479
480
480
481
def read_file (file_path : str ) -> str :
481
482
"""
@@ -662,7 +663,7 @@ def create_album_name(asset_path_chunks: list[str], album_separator: str, album_
662
663
for pattern , * repl in album_name_postprocess_regex :
663
664
# If no replacement string provided, default to empty string
664
665
replace = repl [0 ] if repl else ''
665
- album_name = re .sub (pattern , replace , album_name )
666
+ album_name = regex .sub (pattern , replace , album_name )
666
667
logging .debug ("Album Post Regex s/%s/%s/g --> %s" , pattern , replace , album_name )
667
668
668
669
return album_name .strip ()
@@ -874,15 +875,15 @@ def is_path_ignored(path_to_check: str) -> bool:
874
875
if len (path_filter_regex ) > 0 :
875
876
any_match = False
876
877
for path_filter_regex_entry in path_filter_regex :
877
- if re .fullmatch (path_filter_regex_entry , path_to_check .replace (asset_root_path , '' )):
878
+ if regex .fullmatch (path_filter_regex_entry , path_to_check .replace (asset_root_path , '' )):
878
879
any_match = True
879
880
if not any_match :
880
881
logging .debug ("Ignoring path %s due to path_filter setting!" , path_to_check )
881
882
is_path_ignored_result = True
882
883
# If the asset "survived" the path filter, check if it is in the ignore_albums argument
883
884
if not is_path_ignored_result and len (ignore_albums_regex ) > 0 :
884
885
for ignore_albums_regex_entry in ignore_albums_regex :
885
- if re .fullmatch (ignore_albums_regex_entry , path_to_check .replace (asset_root_path , '' )):
886
+ if regex .fullmatch (ignore_albums_regex_entry , path_to_check .replace (asset_root_path , '' )):
886
887
is_path_ignored_result = True
887
888
logging .debug ("Ignoring path %s due to ignore_albums setting!" , path_to_check )
888
889
break
0 commit comments