Add option for archiver full context
This commit is contained in:
@@ -50,6 +50,7 @@ _downloader_options = [
|
||||
|
||||
_archiver_options = [
|
||||
click.option('--all-comments', is_flag=True, default=None),
|
||||
click.option('--full-context', is_flag=True, default=None),
|
||||
click.option('-f', '--format', type=click.Choice(('xml', 'json', 'yaml')), default=None),
|
||||
]
|
||||
|
||||
|
||||
@@ -61,6 +61,9 @@ class Archiver(RedditConnector):
|
||||
raise ArchiverError(f'Factory failed to classify item of type {type(praw_item).__name__}')
|
||||
|
||||
def write_entry(self, praw_item: (praw.models.Submission, praw.models.Comment)):
|
||||
if self.args.full_context and isinstance(praw_item, praw.models.Comment):
|
||||
logger.debug(f'Converting comment {praw_item.id} to submission {praw_item.submission.id}')
|
||||
praw_item = praw_item.submission
|
||||
archive_entry = self._pull_lever_entry_factory(praw_item)
|
||||
if self.args.format == 'json':
|
||||
self._write_entry_json(archive_entry)
|
||||
|
||||
@@ -41,8 +41,9 @@ class Configuration(Namespace):
|
||||
self.verbose: int = 0
|
||||
|
||||
# Archiver-specific options
|
||||
self.format = 'json'
|
||||
self.all_comments = False
|
||||
self.format = 'json'
|
||||
self.full_context: bool = False
|
||||
|
||||
def process_click_arguments(self, context: click.Context):
|
||||
for arg_key in context.params.keys():
|
||||
|
||||
Reference in New Issue
Block a user