Merge branch 'master' into rtmpdump
[youtube-dl] / youtube_dl / utils.py
index 833f981f24ca7b9dc2b2fd6cd79a40fe83afd019..1d9785341ec685071ea8fcc4846029a3e889bc72 100644 (file)
@@ -572,6 +572,11 @@ class ExtractorError(Exception):
         return u''.join(traceback.format_tb(self.traceback))
 
 
+class RegexNotFoundError(ExtractorError):
+    """Error when a regex didn't match"""
+    pass
+
+
 class DownloadError(Exception):
     """Download Error exception.
 
@@ -947,6 +952,15 @@ def shell_quote(args):
     return ' '.join(map(pipes.quote, args))
 
 
+def takewhile_inclusive(pred, seq):
+    """ Like itertools.takewhile, but include the latest evaluated element
+        (the first element so that Not pred(e)) """
+    for e in seq:
+        yield e
+        if not pred(e):
+            return
+
+
 def smuggle_url(url, data):
     """ Pass additional data in a URL for internal use. """