summaryrefslogtreecommitdiff
path: root/Pb/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'Pb/__init__.py')
-rw-r--r--Pb/__init__.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/Pb/__init__.py b/Pb/__init__.py
index 5e5aa65..909f03b 100644
--- a/Pb/__init__.py
+++ b/Pb/__init__.py
@@ -48,14 +48,16 @@ class Pb(object):
except (ValueError, TypeError):
return False
- @staticmethod
- def bool_correct(s):
- if re.match(r'^false$', s, re.IGNORECASE):
- return False
- elif re.match(r'^true$', s, re.IGNORECASE):
- return True
- else:
- return s
+ def bool_correct(self, s):
+ try:
+ if re.match(r'^false$', str(s), re.IGNORECASE):
+ return False
+ elif re.match(r'^true$', str(s), re.IGNORECASE):
+ return True
+ else:
+ return s
+ except Exception as e:
+ sys.stderr.write("WHAT THE FUCK")
@staticmethod
def get_mimetype(f):
@@ -69,8 +71,7 @@ class Pb(object):
sys.stderr.write(str(e))
raise;
- @staticmethod
- def sanitize (s):
+ def sanitize (self, s):
return re.sub(r'\W+', '', s)
@staticmethod
@@ -140,11 +141,11 @@ class Pb(object):
def _get_filename_and_type_from_url (self, url):
name = re.sub(r'(?:\s|\?.*|.*/)', '', urllib.unquote(url));
try:
- basename, ext = map(lambda s: self.santize(s), re.search(r'(^.*)\.(.*$)', name).groups());
+ basename, ext = map(lambda s: self.sanitize(s), re.search(r'(^.*)\.(.*$)', name).groups());
except Exception as e:
self.err_warn("Incompatible input file type")
- if (len(name_part) > 20):
- name_part = name_part[:-20]
+ if (len(basename) > 20):
+ basename = basename[:-20]
return "{}{}_{}_{}".format(self.tag, basename, self._now, self.params.username or ""), ext
def random_string_create(self):