diff options
| author | yo mama <pepper@scannerjammer.com> | 2015-08-21 21:42:11 -0700 |
|---|---|---|
| committer | yo mama <pepper@scannerjammer.com> | 2015-08-21 21:42:11 -0700 |
| commit | 7aaa91d7a090e4ab9be979160622f4c48e3d9b46 (patch) | |
| tree | 2f5ca8e2a334ec9035d6f8d77f16580ba6bc7cd6 /Pb/__init__.py | |
| parent | 15b1c79753658714df7f79bc5fcd7f96a68addc0 (diff) | |
debugged first
Diffstat (limited to 'Pb/__init__.py')
| -rw-r--r-- | Pb/__init__.py | 27 |
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): |
