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.
Files changed (44) hide show
  1. {fastcore-2.2.7/fastcore.egg-info → fastcore-2.2.8}/PKG-INFO +1 -1
  2. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/__init__.py +1 -1
  3. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/_modidx.py +4 -0
  4. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/xtras.py +21 -5
  5. {fastcore-2.2.7 → fastcore-2.2.8/fastcore.egg-info}/PKG-INFO +1 -1
  6. {fastcore-2.2.7 → fastcore-2.2.8}/CONTRIBUTING.md +0 -0
  7. {fastcore-2.2.7 → fastcore-2.2.8}/LICENSE +0 -0
  8. {fastcore-2.2.7 → fastcore-2.2.8}/MANIFEST.in +0 -0
  9. {fastcore-2.2.7 → fastcore-2.2.8}/README.md +0 -0
  10. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/aio.py +0 -0
  11. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/all.py +0 -0
  12. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/ansi.py +0 -0
  13. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/apisurface.py +0 -0
  14. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/basics.py +0 -0
  15. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/dispatch.py +0 -0
  16. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/docments.py +0 -0
  17. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/docscrape.py +0 -0
  18. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/editskill.py +0 -0
  19. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/foundation.py +0 -0
  20. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/funccall.py +0 -0
  21. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/imghdr.py +0 -0
  22. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/imports.py +0 -0
  23. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/meta.py +0 -0
  24. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/nb_imports.py +0 -0
  25. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/nbio.py +0 -0
  26. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/net.py +0 -0
  27. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/parallel.py +0 -0
  28. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/py2pyi.py +0 -0
  29. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/script.py +0 -0
  30. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/shutil.py +0 -0
  31. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/style.py +0 -0
  32. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/test.py +0 -0
  33. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/tools.py +0 -0
  34. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/transform.py +0 -0
  35. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/utils.py +0 -0
  36. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/xdg.py +0 -0
  37. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore/xml.py +0 -0
  38. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore.egg-info/SOURCES.txt +0 -0
  39. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore.egg-info/dependency_links.txt +0 -0
  40. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore.egg-info/entry_points.txt +0 -0
  41. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore.egg-info/requires.txt +0 -0
  42. {fastcore-2.2.7 → fastcore-2.2.8}/fastcore.egg-info/top_level.txt +0 -0
  43. {fastcore-2.2.7 → fastcore-2.2.8}/pyproject.toml +0 -0
  44. {fastcore-2.2.7 → fastcore-2.2.8}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastcore
3
- Version: 2.2.7
3
+ Version: 2.2.8
4
4
  Summary: Python supercharged for fastai development
5
5
  Author-email: Jeremy Howard and Sylvain Gugger <infos@fast.ai>
6
6
  License: Apache-2.0
@@ -55,4 +55,4 @@ Modules:
55
55
  - `fastcore.xml`: Concise generation of XML.
56
56
  - `fastcore.xtras`: Utility functions used in the fastai library"""
57
57
 
58
- __version__ = "2.2.7"
58
+ __version__ = "2.2.8"
@@ -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', 'fenced',
33
- 'fenced_blocks', 'str_diff', 'utc2local', 'local2utc', 'trace', 'modified_env', 'ContextManagers',
34
- 'shufflish', 'console_help', 'hl_md', 'type2str', 'dataclass_src', 'nullable_dc', 'make_nullable',
35
- 'flexiclass', 'asdict', 'vars_pub', 'is_typeddict', 'is_namedtuple', 'CachedIter', 'flexicache',
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)"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastcore
3
- Version: 2.2.7
3
+ Version: 2.2.8
4
4
  Summary: Python supercharged for fastai development
5
5
  Author-email: Jeremy Howard and Sylvain Gugger <infos@fast.ai>
6
6
  License: Apache-2.0
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