summaryrefslogtreecommitdiff
path: root/lib/param/string.py
diff options
context:
space:
mode:
authorPepper <pepper@scannerjammer.com>2015-09-27 00:03:42 -0400
committerPepper <pepper@scannerjammer.com>2015-09-27 00:03:42 -0400
commit30126dfc2877a82b8af02d68ca3b155068d551dd (patch)
treea706d699cd1e1f50c2007e69d6ca9ba96819eaed /lib/param/string.py
parentff31f2c4cf1792df351359f1749f63b3d0cce23b (diff)
done linting...just need to wrap up and publish
Diffstat (limited to 'lib/param/string.py')
-rw-r--r--lib/param/string.py32
1 files changed, 19 insertions, 13 deletions
diff --git a/lib/param/string.py b/lib/param/string.py
index bd3d6d8..14e8e87 100644
--- a/lib/param/string.py
+++ b/lib/param/string.py
@@ -1,15 +1,21 @@
-from param import Param
+"""String class definition lives here"""
+from .param import Param
import re
-import sys
class String(Param):
- def __init__(self, value, classname=""):
- super(String, self).__init__(classname=classname)
- if value:
- try:
- self.value = self.sanitize(value)
- except Exception as e:
- self.err_warn("Unable to sanitize: %s\nreason:%s" % (str(value), str(e)))
- else:
- self.value = ""
- def sanitize (self, s):
- return re.sub(r'\W+', '', s)
+ """String param class definition
+ Args:
+ value: a string
+ classname: name of the class to which the param instance will belong
+ """
+ def __init__(self, value, classname=""):
+ super(String, self).__init__(classname=classname)
+ if value:
+ try:
+ self.value = self.sanitize(value)
+ except Exception as e:
+ self.err_warn("Unable to sanitize: %s\nreason:%s" % (str(value), str(e)))
+ else:
+ self.value = ""
+ def sanitize(self, s):
+ """Removes non-word characters from the string for security reasons"""
+ return re.sub(r'\W+', '', s)