Пример #1
0
 def _writing(self, path: AbsolutePath, mode: str = "w+b") -> IO:
     blob = storage.blob.Blob(path.as_relative_path(), self.bucket)
     local_path = self.tempdir.append(path.as_relative_path())
     makedirs(dirname(local_path), exist_ok=True)
     writing_file = localfs_open(local_path, mode=mode)
     yield writing_file
     writing_file.close()
     blob.upload_from_filename(local_path)
Пример #2
0
def test_joining_absolute_paths():
    absolute_one = AbsolutePath("/an/absolute/path.ext")
    absolute_two = AbsolutePath("/prefix/absolute/path")
    relative_one = absolute_one.as_relative_path()
    joined_1 = relative_one.prepend(absolute_two)
    joined_2 = absolute_two.append(relative_one)
    assert joined_1 == joined_2
Пример #3
0
 def _download(self, path: AbsolutePath) -> AbsolutePath:
     local_path = self.tempdir.append(path.as_relative_path())
     makedirs(dirname(local_path), exist_ok=True)
     blob = storage.blob.Blob(path.as_relative_path(), self.bucket)
     blob.download_to_filename(local_path)
     return local_path