1111
1212import pprint
1313import re
14- import string
1514import sys
1615
1716pp = pprint .PrettyPrinter (indent = 4 , width = 80 )
1817
1918
20- # Python 2/3 compatibility
21- def _normalize_string_type (d ):
22- '''Normalize string type between python2 & python3'''
23- if sys .version_info .major < 3 :
24- if type (d ) is dict :
25- for k in d :
26- d [k ] = _normalize_string_type (d [k ])
27- elif type (d ) is str :
28- d = d .decode ('utf-8' )
29- return d
30-
31-
3219def get_indented_docstring_snippet (d , indent = 4 ):
3320 '''Returns a docstring with the correct amount of indentation.
3421
@@ -52,7 +39,7 @@ def get_indented_docstring_snippet(d, indent=4):
5239 ret_val += '\n '
5340 if len (line .rstrip ()) > 0 :
5441 ret_val += (' ' * indent )
55- ret_val += _normalize_string_type ( line .rstrip () )
42+ ret_val += line .rstrip ()
5643 return ret_val
5744
5845
@@ -637,17 +624,13 @@ def as_rest_table(data, header=True):
637624 template = '{0}{1}{2}' .format (start_of_line , meta_template .format (* sizes ), end_of_line )
638625 # determine top/bottom borders
639626 to_separator = {ord ('|' ): '+' , ord (' ' ): '-' }
640- if sys .version_info .major < 3 :
641- to_separator = string .maketrans ('| ' , '+-' )
642627
643628 start_of_line = start_of_line .translate (to_separator )
644629 vertical_separator = vertical_separator .translate (to_separator )
645630 end_of_line = end_of_line .translate (to_separator )
646631 separator = '{0}{1}{2}' .format (start_of_line , vertical_separator .join ([x * line_marker for x in sizes ]), end_of_line )
647632 # determine header separator
648633 th_separator_tr = {ord ('-' ): '=' }
649- if sys .version_info .major < 3 :
650- th_separator_tr = string .maketrans ('-' , '=' )
651634 start_of_line = start_of_line .translate (th_separator_tr )
652635 line_marker = line_marker .translate (th_separator_tr )
653636 vertical_separator = vertical_separator .translate (th_separator_tr )
0 commit comments