This commit is contained in:
Jesse Bannon 2022-09-07 13:20:55 -07:00
parent cc5daea41b
commit 376a5b9137
4 changed files with 7 additions and 61 deletions

View file

@ -9,8 +9,6 @@ from typing import Optional
from typing import Set from typing import Set
from typing import Union from typing import Union
import yaml
class FileMetadata: class FileMetadata:
""" """
@ -66,21 +64,21 @@ class FileMetadata:
value_dict = json.loads(json.dumps(value_dict, sort_keys=True, ensure_ascii=False)) value_dict = json.loads(json.dumps(value_dict, sort_keys=True, ensure_ascii=False))
def _indent_lines(value: str, indent: int) -> str: def _indent_lines(value: str, indent: int) -> str:
if '\n' not in value: if "\n" not in value:
return value return value
output_str = '' output_str = ""
_indent = " " * indent _indent = " " * indent
for line in value.split('\n'): for line in value.split("\n"):
output_str += f"{_indent}{line}\n" output_str += f"{_indent}{line}\n"
return output_str return f"{output_str.rstrip()}\n"
def _single_value(value: Any) -> Optional[str]: def _single_value(value: Any) -> Optional[str]:
if isinstance(value, list) and len(value) == 1: if isinstance(value, list) and len(value) == 1:
return _single_value(value=value[0]) return _single_value(value=value[0])
if isinstance(value, (dict, list)): if isinstance(value, (dict, list)):
return None return None
if isinstance(value, str) and '\n' in value: if isinstance(value, str) and "\n" in value:
return None return None
return value return value
@ -108,7 +106,7 @@ class FileMetadata:
elif isinstance(value, str): # multi-line string elif isinstance(value, str): # multi-line string
output_str += _indent_lines(value, indent=indent + 2) output_str += _indent_lines(value, indent=indent + 2)
else: else:
assert False, 'should never reach here' assert False, "should never reach here"
return output_str return output_str
out = _recursive_lines(value_dict).rstrip().split("\n") out = _recursive_lines(value_dict).rstrip().split("\n")

View file

@ -10,7 +10,7 @@ def assert_transaction_log_matches(
output_directory: str, output_directory: str,
transaction_log: FileHandlerTransactionLog, transaction_log: FileHandlerTransactionLog,
transaction_log_summary_file_name: str, transaction_log_summary_file_name: str,
regenerate_transaction_log: bool = True, regenerate_transaction_log: bool = False,
): ):
""" """
Parameters Parameters

View file

@ -11,46 +11,32 @@ Rick Beato - Can you hear the difference 🎸🔥 #shorts.nfo
kodi_safe_multi_title 🎸: kodi_safe_multi_title 🎸:
- value 1 🎸 - value 1 🎸
- value 2 🎸 - value 2 🎸
kodi_safe_multi_title_with_attrs: kodi_safe_multi_title_with_attrs:
- -
attributes: attributes:
🎸?: 🎸?:
value value
newlines 🎸 newlines 🎸
tag: tag:
the the
tag 1 🎸🎸 tag 1 🎸🎸
- -
attributes: attributes:
🎸?: 🎸?:
value value
newlines 🎸 newlines 🎸
tag: tag:
the the
tag 2 🎸🎸 tag 2 🎸🎸
kodi_safe_title 🎸: kodi_safe_value 🎸 kodi_safe_title 🎸: kodi_safe_value 🎸
kodi_safe_title_with_attrs: kodi_safe_title_with_attrs:
attributes: attributes:
🎸?: 🎸?:
value value
newlines 🎸 newlines 🎸
tag: tag:
the the
tag 🎸🎸 tag 🎸🎸
title: Can you hear the difference? 🎸🔥 #shorts title: Can you hear the difference? 🎸🔥 #shorts
year: 2022 year: 2022
test.nfo test.nfo
@ -59,41 +45,29 @@ test.nfo
kodi_safe_multi_title 🎸: kodi_safe_multi_title 🎸:
- value 1 🎸 - value 1 🎸
- value 2 🎸 - value 2 🎸
kodi_safe_multi_title_with_attrs: kodi_safe_multi_title_with_attrs:
- -
attributes: attributes:
🎸?: 🎸?:
value value
newlines 🎸 newlines 🎸
tag: tag:
the the
tag 1 🎸🎸 tag 1 🎸🎸
- -
attributes: attributes:
🎸?: 🎸?:
value value
newlines 🎸 newlines 🎸
tag: tag:
the the
tag 2 🎸🎸 tag 2 🎸🎸
kodi_safe_title 🎸: kodi_safe_value 🎸 kodi_safe_title 🎸: kodi_safe_value 🎸
kodi_safe_title_with_attrs: kodi_safe_title_with_attrs:
attributes: attributes:
🎸?: 🎸?:
value value
newlines 🎸 newlines 🎸
tag: tag:
the the
tag 🎸🎸 tag 🎸🎸

View file

@ -11,46 +11,32 @@ Rick Beato - Can you hear the difference 🎸🔥 #shorts.nfo
kodi_safe_multi_title □: kodi_safe_multi_title □:
- value 1 □ - value 1 □
- value 2 □ - value 2 □
kodi_safe_multi_title_with_attrs: kodi_safe_multi_title_with_attrs:
- -
attributes: attributes:
□?: □?:
value value
newlines □ newlines □
tag: tag:
the the
tag 1 □□ tag 1 □□
- -
attributes: attributes:
□?: □?:
value value
newlines □ newlines □
tag: tag:
the the
tag 2 □□ tag 2 □□
kodi_safe_title □: kodi_safe_value □ kodi_safe_title □: kodi_safe_value □
kodi_safe_title_with_attrs: kodi_safe_title_with_attrs:
attributes: attributes:
□?: □?:
value value
newlines □ newlines □
tag: tag:
the the
tag □□ tag □□
title: Can you hear the difference? □□ #shorts title: Can you hear the difference? □□ #shorts
year: 2022 year: 2022
test.nfo test.nfo
@ -59,41 +45,29 @@ test.nfo
kodi_safe_multi_title □: kodi_safe_multi_title □:
- value 1 □ - value 1 □
- value 2 □ - value 2 □
kodi_safe_multi_title_with_attrs: kodi_safe_multi_title_with_attrs:
- -
attributes: attributes:
□?: □?:
value value
newlines □ newlines □
tag: tag:
the the
tag 1 □□ tag 1 □□
- -
attributes: attributes:
□?: □?:
value value
newlines □ newlines □
tag: tag:
the the
tag 2 □□ tag 2 □□
kodi_safe_title □: kodi_safe_value □ kodi_safe_title □: kodi_safe_value □
kodi_safe_title_with_attrs: kodi_safe_title_with_attrs:
attributes: attributes:
□?: □?:
value value
newlines □ newlines □
tag: tag:
the the
tag □□ tag □□