diff --git a/installsystems/tools.py b/installsystems/tools.py index 0dcc04b43e11608442fda3ad2e15217037a27793..2e5b2fce0ea85db4d76da6b6ecbe841851349e76 100644 --- a/installsystems/tools.py +++ b/installsystems/tools.py @@ -32,6 +32,7 @@ import time import urllib2 from subprocess import call, check_call, CalledProcessError +from itertools import takewhile import installsystems from progressbar import Widget, ProgressBar, Percentage @@ -733,3 +734,9 @@ def argv(): return [unicode(x, encoding=locale.getpreferredencoding()) for x in sys.argv] except UnicodeDecodeError as e: raise ISError("Invalid character encoding in command line") + +def strcspn(string, pred): + ''' + Python implementation of libc strcspn + ''' + return len(list(takewhile(lambda x: x not in pred, string)))