Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions dev/fsspec_inspector/generate_flavours.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ def _fix_azure_blob_file_system(x: str) -> str:
return x


def _fix_data_file_system(x: str) -> str:
return re.sub(
"sep = '/'",
"sep = '' # type: ignore[assignment]\n "
"altsep = ' ' # type: ignore[assignment]",
x,
)


def _fix_memfs_file_system(x: str) -> str:
return re.sub(
"_MemFS",
Expand Down Expand Up @@ -184,6 +193,7 @@ def _fix_xrootd_file_system(x: str) -> str:
FIX_SOURCE = {
"AbstractFileSystem": _fix_abstract_file_system,
"AzureBlobFileSystem": _fix_azure_blob_file_system,
"DataFileSystem": _fix_data_file_system,
"MemFS": _fix_memfs_file_system,
"MemoryFileSystem": _fix_memory_file_system,
"OSSFileSystem": _fix_oss_file_system,
Expand Down
2 changes: 1 addition & 1 deletion upath/_flavour.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def sep(self) -> str: # type: ignore[override]

@property
def altsep(self) -> str | None: # type: ignore[override]
return None
return getattr(self._spec, "altsep", None)

def isabs(self, path: JoinablePathLike) -> bool:
path = self.strip_protocol(path)
Expand Down
3 changes: 2 additions & 1 deletion upath/_flavour_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ class DataFileSystemFlavour(AbstractFileSystemFlavour):
__orig_version__ = '2025.10.0'
protocol = ('data',)
root_marker = ''
sep = '/'
sep = "" # type: ignore[assignment]
altsep = " " # type: ignore[assignment]


class DatabricksFileSystemFlavour(AbstractFileSystemFlavour):
Expand Down
62 changes: 60 additions & 2 deletions upath/implementations/data.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from __future__ import annotations

import sys
from collections.abc import Iterator
from collections.abc import Sequence
from typing import TYPE_CHECKING
from urllib.parse import quote_plus

from upath._protocol import get_upath_protocol
from upath.core import UnsupportedOperation
from upath.core import UPath
from upath.types import JoinablePathLike
Expand Down Expand Up @@ -45,10 +48,49 @@ def __str__(self) -> str:
return self.parser.join(*self._raw_urlpaths)

def with_segments(self, *pathsegments: JoinablePathLike) -> Self:
raise UnsupportedOperation("path operation not supported by DataPath")
try:
(segment,) = pathsegments
except ValueError:
raise UnsupportedOperation("join not supported by DataPath")
if get_upath_protocol(segment) != "data":
raise ValueError(f"requires a data URI, got: {segment!r}")
return type(self)(segment, protocol="data", **self.storage_options)

@property
def name(self) -> str:
return quote_plus(self.path)

@property
def stem(self) -> str:
return quote_plus(self.path)

@property
def suffix(self) -> str:
return ""

@property
def suffixes(self) -> list[str]:
return []

def with_name(self, name: str) -> Self:
raise UnsupportedOperation("with_name not supported by DataPath")

def with_suffix(self, suffix: str) -> Self:
raise UnsupportedOperation("path operation not supported by DataPath")
raise UnsupportedOperation("with_suffix not supported by DataPath")

def with_stem(self, stem: str) -> Self:
raise UnsupportedOperation("with_stem not supported by DataPath")

@property
def parent(self) -> Self:
return self

@property
def parents(self) -> Sequence[Self]:
return []

def full_match(self, pattern, *, case_sensitive: bool | None = None) -> bool:
return super().full_match(pattern, case_sensitive=case_sensitive)

def mkdir(
self, mode: int = 0o777, parents: bool = False, exist_ok: bool = False
Expand All @@ -66,3 +108,19 @@ def write_text(
newline: str | None = None,
) -> int:
raise UnsupportedOperation("DataPath does not support writing")

def iterdir(self) -> Iterator[Self]:
raise NotADirectoryError

def glob(
self, pattern, *, case_sensitive=None, recurse_symlinks=False
) -> Iterator[Self]:
return iter([])

def rglob(
self, pattern, *, case_sensitive=None, recurse_symlinks=False
) -> Iterator[Self]:
return iter([])

def unlink(self, missing_ok: bool = False) -> None:
raise UnsupportedOperation
Loading