bmonreporter/file_util.py
def copy_dir_tree(from_dir, to_dir, content_type=None):
    """Recursively copies a directory to another location, deleting any files
    at that location that are not in the source directory.  'from_dir' and 'to_dir'
    directories can be S3 buckets + key prefix.
    If 'content_type' is not None, then the content-type of the files will be
    explicitly set to the passed in value.
    """
    # determine whether from and to directories are S3 directories
    from_is_s3 = (from_dir[:5] == 's3://')
    to_is_s3 = (to_dir[:5] == 's3://')
    
    # If neither directories are on S3, use a coventional copy tree command.
    # This will error if 'to_dir' exists, so first remove it if it is present.
    if from_is_s3 or to_is_s3:
        # use the AWS CLI S3 sync command.  Delete any destination files that
        # do not exist in the source.
        if content_type:
            subprocess.run(['aws', 's3', 'sync', from_dir, to_dir, '--delete', '--content-type', content_type, '--profile', 'bmonreporter'])
        else:
            subprocess.run(['aws', 's3', 'sync', from_dir, to_dir, '--delete',  '--profile', 'bmonreporter'])
    else:
        if Path(to_dir).exists():
            shutil.rmtree(to_dir)
        shutil.copytree(from_dir, to_dir)
Recursively copies a directory to another location, deleting any files
    at that location that are not in the source directory.  'from_dir' and 'to_dir'
    directories can be S3 buckets + key prefix.
    If 'content_type' is not None, then the content-type of the files will be
    explicitly set to the passed in value.
    
Recursively copies a directory to another location, deleting any files
at that location that are not in the source directory.  'from_dir' and 'to_dir'
directories can be S3 buckets + key prefix.
If 'content_type' is not None, then the content-type of the files will be
explicitly set to the passed in value.
Recursively copies a directory to another location deleting any files at that location that are not in the source directory . ' from_dir ' and ' to_dir ' directories can be S3 buckets + key prefix . If ' content_type ' is not None then the content - type of the files will be explicitly set to the passed in value .
def copy_dir_tree(from_dir, to_dir, content_type=None):
    from_is_s3 = (from_dir[:5] == 's3://')
    to_is_s3 = (to_dir[:5] == 's3://')
    if from_is_s3 or to_is_s3:
        if content_type:
            subprocess.run(['aws', 's3', 'sync', from_dir, to_dir, '--delete', '--content-type', content_type, '--profile', 'bmonreporter'])
        else:
            subprocess.run(['aws', 's3', 'sync', from_dir, to_dir, '--delete',  '--profile', 'bmonreporter'])
    else:
        if Path(to_dir).exists():
            shutil.rmtree(to_dir)
        shutil.copytree(from_dir, to_dir)
def copy_dir_tree ( from_dir , to_dir , content_type = None ) : from_is_s3 = ( from_dir [ : 5 ] == 's3://' ) to_is_s3 = ( to_dir [ : 5 ] == 's3://' ) if from_is_s3 or to_is_s3 : if content_type : subprocess . run ( [ 'aws' , 's3' , 'sync' , from_dir , to_dir , '--delete' , '--content-type' , content_type , '--profile' , 'bmonreporter' ] ) else : subprocess . run ( [ 'aws' , 's3' , 'sync' , from_dir , to_dir , '--delete' , '--profile' , 'bmonreporter' ] ) else : if Path ( to_dir ) . exists ( ) : shutil . rmtree ( to_dir ) shutil . copytree ( from_dir , to_dir )
Recursively copies a directory to another location, deleting any files
at that location that are not in the source directory.
Recursively copies a directory to another location deleting any files at that location that are not in the source directory .
"""Recursively copies a directory to another location, deleting any files
    at that location that are not in the source directory.  'from_dir' and 'to_dir'
    directories can be S3 buckets + key prefix.
    If 'content_type' is not None, then the content-type of the files will be
    explicitly set to the passed in value.
    """ # determine whether from and to directories are S3 directories # If neither directories are on S3, use a coventional copy tree command. # This will error if 'to_dir' exists, so first remove it if it is present. # use the AWS CLI S3 sync command.  Delete any destination files that # do not exist in the source.
from_dir
to_dir
content_type