Ejemplo n.º 1
0
    def _load(self):
        # it raises the proper exceptions by priority:
        # 1. when the file doesn't exists
        # 2. filename is not a DVC-file
        # 3. path doesn't represent a regular file
        if not self.exists():
            raise StageFileDoesNotExistError(self.path)
        check_dvc_filename(self.path)
        if not self.repo.tree.isfile(self.path):
            raise StageFileIsNotDvcFileError(self.path)

        with self.repo.tree.open(self.path) as fd:
            stage_text = fd.read()
        d = parse_yaml(stage_text, self.path)
        self.validate(d, self.relpath)
        return d, stage_text
Ejemplo n.º 2
0
    def _load(self, **kwargs: Any) -> Tuple[Any, str]:
        # it raises the proper exceptions by priority:
        # 1. when the file doesn't exists
        # 2. filename is not a DVC file
        # 3. path doesn't represent a regular file
        # 4. when the file is git ignored
        if not self.exists():
            dvc_ignored = self.repo.dvcignore.is_ignored_file(self.path)
            raise StageFileDoesNotExistError(self.path,
                                             dvc_ignored=dvc_ignored)

        self._verify_filename()
        if not self.repo.fs.isfile(self.path):
            raise StageFileIsNotDvcFileError(self.path)

        self._check_gitignored()
        return self._load_yaml(**kwargs)
Ejemplo n.º 3
0
    def _load(self):
        # it raises the proper exceptions by priority:
        # 1. when the file doesn't exists
        # 2. filename is not a DVC file
        # 3. path doesn't represent a regular file
        # 4. when the file is git ignored
        if not self.exists():
            is_ignored = self.repo.fs.exists(self.path, use_dvcignore=False)
            raise StageFileDoesNotExistError(self.path, dvc_ignored=is_ignored)

        self._verify_filename()
        if not self.repo.fs.isfile(self.path):
            raise StageFileIsNotDvcFileError(self.path)

        self._check_gitignored()
        with self.repo.fs.open(self.path, encoding="utf-8") as fd:
            stage_text = fd.read()
        d = parse_yaml(stage_text, self.path)
        return self.validate(d, self.relpath), stage_text
Ejemplo n.º 4
0
 def check_isfile(self):
     if not self.repo.tree.isfile(self.path):
         raise StageFileIsNotDvcFileError(self.path)