fastcore 2.2.7__tar.gz → 2.2.8__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.
- {fastcore-2.2.7/fastcore.egg-info → fastcore-2.2.8}/PKG-INFO +1 -1
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/__init__.py +1 -1
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/_modidx.py +4 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/xtras.py +21 -5
- {fastcore-2.2.7 → fastcore-2.2.8/fastcore.egg-info}/PKG-INFO +1 -1
- {fastcore-2.2.7 → fastcore-2.2.8}/CONTRIBUTING.md +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/LICENSE +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/MANIFEST.in +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/README.md +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/aio.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/all.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/ansi.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/apisurface.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/basics.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/dispatch.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/docments.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/docscrape.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/editskill.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/foundation.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/funccall.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/imghdr.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/imports.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/meta.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/nb_imports.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/nbio.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/net.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/parallel.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/py2pyi.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/script.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/shutil.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/style.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/test.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/tools.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/transform.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/utils.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/xdg.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/xml.py +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore.egg-info/SOURCES.txt +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore.egg-info/dependency_links.txt +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore.egg-info/entry_points.txt +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore.egg-info/requires.txt +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/fastcore.egg-info/top_level.txt +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/pyproject.toml +0 -0
- {fastcore-2.2.7 → fastcore-2.2.8}/setup.cfg +0 -0
|
@@ -891,6 +891,9 @@ d = { 'settings': { 'branch': 'main',
|
|
|
891
891
|
'fastcore.xtras.SaveReturn': ('xtras.html#savereturn', 'fastcore/xtras.py'),
|
|
892
892
|
'fastcore.xtras.SaveReturn.__init__': ('xtras.html#savereturn.__init__', 'fastcore/xtras.py'),
|
|
893
893
|
'fastcore.xtras.SaveReturn.__iter__': ('xtras.html#savereturn.__iter__', 'fastcore/xtras.py'),
|
|
894
|
+
'fastcore.xtras.TruncatedString': ('xtras.html#truncatedstring', 'fastcore/xtras.py'),
|
|
895
|
+
'fastcore.xtras.TruncatedString.__new__': ('xtras.html#truncatedstring.__new__', 'fastcore/xtras.py'),
|
|
896
|
+
'fastcore.xtras.TruncatedString.__repr__': ('xtras.html#truncatedstring.__repr__', 'fastcore/xtras.py'),
|
|
894
897
|
'fastcore.xtras.Unset': ('xtras.html#unset', 'fastcore/xtras.py'),
|
|
895
898
|
'fastcore.xtras.Unset.__bool__': ('xtras.html#unset.__bool__', 'fastcore/xtras.py'),
|
|
896
899
|
'fastcore.xtras.Unset.__repr__': ('xtras.html#unset.__repr__', 'fastcore/xtras.py'),
|
|
@@ -982,6 +985,7 @@ d = { 'settings': { 'branch': 'main',
|
|
|
982
985
|
'fastcore.xtras.timed_cache': ('xtras.html#timed_cache', 'fastcore/xtras.py'),
|
|
983
986
|
'fastcore.xtras.trace': ('xtras.html#trace', 'fastcore/xtras.py'),
|
|
984
987
|
'fastcore.xtras.trim_wraps': ('xtras.html#trim_wraps', 'fastcore/xtras.py'),
|
|
988
|
+
'fastcore.xtras.trunc_ctr': ('xtras.html#trunc_ctr', 'fastcore/xtras.py'),
|
|
985
989
|
'fastcore.xtras.truncstr': ('xtras.html#truncstr', 'fastcore/xtras.py'),
|
|
986
990
|
'fastcore.xtras.type2str': ('xtras.html#type2str', 'fastcore/xtras.py'),
|
|
987
991
|
'fastcore.xtras.unqid': ('xtras.html#unqid', 'fastcore/xtras.py'),
|
|
@@ -29,11 +29,11 @@ __all__ = ['UNSET', 'spark_chars', 'walk_join', 'walk', 'exttypes', 'globtastic'
|
|
|
29
29
|
'ReindexCollection', 'SaveReturn', 'trim_wraps', 'save_iter', 'asave_iter', 'strloader', 'frontmatter',
|
|
30
30
|
'clean_cli_output', 'unqid', 'rtoken_hex', 'friendly_name', 'n_friendly_names', 'exec_eval',
|
|
31
31
|
'get_source_link', 'sparkline', 'modify_exception', 'round_multiple', 'set_num_threads', 'join_path_file',
|
|
32
|
-
'autostart', 'EventTimer', 'stringfmt_names', 'PartialFormatter', 'partial_format', 'truncstr', '
|
|
33
|
-
'fenced_blocks', 'str_diff', 'utc2local', 'local2utc', 'trace', 'modified_env',
|
|
34
|
-
'shufflish', 'console_help', 'hl_md', 'type2str', 'dataclass_src', 'nullable_dc',
|
|
35
|
-
'flexiclass', 'asdict', 'vars_pub', 'is_typeddict', 'is_namedtuple', 'CachedIter',
|
|
36
|
-
'time_policy', 'mtime_policy', 'timed_cache']
|
|
32
|
+
'autostart', 'EventTimer', 'stringfmt_names', 'PartialFormatter', 'partial_format', 'truncstr', 'trunc_ctr',
|
|
33
|
+
'TruncatedString', 'fenced', 'fenced_blocks', 'str_diff', 'utc2local', 'local2utc', 'trace', 'modified_env',
|
|
34
|
+
'ContextManagers', 'shufflish', 'console_help', 'hl_md', 'type2str', 'dataclass_src', 'nullable_dc',
|
|
35
|
+
'make_nullable', 'flexiclass', 'asdict', 'vars_pub', 'is_typeddict', 'is_namedtuple', 'CachedIter',
|
|
36
|
+
'flexicache', 'time_policy', 'mtime_policy', 'timed_cache']
|
|
37
37
|
|
|
38
38
|
# %% ../nbs/03_xtras.ipynb #3401d507
|
|
39
39
|
from .imports import *
|
|
@@ -983,6 +983,22 @@ def truncstr(s:str, maxlen:int, suf:str='…', space='', sizevar:str=None)->str:
|
|
|
983
983
|
if sizevar: suf = suf.format_map({sizevar: len(s)})
|
|
984
984
|
return s[:maxlen-len(suf)]+suf if len(s)+len(space)>maxlen else s+space
|
|
985
985
|
|
|
986
|
+
# %% ../nbs/03_xtras.ipynb #a67b3fca
|
|
987
|
+
def trunc_ctr(s:str, mx:int=1000)->str:
|
|
988
|
+
"Truncate the middle of `s` so ~`mx` chars remain, marking the elision with its `humanize`d size"
|
|
989
|
+
if mx is None or len(s)<=mx: return s
|
|
990
|
+
h = mx//2
|
|
991
|
+
return f'{s[:h]}…[{humanize(len(s)-mx)} chars]…{s[len(s)-(mx-h):]}'
|
|
992
|
+
|
|
993
|
+
# %% ../nbs/03_xtras.ipynb #8d120ca6
|
|
994
|
+
class TruncatedString(str):
|
|
995
|
+
"A `str` whose repr shows contents verbatim, middle-truncated to ~`mx` chars"
|
|
996
|
+
def __new__(cls, s='', mx:int=1000):
|
|
997
|
+
res = super().__new__(cls, s)
|
|
998
|
+
res.mx = mx
|
|
999
|
+
return res
|
|
1000
|
+
def __repr__(self): return trunc_ctr(self, self.mx)
|
|
1001
|
+
|
|
986
1002
|
# %% ../nbs/03_xtras.ipynb #2f5e6b12
|
|
987
1003
|
def fenced(text:str, info:str='', ch:str='`')->str:
|
|
988
1004
|
"Wrap `text` in a fence of `ch`, one char longer than any run of `ch` inside it (min 3)"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|