# Path: apasvo/utils/futils.py
# def istextfile(filename, blocksize=512):
# def is_little_endian():
# def read_in_chunks(file_object, chunk_size=1024):
# def read_txt_in_chunks(file_object, n=1024, comments='#'):
# def getSize(f):
# def get_delimiter(fileobject, lines=16):
# def get_sample_rate(filename, max_header_lines=64, comments='#'):
# def copytree(src, dst, symlinks=False, ignore=None):


import argparse
import os
import glob
from apasvo.utils import futils

def fraction(arg):
    """Determines if an argument is a number in the range [0,1)."""
    value = float(arg)
    if value < 0 or value > 1:
        msg = "%r must be a value between [0,1)" % arg
        raise argparse.ArgumentTypeError(msg)
    return value


class GlobInputFilenames(argparse.Action):
    """Finds all the pathnames according to the specified filename arguments.

    Expands a list of string arguments that represent pathnames. They can be
    either absolute (e.g. /usr/bin/example.txt ) or relative pathnames
    (e.g. ./examples/*.bin).
    Returns a list containing an argparse.FileType object for each filename
    that matches the pattern list.
    """

    def __call__(self, parser, namespace, values, option_string=None):
        fnames = []
        for pname in values:
            if '*' in pname or '?' in pname:
                fnames.extend(glob.glob(pname))
            else:
                fnames.append(pname)
        setattr(namespace, self.dest, fnames)

    def _fopen(self, fname):

# Path: apasvo/utils/futils.py
# def istextfile(filename, blocksize=512):
# def is_little_endian():
# def read_in_chunks(file_object, chunk_size=1024):
# def read_txt_in_chunks(file_object, n=1024, comments='#'):
# def getSize(f):
# def get_delimiter(fileobject, lines=16):
# def get_sample_rate(filename, max_header_lines=64, comments='#'):
# def copytree(src, dst, symlinks=False, ignore=None):


# Path: apasvo/utils/parse.py
import argparse
import os
import glob
from apasvo.utils import futils


def fraction(arg):
    """Determines if an argument is a number in the range [0,1)."""
    value = float(arg)
    if value < 0 or value > 1:
        msg = "%r must be a value between [0,1)" % arg
        raise argparse.ArgumentTypeError(msg)
    return value


class GlobInputFilenames(argparse.Action):
    """Finds all the pathnames according to the specified filename arguments.

    Expands a list of string arguments that represent pathnames. They can be
    either absolute (e.g. /usr/bin/example.txt ) or relative pathnames
    (e.g. ./examples/*.bin).
    Returns a list containing an argparse.FileType object for each filename
    that matches the pattern list.
    """

    def __call__(self, parser, namespace, values, option_string=None):
        fnames = []
        for pname in values:
            if '*' in pname or '?' in pname:
                fnames.extend(glob.glob(pname))
            else:
                fnames.append(pname)
        setattr(namespace, self.dest, fnames)

    def _fopen(self, fname):

        if futils.istextfile(fname):