Commit e569c7d9 authored by Gerion Entrup's avatar Gerion Entrup
Browse files

sqlfuse: replace slash in filenames

parent fcbc7222
import re
import logging
from sqlalchemy.orm.attributes import InstrumentedAttribute
from sqlalchemy.sql import or_
import settings
class Functions:
......@@ -79,7 +83,7 @@ class Functions:
name.append(elem)
else:
try:
name.append(getattr(row, elem))
name.append(getattr(row, elem).replace('/', settings.slash_replacement))
except AttributeError:
raise Exception('Cannot access ' + elem +
'. Row: ' + str(row) +
......@@ -101,5 +105,10 @@ class Functions:
if res is None:
return None
for (attr, group_name) in self._regex_groups:
query = query.where(attr == res.group(group_name))
value = res.group(group_name)
if '-' in value:
query = query.where(or_(attr == value,
attr == value.replace(settings.slash_replacement, '/')))
else:
query = query.where(attr == value)
return query
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment