def _validate_data_path()

in azdev/operations/secret.py [0:0]


def _validate_data_path(file_path=None, directory_path=None, include_pattern=None, exclude_pattern=None, data=None):
    if file_path and directory_path:
        raise ValueError('Can not specify file path and directory path at the same time')
    if file_path and data:
        raise ValueError('Can not specify file path and raw string at the same time')
    if directory_path and data:
        raise ValueError('Can not specify directory path and raw string at the same time')
    if not file_path and not directory_path and not data:
        raise ValueError('No file path or directory path or raw string provided')

    if directory_path and not os.path.isdir(directory_path):
        raise ValueError(f'invalid directory path:{directory_path}')
    if file_path and not os.path.isfile(file_path):
        raise ValueError(f'invalid file path:{file_path}')
    if not directory_path and include_pattern:
        raise ValueError('--include-pattern need to be used together with --directory-path')
    if not directory_path and exclude_pattern:
        raise ValueError('--exclude-pattern need to be used together with --directory-path')
    if include_pattern and exclude_pattern:
        raise ValueError('--include-pattern and --exclude-pattern are mutually exclusive')