Commit 8f2ec5bf authored by Seblu's avatar Seblu

Add strcspn in tools

parent 4af21fc1
...@@ -32,6 +32,7 @@ import time ...@@ -32,6 +32,7 @@ import time
import urllib2 import urllib2
from subprocess import call, check_call, CalledProcessError from subprocess import call, check_call, CalledProcessError
from itertools import takewhile
import installsystems import installsystems
from progressbar import Widget, ProgressBar, Percentage from progressbar import Widget, ProgressBar, Percentage
...@@ -733,3 +734,9 @@ def argv(): ...@@ -733,3 +734,9 @@ def argv():
return [unicode(x, encoding=locale.getpreferredencoding()) for x in sys.argv] return [unicode(x, encoding=locale.getpreferredencoding()) for x in sys.argv]
except UnicodeDecodeError as e: except UnicodeDecodeError as e:
raise ISError("Invalid character encoding in command line") 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)))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment