def dialect_of(data, **kwargs):
    """ CSV dialect of a CSV file stored in SSH, HDFS, or a Directory. """
    keys = set(['delimiter', 'doublequote', 'escapechar', 'lineterminator',
                'quotechar', 'quoting', 'skipinitialspace', 'strict', 'has_header'])
    if isinstance(data, (HDFS(CSV), SSH(CSV))):
        with sample(data) as fn:
            d = dialect_of(CSV(fn, **data.dialect))
    elif isinstance(data, (HDFS(Directory(CSV)), SSH(Directory(CSV)))):
        with sample(data) as fn:
            d = dialect_of(CSV(fn, **data.kwargs))
    elif isinstance(data, Directory(CSV)):
        d = dialect_of(next(data))
    else:
        assert isinstance(data, CSV)

        # Get sample text
        with open(data.path, 'r') as f:
            text = f.read()

        result = dict()

        d = sniffer.sniff(text)
        d = dict((k, getattr(d, k)) for k in keys if hasattr(d, k))

        if data.has_header is None:
            d['has_header'] = sniffer.has_header(text)
        else:
            d['has_header'] = data.has_header

        d.update(data.dialect)

    d.update(kwargs)
    d = dict((k, v) for k, v in d.items() if k in keys)

    return d
dataset/ETHPy150Open blaze/odo/odo/backends/hdfs.py/dialect_of/original