|
2 | 2 |
|
3 | 3 | __all__ = ['dict2obj', 'obj2dict', 'repr_dict', 'is_listy', 'shufflish', 'mapped', 'IterLen', 'ReindexCollection', |
4 | 4 | 'maybe_open', 'image_size', 'bunzip', 'join_path_file', 'loads', 'untar_dir', 'repo_details', 'run', |
5 | | - 'open_file', 'save_pickle', 'load_pickle', 'spark_chars', 'sparkline', 'autostart', 'time_events', |
6 | | - 'stringfmt_names', 'PartialFormatter', 'partial_format', 'utc2local', 'local2utc', 'trace', 'round_multiple', |
7 | | - 'modified_env', 'ContextManagers', 'str2bool', 'sort_by_run'] |
| 5 | + 'open_file', 'save_pickle', 'load_pickle', 'truncstr', 'spark_chars', 'sparkline', 'autostart', |
| 6 | + 'time_events', 'stringfmt_names', 'PartialFormatter', 'partial_format', 'utc2local', 'local2utc', 'trace', |
| 7 | + 'round_multiple', 'modified_env', 'ContextManagers', 'str2bool', 'sort_by_run'] |
8 | 8 |
|
9 | 9 | # Cell |
10 | 10 | from .imports import * |
@@ -221,6 +221,11 @@ def __repr__(self:Path): |
221 | 221 | except: pass |
222 | 222 | return f"Path({self.as_posix()!r})" |
223 | 223 |
|
| 224 | +# Cell |
| 225 | +def truncstr(s:str, maxlen:int, suf:str='…')->str: |
| 226 | + "Truncate `s` to length `maxlen`, adding suffix `suf` if truncated" |
| 227 | + return s[:maxlen-len(suf)]+suf if len(s)>maxlen else s |
| 228 | + |
224 | 229 | # Cell |
225 | 230 | spark_chars = '▁▂▃▅▆▇' |
226 | 231 |
|
|
0 commit comments