def get_fs(path, opts=None, rtype='instance'):
    "Helper to infer filesystem correctly.\n\n    Gets filesystem options from settings and updates them with given `opts`.\n\n    Parameters\n    ----------\n    path: str\n        Path for which we want to infer filesystem.\n    opts: dict\n        Kwargs that will be passed to inferred filesystem instance.\n    rtype: str\n        Either 'instance' (default) or 'class'.\n    "
    from drfs.filesystems import FILESYSTEMS
    try:
        protocol = path.scheme
    except AttributeError:
        protocol = _get_protocol(path)
    try:
        cls = FILESYSTEMS[protocol]
        if (rtype == 'class'):
            return cls
    except KeyError:
        raise KeyError(f'No filesystem for protocol {protocol}. Try installing it. Available protocols are: {set(FILESYSTEMS.keys())}')
    config_scheme_key = (protocol if protocol else 'file')
    opts_ = config['fs_opts'][config_scheme_key].get(dict).copy()
    if (opts is not None):
        opts_.update(opts)
    opts_ = _fix_opts_abfs(cls, path, opts_)
    return cls(**opts_)
Helper to infer filesystem correctly.

Gets filesystem options from settings and updates them with given `opts`.

Parameters
----------
path: str
    Path for which we want to infer filesystem.
opts: dict
    Kwargs that will be passed to inferred filesystem instance.
rtype: str
    Either 'instance' (default) or 'class'.
def get_fs(path, opts=None, rtype='instance'):
    "Helper to infer filesystem correctly.\n\n    Gets filesystem options from settings and updates them with given `opts`.\n\n    Parameters\n    ----------\n    path: str\n        Path for which we want to infer filesystem.\n    opts: dict\n        Kwargs that will be passed to inferred filesystem instance.\n    rtype: str\n        Either 'instance' (default) or 'class'.\n    "
    from drfs.filesystems import FILESYSTEMS
    try:
        protocol = path.scheme
    except AttributeError:
        protocol = _get_protocol(path)
    try:
        cls = FILESYSTEMS[protocol]
        if (rtype == 'class'):
            return cls
    except KeyError:
        raise KeyError(f'No filesystem for protocol {protocol}. Try installing it. Available protocols are: {set(FILESYSTEMS.keys())}')
    config_scheme_key = (protocol if protocol else 'file')
    opts_ = config['fs_opts'][config_scheme_key].get(dict).copy()
    if (opts is not None):
        opts_.update(opts)
    opts_ = _fix_opts_abfs(cls, path, opts_)
    return cls(**opts_)