PEP8
Enable $MEGAPATH functionality in discover_ntuples.py
Factor out some complexity
Fix McCabe complexity
Enable MEGAPATH for metadata extraction