Add chunks util function
This commit is contained in:
parent
b87348be3b
commit
d5a73b8b4f
1 changed files with 10 additions and 0 deletions
|
|
@ -442,6 +442,16 @@ def to_unicode(s_or_u, encoding="utf-8", errors="strict"):
|
|||
return s_or_u
|
||||
|
||||
|
||||
def chunks(l, n):
|
||||
"""
|
||||
Yield successive n-sized chunks from l.
|
||||
|
||||
Taken from http://stackoverflow.com/a/312464/2028598
|
||||
"""
|
||||
for i in range(0, len(l), n):
|
||||
yield l[i:i+n]
|
||||
|
||||
|
||||
def is_running_from_source():
|
||||
root = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../.."))
|
||||
return os.path.isdir(os.path.join(root, "src")) and os.path.isfile(os.path.join(root, "setup.py"))
|
||||
|
|
|
|||
Loading…
Reference in a new issue