misc cleanup and minor optimizations
This commit is contained in:
@@ -26,6 +26,7 @@ import logging
|
||||
from cStringIO import StringIO
|
||||
import ctypes
|
||||
import platform
|
||||
from itertools import cycle, islice
|
||||
|
||||
def get_program_path():
|
||||
if hasattr(sys, "frozen") or imp.is_frozen("__main__"):
|
||||
@@ -79,6 +80,20 @@ def findGitVersion():
|
||||
except Exception:
|
||||
return "unknown"
|
||||
|
||||
# http://docs.python.org/library/itertools.html
|
||||
def roundrobin(iterables):
|
||||
"roundrobin('ABC', 'D', 'EF') --> A D E B F C"
|
||||
# Recipe credited to George Sakkis
|
||||
pending = len(iterables)
|
||||
nexts = cycle(iter(it).next for it in iterables)
|
||||
while pending:
|
||||
try:
|
||||
for next in nexts:
|
||||
yield next()
|
||||
except StopIteration:
|
||||
pending -= 1
|
||||
nexts = cycle(islice(nexts, pending))
|
||||
|
||||
|
||||
# Logging related classes are below
|
||||
|
||||
|
||||
Reference in New Issue
Block a user