pathutilx 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,44 @@
1
+ Metadata-Version: 2.4
2
+ Name: pathutilx
3
+ Version: 0.1.0
4
+ Summary: Simple, readable Windows path helpers inspired by pathlib and os.
5
+ Keywords: path,pathlib,windows,filesystem,utility
6
+ Classifier: Development Status :: 3 - Alpha
7
+ Classifier: Intended Audience :: Developers
8
+ Classifier: Operating System :: Microsoft :: Windows
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
+ Classifier: Topic :: System :: Filesystems
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+
19
+ # pathutilx
20
+
21
+ `pathutilx` is a small Python package that exposes readable Windows path shortcuts and path-building helpers.
22
+
23
+ ## Examples
24
+
25
+ ```python
26
+ from pathutilx import desktop, join
27
+
28
+ notes = join("notes.txt", base=desktop)
29
+ print(notes)
30
+ ```
31
+ ```python
32
+ import pathutilx as p
33
+
34
+ program_files = p.program_files
35
+ appdata_local = p.appdata.local
36
+ desktop = p.desktop
37
+ ```
38
+
39
+ ## Available helpers
40
+
41
+ - `build(*parts, base=None)`
42
+ - `join(*parts, base=None)`
43
+ - `windows_root()`
44
+ - common Windows locations like `desktop`, `downloads`, `documents`, `appdata`, and `temp`
@@ -0,0 +1,26 @@
1
+ # pathutilx
2
+
3
+ `pathutilx` is a small Python package that exposes readable Windows path shortcuts and path-building helpers.
4
+
5
+ ## Examples
6
+
7
+ ```python
8
+ from pathutilx import desktop, join
9
+
10
+ notes = join("notes.txt", base=desktop)
11
+ print(notes)
12
+ ```
13
+ ```python
14
+ import pathutilx as p
15
+
16
+ program_files = p.program_files
17
+ appdata_local = p.appdata.local
18
+ desktop = p.desktop
19
+ ```
20
+
21
+ ## Available helpers
22
+
23
+ - `build(*parts, base=None)`
24
+ - `join(*parts, base=None)`
25
+ - `windows_root()`
26
+ - common Windows locations like `desktop`, `downloads`, `documents`, `appdata`, and `temp`
@@ -0,0 +1 @@
1
+ from .main import *
@@ -0,0 +1,3 @@
1
+ from .windows import PathNode, build_path, windows_root
2
+
3
+ __all__ = ["PathNode", "build_path", "windows_root"]
@@ -0,0 +1,150 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ from pathlib import Path
5
+ from typing import Iterable
6
+
7
+
8
+ PathLike = str | os.PathLike[str]
9
+
10
+
11
+ def _as_path(value: PathLike | "PathNode") -> Path:
12
+ if isinstance(value, PathNode):
13
+ return value.path
14
+ return Path(value)
15
+
16
+
17
+ def _normalize_part(part: PathLike | "PathNode") -> Path:
18
+ raw = os.fspath(_as_path(part))
19
+ expanded = os.path.expandvars(os.path.expanduser(raw))
20
+ return Path(expanded)
21
+
22
+
23
+ def build_path(
24
+ *parts: PathLike | "PathNode",
25
+ base: PathLike | "PathNode" | None = None,
26
+ ) -> Path:
27
+ if base is None and not parts:
28
+ raise ValueError("build_path requires at least one path part or a base path")
29
+
30
+ path = _normalize_part(base) if base is not None else _normalize_part(parts[0])
31
+ remaining_parts: Iterable[PathLike | PathNode] = parts if base is not None else parts[1:]
32
+
33
+ for part in remaining_parts:
34
+ path = path / _normalize_part(part)
35
+
36
+ return path
37
+
38
+
39
+ class PathNode:
40
+ def __init__(self, path: PathLike, **children: "PathNode") -> None:
41
+ self._path = _normalize_part(path)
42
+ for name, child in children.items():
43
+ setattr(self, name, child)
44
+
45
+ @property
46
+ def path(self) -> Path:
47
+ return self._path
48
+
49
+ @property
50
+ def name(self) -> str:
51
+ return self._path.name
52
+
53
+ @property
54
+ def parent(self) -> Path:
55
+ return self._path.parent
56
+
57
+ def build(self, *parts: PathLike | "PathNode") -> Path:
58
+ return build_path(*parts, base=self)
59
+
60
+ def joinpath(self, *parts: PathLike | "PathNode") -> Path:
61
+ return self.build(*parts)
62
+
63
+ def exists(self) -> bool:
64
+ return self._path.exists()
65
+
66
+ def is_dir(self) -> bool:
67
+ return self._path.is_dir()
68
+
69
+ def is_file(self) -> bool:
70
+ return self._path.is_file()
71
+
72
+ def __call__(self, *parts: PathLike | "PathNode") -> Path:
73
+ return self.build(*parts)
74
+
75
+ def __truediv__(self, other: PathLike | "PathNode") -> Path:
76
+ return self._path / _normalize_part(other)
77
+
78
+ def __fspath__(self) -> str:
79
+ return os.fspath(self._path)
80
+
81
+ def __str__(self) -> str:
82
+ return str(self._path)
83
+
84
+ def __repr__(self) -> str:
85
+ return f"PathNode({self._path!s})"
86
+
87
+
88
+ def _env_path(name: str, fallback: PathLike) -> Path:
89
+ value = os.environ.get(name)
90
+ if value:
91
+ return Path(value)
92
+ return _normalize_part(fallback)
93
+
94
+
95
+ def windows_root() -> PathNode:
96
+ home = _env_path("USERPROFILE", Path.home())
97
+ appdata_roaming = _env_path("APPDATA", home / "AppData" / "Roaming")
98
+ appdata_local = _env_path("LOCALAPPDATA", home / "AppData" / "Local")
99
+ appdata_local_low = appdata_local.parent / "LocalLow"
100
+ desktop = home / "Desktop"
101
+ documents = home / "Documents"
102
+ downloads = home / "Downloads"
103
+ pictures = home / "Pictures"
104
+ videos = home / "Videos"
105
+ music = home / "Music"
106
+ favorites = home / "Favorites"
107
+ saved_games = home / "Saved Games"
108
+ contacts = home / "Contacts"
109
+ links = home / "Links"
110
+
111
+ system_drive = _env_path("SystemDrive", r"C:")
112
+ windows_dir = _env_path("WINDIR", system_drive / "Windows")
113
+ system32 = windows_dir / "System32"
114
+ temp = _env_path("TEMP", appdata_local / "Temp")
115
+ tmp = _env_path("TMP", temp)
116
+ program_files = _env_path("ProgramFiles", r"C:\Program Files")
117
+ program_files_x86 = _env_path("ProgramFiles(x86)", r"C:\Program Files (x86)")
118
+ program_data = _env_path("ProgramData", r"C:\ProgramData")
119
+ public = _env_path("PUBLIC", system_drive / "Users" / "Public")
120
+
121
+ return PathNode(
122
+ system_drive,
123
+ appdata=PathNode(
124
+ appdata_roaming,
125
+ roaming=PathNode(appdata_roaming),
126
+ local=PathNode(appdata_local),
127
+ local_low=PathNode(appdata_local_low),
128
+ ),
129
+ contacts=PathNode(contacts),
130
+ desktop=PathNode(desktop),
131
+ documents=PathNode(documents),
132
+ downloads=PathNode(downloads),
133
+ favorites=PathNode(favorites),
134
+ home=PathNode(home),
135
+ links=PathNode(links),
136
+ music=PathNode(music),
137
+ pictures=PathNode(pictures),
138
+ program_data=PathNode(program_data),
139
+ program_files=PathNode(program_files),
140
+ program_files_x86=PathNode(program_files_x86),
141
+ public=PathNode(public),
142
+ saved_games=PathNode(saved_games),
143
+ system32=PathNode(system32),
144
+ system_drive=PathNode(system_drive),
145
+ temp=PathNode(temp),
146
+ tmp=PathNode(tmp),
147
+ user_profile=PathNode(home),
148
+ videos=PathNode(videos),
149
+ windows_dir=PathNode(windows_dir),
150
+ )
@@ -0,0 +1,65 @@
1
+ from .finder.windows import PathNode, build_path, windows_root
2
+
3
+
4
+ _windows = windows_root()
5
+
6
+ appdata = _windows.appdata
7
+ contacts = _windows.contacts
8
+ desktop = _windows.desktop
9
+ documents = _windows.documents
10
+ downloads = _windows.downloads
11
+ favorites = _windows.favorites
12
+ home = _windows.home
13
+ links = _windows.links
14
+ music = _windows.music
15
+ pictures = _windows.pictures
16
+ program_files = _windows.program_files
17
+ program_files_x86 = _windows.program_files_x86
18
+ program_data = _windows.program_data
19
+ public = _windows.public
20
+ saved_games = _windows.saved_games
21
+ system32 = _windows.system32
22
+ system_drive = _windows.system_drive
23
+ temp = _windows.temp
24
+ tmp = _windows.tmp
25
+ user_profile = _windows.user_profile
26
+ videos = _windows.videos
27
+ windows_dir = _windows.windows_dir
28
+
29
+
30
+ def build(*parts, base=None):
31
+ return build_path(*parts, base=base)
32
+
33
+
34
+ def join(*parts, base=None):
35
+ return build(*parts, base=base)
36
+
37
+
38
+ __all__ = [
39
+ "PathNode",
40
+ "appdata",
41
+ "build",
42
+ "contacts",
43
+ "desktop",
44
+ "documents",
45
+ "downloads",
46
+ "favorites",
47
+ "home",
48
+ "join",
49
+ "links",
50
+ "music",
51
+ "pictures",
52
+ "program_data",
53
+ "program_files",
54
+ "program_files_x86",
55
+ "public",
56
+ "saved_games",
57
+ "system32",
58
+ "system_drive",
59
+ "temp",
60
+ "tmp",
61
+ "user_profile",
62
+ "videos",
63
+ "windows_dir",
64
+ "windows_root",
65
+ ]
@@ -0,0 +1,44 @@
1
+ Metadata-Version: 2.4
2
+ Name: pathutilx
3
+ Version: 0.1.0
4
+ Summary: Simple, readable Windows path helpers inspired by pathlib and os.
5
+ Keywords: path,pathlib,windows,filesystem,utility
6
+ Classifier: Development Status :: 3 - Alpha
7
+ Classifier: Intended Audience :: Developers
8
+ Classifier: Operating System :: Microsoft :: Windows
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
+ Classifier: Topic :: System :: Filesystems
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+
19
+ # pathutilx
20
+
21
+ `pathutilx` is a small Python package that exposes readable Windows path shortcuts and path-building helpers.
22
+
23
+ ## Examples
24
+
25
+ ```python
26
+ from pathutilx import desktop, join
27
+
28
+ notes = join("notes.txt", base=desktop)
29
+ print(notes)
30
+ ```
31
+ ```python
32
+ import pathutilx as p
33
+
34
+ program_files = p.program_files
35
+ appdata_local = p.appdata.local
36
+ desktop = p.desktop
37
+ ```
38
+
39
+ ## Available helpers
40
+
41
+ - `build(*parts, base=None)`
42
+ - `join(*parts, base=None)`
43
+ - `windows_root()`
44
+ - common Windows locations like `desktop`, `downloads`, `documents`, `appdata`, and `temp`
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pyproject.toml
3
+ pathutilx/__init__.py
4
+ pathutilx/main.py
5
+ pathutilx.egg-info/PKG-INFO
6
+ pathutilx.egg-info/SOURCES.txt
7
+ pathutilx.egg-info/dependency_links.txt
8
+ pathutilx.egg-info/top_level.txt
9
+ pathutilx/finder/__init__.py
10
+ pathutilx/finder/windows.py
@@ -0,0 +1 @@
1
+ pathutilx
@@ -0,0 +1,29 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "pathutilx"
7
+ version = "0.1.0"
8
+ description = "Simple, readable Windows path helpers inspired by pathlib and os."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ keywords = ["path", "pathlib", "windows", "filesystem", "utility"]
12
+ classifiers = [
13
+ "Development Status :: 3 - Alpha",
14
+ "Intended Audience :: Developers",
15
+ "Operating System :: Microsoft :: Windows",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.10",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Programming Language :: Python :: 3.12",
20
+ "Programming Language :: Python :: 3.13",
21
+ "Topic :: Software Development :: Libraries :: Python Modules",
22
+ "Topic :: System :: Filesystems",
23
+ ]
24
+
25
+ [tool.setuptools]
26
+ include-package-data = false
27
+
28
+ [tool.setuptools.packages.find]
29
+ include = ["pathutilx*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+