#814449 [wrap-and-sort] to remove double or more spaces

Package:
devscripts
Source:
devscripts
Description:
scripts to make the life of a Debian Package maintainer easier
Submitter:
Herbert Fortes
Date:
2022-07-02 20:09:05 UTC
Severity:
wishlist
#814449#5
Date:
2016-02-11 16:49:28 UTC
From:
To:
Package: devscripts
Version: 2.15.10
Severity: wishlist
File: /usr/bin/wrap-and-sort

Hi,

The wrap-and-sort script has:

def remove_trailing_whitespaces(filename):

But it doesn't remove double or more spaces
inside a line. e.g:

' text which belongs to     long description.   End of line'

I'm not a programmer, but I did a search and added
a line to do that. I copied these lines and made a
test:

#!/usr/bin/python3

import re

 content = open("control").read().rstrip() + "\n"
 lines = content.split("\n")
 lines = [l.rstrip() for l in lines]
+lines = [re.sub('\s+', ' ', l) for l in lines]
 new_content = "\n".join(lines)
 f = open("control", "w")
 f.write(new_content)
 f.close()


The line I added doesn't remove all spaces at the
end of the line. That's why two for loops. It works
in a separate test script. But I put it in wrap-and-sort
and it didn't.

It can be useful for long description in debian/control.
I don't know about the others files.


regards,

#814449#10
Date:
2022-01-05 05:50:46 UTC
From:
To:
This could also be useful for a diff seen in #1002683,
where an additional space was inserted in dependencies: