#!/usr/bin/env python

import os
import sys
from glob import glob
import numpy as np


def display_file(fn):
    if fn.endswith('.npy'):
        res = np.load(fn, 'r')
        print(fn, res.shape, res.dtype)
    elif fn.endswith('.npz'):
        npz = np.load(fn)
        for key in npz:
            res = npz[key]
            print(fn, key, res.shape, res.dtype)


def npls():
    args = sys.argv[1:]
    for arg in args:
        if (arg.endswith('.npy') or arg.endswith('.npz')) and os.path.isfile(arg):
            display_file(arg)
        elif os.path.isdir(arg):
            fns = sorted(glob(os.path.join(arg, '*.npy'))) + sorted(glob(os.path.join(arg, '*.npz')))
            for fn in fns:
                display_file(fn)


if __name__ == '__main__':
    npls()
