Make sure all device state categories are slugified
parent
08f4c70b4e
commit
8124188264
|
@ -278,10 +278,8 @@ class DeviceTracker(object):
|
|||
|
||||
# Make sure that each device is mapped
|
||||
# to a unique category name
|
||||
name = row['name']
|
||||
|
||||
if not name:
|
||||
name = "unnamed_device"
|
||||
name = util.slugify(row['name']) if row['name'] \
|
||||
else "unnamed_device"
|
||||
|
||||
tries = 0
|
||||
suffix = ""
|
||||
|
|
|
@ -2,7 +2,17 @@
|
|||
|
||||
import re
|
||||
|
||||
RE_SANITIZE_FILENAME = re.compile(r"(~|(\.\.)|/|\+)")
|
||||
RE_SLUGIFY = re.compile(r'[^A-Za-z0-9_]+')
|
||||
|
||||
|
||||
def sanitize_filename(filename):
|
||||
""" Sanitizes a filename by removing .. / and \\. """
|
||||
return re.sub(r"(~|(\.\.)|/|\+)", "", filename)
|
||||
return RE_SANITIZE_FILENAME.sub("", filename)
|
||||
|
||||
|
||||
def slugify(text):
|
||||
""" Slugifies a given text. """
|
||||
text = text.strip().replace(" ", "_")
|
||||
|
||||
return RE_SLUGIFY.sub("", text)
|
||||
|
|
Loading…
Reference in New Issue