'Initialize netcdf_file from fileobj (str or file-like).'

def __init__(self, filename, mode='r', mmap=None, version=1, maskandscale=False):

    if (mode not in 'rwa'):
        raise ValueError("Mode    must    be    either    'r',    'w'    or    'a'.")
    if hasattr(filename, 'seek'):
        self.fp = filename
        self.filename = 'None'
        if (mmap is None):
            mmap = False
        elif (mmap and (not hasattr(filename, 'fileno'))):
            raise ValueError('Cannot    use    file    object    for    mmap')
    else:
        self.filename = filename
        omode = ('r+' if (mode == 'a') else mode)
        self.fp = open(self.filename, ('%sb' % omode))
        if (mmap is None):
            mmap = True
    if (mode != 'r'):
        mmap = False
    self.use_mmap = mmap
    self.mode = mode
    self.version_byte = version
    self.maskandscale = maskandscale
    self.dimensions = OrderedDict()
    self.variables = OrderedDict()
    self._dims = []
    self._recs = 0
    self._recsize = 0
    self._mm = None
    self._mm_buf = None
    if self.use_mmap:
        self._mm = mm.mmap(self.fp.fileno(), 0, access=mm.ACCESS_READ)
        self._mm_buf = np.frombuffer(self._mm, dtype=np.int8)
    self._attributes = OrderedDict()
    if (mode in 'ra'):
        self._read()
