webtap-tool 0.2.2__py3-none-any.whl → 0.2.3__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.

@@ -10,7 +10,26 @@ from .filters import FilterSetupService
10
10
  from .extension import ExtensionSetupService
11
11
  from .chrome import ChromeSetupService
12
12
  from .desktop import DesktopSetupService
13
- from .platform import get_platform_info, ensure_directories
13
+ from .platform import get_platform_info, ensure_directories, APP_NAME
14
+
15
+ # Old installation paths to clean up
16
+ OLD_EXTENSION_PATH = ".config/webtap/extension"
17
+ OLD_WRAPPER_PATH = ".local/bin/wrappers/google-chrome-stable"
18
+ OLD_DESKTOP_PATH = ".local/share/applications/google-chrome.desktop"
19
+ OLD_DEBUG_DIR = ".config/google-chrome-debug"
20
+
21
+ # Path components
22
+ WRAPPERS_DIR = "wrappers"
23
+ GOOGLE_CHROME_STABLE = "google-chrome-stable"
24
+
25
+ # Size formatting constants
26
+ KB_SIZE = 1024
27
+ SIZE_FORMAT_KB = "{:.1f} KB"
28
+ SIZE_FORMAT_EMPTY = "empty"
29
+
30
+ # Mount point command
31
+ MOUNTPOINT_CMD = "mountpoint"
32
+ MOUNTPOINT_CHECK_FLAG = "-q"
14
33
 
15
34
 
16
35
  class SetupService:
@@ -108,11 +127,11 @@ class SetupService:
108
127
  result = {}
109
128
 
110
129
  # Check old extension location
111
- old_extension_path = Path.home() / ".config" / "webtap" / "extension"
130
+ old_extension_path = Path.home() / OLD_EXTENSION_PATH
112
131
  if old_extension_path.exists():
113
132
  # Calculate size
114
133
  size = sum(f.stat().st_size for f in old_extension_path.rglob("*") if f.is_file())
115
- size_str = f"{size / 1024:.1f} KB" if size > 0 else "empty"
134
+ size_str = SIZE_FORMAT_KB.format(size / KB_SIZE) if size > 0 else SIZE_FORMAT_EMPTY
116
135
 
117
136
  result["old_extension"] = {"path": str(old_extension_path), "size": size_str, "removed": False}
118
137
 
@@ -128,7 +147,7 @@ class SetupService:
128
147
  result["old_extension"]["error"] = str(e)
129
148
 
130
149
  # Check old Chrome wrapper location
131
- old_wrapper_path = Path.home() / ".local" / "bin" / "wrappers" / "google-chrome-stable"
150
+ old_wrapper_path = Path.home() / OLD_WRAPPER_PATH
132
151
  if old_wrapper_path.exists():
133
152
  result["old_wrapper"] = {"path": str(old_wrapper_path), "removed": False}
134
153
 
@@ -144,12 +163,13 @@ class SetupService:
144
163
  result["old_wrapper"]["error"] = str(e)
145
164
 
146
165
  # Check old desktop entry
147
- old_desktop_path = Path.home() / ".local" / "share" / "applications" / "google-chrome.desktop"
166
+ old_desktop_path = Path.home() / OLD_DESKTOP_PATH
148
167
  if old_desktop_path.exists():
149
168
  # Check if it's our override (contains reference to wrapper)
150
169
  try:
151
170
  content = old_desktop_path.read_text()
152
- if "wrappers/google-chrome-stable" in content or "webtap" in content.lower():
171
+ wrapper_ref = f"{WRAPPERS_DIR}/{GOOGLE_CHROME_STABLE}"
172
+ if wrapper_ref in content or APP_NAME in content.lower():
153
173
  result["old_desktop"] = {"path": str(old_desktop_path), "removed": False}
154
174
 
155
175
  if not dry_run:
@@ -162,11 +182,11 @@ class SetupService:
162
182
  pass # If we can't read it, skip it
163
183
 
164
184
  # Check for bindfs mount
165
- debug_dir = Path.home() / ".config" / "google-chrome-debug"
185
+ debug_dir = Path.home() / OLD_DEBUG_DIR
166
186
  if debug_dir.exists():
167
187
  try:
168
188
  # Check if it's a mount point
169
- output = subprocess.run(["mountpoint", "-q", str(debug_dir)], capture_output=True)
189
+ output = subprocess.run([MOUNTPOINT_CMD, MOUNTPOINT_CHECK_FLAG, str(debug_dir)], capture_output=True)
170
190
  if output.returncode == 0:
171
191
  result["bindfs_mount"] = str(debug_dir)
172
192
  except (FileNotFoundError, OSError):
@@ -168,11 +168,11 @@ class DesktopSetupService:
168
168
  # Create launcher script that directly launches Chrome
169
169
  # This avoids Rosetta warnings from nested bash scripts
170
170
  launcher_path = macos_dir / "Chrome Debug"
171
-
171
+
172
172
  # Get Chrome path from platform info
173
173
  chrome_path = self.chrome["path"]
174
174
  profile_dir = self.paths["data_dir"] / "profiles" / "default"
175
-
175
+
176
176
  launcher_content = f"""#!/bin/bash
177
177
  # Chrome Debug app launcher - direct Chrome execution
178
178
  # Avoids Rosetta warnings by directly launching Chrome
@@ -7,6 +7,46 @@ from typing import Optional
7
7
 
8
8
  import platformdirs
9
9
 
10
+ # Application constants
11
+ APP_NAME = "webtap"
12
+ APP_AUTHOR = "webtap"
13
+
14
+ # Directory names
15
+ BIN_DIR_NAME = ".local/bin"
16
+ WRAPPER_NAME = "chrome-debug"
17
+ TMP_RUNTIME_DIR = "/tmp"
18
+
19
+ # Chrome executable names for Linux
20
+ CHROME_NAMES_LINUX = [
21
+ "google-chrome",
22
+ "google-chrome-stable",
23
+ "chromium",
24
+ "chromium-browser",
25
+ ]
26
+
27
+ # Chrome paths for macOS
28
+ CHROME_PATHS_MACOS = [
29
+ "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
30
+ "Applications/Google Chrome.app/Contents/MacOS/Google Chrome", # Relative to home
31
+ ]
32
+
33
+ # Chrome paths for Linux
34
+ CHROME_PATHS_LINUX = [
35
+ "/usr/bin/google-chrome",
36
+ "/usr/bin/google-chrome-stable",
37
+ "/usr/bin/chromium",
38
+ "/usr/bin/chromium-browser",
39
+ "/snap/bin/chromium",
40
+ ]
41
+
42
+ # Platform identifiers
43
+ PLATFORM_DARWIN = "Darwin"
44
+ PLATFORM_LINUX = "Linux"
45
+
46
+ # Application directories
47
+ MACOS_APPLICATIONS_DIR = "Applications"
48
+ LINUX_APPLICATIONS_DIR = ".local/share/applications"
49
+
10
50
 
11
51
  def get_platform_paths() -> dict[str, Path]:
12
52
  """Get platform-appropriate paths using platformdirs.
@@ -14,10 +54,7 @@ def get_platform_paths() -> dict[str, Path]:
14
54
  Returns:
15
55
  Dictionary of paths for config, data, cache, runtime, and state directories.
16
56
  """
17
- app_name = "webtap"
18
- app_author = "webtap"
19
-
20
- dirs = platformdirs.PlatformDirs(app_name, app_author)
57
+ dirs = platformdirs.PlatformDirs(APP_NAME, APP_AUTHOR)
21
58
 
22
59
  paths = {
23
60
  "config_dir": Path(dirs.user_config_dir), # ~/.config/webtap or ~/Library/Application Support/webtap
@@ -31,7 +68,7 @@ def get_platform_paths() -> dict[str, Path]:
31
68
  paths["runtime_dir"] = Path(dirs.user_runtime_dir)
32
69
  except AttributeError:
33
70
  # Fallback for platforms without runtime dir
34
- paths["runtime_dir"] = Path("/tmp") / app_name
71
+ paths["runtime_dir"] = Path(TMP_RUNTIME_DIR) / APP_NAME
35
72
 
36
73
  return paths
37
74
 
@@ -44,21 +81,15 @@ def get_chrome_path() -> Optional[Path]:
44
81
  """
45
82
  system = platform.system()
46
83
 
47
- if system == "Darwin":
84
+ if system == PLATFORM_DARWIN:
48
85
  # macOS standard locations
49
86
  candidates = [
50
- Path("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"),
51
- Path.home() / "Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
87
+ Path(CHROME_PATHS_MACOS[0]),
88
+ Path.home() / CHROME_PATHS_MACOS[1],
52
89
  ]
53
- elif system == "Linux":
90
+ elif system == PLATFORM_LINUX:
54
91
  # 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
- ]
92
+ candidates = [Path(p) for p in CHROME_PATHS_LINUX]
62
93
  else:
63
94
  return None
64
95
 
@@ -67,7 +98,7 @@ def get_chrome_path() -> Optional[Path]:
67
98
  return path
68
99
 
69
100
  # Try to find in PATH
70
- for name in ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"]:
101
+ for name in CHROME_NAMES_LINUX:
71
102
  if found := shutil.which(name):
72
103
  return Path(found)
73
104
 
@@ -84,31 +115,30 @@ def get_platform_info() -> dict:
84
115
  paths = get_platform_paths()
85
116
 
86
117
  # 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
118
+ paths["bin_dir"] = Path.home() / BIN_DIR_NAME # User space, no sudo needed
89
119
 
90
120
  # Platform-specific launcher locations
91
- if system == "Darwin":
92
- paths["applications_dir"] = Path.home() / "Applications"
121
+ if system == PLATFORM_DARWIN:
122
+ paths["applications_dir"] = Path.home() / MACOS_APPLICATIONS_DIR
93
123
  else: # Linux
94
- paths["applications_dir"] = Path.home() / ".local/share/applications"
124
+ paths["applications_dir"] = Path.home() / LINUX_APPLICATIONS_DIR
95
125
 
96
126
  chrome_path = get_chrome_path()
97
127
 
98
128
  return {
99
129
  "system": system.lower(),
100
- "is_macos": system == "Darwin",
101
- "is_linux": system == "Linux",
130
+ "is_macos": system == PLATFORM_DARWIN,
131
+ "is_linux": system == PLATFORM_LINUX,
102
132
  "paths": paths,
103
133
  "chrome": {
104
134
  "path": chrome_path,
105
135
  "found": chrome_path is not None,
106
- "wrapper_name": wrapper_name,
136
+ "wrapper_name": WRAPPER_NAME,
107
137
  },
108
138
  "capabilities": {
109
- "desktop_files": system == "Linux",
110
- "app_bundles": system == "Darwin",
111
- "bindfs": system == "Linux" and shutil.which("bindfs") is not None,
139
+ "desktop_files": system == PLATFORM_LINUX,
140
+ "app_bundles": system == PLATFORM_DARWIN,
141
+ "bindfs": system == PLATFORM_LINUX and shutil.which("bindfs") is not None,
112
142
  },
113
143
  }
114
144
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: webtap-tool
3
- Version: 0.2.2
3
+ Version: 0.2.3
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
@@ -36,13 +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=rCi6HjyWQmtoBu6NwB1Aw3bEklxsC-bt1jPJ8rGeNgA,6635
39
+ webtap/services/setup/__init__.py,sha256=lfoKCAroc-JoE_r7L-KZkF85ZWiB41MBIgrR7ZISSoE,7157
40
40
  webtap/services/setup/chrome.py,sha256=zfPWeb6zm_xjIfiS2S_O9lR2BjGKaPXXo06pN_B9lAU,7187
41
- webtap/services/setup/desktop.py,sha256=P5bBllQeiHsM2ELbVVmvOxE5k9UiooDh1cRQNKbWm6s,8038
41
+ webtap/services/setup/desktop.py,sha256=fXwQa201W-s2mengm_dJZ9BigJopVrO9YFUQcW_TSFQ,8022
42
42
  webtap/services/setup/extension.py,sha256=OvTLuSi5u-kBAkqWAzfYt5lTNZrduXoCMZhFCuMisew,3318
43
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.2.dist-info/METADATA,sha256=ukRef3zrO-0wrxzGksrDieJ7lBpNNgizETkRIApz_Tg,17588
46
- webtap_tool-0.2.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
47
- webtap_tool-0.2.2.dist-info/entry_points.txt,sha256=iFe575I0CIb1MbfPt0oX2VYyY5gSU_dA551PKVR83TU,39
48
- webtap_tool-0.2.2.dist-info/RECORD,,
44
+ webtap/services/setup/platform.py,sha256=7yn-7LQFffgerWzWRtOG-yNEsR36ICThYUAu_N2FAso,4532
45
+ webtap_tool-0.2.3.dist-info/METADATA,sha256=L0HI4R6Po66JFoxkNp7yo9RKLpj1vPKzxOYqF4o6ohI,17588
46
+ webtap_tool-0.2.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
47
+ webtap_tool-0.2.3.dist-info/entry_points.txt,sha256=iFe575I0CIb1MbfPt0oX2VYyY5gSU_dA551PKVR83TU,39
48
+ webtap_tool-0.2.3.dist-info/RECORD,,