Skip to content

Commit 0829243

Browse files
authored
Merge pull request #2811 from Wurschdhaud/develop
PY3 compatibility for itertools
2 parents d35d45d + ad8a199 commit 0829243

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

pyrevitlib/pyrevit/output/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@
2121

2222
from __future__ import print_function
2323
import os.path as op
24-
import itertools
24+
import sys
25+
from pyrevit.compat import PY2, PY3
26+
if PY2:
27+
from itertools import izip_longest as zip_longest
28+
elif PY3:
29+
from itertools import zip_longest
2530

2631
from pyrevit import HOST_APP, EXEC_PARAMS
2732
from pyrevit import framework
@@ -543,6 +548,8 @@ def print_md(md_str):
543548
markdown_html = markdown_html.replace('\n', '').replace('\r', '')
544549
html_code = coreutils.prepare_html_str(markdown_html)
545550
print(html_code, end="")
551+
if PY3:
552+
sys.stdout.flush()
546553

547554
def print_table(self, table_data, columns=None, formats=None,
548555
title='', last_line_style=''):
@@ -579,7 +586,6 @@ def print_table(self, table_data, columns=None, formats=None,
579586
self.add_style('tr:last-child {{ {style} }}'
580587
.format(style=last_line_style))
581588

582-
zipper = itertools.izip_longest #pylint: disable=E1101
583589
adjust_base_col = '|'
584590
adjust_extra_col = ':---|'
585591
base_col = '|'
@@ -591,7 +597,7 @@ def print_table(self, table_data, columns=None, formats=None,
591597
header = ''
592598
if columns:
593599
header = base_col
594-
for idx, col_name in zipper(range(max_col), columns, fillvalue=''): #pylint: disable=W0612
600+
for idx, col_name in zip_longest(range(max_col), columns, fillvalue=''): #pylint: disable=W0612
595601
header += extra_col.format(data=col_name)
596602

597603
header += '\n'
@@ -606,7 +612,7 @@ def print_table(self, table_data, columns=None, formats=None,
606612
for entry in table_data:
607613
row = base_col
608614
for idx, attrib, attr_format \
609-
in zipper(range(max_col), entry, formats, fillvalue=''):
615+
in zip_longest(range(max_col), entry, formats, fillvalue=''):
610616
if attr_format:
611617
value = attr_format.format(attrib)
612618
else:

0 commit comments

Comments
 (0)