'Open the input file specified on the command line.'

def _open_input_file(self, path):

    if six.PY2:
        mode = 'rb'
        kwargs = {}
    else:
        mode = 'rt'
        kwargs = {'encoding': self.args.encoding}
    if ((not path) or (path == '-')):
        if self.buffers_input:
            f = six.StringIO(sys.stdin.read())
        else:
            f = sys.stdin
    else:
        extension = splitext(path)[1]
        if (extension == '.gz'):
            f = LazyFile(gzip.open, path, mode, **kwargs)
        elif (extension == '.bz2'):
            if six.PY2:
                f = LazyFile(bz2.BZ2File, path, mode, **kwargs)
            else:
                f = LazyFile(bz2.open, path, mode, **kwargs)
        else:
            f = LazyFile(open, path, mode, **kwargs)
    return f
