ipykernel-helper 0.0.10__py3-none-any.whl → 0.0.12__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 ipykernel-helper might be problematic. Click here for more details.
- ipykernel_helper/__init__.py +1 -1
- ipykernel_helper/_modidx.py +1 -0
- ipykernel_helper/core.py +20 -6
- {ipykernel_helper-0.0.10.dist-info → ipykernel_helper-0.0.12.dist-info}/METADATA +2 -1
- ipykernel_helper-0.0.12.dist-info/RECORD +9 -0
- ipykernel_helper-0.0.10.dist-info/RECORD +0 -9
- {ipykernel_helper-0.0.10.dist-info → ipykernel_helper-0.0.12.dist-info}/WHEEL +0 -0
- {ipykernel_helper-0.0.10.dist-info → ipykernel_helper-0.0.12.dist-info}/entry_points.txt +0 -0
- {ipykernel_helper-0.0.10.dist-info → ipykernel_helper-0.0.12.dist-info}/licenses/LICENSE +0 -0
- {ipykernel_helper-0.0.10.dist-info → ipykernel_helper-0.0.12.dist-info}/top_level.txt +0 -0
ipykernel_helper/__init__.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version__ = "0.0.
|
|
1
|
+
__version__ = "0.0.12"
|
|
2
2
|
from .core import *
|
ipykernel_helper/_modidx.py
CHANGED
|
@@ -30,4 +30,5 @@ d = { 'settings': { 'branch': 'main',
|
|
|
30
30
|
'ipykernel_helper/core.py'),
|
|
31
31
|
'ipykernel_helper.core.read_url': ('core.html#read_url', 'ipykernel_helper/core.py'),
|
|
32
32
|
'ipykernel_helper.core.run_cmd': ('core.html#run_cmd', 'ipykernel_helper/core.py'),
|
|
33
|
+
'ipykernel_helper.core.scrape_url': ('core.html#scrape_url', 'ipykernel_helper/core.py'),
|
|
33
34
|
'ipykernel_helper.core.transient': ('core.html#transient', 'ipykernel_helper/core.py')}}}
|
ipykernel_helper/core.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/00_core.ipynb.
|
|
4
4
|
|
|
5
5
|
# %% auto 0
|
|
6
|
-
__all__ = ['transient', 'run_cmd', 'get_md', 'read_url', 'load_ipython_extension']
|
|
6
|
+
__all__ = ['transient', 'run_cmd', 'get_md', 'scrape_url', 'read_url', 'load_ipython_extension']
|
|
7
7
|
|
|
8
8
|
# %% ../nbs/00_core.ipynb
|
|
9
9
|
from fastcore.meta import delegates
|
|
@@ -13,6 +13,7 @@ from inspect import signature, currentframe
|
|
|
13
13
|
from functools import cmp_to_key,partial
|
|
14
14
|
from collections.abc import Mapping
|
|
15
15
|
from textwrap import dedent
|
|
16
|
+
from cloudscraper import create_scraper
|
|
16
17
|
from toolslm.funccall import *
|
|
17
18
|
|
|
18
19
|
import typing,warnings,re
|
|
@@ -151,6 +152,9 @@ def get_md(cts):
|
|
|
151
152
|
def _f(m): return f'```\n{dedent(m.group(1))}\n```'
|
|
152
153
|
return re.sub(r'\[code]\s*\n(.*?)\n\[/code]', _f, res or '', flags=re.DOTALL).strip()
|
|
153
154
|
|
|
155
|
+
# %% ../nbs/00_core.ipynb
|
|
156
|
+
def scrape_url(url): return create_scraper().get(url)
|
|
157
|
+
|
|
154
158
|
# %% ../nbs/00_core.ipynb
|
|
155
159
|
def read_url(
|
|
156
160
|
url:str, # URL to read
|
|
@@ -159,20 +163,30 @@ def read_url(
|
|
|
159
163
|
selector:str=None # Select section(s) using BeautifulSoup.select (overrides extract_section)
|
|
160
164
|
):
|
|
161
165
|
"Read URL and return contents"
|
|
162
|
-
import httpx
|
|
163
166
|
from urllib.parse import urlparse
|
|
164
167
|
from bs4 import BeautifulSoup
|
|
165
168
|
|
|
166
|
-
res =
|
|
169
|
+
res = scrape_url(url).text
|
|
170
|
+
soup = BeautifulSoup(res, "html.parser")
|
|
171
|
+
|
|
167
172
|
if selector:
|
|
168
|
-
sections =
|
|
173
|
+
sections = soup.select(selector)
|
|
169
174
|
if sections: res = '\n\n'.join(str(section) for section in sections)
|
|
170
175
|
else: res = ''
|
|
171
176
|
elif extract_section:
|
|
172
177
|
parsed = urlparse(url)
|
|
173
178
|
if parsed.fragment:
|
|
174
|
-
section =
|
|
175
|
-
if section:
|
|
179
|
+
section = soup.find(id=parsed.fragment)
|
|
180
|
+
if section:
|
|
181
|
+
tag_name = section.name
|
|
182
|
+
elements = [section]
|
|
183
|
+
current = section.next_sibling
|
|
184
|
+
while current:
|
|
185
|
+
if hasattr(current, 'name') and current.name == tag_name: break
|
|
186
|
+
elements.append(current)
|
|
187
|
+
current = current.next_sibling
|
|
188
|
+
res = ''.join(str(el) for el in elements)
|
|
189
|
+
else: res = ''
|
|
176
190
|
if as_md: return get_md(res)
|
|
177
191
|
return res
|
|
178
192
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ipykernel-helper
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.12
|
|
4
4
|
Summary: Helpers for ipykernel and friends
|
|
5
5
|
Home-page: https://github.com/AnswerDotAI/ipykernel-helper
|
|
6
6
|
Author: Jeremy Howard
|
|
@@ -25,6 +25,7 @@ Requires-Dist: ipython
|
|
|
25
25
|
Requires-Dist: ipykernel
|
|
26
26
|
Requires-Dist: beautifulsoup4
|
|
27
27
|
Requires-Dist: html2text
|
|
28
|
+
Requires-Dist: cloudscraper
|
|
28
29
|
Provides-Extra: dev
|
|
29
30
|
Dynamic: author
|
|
30
31
|
Dynamic: author-email
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
ipykernel_helper/__init__.py,sha256=NBQPBiYNpbwRh0tbd9ruOAJTKO2W4erG6F75QoavDZQ,43
|
|
2
|
+
ipykernel_helper/_modidx.py,sha256=AEG4MccZfb25rQi8UWrOpUrs1VIYHbexKEQGWnwYkRg,3706
|
|
3
|
+
ipykernel_helper/core.py,sha256=22E6FiiTI7Q8vPESVUHXyz8CoOWxDLkDe8tlSdJNEMQ,8150
|
|
4
|
+
ipykernel_helper-0.0.12.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
5
|
+
ipykernel_helper-0.0.12.dist-info/METADATA,sha256=EYR5VZ2ZiIDN_Jn_UAKqFqoKYVnnknoj_bT_9Th-x60,2709
|
|
6
|
+
ipykernel_helper-0.0.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
7
|
+
ipykernel_helper-0.0.12.dist-info/entry_points.txt,sha256=HWiK9xz75QtZUaPaYrwpyH5B8MbW0Ea_vi11UmwBImM,54
|
|
8
|
+
ipykernel_helper-0.0.12.dist-info/top_level.txt,sha256=_diD--64d9MauLE0pTxzZ58lkI8DvCrVc1hVAJsyc_Q,17
|
|
9
|
+
ipykernel_helper-0.0.12.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
ipykernel_helper/__init__.py,sha256=vGb5bWRnqikdeGjmhzb9R8htmRhc2CloD1a9bB7Ttvo,43
|
|
2
|
-
ipykernel_helper/_modidx.py,sha256=INE9z1o4nb_NMRepxbiF5fBE5Il5BeKJZFTLmdxUGLw,3577
|
|
3
|
-
ipykernel_helper/core.py,sha256=hf7ml7uXFjzllCvwuiRVfu8NQlq9AQ3Xdfd3trkY0sk,7650
|
|
4
|
-
ipykernel_helper-0.0.10.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
5
|
-
ipykernel_helper-0.0.10.dist-info/METADATA,sha256=4ZPHVdmWsfST3aFKoJFXRbc3ODHNIDJRotcz9F02YDI,2681
|
|
6
|
-
ipykernel_helper-0.0.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
7
|
-
ipykernel_helper-0.0.10.dist-info/entry_points.txt,sha256=HWiK9xz75QtZUaPaYrwpyH5B8MbW0Ea_vi11UmwBImM,54
|
|
8
|
-
ipykernel_helper-0.0.10.dist-info/top_level.txt,sha256=_diD--64d9MauLE0pTxzZ58lkI8DvCrVc1hVAJsyc_Q,17
|
|
9
|
-
ipykernel_helper-0.0.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|