Skip to content

Remove blank line from N-Triples output#405

Merged
tcmitchell merged 1 commit intoSynBioDex:mainfrom
tcmitchell:404-ntriples-blank-lines
Jun 14, 2022
Merged

Remove blank line from N-Triples output#405
tcmitchell merged 1 commit intoSynBioDex:mainfrom
tcmitchell:404-ntriples-blank-lines

Conversation

@tcmitchell
Copy link
Copy Markdown
Collaborator

Remove the extra blank line in N-Triples output that RDFLib includes.
Filter the blank line out in both N-Triples and Sorted N-Triples formats.

Closes #404

Remove the extra blank line in N-Triples output that RDFLib includes.
Filter the blank line out in both N-Triples and Sorted N-Triples formats.
@tcmitchell tcmitchell added this to the 1.1 milestone Jun 14, 2022
@tcmitchell tcmitchell requested a review from jakebeal June 14, 2022 17:43
@tcmitchell tcmitchell self-assigned this Jun 14, 2022
Comment thread sbol3/document.py
if lines_type is bytes:
# rdflib 5
return b''.join(lines)
return b'\n'.join(lines) + b'\n'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Will this cause any issue for Windows expecting its "two-character newline", or is string-writing smart about that?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Great question. Looking at the documentation for os.linesep it seems like '\n' (or b'\n') is the right thing to use, and that lower level stuff handles platform specific line endings. The documentation says:

Do not use os.linesep as a line terminator when writing files opened in text mode (the default); use a single '\n' instead, on all platforms.

My conclusion is that we are doing the right thing by using '\n' (or b'\n').

@tcmitchell tcmitchell requested a review from jakebeal June 14, 2022 17:56
@tcmitchell tcmitchell merged commit f0a177f into SynBioDex:main Jun 14, 2022
@tcmitchell tcmitchell deleted the 404-ntriples-blank-lines branch June 14, 2022 18:11
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.

Eliminate empty lines in .nt serializations

2 participants