mirror of
https://git.freebsd.org/ports.git
synced 2025-05-24 23:16:33 -04:00
misc/py-aider-chat: update to 0.45.0
Reported by: portscout Sponsored by: SkunkWerks, GmbH
This commit is contained in:
parent
b8c6a63d4c
commit
800bb7c50c
6 changed files with 78 additions and 75 deletions
|
@ -1,5 +1,5 @@
|
||||||
PORTNAME= aider_chat
|
PORTNAME= aider_chat
|
||||||
DISTVERSION= 0.42.0
|
DISTVERSION= 0.45.0
|
||||||
CATEGORIES= misc python
|
CATEGORIES= misc python
|
||||||
MASTER_SITES= PYPI
|
MASTER_SITES= PYPI
|
||||||
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
|
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
TIMESTAMP = 1720106776
|
TIMESTAMP = 1722097913
|
||||||
SHA256 (aider_chat-0.42.0.tar.gz) = e64a63befcadea2500485ed7c60f91495e31d3a33c9955bd18fe9901c0d0f31e
|
SHA256 (aider_chat-0.45.0.tar.gz) = 47afeb18a342dd5d33aa1b034ca04120b7a599f55c127365297bc097ee565b6b
|
||||||
SIZE (aider_chat-0.42.0.tar.gz) = 124553
|
SIZE (aider_chat-0.45.0.tar.gz) = 135453
|
||||||
|
|
|
@ -1,23 +1,66 @@
|
||||||
--- aider/scrape.py.orig 2024-07-04 14:23:32 UTC
|
--- aider/scrape.py.orig 2024-07-27 19:09:04 UTC
|
||||||
+++ aider/scrape.py
|
+++ aider/scrape.py
|
||||||
@@ -3,9 +3,7 @@ import sys
|
@@ -15,56 +15,9 @@ def install_playwright(io):
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
|
|
||||||
-import playwright
|
|
||||||
import pypandoc
|
|
||||||
-from playwright.sync_api import sync_playwright
|
|
||||||
|
|
||||||
from aider import __version__, urls
|
def install_playwright(io):
|
||||||
from aider.dump import dump # noqa: F401
|
- try:
|
||||||
@@ -42,14 +40,10 @@ class Scraper:
|
- from playwright.sync_api import sync_playwright
|
||||||
|
+ return
|
||||||
|
|
||||||
|
- has_pip = True
|
||||||
|
- except ImportError:
|
||||||
|
- has_pip = False
|
||||||
|
|
||||||
|
- try:
|
||||||
|
- with sync_playwright() as p:
|
||||||
|
- p.chromium.launch()
|
||||||
|
- has_chromium = True
|
||||||
|
- except Exception:
|
||||||
|
- has_chromium = False
|
||||||
|
-
|
||||||
|
- if has_pip and has_chromium:
|
||||||
|
- return True
|
||||||
|
-
|
||||||
|
- pip_cmd = utils.get_pip_install(["aider-chat[playwright]"])
|
||||||
|
- chromium_cmd = "playwright install --with-deps chromium".split()
|
||||||
|
-
|
||||||
|
- cmds = ""
|
||||||
|
- if not has_pip:
|
||||||
|
- cmds += " ".join(pip_cmd) + "\n"
|
||||||
|
- if not has_chromium:
|
||||||
|
- cmds += " ".join(chromium_cmd) + "\n"
|
||||||
|
-
|
||||||
|
- text = f"""For the best web scraping, install Playwright:
|
||||||
|
-
|
||||||
|
-{cmds}
|
||||||
|
-See {urls.enable_playwright} for more info.
|
||||||
|
-"""
|
||||||
|
-
|
||||||
|
- io.tool_error(text)
|
||||||
|
- if not io.confirm_ask("Install playwright?", default="y"):
|
||||||
|
- return
|
||||||
|
-
|
||||||
|
- if not has_pip:
|
||||||
|
- success, output = utils.run_install(pip_cmd)
|
||||||
|
- if not success:
|
||||||
|
- io.tool_error(output)
|
||||||
|
- return
|
||||||
|
-
|
||||||
|
- success, output = utils.run_install(chromium_cmd)
|
||||||
|
- if not success:
|
||||||
|
- io.tool_error(output)
|
||||||
|
- return
|
||||||
|
-
|
||||||
|
- return True
|
||||||
|
-
|
||||||
|
-
|
||||||
|
class Scraper:
|
||||||
|
pandoc_available = None
|
||||||
|
playwright_available = None
|
||||||
|
@@ -89,10 +42,7 @@ class Scraper:
|
||||||
|
`url` - the URLto scrape.
|
||||||
"""
|
"""
|
||||||
Scrape a url and turn it into readable markdown.
|
|
||||||
|
|
||||||
- `url` - the URLto scrape.
|
|
||||||
+ `url` - the URL to scrape.
|
|
||||||
"""
|
|
||||||
- self.try_playwright()
|
|
||||||
|
|
||||||
- if self.playwright_available:
|
- if self.playwright_available:
|
||||||
- content = self.scrape_with_playwright(url)
|
- content = self.scrape_with_playwright(url)
|
||||||
|
@ -27,54 +70,3 @@
|
||||||
|
|
||||||
if not content:
|
if not content:
|
||||||
return
|
return
|
||||||
@@ -62,50 +56,8 @@ class Scraper:
|
|
||||||
|
|
||||||
# Internals...
|
|
||||||
def scrape_with_playwright(self, url):
|
|
||||||
- with sync_playwright() as p:
|
|
||||||
- try:
|
|
||||||
- browser = p.chromium.launch()
|
|
||||||
- except Exception as e:
|
|
||||||
- self.playwright_available = False
|
|
||||||
- self.print_error(e)
|
|
||||||
- return
|
|
||||||
-
|
|
||||||
- page = browser.new_page()
|
|
||||||
-
|
|
||||||
- user_agent = page.evaluate("navigator.userAgent")
|
|
||||||
- user_agent = user_agent.replace("Headless", "")
|
|
||||||
- user_agent = user_agent.replace("headless", "")
|
|
||||||
- user_agent += " " + aider_user_agent
|
|
||||||
-
|
|
||||||
- page = browser.new_page(user_agent=user_agent)
|
|
||||||
- try:
|
|
||||||
- page.goto(url, wait_until="networkidle", timeout=5000)
|
|
||||||
- except playwright._impl._errors.TimeoutError:
|
|
||||||
- pass
|
|
||||||
- content = page.content()
|
|
||||||
- browser.close()
|
|
||||||
-
|
|
||||||
- return content
|
|
||||||
-
|
|
||||||
- def try_playwright(self):
|
|
||||||
- if self.playwright_available is not None:
|
|
||||||
- return
|
|
||||||
-
|
|
||||||
- try:
|
|
||||||
- with sync_playwright() as p:
|
|
||||||
- p.chromium.launch()
|
|
||||||
- self.playwright_available = True
|
|
||||||
- except Exception:
|
|
||||||
self.playwright_available = False
|
|
||||||
-
|
|
||||||
- def get_playwright_instructions(self):
|
|
||||||
- if self.playwright_available in (True, None):
|
|
||||||
return
|
|
||||||
- if self.playwright_instructions_shown:
|
|
||||||
- return
|
|
||||||
-
|
|
||||||
- self.playwright_instructions_shown = True
|
|
||||||
- return PLAYWRIGHT_INFO
|
|
||||||
|
|
||||||
def scrape_with_httpx(self, url):
|
|
||||||
import httpx
|
|
||||||
|
|
11
misc/py-aider-chat/files/patch-setup.py
Normal file
11
misc/py-aider-chat/files/patch-setup.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
--- setup.py.orig 2024-07-27 19:19:07 UTC
|
||||||
|
+++ setup.py
|
||||||
|
@@ -33,7 +33,7 @@ print("Packages:", packages)
|
||||||
|
|
||||||
|
print("Packages:", packages)
|
||||||
|
|
||||||
|
-extras = "dev help browser playwright".split()
|
||||||
|
+extras = []
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name="aider-chat",
|
|
@ -1,5 +1,5 @@
|
||||||
PORTNAME= streamlit
|
PORTNAME= streamlit
|
||||||
DISTVERSION= 1.34.0
|
DISTVERSION= 1.37.0
|
||||||
CATEGORIES= www python
|
CATEGORIES= www python
|
||||||
MASTER_SITES= PYPI
|
MASTER_SITES= PYPI
|
||||||
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
|
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
TIMESTAMP = 1716368381
|
TIMESTAMP = 1722096984
|
||||||
SHA256 (streamlit-1.34.0.tar.gz) = 135a3b79a686b3132b73f204450ad6e889de04f3349d692925e09f0e21e74b52
|
SHA256 (streamlit-1.37.0.tar.gz) = 463ef728ba21e74e05122e3704e8af644a7bdbb5822e281b8daf4a0a48761879
|
||||||
SIZE (streamlit-1.34.0.tar.gz) = 8142532
|
SIZE (streamlit-1.37.0.tar.gz) = 8274522
|
||||||
|
|
Loading…
Add table
Reference in a new issue