webtap-tool 0.1.5__py3-none-any.whl → 0.2.1__py3-none-any.whl

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.

Potentially problematic release.


This version of webtap-tool might be problematic. Click here for more details.

@@ -0,0 +1,126 @@
1
+ """Platform detection and path management using platformdirs."""
2
+
3
+ import platform
4
+ import shutil
5
+ from pathlib import Path
6
+ from typing import Optional
7
+
8
+ import platformdirs
9
+
10
+
11
+ def get_platform_paths() -> dict[str, Path]:
12
+ """Get platform-appropriate paths using platformdirs.
13
+
14
+ Returns:
15
+ Dictionary of paths for config, data, cache, runtime, and state directories.
16
+ """
17
+ app_name = "webtap"
18
+ app_author = "webtap"
19
+
20
+ dirs = platformdirs.PlatformDirs(app_name, app_author)
21
+
22
+ paths = {
23
+ "config_dir": Path(dirs.user_config_dir), # ~/.config/webtap or ~/Library/Application Support/webtap
24
+ "data_dir": Path(dirs.user_data_dir), # ~/.local/share/webtap or ~/Library/Application Support/webtap
25
+ "cache_dir": Path(dirs.user_cache_dir), # ~/.cache/webtap or ~/Library/Caches/webtap
26
+ "state_dir": Path(dirs.user_state_dir), # ~/.local/state/webtap or ~/Library/Application Support/webtap
27
+ }
28
+
29
+ # Runtime dir (not available on all platforms)
30
+ try:
31
+ paths["runtime_dir"] = Path(dirs.user_runtime_dir)
32
+ except AttributeError:
33
+ # Fallback for platforms without runtime dir
34
+ paths["runtime_dir"] = Path("/tmp") / app_name
35
+
36
+ return paths
37
+
38
+
39
+ def get_chrome_path() -> Optional[Path]:
40
+ """Find Chrome executable path for current platform.
41
+
42
+ Returns:
43
+ Path to Chrome executable or None if not found.
44
+ """
45
+ system = platform.system()
46
+
47
+ if system == "Darwin":
48
+ # macOS standard locations
49
+ candidates = [
50
+ Path("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"),
51
+ Path.home() / "Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
52
+ ]
53
+ elif system == "Linux":
54
+ # Linux standard locations
55
+ candidates = [
56
+ Path("/usr/bin/google-chrome"),
57
+ Path("/usr/bin/google-chrome-stable"),
58
+ Path("/usr/bin/chromium"),
59
+ Path("/usr/bin/chromium-browser"),
60
+ Path("/snap/bin/chromium"),
61
+ ]
62
+ else:
63
+ return None
64
+
65
+ for path in candidates:
66
+ if path.exists():
67
+ return path
68
+
69
+ # Try to find in PATH
70
+ for name in ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"]:
71
+ if found := shutil.which(name):
72
+ return Path(found)
73
+
74
+ return None
75
+
76
+
77
+ def get_platform_info() -> dict:
78
+ """Get comprehensive platform information.
79
+
80
+ Returns:
81
+ Dictionary with system info, paths, and capabilities.
82
+ """
83
+ system = platform.system()
84
+ paths = get_platform_paths()
85
+
86
+ # Unified paths for both platforms
87
+ paths["bin_dir"] = Path.home() / ".local/bin" # User space, no sudo needed
88
+ wrapper_name = "chrome-debug" # Same name on both platforms
89
+
90
+ # Platform-specific launcher locations
91
+ if system == "Darwin":
92
+ paths["applications_dir"] = Path.home() / "Applications"
93
+ else: # Linux
94
+ paths["applications_dir"] = Path.home() / ".local/share/applications"
95
+
96
+ chrome_path = get_chrome_path()
97
+
98
+ return {
99
+ "system": system.lower(),
100
+ "is_macos": system == "Darwin",
101
+ "is_linux": system == "Linux",
102
+ "paths": paths,
103
+ "chrome": {
104
+ "path": chrome_path,
105
+ "found": chrome_path is not None,
106
+ "wrapper_name": wrapper_name,
107
+ },
108
+ "capabilities": {
109
+ "desktop_files": system == "Linux",
110
+ "app_bundles": system == "Darwin",
111
+ "bindfs": system == "Linux" and shutil.which("bindfs") is not None,
112
+ },
113
+ }
114
+
115
+
116
+ def ensure_directories() -> None:
117
+ """Ensure all required directories exist with proper permissions."""
118
+ paths = get_platform_paths()
119
+
120
+ for name, path in paths.items():
121
+ if name != "runtime_dir": # Runtime dir is often system-managed
122
+ path.mkdir(parents=True, exist_ok=True, mode=0o755)
123
+
124
+ # Ensure bin directory exists
125
+ info = get_platform_info()
126
+ info["paths"]["bin_dir"].mkdir(parents=True, exist_ok=True, mode=0o755)
@@ -1,9 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: webtap-tool
3
- Version: 0.1.5
3
+ Version: 0.2.1
4
4
  Summary: Terminal-based web page inspector for AI debugging sessions
5
5
  Author-email: Fredrik Angelsen <fredrikangelsen@gmail.com>
6
6
  Classifier: Development Status :: 3 - Alpha
7
+ Classifier: Operating System :: MacOS :: MacOS X
8
+ Classifier: Operating System :: POSIX :: Linux
7
9
  Classifier: Programming Language :: Python :: 3.12
8
10
  Classifier: Topic :: Internet :: WWW/HTTP :: Browsers
9
11
  Classifier: Topic :: Software Development :: Debuggers
@@ -15,6 +17,7 @@ Requires-Dist: fastapi>=0.116.1
15
17
  Requires-Dist: httpx>=0.28.1
16
18
  Requires-Dist: lxml>=6.0.1
17
19
  Requires-Dist: msgpack-python>=0.5.6
20
+ Requires-Dist: platformdirs>=4.4.0
18
21
  Requires-Dist: protobuf>=6.32.0
19
22
  Requires-Dist: pyjwt>=2.10.1
20
23
  Requires-Dist: pyyaml>=6.0.2
@@ -28,7 +28,7 @@ webtap/commands/javascript.py,sha256=QpQdqqoQwwTyz1lpibZ92XKOL89scu_ndgSjkhaYuDk
28
28
  webtap/commands/launch.py,sha256=iZDLundKlxKRLKf3Vz5at42-tp2f-Uj5wZf7fbhBfA0,2202
29
29
  webtap/commands/navigation.py,sha256=Mapawp2AZTJQaws2uwlTgMUhqz7HlVTLxiZ06n_MQc0,6071
30
30
  webtap/commands/network.py,sha256=hwZshGGdVsJ_9MFjOKJXT07I990JjZInw2LLnKXLQ5Y,2910
31
- webtap/commands/setup.py,sha256=NvCZF9FJuw6vaNQjeSi0UF2QORwIvGiQeMuX9cf44Mo,5830
31
+ webtap/commands/setup.py,sha256=dov1LaN50nAEMNIuBLSK7mcnwhfn9rtqdTopBm1-PhA,9648
32
32
  webtap/services/README.md,sha256=rala_jtnNgSiQ1lFLM7x_UQ4SJZDceAm7dpkQMRTYaI,2346
33
33
  webtap/services/__init__.py,sha256=IjFqu0Ak6D-r18aokcQMtenDV3fbelvfjTCejGv6CZ0,570
34
34
  webtap/services/body.py,sha256=XQPa19y5eUc3XJ2TuwVK6kffO1VQoKqNs33MBBz7hzU,3913
@@ -36,12 +36,13 @@ webtap/services/console.py,sha256=XVfSKTvEHyyOdujsg85S3wtj1CdZhzKtWwlx25MvSv8,37
36
36
  webtap/services/fetch.py,sha256=nl6bpU2Vnf40kau4-mqAnIkhC-7Lx2vbTJKUglz9KnE,13602
37
37
  webtap/services/main.py,sha256=HcXdPuI7hzsxsNvfN0npGhj_M7HObc83Lr3fuy7BMeE,5673
38
38
  webtap/services/network.py,sha256=0o_--F6YvmXqqFqrcjL1gc6Vr9V1Ytb_U7r_DSUWupA,3444
39
- webtap/services/setup/__init__.py,sha256=HZ--2oYU724onxa3h4wHSy_CSanG3EXzpK39Ha4V-zY,1738
40
- webtap/services/setup/chrome.py,sha256=-xX5YHMkhzSwxcn9wf_oZ9naKOhQdjHnAcRCiA7jn8E,2279
41
- webtap/services/setup/desktop.py,sha256=MGaylnMCbiqIY5xCPSReTt_WAQOmAkuiKsermRPEJFQ,5392
42
- webtap/services/setup/extension.py,sha256=sYeZBbNjhG_lkqlx6dTqiGjfVba3kyff4_Q6HvKYdao,2651
43
- webtap/services/setup/filters.py,sha256=fe85CoH4H-06B1vwjdIIroICz5EfLp0HUYSdLZz8DuQ,2661
44
- webtap_tool-0.1.5.dist-info/METADATA,sha256=ZGwJqOrlH7PrHyux90aoZWuNURxEgXqtBkqXFN3lSBo,17457
45
- webtap_tool-0.1.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
46
- webtap_tool-0.1.5.dist-info/entry_points.txt,sha256=iFe575I0CIb1MbfPt0oX2VYyY5gSU_dA551PKVR83TU,39
47
- webtap_tool-0.1.5.dist-info/RECORD,,
39
+ webtap/services/setup/__init__.py,sha256=rCi6HjyWQmtoBu6NwB1Aw3bEklxsC-bt1jPJ8rGeNgA,6635
40
+ webtap/services/setup/chrome.py,sha256=zfPWeb6zm_xjIfiS2S_O9lR2BjGKaPXXo06pN_B9lAU,7187
41
+ webtap/services/setup/desktop.py,sha256=pMH5gk14iGEZ7SyaBNb4pYt7C1xJSx47oFzQCBIB_E4,7317
42
+ webtap/services/setup/extension.py,sha256=OvTLuSi5u-kBAkqWAzfYt5lTNZrduXoCMZhFCuMisew,3318
43
+ webtap/services/setup/filters.py,sha256=lAPSLMH_KZQO-7bRkmURwzforx7C3SDrKEw2ZogN-Lo,3220
44
+ webtap/services/setup/platform.py,sha256=RQrhvp8mLg5Bssy5Slfl5SPVGo3BlUIn3lxVm-ZmkAM,3987
45
+ webtap_tool-0.2.1.dist-info/METADATA,sha256=HTlR5Z1l1xBdsleyRU0QmFSUvnuK6Fw2N6VSpY2JfO8,17588
46
+ webtap_tool-0.2.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
47
+ webtap_tool-0.2.1.dist-info/entry_points.txt,sha256=iFe575I0CIb1MbfPt0oX2VYyY5gSU_dA551PKVR83TU,39
48
+ webtap_tool-0.2.1.dist-info/RECORD,,