1818manage and inserting data into the output.
1919"""
2020
21- import string
2221import sys
23- from types import StringType
2422
2523
2624AS_IS = None
@@ -119,7 +117,7 @@ def add_label_data(self, format, counter, blankline = None):
119117 self .writer .send_line_break ()
120118 if not self .para_end :
121119 self .writer .send_paragraph ((blankline and 1 ) or 0 )
122- if type (format ) is StringType :
120+ if isinstance (format , str ) :
123121 self .writer .send_label_data (self .format_counter (format , counter ))
124122 else :
125123 self .writer .send_label_data (format )
@@ -176,16 +174,13 @@ def format_roman(self, case, counter):
176174 return label .upper ()
177175 return label
178176
179- def add_flowing_data (self , data ,
180- # These are only here to load them into locals:
181- whitespace = string .whitespace ,
182- join = string .join , split = string .split ):
177+ def add_flowing_data (self , data ):
183178 if not data : return
184179 # The following looks a bit convoluted but is a great improvement over
185180 # data = regsub.gsub('[' + string.whitespace + ']+', ' ', data)
186- prespace = data [:1 ] in whitespace
187- postspace = data [- 1 :] in whitespace
188- data = join (split (data ))
181+ prespace = data [:1 ]. isspace ()
182+ postspace = data [- 1 :]. isspace ()
183+ data = " " . join (data . split ())
189184 if self .nospace and not data :
190185 return
191186 elif prespace or self .softspace :
@@ -411,7 +406,7 @@ def send_literal_data(self, data):
411406
412407 def send_flowing_data (self , data ):
413408 if not data : return
414- atbreak = self .atbreak or data [0 ] in string . whitespace
409+ atbreak = self .atbreak or data [0 ]. isspace ()
415410 col = self .col
416411 maxcol = self .maxcol
417412 write = self .file .write
@@ -427,7 +422,7 @@ def send_flowing_data(self, data):
427422 col = col + len (word )
428423 atbreak = 1
429424 self .col = col
430- self .atbreak = data [- 1 ] in string . whitespace
425+ self .atbreak = data [- 1 ]. isspace ()
431426
432427
433428def test (file = None ):
0 commit comments