create-browser-app 0.1.7__py3-none-any.whl → 0.1.9__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.
@@ -1,75 +1,74 @@
1
1
  #!/usr/bin/env python3
2
2
  import urllib.request
3
- import json
4
3
  from typing import Dict, List, Optional
5
- from pathlib import Path
6
- import base64
4
+ from dataclasses import dataclass
7
5
 
8
- GITHUB_API_BASE = "https://api.github.com"
9
- REPO_OWNER = "browserbase"
10
- REPO_NAME = "stagehand-python"
11
- EXAMPLES_PATH = "examples"
6
+ @dataclass
7
+ class TemplateInfo:
8
+ name: str
9
+ url: str
12
10
 
13
- def get_available_templates() -> List[Dict[str, str]]:
14
- """Fetch list of available templates from GitHub repository."""
15
- try:
16
- url = f"{GITHUB_API_BASE}/repos/{REPO_OWNER}/{REPO_NAME}/contents/{EXAMPLES_PATH}"
17
- req = urllib.request.Request(url)
18
- req.add_header("Accept", "application/vnd.github.v3+json")
19
- req.add_header("User-Agent", "create-browser-app-py")
20
-
21
- with urllib.request.urlopen(req) as response:
22
- data = json.loads(response.read().decode())
11
+ GITHUB_TEMPLATES: List[TemplateInfo] = [
12
+ TemplateInfo(
13
+ name="example",
14
+ url="https://raw.githubusercontent.com/browserbase/stagehand-python/main/examples/example.py",
15
+ ),
16
+ TemplateInfo(
17
+ name="cua-example",
18
+ url="https://raw.githubusercontent.com/browserbase/stagehand-python/main/examples/cua-example.py",
19
+ ),
20
+ TemplateInfo(
21
+ name="form-filling",
22
+ url="https://raw.githubusercontent.com/browserbase/templates/refs/heads/dev/python/form-filling/index.py",
23
+ ),
24
+ TemplateInfo(
25
+ name="gift-finder",
26
+ url="https://raw.githubusercontent.com/browserbase/templates/refs/heads/dev/python/gift-finder/index.py",
27
+ ),
28
+ TemplateInfo(
29
+ name="pickleball",
30
+ url="https://raw.githubusercontent.com/browserbase/templates/refs/heads/dev/python/pickleball/index.py",
31
+ ),
32
+ TemplateInfo(
33
+ name="license-verification",
34
+ url="https://raw.githubusercontent.com/browserbase/templates/refs/heads/dev/python/license-verification/index.py",
35
+ ),
36
+ TemplateInfo(
37
+ name="context",
38
+ url="https://raw.githubusercontent.com/browserbase/templates/refs/heads/dev/python/context/index.py",
39
+ ),
40
+ TemplateInfo(
41
+ name="proxies",
42
+ url="https://raw.githubusercontent.com/browserbase/templates/refs/heads/dev/python/proxies/index.py",
43
+ ),
44
+ ]
23
45
 
24
- templates = []
25
- for item in data:
26
- if item["type"] == "file" and item["name"].endswith(".py"):
27
- # Keep the original name without replacing underscores
28
- template_name = item["name"].replace(".py", "")
29
- templates.append({
30
- "name": template_name,
31
- "filename": item["name"],
32
- "url": item["download_url"],
33
- "api_url": item["url"]
34
- })
35
-
36
- return templates
37
- except Exception as e:
38
- print(f"Error fetching templates: {e}")
39
- return []
46
+ def get_template_by_name(name: str) -> Optional[TemplateInfo]:
47
+ """Get a specific template by name."""
48
+ for template in GITHUB_TEMPLATES:
49
+ if template.name == name:
50
+ return template
51
+ return None
40
52
 
41
- def fetch_template_content(template_info: Dict[str, str]) -> Optional[str]:
53
+ def fetch_template_content(template: TemplateInfo) -> Optional[str]:
42
54
  """Fetch the content of a specific template from GitHub."""
43
55
  try:
44
- url = template_info.get("api_url", template_info.get("url"))
45
- req = urllib.request.Request(url)
46
- req.add_header("Accept", "application/vnd.github.v3+json")
56
+ req = urllib.request.Request(template.url)
47
57
  req.add_header("User-Agent", "create-browser-app-py")
48
58
 
49
59
  with urllib.request.urlopen(req) as response:
50
- data = json.loads(response.read().decode())
51
-
52
- if "content" in data:
53
- content = base64.b64decode(data["content"]).decode("utf-8")
54
- else:
55
- # Fallback to direct download
56
- with urllib.request.urlopen(template_info["url"]) as response:
57
- content = response.read().decode("utf-8")
58
-
59
- return content
60
- except Exception as e:
61
- print(f"Error fetching template content: {e}")
60
+ if response.status != 200:
61
+ return None
62
+ return response.read().decode("utf-8")
63
+ except Exception:
62
64
  return None
63
65
 
64
- def get_template_by_name(name: str) -> Optional[Dict[str, str]]:
65
- """Get a specific template by name."""
66
- templates = get_available_templates()
67
- for template in templates:
68
- if template["name"] == name:
69
- return template
70
- return None
66
+ def get_available_templates() -> List[str]:
67
+ """Get a list of available template names."""
68
+ default_templates = ["basic"]
69
+ github_templates = [t.name for t in GITHUB_TEMPLATES]
70
+ return default_templates + github_templates
71
71
 
72
72
  def list_templates() -> List[str]:
73
73
  """Get a list of template names."""
74
- templates = get_available_templates()
75
- return [t["name"] for t in templates]
74
+ return get_available_templates()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: create-browser-app
3
- Version: 0.1.7
3
+ Version: 0.1.9
4
4
  Summary: Start your Stagehand project with a single command
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -0,0 +1,9 @@
1
+ create_browser_app/__init__.py,sha256=izlkaSvrxNqPnulbHlD8VYldR618NxRQRlKQFgQn0Gk,42
2
+ create_browser_app/main.py,sha256=8n6Mot1AAM5Vwd7YhzUjresboJtwnt-hwFo1_jBI98Q,4864
3
+ create_browser_app/template_fetcher.py,sha256=wGbt-Seztx9Zj11N8nkKkjPU0Fg8IrP01L4PN6X_8s8,2579
4
+ create_browser_app/templates.py,sha256=ipfp4zmfbD4-vhoggEW9M_EBXYvvyCzvmHew9tTgi7w,2636
5
+ create_browser_app-0.1.9.dist-info/METADATA,sha256=7512gD8xFAGgPPGDphiiMTkX37TSDDe0PAYsQg3r5zU,648
6
+ create_browser_app-0.1.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
+ create_browser_app-0.1.9.dist-info/entry_points.txt,sha256=yyAKhFZs2kraGA_ixwnRZeStL0uxWvBCMzysg8S-0VE,68
8
+ create_browser_app-0.1.9.dist-info/top_level.txt,sha256=sLW8imVtlXvOy1D5aGPBDxbMP3Yvonif7VxcLu_Izy4,19
9
+ create_browser_app-0.1.9.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- create_browser_app/__init__.py,sha256=izlkaSvrxNqPnulbHlD8VYldR618NxRQRlKQFgQn0Gk,42
2
- create_browser_app/main.py,sha256=8n6Mot1AAM5Vwd7YhzUjresboJtwnt-hwFo1_jBI98Q,4864
3
- create_browser_app/template_fetcher.py,sha256=kfNOFdJlBPjgtAuroVsD-zuXWd04wSpQHTBmYXHDJAc,2723
4
- create_browser_app/templates.py,sha256=ipfp4zmfbD4-vhoggEW9M_EBXYvvyCzvmHew9tTgi7w,2636
5
- create_browser_app-0.1.7.dist-info/METADATA,sha256=hyZXuG-3mGuAKM1OjqdPyxHMlyD7VxhTok-9xxTH9EU,648
6
- create_browser_app-0.1.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- create_browser_app-0.1.7.dist-info/entry_points.txt,sha256=yyAKhFZs2kraGA_ixwnRZeStL0uxWvBCMzysg8S-0VE,68
8
- create_browser_app-0.1.7.dist-info/top_level.txt,sha256=sLW8imVtlXvOy1D5aGPBDxbMP3Yvonif7VxcLu_Izy4,19
9
- create_browser_app-0.1.7.dist-info/RECORD,,