openpreserve / jpylyzer

JP2 (JPEG 2000 Part 1) validator and properties extractor. Jpylyzer was specifically created to check that a JP2 file really conforms to the format's specifications. Additionally jpylyzer is able to extract technical characteristics.
http://jpylyzer.openpreservation.org/
Other
69 stars 28 forks source link

Refactor findFiles function #178

Open bitsgalore opened 2 years ago

bitsgalore commented 2 years ago

The code in the findFiles function is very complex and difficult to read. It might be possible to simplify things using e.g. the Pathlib module, which also supports glob patterns. See also here.

Pathlib is only available for Python 3.4 and more recent, so this refactor should wait until we decide to drop Python 2.7 support.

Also, any changes in this part of the code will need thorough cross-platform testing, as I remember getting this to work in the first place was quite a challenge, see discussion here and here.

bitsgalore commented 2 years ago

First step could be to simplify handling of glob patterns, following:

https://github.com/KBNLresearch/isolyzer/commit/fa48ba677897e10dafd41d9533ec2fbf3d1334e6

(In this case the OS takes care of the glob expansion on Linux-based platforms)

Stand-alone test script here:

https://gist.github.com/bitsgalore/668eed7ae4421468f83c8ab7e38556f1