toolslm 0.3.13__py3-none-any.whl → 0.3.14__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.
- toolslm/__init__.py +1 -1
- toolslm/_modidx.py +5 -1
- toolslm/xml.py +35 -6
- {toolslm-0.3.13.dist-info → toolslm-0.3.14.dist-info}/METADATA +1 -1
- toolslm-0.3.14.dist-info/RECORD +13 -0
- toolslm-0.3.13.dist-info/RECORD +0 -13
- {toolslm-0.3.13.dist-info → toolslm-0.3.14.dist-info}/WHEEL +0 -0
- {toolslm-0.3.13.dist-info → toolslm-0.3.14.dist-info}/entry_points.txt +0 -0
- {toolslm-0.3.13.dist-info → toolslm-0.3.14.dist-info}/licenses/LICENSE +0 -0
- {toolslm-0.3.13.dist-info → toolslm-0.3.14.dist-info}/top_level.txt +0 -0
toolslm/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.3.
|
|
1
|
+
__version__ = "0.3.14"
|
toolslm/_modidx.py
CHANGED
|
@@ -51,4 +51,8 @@ d = { 'settings': { 'branch': 'main',
|
|
|
51
51
|
'toolslm.xml.nb2xml': ('xml.html#nb2xml', 'toolslm/xml.py'),
|
|
52
52
|
'toolslm.xml.parse_gh_url': ('xml.html#parse_gh_url', 'toolslm/xml.py'),
|
|
53
53
|
'toolslm.xml.read_file': ('xml.html#read_file', 'toolslm/xml.py'),
|
|
54
|
-
'toolslm.xml.repo2ctx': ('xml.html#repo2ctx', 'toolslm/xml.py')
|
|
54
|
+
'toolslm.xml.repo2ctx': ('xml.html#repo2ctx', 'toolslm/xml.py'),
|
|
55
|
+
'toolslm.xml.sym2file': ('xml.html#sym2file', 'toolslm/xml.py'),
|
|
56
|
+
'toolslm.xml.sym2folderctx': ('xml.html#sym2folderctx', 'toolslm/xml.py'),
|
|
57
|
+
'toolslm.xml.sym2pkgctx': ('xml.html#sym2pkgctx', 'toolslm/xml.py'),
|
|
58
|
+
'toolslm.xml.sym2pkgpath': ('xml.html#sym2pkgpath', 'toolslm/xml.py')}}}
|
toolslm/xml.py
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
# %% auto 0
|
|
4
4
|
__all__ = ['doctype', 'json_to_xml', 'get_mime_text', 'cell2out', 'cell2xml', 'nb2xml', 'mk_doctype', 'mk_doc', 'docs_xml',
|
|
5
|
-
'read_file', 'files2ctx', 'folder2ctx', '
|
|
5
|
+
'read_file', 'files2ctx', 'folder2ctx', 'sym2file', 'sym2folderctx', 'sym2pkgpath', 'sym2pkgctx',
|
|
6
|
+
'folder2ctx_cli', 'parse_gh_url', 'repo2ctx']
|
|
6
7
|
|
|
7
8
|
# %% ../00_xml.ipynb
|
|
8
|
-
import hashlib,xml.etree.ElementTree as ET
|
|
9
|
+
import hashlib, inspect, xml.etree.ElementTree as ET
|
|
9
10
|
from collections import namedtuple
|
|
10
11
|
from ghapi.all import GhApi
|
|
11
12
|
|
|
@@ -152,15 +153,43 @@ def folder2ctx(
|
|
|
152
153
|
)->Union[str,dict]:
|
|
153
154
|
"Convert folder contents to XML context, handling notebooks"
|
|
154
155
|
folder = Path(folder)
|
|
155
|
-
fnames =
|
|
156
|
-
if files_only: return {str(
|
|
157
|
-
if readme_first: fnames = sorted(fnames, key=lambda f: (0 if 'readme' in
|
|
158
|
-
srcs = fnames if include_base else [
|
|
156
|
+
fnames = pglob(folder, **kwargs)
|
|
157
|
+
if files_only: return {str(f.relative_to(folder)): f.stat().st_size for f in fnames}
|
|
158
|
+
if readme_first: fnames = sorted(fnames, key=lambda f: (0 if 'readme' in f.name.lower() else 1, f))
|
|
159
|
+
srcs = fnames if include_base else [f.relative_to(folder) for f in fnames]
|
|
159
160
|
res = files2ctx(fnames, prefix=prefix, out=out, srcs=srcs, title=title, max_size=max_size)
|
|
160
161
|
suf = f"\n\n[TRUNCATED: output size {{_outsz_}} exceeded max size {max_total} bytes]"
|
|
161
162
|
if max_total and len(res) > max_total: res = truncstr(res, max_total, suf=suf, sizevar='_outsz_')
|
|
162
163
|
return res
|
|
163
164
|
|
|
165
|
+
# %% ../00_xml.ipynb
|
|
166
|
+
def sym2file(sym):
|
|
167
|
+
"Return (filepath, contents) for a symbol's source file"
|
|
168
|
+
f = Path(inspect.getfile(sym))
|
|
169
|
+
return f"- `{f}`\n\n````\n{f.read_text()}\n````"
|
|
170
|
+
|
|
171
|
+
# %% ../00_xml.ipynb
|
|
172
|
+
@delegates(folder2ctx)
|
|
173
|
+
def sym2folderctx(
|
|
174
|
+
sym,
|
|
175
|
+
types:str|list='py', # list or comma-separated str of ext types from: py, js, java, c, cpp, rb, r, ex, sh, web, doc, cfg
|
|
176
|
+
skip_file_re=r'^_mod',
|
|
177
|
+
**kwargs):
|
|
178
|
+
"Return folder context for a symbol's source file location"
|
|
179
|
+
return folder2ctx(Path(inspect.getfile(sym)).parent, types=types, skip_file_re=skip_file_re, **kwargs)
|
|
180
|
+
|
|
181
|
+
# %% ../00_xml.ipynb
|
|
182
|
+
def sym2pkgpath(sym):
|
|
183
|
+
"Get root package path for a symbol"
|
|
184
|
+
root = sym.__module__.split('.')[0]
|
|
185
|
+
return Path(sys.modules[root].__path__[0])
|
|
186
|
+
|
|
187
|
+
# %% ../00_xml.ipynb
|
|
188
|
+
@delegates(folder2ctx)
|
|
189
|
+
def sym2pkgctx(sym, types:str|list='py', skip_file_re=r'^_mod', **kwargs):
|
|
190
|
+
"Return repo context for a symbol's root package"
|
|
191
|
+
return folder2ctx(sym2pkgpath(sym), types=types, skip_file_re=skip_file_re, **kwargs)
|
|
192
|
+
|
|
164
193
|
# %% ../00_xml.ipynb
|
|
165
194
|
@call_parse
|
|
166
195
|
@delegates(folder2ctx)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
toolslm/__init__.py,sha256=C4hELt6-C98d411Tr5sUxE2yF7ZqH9GYEgLTCMKRGw0,23
|
|
2
|
+
toolslm/_modidx.py,sha256=EC1pFuHb5MbfRMml7RXx1sxGXlTiczjUimXICuXUMn0,5806
|
|
3
|
+
toolslm/download.py,sha256=yMhyY3u26XRr6a4eZuCCmkprS7LQhHASl01Zn2B4q_o,4481
|
|
4
|
+
toolslm/funccall.py,sha256=_5TyhTjWaWLi-eJ96-4P3_faFv6Ft07nO60UjCF-bPU,11160
|
|
5
|
+
toolslm/md_hier.py,sha256=r_NPezhgfxjRmSYFlu_ND42hXt1qSbaPWHTcjbviOn4,11010
|
|
6
|
+
toolslm/shell.py,sha256=dGInuRKvexu21VmtZkw_0S3BGiTsbAongUG-yG4YHpc,1566
|
|
7
|
+
toolslm/xml.py,sha256=4OcCC_I_GwORgCdT3WcIU913wwlkTWkE6d-52T4XQx0,10908
|
|
8
|
+
toolslm-0.3.14.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
9
|
+
toolslm-0.3.14.dist-info/METADATA,sha256=3QMIJJiJiAFVqDrWdxUd1D6zuI5g6Hv4VfKQ-lgKrd8,2404
|
|
10
|
+
toolslm-0.3.14.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
11
|
+
toolslm-0.3.14.dist-info/entry_points.txt,sha256=xFz0Eymlo5X7BGpaO6DI9gMxvN5A7faebzrlr8ctp5I,95
|
|
12
|
+
toolslm-0.3.14.dist-info/top_level.txt,sha256=4hRTrFWayz_Kz5221XjvlpCwVFrW3WPi1P0fllkTq9s,8
|
|
13
|
+
toolslm-0.3.14.dist-info/RECORD,,
|
toolslm-0.3.13.dist-info/RECORD
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
toolslm/__init__.py,sha256=jXmhGysidmiPOxLAzcyzQjjT98GxaQk2jHMECTsHr04,23
|
|
2
|
-
toolslm/_modidx.py,sha256=DMBoEHx7c0EvxmSiLYbi0Grd8hjSQKiuK4xJdfa1rFo,5410
|
|
3
|
-
toolslm/download.py,sha256=yMhyY3u26XRr6a4eZuCCmkprS7LQhHASl01Zn2B4q_o,4481
|
|
4
|
-
toolslm/funccall.py,sha256=_5TyhTjWaWLi-eJ96-4P3_faFv6Ft07nO60UjCF-bPU,11160
|
|
5
|
-
toolslm/md_hier.py,sha256=r_NPezhgfxjRmSYFlu_ND42hXt1qSbaPWHTcjbviOn4,11010
|
|
6
|
-
toolslm/shell.py,sha256=dGInuRKvexu21VmtZkw_0S3BGiTsbAongUG-yG4YHpc,1566
|
|
7
|
-
toolslm/xml.py,sha256=5sT-rRwpYTNpxNnZPr0QqIS2uZAAjsR3aE3c90nXzWA,9820
|
|
8
|
-
toolslm-0.3.13.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
9
|
-
toolslm-0.3.13.dist-info/METADATA,sha256=uWzDigLPr9FoLJUdC3oXk8KfioKRfm4wTJi8k9K52iM,2404
|
|
10
|
-
toolslm-0.3.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
11
|
-
toolslm-0.3.13.dist-info/entry_points.txt,sha256=xFz0Eymlo5X7BGpaO6DI9gMxvN5A7faebzrlr8ctp5I,95
|
|
12
|
-
toolslm-0.3.13.dist-info/top_level.txt,sha256=4hRTrFWayz_Kz5221XjvlpCwVFrW3WPi1P0fllkTq9s,8
|
|
13
|
-
toolslm-0.3.13.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|