def test_resolve(self):
     temp_file = NamedTemporaryFile(dir=os.getcwd(), delete=False)
     file_name = temp_file.name
     temp_file.close()
     base_name = os.path.basename(file_name)
     try:
         recent_path = RecentPath(os.path.join("temp/datasets", base_name),
                                  "", os.path.join("datasets", base_name))
         search_paths = [("basedir", os.getcwd())]
         self.assertIsNotNone(recent_path.resolve(search_paths))
     finally:
         os.remove(file_name)
Ejemplo n.º 2
0
    def __relocate_file(self, path: RecentPath) -> RecentPath:
        basedir = self.workflowEnv().get("basedir", None)
        if basedir is None or path is None:
            return path

        search_paths = [("basedir", basedir)]
        resolved = path.resolve(search_paths)
        kwargs = dict(title=path.title, sheet=path.sheet,
                      file_format=path.file_format)
        if resolved is not None:
            return RecentPath.create(resolved.abspath, search_paths, **kwargs)
        elif path.search(search_paths) is not None:
            return RecentPath.create(path.search(search_paths),
                                     search_paths, **kwargs)
        return path