fsspec/implementations/tests/test_local.py
def filetexts(d, open=open, mode="t"):
    """Dumps a number of textfiles to disk

    d - dict
        a mapping from filename to text like {'a.csv': '1,1\n2,2'}

    Since this is meant for use in tests, this context manager will
    automatically switch to a temporary current directory, to avoid
    race conditions when running tests in parallel.
    """
    dirname = tempfile.mkdtemp()
    try:
        os.chdir(dirname)
        for filename, text in d.items():
            f = open(filename, "w" + mode)
            try:
                f.write(text)
            finally:
                try:
                    f.close()
                except AttributeError:
                    pass

        yield list(d)

        for filename in d:
            if os.path.exists(filename):
                try:
                    os.remove(filename)
                except (IOError, OSError):
                    pass
    finally:
        os.chdir(odir)
Dumps a number of textfiles to disk

    d - dict
        a mapping from filename to text like {'a.csv': '1,1\n2,2'}

    Since this is meant for use in tests, this context manager will
    automatically switch to a temporary current directory, to avoid
    race conditions when running tests in parallel.
    
Dumps a number of textfiles to disk
d - dict
a mapping from filename to text like {'a.csv': '1,1\n2,2'}

Since this is meant for use in tests, this context manager will
automatically switch to a temporary current directory, to avoid
race conditions when running tests in parallel.
Dumps a number of textfiles to disk d - dict a mapping from filename to text like { ' a . csv ' : ' 1 1 \ n2 2 ' } Since this is meant for use in tests this context manager will automatically switch to a temporary current directory to avoid race conditions when running tests in parallel .
def filetexts(d, open=open, mode="t"):
    dirname = tempfile.mkdtemp()
    try:
        os.chdir(dirname)
        for filename, text in d.items():
            f = open(filename, "w" + mode)
            try:
                f.write(text)
            finally:
                try:
                    f.close()
                except AttributeError:
                    pass
        yield list(d)
        for filename in d:
            if os.path.exists(filename):
                try:
                    os.remove(filename)
                except (IOError, OSError):
                    pass
    finally:
        os.chdir(odir)
def filetexts ( d , open = open , mode = "t" ) : dirname = tempfile . mkdtemp ( ) try : os . chdir ( dirname ) for filename , text in d . items ( ) : f = open ( filename , "w" + mode ) try : f . write ( text ) finally : try : f . close ( ) except AttributeError : pass yield list ( d ) for filename in d : if os . path . exists ( filename ) : try : os . remove ( filename ) except ( IOError , OSError ) : pass finally : os . chdir ( odir )
Dumps a number of textfiles to disk
d - dict
a mapping from filename to text like {'a.csv': '1,1\n2,2'}
Dumps a number of textfiles to disk d - dict a mapping from filename to text like { ' a . csv ' : ' 1 1 \ n2 2 ' }
"""Dumps a number of textfiles to disk

    d - dict
        a mapping from filename to text like {'a.csv': '1,1\n2,2'}

    Since this is meant for use in tests, this context manager will
    automatically switch to a temporary current directory, to avoid
    race conditions when running tests in parallel.
    """
d
open
mode