0

misc cleanup and minor optimizations

This commit is contained in:
Andrew Brown
2011-11-08 15:31:01 -05:00
parent 75070f817f
commit 14ed48f975
3 changed files with 69 additions and 72 deletions

View File

@@ -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