Skip to content

Commit 10ed3a8

Browse files
committed
DEVTOOLS: COMPANION: Add version checker pycdlib module
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
1 parent a9beeef commit 10ed3a8

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

devtools/dumper-companion.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,28 @@ def create_macfonts(args: argparse.Namespace) -> int:
943943
return 0
944944

945945

946+
def search_encoding_parameter(s: str) -> bool:
947+
l = -1
948+
u = -1
949+
for i, line in enumerate(s.split('\n')):
950+
if line.strip() == 'Parameters:':
951+
l = i + 1
952+
if line.strip() == 'Yields:':
953+
u = i
954+
break
955+
parameters = [i.split('-')[0].strip() for i in s.split('\n')[l:u]]
956+
if 'encoding' in parameters:
957+
return True
958+
return False
959+
960+
961+
def check_pycdlib_version() -> bool:
962+
iso_test = pycdlib.PyCdlib()
963+
doc_walk = iso_test.walk.__doc__
964+
doc_get_file_from_iso_fp = iso_test.get_file_from_iso_fp.__doc__
965+
return search_encoding_parameter(doc_walk) and search_encoding_parameter(doc_get_file_from_iso_fp)
966+
967+
946968
def generate_parser() -> argparse.ArgumentParser:
947969
"""
948970
Generate the parser
@@ -1060,6 +1082,8 @@ def generate_parser() -> argparse.ArgumentParser:
10601082

10611083

10621084
if __name__ == "__main__":
1085+
if not check_pycdlib_version():
1086+
print('WARNING: Old version of pycdlib detected. Parsing of Japanese filenames in ISO9660 may not work')
10631087
parser = generate_parser()
10641088
args = parser.parse_args()
10651089
try:

0 commit comments

Comments
 (0)