From 376a5b913776eb1a3df4309eddb8660141df2910 Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Wed, 7 Sep 2022 13:20:55 -0700 Subject: [PATCH] ready? --- src/ytdl_sub/utils/file_handler.py | 14 +++++----- tests/e2e/expected_transaction_log.py | 2 +- .../plugins/nfo_tags/test_nfo.txt | 26 ------------------- .../plugins/nfo_tags/test_nfo_kodi_safe.txt | 26 ------------------- 4 files changed, 7 insertions(+), 61 deletions(-) diff --git a/src/ytdl_sub/utils/file_handler.py b/src/ytdl_sub/utils/file_handler.py index 243b65c0..ac83738e 100644 --- a/src/ytdl_sub/utils/file_handler.py +++ b/src/ytdl_sub/utils/file_handler.py @@ -9,8 +9,6 @@ from typing import Optional from typing import Set from typing import Union -import yaml - class FileMetadata: """ @@ -66,21 +64,21 @@ class FileMetadata: value_dict = json.loads(json.dumps(value_dict, sort_keys=True, ensure_ascii=False)) def _indent_lines(value: str, indent: int) -> str: - if '\n' not in value: + if "\n" not in value: return value - output_str = '' + output_str = "" _indent = " " * indent - for line in value.split('\n'): + for line in value.split("\n"): output_str += f"{_indent}{line}\n" - return output_str + return f"{output_str.rstrip()}\n" def _single_value(value: Any) -> Optional[str]: if isinstance(value, list) and len(value) == 1: return _single_value(value=value[0]) if isinstance(value, (dict, list)): return None - if isinstance(value, str) and '\n' in value: + if isinstance(value, str) and "\n" in value: return None return value @@ -108,7 +106,7 @@ class FileMetadata: elif isinstance(value, str): # multi-line string output_str += _indent_lines(value, indent=indent + 2) else: - assert False, 'should never reach here' + assert False, "should never reach here" return output_str out = _recursive_lines(value_dict).rstrip().split("\n") diff --git a/tests/e2e/expected_transaction_log.py b/tests/e2e/expected_transaction_log.py index f50fda2c..12d23187 100644 --- a/tests/e2e/expected_transaction_log.py +++ b/tests/e2e/expected_transaction_log.py @@ -10,7 +10,7 @@ def assert_transaction_log_matches( output_directory: str, transaction_log: FileHandlerTransactionLog, transaction_log_summary_file_name: str, - regenerate_transaction_log: bool = True, + regenerate_transaction_log: bool = False, ): """ Parameters diff --git a/tests/e2e/resources/transaction_log_summaries/plugins/nfo_tags/test_nfo.txt b/tests/e2e/resources/transaction_log_summaries/plugins/nfo_tags/test_nfo.txt index fcf0f863..da764f02 100644 --- a/tests/e2e/resources/transaction_log_summaries/plugins/nfo_tags/test_nfo.txt +++ b/tests/e2e/resources/transaction_log_summaries/plugins/nfo_tags/test_nfo.txt @@ -11,46 +11,32 @@ Rick Beato - Can you hear the difference? 🎸🔥 #shorts.nfo kodi_safe_multi_title 🎸: - value 1 🎸 - value 2 🎸 - kodi_safe_multi_title_with_attrs: - attributes: 🎸?: value newlines 🎸 - - tag: the tag 1 🎸🎸 - - - attributes: 🎸?: value newlines 🎸 - - tag: the tag 2 🎸🎸 - - - kodi_safe_title 🎸: kodi_safe_value 🎸 kodi_safe_title_with_attrs: attributes: 🎸?: value newlines 🎸 - - tag: the tag 🎸🎸 - - title: Can you hear the difference? 🎸🔥 #shorts year: 2022 test.nfo @@ -59,41 +45,29 @@ test.nfo kodi_safe_multi_title 🎸: - value 1 🎸 - value 2 🎸 - kodi_safe_multi_title_with_attrs: - attributes: 🎸?: value newlines 🎸 - - tag: the tag 1 🎸🎸 - - - attributes: 🎸?: value newlines 🎸 - - tag: the tag 2 🎸🎸 - - - kodi_safe_title 🎸: kodi_safe_value 🎸 kodi_safe_title_with_attrs: attributes: 🎸?: value newlines 🎸 - - tag: the tag 🎸🎸 \ No newline at end of file diff --git a/tests/e2e/resources/transaction_log_summaries/plugins/nfo_tags/test_nfo_kodi_safe.txt b/tests/e2e/resources/transaction_log_summaries/plugins/nfo_tags/test_nfo_kodi_safe.txt index 2f6c91a1..0e823dbe 100644 --- a/tests/e2e/resources/transaction_log_summaries/plugins/nfo_tags/test_nfo_kodi_safe.txt +++ b/tests/e2e/resources/transaction_log_summaries/plugins/nfo_tags/test_nfo_kodi_safe.txt @@ -11,46 +11,32 @@ Rick Beato - Can you hear the difference? 🎸🔥 #shorts.nfo kodi_safe_multi_title □: - value 1 □ - value 2 □ - kodi_safe_multi_title_with_attrs: - attributes: □?: value newlines □ - - tag: the tag 1 □□ - - - attributes: □?: value newlines □ - - tag: the tag 2 □□ - - - kodi_safe_title □: kodi_safe_value □ kodi_safe_title_with_attrs: attributes: □?: value newlines □ - - tag: the tag □□ - - title: Can you hear the difference? □□ #shorts year: 2022 test.nfo @@ -59,41 +45,29 @@ test.nfo kodi_safe_multi_title □: - value 1 □ - value 2 □ - kodi_safe_multi_title_with_attrs: - attributes: □?: value newlines □ - - tag: the tag 1 □□ - - - attributes: □?: value newlines □ - - tag: the tag 2 □□ - - - kodi_safe_title □: kodi_safe_value □ kodi_safe_title_with_attrs: attributes: □?: value newlines □ - - tag: the tag □□ \ No newline at end of file