mirror of
https://github.com/beetbox/beets.git
synced 2026-01-30 20:13:37 +01:00
Fixed the regexp function used with sqlite3.
This commit is contained in:
parent
46ec5db3fe
commit
f4a0595b32
1 changed files with 11 additions and 2 deletions
|
|
@ -837,14 +837,23 @@ class Library(BaseLibrary):
|
|||
self.art_filename = bytestring_path(art_filename)
|
||||
self.replacements = replacements
|
||||
|
||||
# uncomment for extra traceback on error
|
||||
#sqlite3.enable_callback_tracebacks(1)
|
||||
|
||||
self.timeout = timeout
|
||||
self.conn = sqlite3.connect(self.path, timeout)
|
||||
self.conn.row_factory = sqlite3.Row
|
||||
# this way we can access our SELECT results like dictionaries
|
||||
|
||||
def regexp(expr, item):
|
||||
reg = re.compile(expr)
|
||||
return reg.search(item) is not None
|
||||
if item == None:
|
||||
return False
|
||||
try:
|
||||
reg = re.compile(expr)
|
||||
res = reg.search(item)
|
||||
return res is not None
|
||||
except:
|
||||
return False
|
||||
|
||||
self.conn.create_function("REGEXP", 2, regexp)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue