tagger.py: fix for latest python
authorColin P. McCabe <cmccabe@apache.org>
Sun, 17 Mar 2024 04:03:09 +0000 (21:03 -0700)
committerColin P. McCabe <cmccabe@apache.org>
Sun, 17 Mar 2024 04:03:09 +0000 (21:03 -0700)
Fix for latest python (that apparently requires escaping backslash when
in a double-quoted string, to get a literal backslash)

tagger.py

index e67f275..c82d7d3 100755 (executable)
--- a/tagger.py
+++ b/tagger.py
@@ -78,23 +78,23 @@ def verify_program_installed(prog):
 
 # Regular expressions for parsing file names--
 # which is, after all, what this program is all about
-music_file_re = re.compile(".*\.mp3$")
+music_file_re = re.compile(".*\\.mp3$")
 
 music_file_name_re = re.compile(".*/" +
             "(?P<dir_name>[^/]*)/" +
             "(?P<track_number>[0123456789][0123456789]*) - " +
             "(?P<track_name>[^/]*)" +
-            "\.[a-zA-Z0123456789]*$")
+            "\\.[a-zA-Z0123456789]*$")
 
 audiobook_file_name_re = re.compile(".*/" +
             "(?P<dir_name>[^/]*)/" +
             "(?P<track_number>[0123456789][0123456789]*)");
 
 dir_name_re = re.compile("(.*/)?" +
-            "(?P<artist>[0-9A-Za-z _.\-]*?) - " +
-            "(?P<album>[0-9A-Za-z _(),'.\-\+]*)" + 
-            "(?P<conductor> = [0-9A-Za-z _'.\-]*)?"
-            "(?P<encoding>\[LL\])?$")
+            "(?P<artist>[0-9A-Za-z _.\\-]*?) - " +
+            "(?P<album>[0-9A-Za-z _(),'.\\-\\+]*)" +
+            "(?P<conductor> = [0-9A-Za-z _'.\\-]*)?"
+            "(?P<encoding>\\[LL\\])?$")
 
 def self_test_music_file(m, artist, album_name, \
                         conductor, track_number, title):
@@ -307,7 +307,7 @@ if (self_test):
     sys.exit(0)
 
 for dir in dirs:
-    if (re.search("\[LL\]", dir)):
+    if (re.search("\\[LL\\]", dir)):
         print("skipping \"" + dir + "\"...")
         continue
     # Assume that paths without a directory prefix are local