Skip to content
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

Allow to force the output file format #259

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions chat_downloader/chat_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def get_chat(self, url=None,

# Output
output=None,
output_format=None,
overwrite=True,
sort_keys=True,
indent=4,
Expand Down Expand Up @@ -149,6 +150,8 @@ def get_chat(self, url=None,
:param output: Path of the output file, defaults to None (print to
standard output)
:type output: str, optional
:param output_format: The output file format, like 'jsonl', 'txt', etc.
:type output_format: str, optional
:param overwrite: If True, overwrite output file. Otherwise, append
to the end of the file. Defaults to True. In both cases, the file
(and directories) is created if it does not exist.
Expand Down Expand Up @@ -266,6 +269,7 @@ def log_on_inactivity_timeout():
indent=params['indent'],
sort_keys=params['sort_keys'],
overwrite=params['overwrite'],
format=params['output_format'],
lazy_initialise=True
))

Expand Down
1 change: 1 addition & 0 deletions chat_downloader/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def add_init_param(group, *keys, **kwargs):

output_group = parser.add_argument_group('Output Arguments')
add_chat_param(output_group, '--output', '-o')
add_chat_param(output_group, '--output_format', '-of')
add_chat_param(output_group, '--overwrite',
type=str2bool, nargs='?', const=True)
add_chat_param(output_group, '--sort_keys',
Expand Down