Merge pull request #457 from Serene-Arc/enhancement_322

Add option for archiver full context
This commit is contained in:
Ali Parlakçı
2021-06-19 13:56:04 +03:00
committed by GitHub
5 changed files with 23 additions and 1 deletions

View File

@@ -50,6 +50,7 @@ _downloader_options = [
_archiver_options = [
click.option('--all-comments', is_flag=True, default=None),
click.option('--comment-context', is_flag=True, default=None),
click.option('-f', '--format', type=click.Choice(('xml', 'json', 'yaml')), default=None),
]

View File

@@ -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.comment_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)

View File

@@ -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.comment_context: bool = False
def process_click_arguments(self, context: click.Context):
for arg_key in context.params.keys():