file_copy

file_copy(from_, to)

Copy files

Parameters

Name Type Description Default
from_ Union[str, List[str]] Path to a file or a list of files required
to Union[str, List[str]] Path to a file or a list of files required

Returns

Name Type Description
Union[None, List[None]] the result of the call to shutil.copyfile or a list of these results in case from_ is a list

Examples

>>> from rlike import *
>>> path = file_path(tempdir(), "test.txt")
>>> file_exists(path)
False
>>> f1 = writeLines(text = 'Hello world. Some more text.', con = 'fname1.txt')
>>> out = file_copy(f1, path)
>>> file_exists(path)
True
>>> readLines(path)
['Hello world. Some more text.']
>>> patha = file_path(tempdir(), "testa.txt")
>>> pathb = file_path(tempdir(), "testb.txt")
>>> out = file_copy([f1, f1], [patha, pathb])
>>> readLines(patha)
['Hello world. Some more text.']
>>> readLines(pathb)
['Hello world. Some more text.']
>>> test = file_remove([path, f1, patha, pathb])
>>> test
[None, None, None, None]