[utils] Add strip_or_none
authorSergey M․ <dstftw@gmail.com>
Sat, 25 Jun 2016 15:32:02 +0000 (22:32 +0700)
committerSergey M․ <dstftw@gmail.com>
Sat, 25 Jun 2016 16:19:18 +0000 (23:19 +0700)
youtube_dl/utils.py

index de66cb482730b564375e227da64b4240566ea3f5..a375282f231d507bda3099b85133092396441afe 100644 (file)
@@ -1660,6 +1660,10 @@ def float_or_none(v, scale=1, invscale=1, default=None):
         return default
 
 
+def strip_or_none(v):
+    return None if v is None else v.strip()
+
+
 def parse_duration(s):
     if not isinstance(s, compat_basestring):
         return None