21
21
22
22
from __future__ import print_function
23
23
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
25
30
26
31
from pyrevit import HOST_APP , EXEC_PARAMS
27
32
from pyrevit import framework
@@ -543,6 +548,8 @@ def print_md(md_str):
543
548
markdown_html = markdown_html .replace ('\n ' , '' ).replace ('\r ' , '' )
544
549
html_code = coreutils .prepare_html_str (markdown_html )
545
550
print (html_code , end = "" )
551
+ if PY3 :
552
+ sys .stdout .flush ()
546
553
547
554
def print_table (self , table_data , columns = None , formats = None ,
548
555
title = '' , last_line_style = '' ):
@@ -579,7 +586,6 @@ def print_table(self, table_data, columns=None, formats=None,
579
586
self .add_style ('tr:last-child {{ {style} }}'
580
587
.format (style = last_line_style ))
581
588
582
- zipper = itertools .izip_longest #pylint: disable=E1101
583
589
adjust_base_col = '|'
584
590
adjust_extra_col = ':---|'
585
591
base_col = '|'
@@ -591,7 +597,7 @@ def print_table(self, table_data, columns=None, formats=None,
591
597
header = ''
592
598
if columns :
593
599
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
595
601
header += extra_col .format (data = col_name )
596
602
597
603
header += '\n '
@@ -606,7 +612,7 @@ def print_table(self, table_data, columns=None, formats=None,
606
612
for entry in table_data :
607
613
row = base_col
608
614
for idx , attrib , attr_format \
609
- in zipper (range (max_col ), entry , formats , fillvalue = '' ):
615
+ in zip_longest (range (max_col ), entry , formats , fillvalue = '' ):
610
616
if attr_format :
611
617
value = attr_format .format (attrib )
612
618
else :
0 commit comments