4444VERSION = '2.5-dev'
4545
4646
47+ def count_lines (string ):
48+ """
49+ Count number of lines in a string or translation.
50+ """
51+ count = len (string .split ('\n ' ))
52+ if count > 1 and string .endswith ('\n ' ):
53+ count -= 1
54+ return count
55+
56+
4757class PoMessage :
4858 """
4959 A message from a gettext file. It is stored as a list of tuples
@@ -234,15 +244,6 @@ def error(self, msg, mid, mstr, error_msg):
234244 print ('---' , mid , sep = '\n ' )
235245 print ('---' , mstr , sep = '\n ' )
236246
237- def count_lines (self , s ):
238- """
239- Count number of lines in a string or translation.
240- """
241- count = len (s .split ('\n ' ))
242- if count > 1 and s .endswith ('\n ' ):
243- count -= 1
244- return count
245-
246247 def check_lines_number (self , msg ):
247248 """
248249 Check number of lines in string and translation.
@@ -252,8 +253,8 @@ def check_lines_number(self, msg):
252253 for mid , mstr in msg .messages :
253254 if not mid or not mstr :
254255 continue
255- nb_id = self . count_lines (mid )
256- nb_str = self . count_lines (mstr )
256+ nb_id = count_lines (mid )
257+ nb_str = count_lines (mstr )
257258 if nb_id != nb_str :
258259 self .error (msg , mid , mstr ,
259260 'number of lines: {0} in string, '
@@ -310,7 +311,7 @@ def check_whitespace(self, msg):
310311 if not mid or not mstr :
311312 continue
312313 # check whitespace at beginning of string
313- if self . count_lines (mid ) == 1 :
314+ if count_lines (mid ) == 1 :
314315 startin = len (mid ) - len (mid .lstrip (' ' ))
315316 startout = len (mstr ) - len (mstr .lstrip (' ' ))
316317 if startin != startout :
0 commit comments