From 1f1680800203f82141bce209e0db40e4dab0ae92 Mon Sep 17 00:00:00 2001 From: Ruud Date: Sun, 5 Feb 2012 15:04:21 +0100 Subject: [PATCH] string to float helper --- couchpotato/core/helpers/variable.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/couchpotato/core/helpers/variable.py b/couchpotato/core/helpers/variable.py index aaee7866..c3a9980a 100644 --- a/couchpotato/core/helpers/variable.py +++ b/couchpotato/core/helpers/variable.py @@ -78,6 +78,10 @@ def tryInt(s): try: return int(s) except: return s +def tryFloat(s): + try: return float(s) if '.' in s else tryInt(s) + except: return s + def natsortKey(s): return map(tryInt, re.findall(r'(\d+|\D+)', s))