Changeset 8230acb in rtems-central for rtemsqual/util.py


Ignore:
Timestamp:
Apr 17, 2020, 12:29:00 PM (14 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
a4e08c5
Parents:
4733ad3
Message:

util: Add copy_files()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rtemsqual/util.py

    r4733ad3 r8230acb  
    2626
    2727import os
    28 from typing import Any
     28import shutil
     29from typing import Any, List
    2930import yaml
     31
     32
     33def copy_files(src_dir: str, dst_dir: str, files: List[str]) -> None:
     34    """
     35    Copies a list of files in the source directory to the destination
     36    directory preserving the directory of the files relative to the source
     37    directory.
     38    """
     39    for a_file in files:
     40        src = os.path.join(src_dir, a_file)
     41        dst = os.path.join(dst_dir, a_file)
     42        os.makedirs(os.path.dirname(dst), exist_ok=True)
     43        shutil.copy2(src, dst)
    3044
    3145
Note: See TracChangeset for help on using the changeset viewer.