~maddevelopers/mg5amcnlo/2.6.5_ewa

« back to all changes in this revision

Viewing changes to madgraph/iolibs/file_writers.py

  • Committer: olivier-mattelaer
  • Date: 2020-08-13 08:01:25 UTC
  • mfrom: (281.3.23 2.7.4)
  • Revision ID: olivier-mattelaer-20200813080125-dvgl90l47g9jekf1
merge with 2.7.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
342
342
        columns. Split in preferential order according to
343
343
        split_characters, and start each new line with line_start."""
344
344
 
345
 
        res_lines = [line]
346
 
 
347
 
        while len(res_lines[-1]) > self.line_length:
 
345
        def get_split_index(line, max_length, max_split, split_characters):
348
346
            split_at = 0
349
347
            for character in split_characters:
350
 
                index = res_lines[-1][(self.line_length - self.max_split): \
351
 
                                      self.line_length].rfind(character)
 
348
                index = line[(max_length - max_split): \
 
349
                                      max_length].rfind(character)
352
350
                if index >= 0:
353
 
                    split_at_tmp = self.line_length - self.max_split + index
 
351
                    split_at_tmp = max_length - max_split + index
354
352
                    if split_at_tmp > split_at:
355
353
                        split_at = split_at_tmp
 
354
            return split_at
 
355
                
 
356
 
 
357
        res_lines = [line]
 
358
 
 
359
        while len(res_lines[-1]) > self.line_length:
 
360
            split_at = get_split_index(res_lines[-1], self.line_length, 
 
361
                                       self.max_split, split_characters)
356
362
            if split_at == 0:
357
 
                split_at = self.line_length
 
363
                split_at = get_split_index(res_lines[-1], self.line_length, 
 
364
                                       self.max_split + 30, split_characters)
 
365
                if split_at == 0:
 
366
                    split_at = self.line_length
358
367
                
359
368
            newline = res_lines[-1][split_at:]
360
369
            nquotes = self.count_number_of_quotes(newline)