aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2014-07-21 12:02:44 +0200
committerPhilipp Hagemeister <phihag@phihag.de>2014-07-21 12:02:44 +0200
commit9732d77ed273406afcf9ed3ccb4d109824c9c69d (patch)
treede87c4b0cf4b62516b1cf6d4c6e8d1406436b95e /youtube_dl/utils.py
parent199ece7eb83ffe7ba069b50080fe971df1db2d6c (diff)
[snotr] PEP8 and minor fixes (#3296)
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r--youtube_dl/utils.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index 919603c62..bf4d1112f 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -1193,13 +1193,6 @@ def format_bytes(bytes):
return u'%.2f%s' % (converted, suffix)
-def str_to_int(int_str):
- if int_str is None:
- return None
- int_str = re.sub(r'[,\.]', u'', int_str)
- return int(int_str)
-
-
def get_term_width():
columns = os.environ.get('COLUMNS', None)
if columns:
@@ -1267,15 +1260,22 @@ class HEADRequest(compat_urllib_request.Request):
return "HEAD"
-def int_or_none(v, scale=1, default=None, get_attr=None):
+def int_or_none(v, scale=1, default=None, get_attr=None, invscale=1):
if get_attr:
if v is not None:
v = getattr(v, get_attr, None)
- return default if v is None else (int(v) // scale)
+ return default if v is None else (int(v) * invscale // scale)
+
+
+def str_to_int(int_str):
+ if int_str is None:
+ return None
+ int_str = re.sub(r'[,\.]', u'', int_str)
+ return int(int_str)
-def float_or_none(v, scale=1, default=None):
- return default if v is None else (float(v) / scale)
+def float_or_none(v, scale=1, invscale=1, default=None):
+ return default if v is None else (float(v) * invscale / scale)
def parse_duration(s):