# Path: numjuggler/utils/resource.py
# def filename_resolver(package=None):
#     def func(resource):
# def path_resolver(package=None):
#     def func(resource):


import os
import sys
from .resource import Path
from contextlib import contextmanager



@contextmanager
def cd_temporarily(cd_to):
    cur_dir = str(Path.cwd())
    try:
        os.chdir(str(cd_to))
        yield
    finally:
        os.chdir(cur_dir)


@contextmanager
def resolve_fname_or_stream(fname_or_stream, mode="r"):
    is_input = mode == 'r'
    if fname_or_stream is None:
        if is_input:
            yield sys.stdin
        else:

# Path: numjuggler/utils/resource.py
# def filename_resolver(package=None):
#     def func(resource):
# def path_resolver(package=None):
#     def func(resource):


# Path: numjuggler/utils/io.py
import os
import sys
from .resource import Path
from contextlib import contextmanager




@contextmanager
def cd_temporarily(cd_to):
    cur_dir = str(Path.cwd())
    try:
        os.chdir(str(cd_to))
        yield
    finally:
        os.chdir(cur_dir)


@contextmanager
def resolve_fname_or_stream(fname_or_stream, mode="r"):
    is_input = mode == 'r'
    if fname_or_stream is None:
        if is_input:
            yield sys.stdin
        else:

            yield sys.stdout