Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/py-polars/tests/unit/io/conftest.py
8424 views
1
from __future__ import annotations
2
3
import sys
4
from pathlib import Path
5
from typing import TYPE_CHECKING
6
7
import pytest
8
9
if TYPE_CHECKING:
10
from typing import Any
11
12
13
@pytest.fixture
14
def io_files_path() -> Path:
15
return Path(__file__).parent / "files"
16
17
18
def format_file_uri(absolute_local_path: str | Path) -> str:
19
absolute_local_path = str(absolute_local_path)
20
21
if sys.platform == "win32":
22
assert absolute_local_path[0].isalpha()
23
assert absolute_local_path[1] == ":"
24
p = absolute_local_path.replace("\\", "/")
25
return f"file:///{p}"
26
27
assert absolute_local_path.startswith("/")
28
return f"file://{absolute_local_path}"
29
30
31
def normalize_path_separator_pl(s: Any) -> Any:
32
if sys.platform == "win32":
33
return s.str.replace_all("\\", "/", literal=True)
34
35
return s
36
37