ipykernel-helper 0.0.10__tar.gz → 0.0.14__tar.gz
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.
- {ipykernel_helper-0.0.10/ipykernel_helper.egg-info → ipykernel_helper-0.0.14}/PKG-INFO +2 -1
- ipykernel_helper-0.0.14/ipykernel_helper/__init__.py +2 -0
- {ipykernel_helper-0.0.10 → ipykernel_helper-0.0.14}/ipykernel_helper/_modidx.py +1 -0
- {ipykernel_helper-0.0.10 → ipykernel_helper-0.0.14}/ipykernel_helper/core.py +29 -9
- {ipykernel_helper-0.0.10 → ipykernel_helper-0.0.14/ipykernel_helper.egg-info}/PKG-INFO +2 -1
- {ipykernel_helper-0.0.10 → ipykernel_helper-0.0.14}/ipykernel_helper.egg-info/requires.txt +1 -0
- {ipykernel_helper-0.0.10 → ipykernel_helper-0.0.14}/settings.ini +2 -2
- ipykernel_helper-0.0.10/ipykernel_helper/__init__.py +0 -2
- {ipykernel_helper-0.0.10 → ipykernel_helper-0.0.14}/LICENSE +0 -0
- {ipykernel_helper-0.0.10 → ipykernel_helper-0.0.14}/MANIFEST.in +0 -0
- {ipykernel_helper-0.0.10 → ipykernel_helper-0.0.14}/README.md +0 -0
- {ipykernel_helper-0.0.10 → ipykernel_helper-0.0.14}/ipykernel_helper.egg-info/SOURCES.txt +0 -0
- {ipykernel_helper-0.0.10 → ipykernel_helper-0.0.14}/ipykernel_helper.egg-info/dependency_links.txt +0 -0
- {ipykernel_helper-0.0.10 → ipykernel_helper-0.0.14}/ipykernel_helper.egg-info/entry_points.txt +0 -0
- {ipykernel_helper-0.0.10 → ipykernel_helper-0.0.14}/ipykernel_helper.egg-info/not-zip-safe +0 -0
- {ipykernel_helper-0.0.10 → ipykernel_helper-0.0.14}/ipykernel_helper.egg-info/top_level.txt +0 -0
- {ipykernel_helper-0.0.10 → ipykernel_helper-0.0.14}/pyproject.toml +0 -0
- {ipykernel_helper-0.0.10 → ipykernel_helper-0.0.14}/setup.cfg +0 -0
- {ipykernel_helper-0.0.10 → ipykernel_helper-0.0.14}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ipykernel-helper
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.14
|
|
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
|
|
@@ -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')}}}
|
|
@@ -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,7 +13,9 @@ 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 *
|
|
18
|
+
from ast import literal_eval
|
|
17
19
|
|
|
18
20
|
import typing,warnings,re
|
|
19
21
|
|
|
@@ -101,10 +103,13 @@ def sig_help(self:InteractiveShell, code, line_no=None, col_no=None):
|
|
|
101
103
|
|
|
102
104
|
# %% ../nbs/00_core.ipynb
|
|
103
105
|
@patch
|
|
104
|
-
def get_vars(self:InteractiveShell, vs:list):
|
|
106
|
+
def get_vars(self:InteractiveShell, vs:list, literal=True):
|
|
105
107
|
"Get variables from namespace."
|
|
106
108
|
ns = self.user_ns
|
|
107
|
-
|
|
109
|
+
def _maybe_eval(o):
|
|
110
|
+
try: literal_eval(repr(o)); return o
|
|
111
|
+
except: return str(o)
|
|
112
|
+
return {v:_maybe_eval(ns[v]) if literal else str(ns[v]) for v in vs if v in ns}
|
|
108
113
|
|
|
109
114
|
# %% ../nbs/00_core.ipynb
|
|
110
115
|
def _get_schema(ns: dict, t):
|
|
@@ -151,6 +156,9 @@ def get_md(cts):
|
|
|
151
156
|
def _f(m): return f'```\n{dedent(m.group(1))}\n```'
|
|
152
157
|
return re.sub(r'\[code]\s*\n(.*?)\n\[/code]', _f, res or '', flags=re.DOTALL).strip()
|
|
153
158
|
|
|
159
|
+
# %% ../nbs/00_core.ipynb
|
|
160
|
+
def scrape_url(url): return create_scraper().get(url)
|
|
161
|
+
|
|
154
162
|
# %% ../nbs/00_core.ipynb
|
|
155
163
|
def read_url(
|
|
156
164
|
url:str, # URL to read
|
|
@@ -159,21 +167,33 @@ def read_url(
|
|
|
159
167
|
selector:str=None # Select section(s) using BeautifulSoup.select (overrides extract_section)
|
|
160
168
|
):
|
|
161
169
|
"Read URL and return contents"
|
|
162
|
-
import httpx
|
|
163
170
|
from urllib.parse import urlparse
|
|
164
171
|
from bs4 import BeautifulSoup
|
|
165
172
|
|
|
166
|
-
|
|
173
|
+
o = scrape_url(url)
|
|
174
|
+
res, ctype = o.text, o.headers.get('content-type').split(';')[0]
|
|
175
|
+
|
|
176
|
+
soup = BeautifulSoup(res, "html.parser")
|
|
177
|
+
|
|
167
178
|
if selector:
|
|
168
|
-
sections =
|
|
179
|
+
sections = soup.select(selector)
|
|
169
180
|
if sections: res = '\n\n'.join(str(section) for section in sections)
|
|
170
181
|
else: res = ''
|
|
171
182
|
elif extract_section:
|
|
172
183
|
parsed = urlparse(url)
|
|
173
184
|
if parsed.fragment:
|
|
174
|
-
section =
|
|
175
|
-
if section:
|
|
176
|
-
|
|
185
|
+
section = soup.find(id=parsed.fragment)
|
|
186
|
+
if section:
|
|
187
|
+
tag_name = section.name
|
|
188
|
+
elements = [section]
|
|
189
|
+
current = section.next_sibling
|
|
190
|
+
while current:
|
|
191
|
+
if hasattr(current, 'name') and current.name == tag_name: break
|
|
192
|
+
elements.append(current)
|
|
193
|
+
current = current.next_sibling
|
|
194
|
+
res = ''.join(str(el) for el in elements)
|
|
195
|
+
else: res = ''
|
|
196
|
+
if as_md and ctype == 'text/html': return get_md(res)
|
|
177
197
|
return res
|
|
178
198
|
|
|
179
199
|
# %% ../nbs/00_core.ipynb
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ipykernel-helper
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.14
|
|
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
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
[DEFAULT]
|
|
2
2
|
repo = ipykernel-helper
|
|
3
3
|
lib_name = ipykernel-helper
|
|
4
|
-
version = 0.0.
|
|
4
|
+
version = 0.0.14
|
|
5
5
|
min_python = 3.9
|
|
6
6
|
license = apache2
|
|
7
7
|
black_formatting = False
|
|
8
|
-
requirements = fastcore toolslm>=0.2.0 jedi ipython ipykernel beautifulsoup4 html2text
|
|
8
|
+
requirements = fastcore toolslm>=0.2.0 jedi ipython ipykernel beautifulsoup4 html2text cloudscraper
|
|
9
9
|
cell_number = False
|
|
10
10
|
doc_path = _docs
|
|
11
11
|
lib_path = ipykernel_helper
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ipykernel_helper-0.0.10 → ipykernel_helper-0.0.14}/ipykernel_helper.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{ipykernel_helper-0.0.10 → ipykernel_helper-0.0.14}/ipykernel_helper.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|