Skip to content

Remove double newline at EOF of po files#1253

Open
CorentinDeBoisset wants to merge 1 commit intopython-babel:masterfrom
CorentinDeBoisset:feat/remove-double-newline
Open

Remove double newline at EOF of po files#1253
CorentinDeBoisset wants to merge 1 commit intopython-babel:masterfrom
CorentinDeBoisset:feat/remove-double-newline

Conversation

@CorentinDeBoisset
Copy link
Copy Markdown

@CorentinDeBoisset CorentinDeBoisset commented Feb 11, 2026

Hello !

This is my first PR, so I'm not fully sure about everything. I used the unit tests to check for regressions, but are there other untested edge-cases we should worry about ?

Fixes #799

Comment on lines +668 to +680
first_message = True

for message in _sort_messages(catalog, sort_by=sort_by):
if not message.id: # This is the header "message"
if omit_header:
continue
is_header = not message.id
if is_header and omit_header:
continue

if first_message:
first_message = False
else:
yield '\n'

if is_header:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this become simpler (not sure if it would!) if first_message was instead something like emitted_messages (boolean or integer)? IOW, the if not message.id: if omit_header: continue check would be as is in the preimage, and then something like

   if emitted_messages:
       # Emit a separator between this and the previous message
       yield '\n'
   emitted_messages = True

?

@akx
Copy link
Copy Markdown
Member

akx commented Apr 10, 2026

Thanks for the contribution! Please see the review comment; I'm not sure if it'd simplify things, but to me it looks like there's maybe more ifs than necessary :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Two <BLANKLINE> in generated PO EOFs

2 participants