[gnome-music: 1/11] Fix removable of invalid characters and multiple spaces when stripping



commit 31754ebff6be91b7500606f16ef1cd4c4f25716d
Author: Arnel A. Borja <arnelborja src gnome org>
Date:   Wed Jul 24 20:16:38 2013 +0800

    Fix removable of invalid characters and multiple spaces when stripping

 gnomemusic/albumArtCache.py |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/gnomemusic/albumArtCache.py b/gnomemusic/albumArtCache.py
index f6c864d..30ca722 100644
--- a/gnomemusic/albumArtCache.py
+++ b/gnomemusic/albumArtCache.py
@@ -17,6 +17,8 @@ class AlbumArtCache:
     curly_brackets = re.compile('\{(.*?)\}', re.DOTALL)
     angle_brackets = re.compile('\<(.*?)\>', re.DOTALL)
     parentheses = re.compile('\((.*?)\)', re.DOTALL)
+    invalid_chars = re.compile('[()<>\[\]{}_! #$^&*+=|\\\/"\'?~]', re.DOTALL)
+    multiple_spaces = re.compile('\t|\s+', re.DOTALL)
 
     @classmethod
     def get_default(self):
@@ -236,9 +238,9 @@ class AlbumArtCache:
         string = self.angle_brackets.sub('', string)
         string = self.parentheses.sub('', string)
         # Strip invalid chars
-        string = string.strip('_! #$^&*+=|\\\/\"\'?~')
+        string = self.invalid_chars.sub('', string)
         # Remove double spaces
-        string = string.replace('  ', ' ')
+        string = self.multiple_spaces.sub(' ', string)
         # Remove trailing spaces and convert to lowercase
         return string.strip().lower()
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]