Closed Deuchnord closed 3 years ago
This issue has not been active since a lot of time. If you think it is still valid, feel free to reply with a simple comment. Without any update, I will close it in 7 days.
Nope, you don't want to close that. :eyes:
This issue has not been active since a lot of time. If you think it is still valid, feel free to reply with a simple comment. Without any update, I will close it in 7 days.
I see that you self-assigned this issue. Are you currently working on this? If not, I would love to give it a shot.
Hello, no, I haven't started it yet, you can take it. Thank you! :smile:
I am having some issues running using the different output types, specifically on this line. When I use json or text, I have to remove the "b" from the arguments so the file isn't opened in binary mode or else I see this error: TypeError: a bytes-like object is required, not 'str'
. I have to add it back to use the pdf output format or else I see the same error. Am I doing something wrong?
No, I think I see what you are facing. It is a bit tricky, since the PDF format is a binary format, but not the plain text and JOSN format.
I think the most elegant way to fix this would be to create a small function you would call in the second argument of open()
and that would return the correct mode depending on the output format.
Something like this:
def get_opening_mode(format: str) -> str:
if format == "pdf":
return "wb"
return "w"
WDYT?
Ok, just wanted to make sure. I like the solution you suggested!
I have something working now. I think all that is left is to add some tests. Would I add these in the end to end test script?
I think you can add them just after the existing export ones :)
Btw @nicfb, be careful, there is a license change, Kosmorro is rolling back to GNU AGPL instead of CeCILL (#196). Your PR can stay under CeCILL if you want (AFAIK it is AGPL-compatible), just making sure you are aware about that :)
(Feature request by @AmauryCarrade on Discord)
Is your feature request related to a problem? Please describe. Currently, to export in a PDF file, we need to give two arguments to the command:
--format=pdf
--output=myfile.pdf
Giving both arguments, even though acceptable, is redundant.Describe the solution you'd like
--format
argument becomes optional.--format
and--output
is given, then the behavior stays the same as today: the content is output in the given file using the given format, even though the extension does not match the format.--output
is given, then guess the format to use from it:--output=myfile.txt
ou--output=myfile
(without extension) will output a file containing the text usually returned in standard output--output=myfile.json
will output a file containing a JSON content--output=myfile.pdf
will output a file containing the PDF content--output
is given, but the file format is not recognized, then an error is returned and nothing is done.