Skip to content

Commit 2e98628

Browse files
Darkhood148sev-
authored andcommitted
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 15efeac commit 2e98628

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

devtools/dumper-companion.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,26 @@ 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+
return 'encoding' in parameters
957+
958+
959+
def check_pycdlib_version() -> bool:
960+
iso_test = pycdlib.PyCdlib()
961+
doc_walk = iso_test.walk.__doc__
962+
doc_get_file_from_iso_fp = iso_test.get_file_from_iso_fp.__doc__
963+
return search_encoding_parameter(doc_walk) and search_encoding_parameter(doc_get_file_from_iso_fp)
964+
965+
946966
def generate_parser() -> argparse.ArgumentParser:
947967
"""
948968
Generate the parser
@@ -1060,6 +1080,8 @@ def generate_parser() -> argparse.ArgumentParser:
10601080

10611081

10621082
if __name__ == "__main__":
1083+
if not check_pycdlib_version():
1084+
print('WARNING: Old version of pycdlib detected. Parsing of Japanese filenames in ISO9660 may not work')
10631085
parser = generate_parser()
10641086
args = parser.parse_args()
10651087
try:

0 commit comments

Comments
 (0)