From: Yen Chi Hsuan Date: Fri, 10 Jul 2015 10:58:12 +0000 (+0800) Subject: [compat] Add compat_itertools_count X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=a0e060ac1e9871974c02fe7cb3e812a3cbe79e73;p=youtube-dl [compat] Add compat_itertools_count 'step' parameter is added in Python 2.7 --- diff --git a/youtube_dl/compat.py b/youtube_dl/compat.py index f9529210d..c3783337a 100644 --- a/youtube_dl/compat.py +++ b/youtube_dl/compat.py @@ -9,6 +9,7 @@ import shutil import socket import subprocess import sys +import itertools try: @@ -388,6 +389,15 @@ else: pass return _terminal_size(columns, lines) +try: + itertools.count(start=0, step=1) + compat_itertools_count = itertools.count +except TypeError: # Python 2.6 + def compat_itertools_count(start=0, step=1): + n = start + while True: + yield n + n += step __all__ = [ 'compat_HTTPError', @@ -401,6 +411,7 @@ __all__ = [ 'compat_html_entities', 'compat_http_client', 'compat_http_server', + 'compat_itertools_count', 'compat_kwargs', 'compat_ord', 'compat_parse_qs',