-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/save document converter result #157
base: main
Are you sure you want to change the base?
Feat/save document converter result #157
Conversation
@microsoft-github-policy-service agree |
def save(self, file_path: str, encoding: str = "utf-8") -> None: | ||
""" | ||
Save the converted document result `text_content` to a file. | ||
params: | ||
file_path: The path to save the document result to. | ||
encoding: The encoding to use when writing the document. | ||
""" | ||
with open(file_path, "w", encoding=encoding) as f: | ||
f.write(self.text_content) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it serves the same purpose as #116. could you refactor the code to use a single function for better reusability?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure @l-lumin,
I think it makes more sense to have the function to save the result into a file inside the DocumentConverterResult
.
- I refactored the CLI to use this function.
- I also added an
encoding
parameter to the arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I think so too. Look good
Hello,
Thanks for the awesome package :)
This is a simple PR that adds a new
save
method to theDocumentConverterResult
class, making it easier to save the converted document result to a file.Changes:
DocumentConverterResult
class, which takes afile_path
and optional encoding parameter. The method writes thetext_content
to the specified file using the specified encoding.save
method.