Skip to content

Commit

Permalink
DEVTOOLS: COMPANION: Add version checker pycdlib module
Browse files Browse the repository at this point in the history
The pycdlib module does not implement the encoding parameter that is required for decoding Japanese filenames. A PR has been made to acknowledge this issue: clalancette/pycdlib#124 . For the time, the PR is not merged, we need a temporary pycdlib version checker. Once the pycdlib PR has been merged, this commit can be removed
  • Loading branch information
Darkhood148 committed Apr 11, 2024
1 parent a9beeef commit 10ed3a8
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions devtools/dumper-companion.py
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,28 @@ def create_macfonts(args: argparse.Namespace) -> int:
return 0


def search_encoding_parameter(s: str) -> bool:
l = -1
u = -1
for i, line in enumerate(s.split('\n')):
if line.strip() == 'Parameters:':
l = i + 1
if line.strip() == 'Yields:':
u = i
break
parameters = [i.split('-')[0].strip() for i in s.split('\n')[l:u]]
if 'encoding' in parameters:
return True
return False


def check_pycdlib_version() -> bool:
iso_test = pycdlib.PyCdlib()
doc_walk = iso_test.walk.__doc__
doc_get_file_from_iso_fp = iso_test.get_file_from_iso_fp.__doc__
return search_encoding_parameter(doc_walk) and search_encoding_parameter(doc_get_file_from_iso_fp)


def generate_parser() -> argparse.ArgumentParser:
"""
Generate the parser
Expand Down Expand Up @@ -1060,6 +1082,8 @@ def generate_parser() -> argparse.ArgumentParser:


if __name__ == "__main__":
if not check_pycdlib_version():
print('WARNING: Old version of pycdlib detected. Parsing of Japanese filenames in ISO9660 may not work')
parser = generate_parser()
args = parser.parse_args()
try:
Expand Down

0 comments on commit 10ed3a8

Please sign in to comment.