示例#1
0
def read_profile(profiles_dir):
    path = os.path.join(profiles_dir, 'profiles.yml')

    contents = None
    if os.path.isfile(path):
        try:
            contents = load_file_contents(path, strip=False)
            return load_yaml_text(contents)
        except ValidationException as e:
            msg = INVALID_PROFILE_MESSAGE.format(error_string=e)
            raise ValidationException(msg)

    return {}
示例#2
0
def read_profile(profiles_dir: str) -> Dict[str, Any]:
    path = os.path.join(profiles_dir, 'profiles.yml')

    contents = None
    if os.path.isfile(path):
        try:
            contents = load_file_contents(path, strip=False)
            yaml_content = load_yaml_text(contents)
            if not yaml_content:
                msg = f'The profiles.yml file at {path} is empty'
                raise DbtProfileError(
                    INVALID_PROFILE_MESSAGE.format(error_string=msg))
            return yaml_content
        except ValidationException as e:
            msg = INVALID_PROFILE_MESSAGE.format(error_string=e)
            raise ValidationException(msg) from e

    return {}
示例#3
0
def _load_yaml(path):
    contents = load_file_contents(path)
    return load_yaml_text(contents)
示例#4
0
文件: base.py 项目: convoyinc/dbt
 def load_file(self, path: FilePath) -> SourceFile:
     file_contents = load_file_contents(path.absolute_path, strip=False)
     checksum = FileHash.from_contents(file_contents)
     source_file = SourceFile(path=path, checksum=checksum)
     source_file.contents = file_contents.strip()
     return source_file