|
10 | 10 | 'bunzip', 'loads', 'loads_multi', 'dumps', 'untar_dir', 'repo_details', 'shell', 'ssh', 'rsync_multi', 'run', |
11 | 11 | 'open_file', 'save_pickle', 'load_pickle', 'parse_env', 'expand_wildcards', 'dict2obj', 'obj2dict', |
12 | 12 | 'repr_dict', 'is_listy', 'mapped', 'IterLen', 'ReindexCollection', 'SaveReturn', 'trim_wraps', 'save_iter', |
13 | | - 'asave_iter', 'friendly_name', 'n_friendly_names', 'exec_eval', 'get_source_link', 'truncstr', 'sparkline', |
14 | | - 'modify_exception', 'round_multiple', 'set_num_threads', 'join_path_file', 'autostart', 'EventTimer', |
15 | | - 'stringfmt_names', 'PartialFormatter', 'partial_format', 'utc2local', 'local2utc', 'trace', 'modified_env', |
16 | | - 'ContextManagers', 'shufflish', 'console_help', 'hl_md', 'type2str', 'dataclass_src', 'Unset', 'nullable_dc', |
17 | | - 'make_nullable', 'flexiclass', 'asdict', 'vars_pub', 'is_typeddict', 'is_namedtuple', 'CachedIter', |
18 | | - 'CachedAwaitable', 'reawaitable', 'flexicache', 'time_policy', 'mtime_policy', 'timed_cache'] |
| 13 | + 'asave_iter', 'unqid', 'friendly_name', 'n_friendly_names', 'exec_eval', 'get_source_link', 'truncstr', |
| 14 | + 'sparkline', 'modify_exception', 'round_multiple', 'set_num_threads', 'join_path_file', 'autostart', |
| 15 | + 'EventTimer', 'stringfmt_names', 'PartialFormatter', 'partial_format', 'utc2local', 'local2utc', 'trace', |
| 16 | + 'modified_env', 'ContextManagers', 'shufflish', 'console_help', 'hl_md', 'type2str', 'dataclass_src', |
| 17 | + 'Unset', 'nullable_dc', 'make_nullable', 'flexiclass', 'asdict', 'vars_pub', 'is_typeddict', 'is_namedtuple', |
| 18 | + 'CachedIter', 'CachedAwaitable', 'reawaitable', 'flexicache', 'time_policy', 'mtime_policy', 'timed_cache'] |
19 | 19 |
|
20 | 20 | # %% ../nbs/03_xtras.ipynb |
21 | 21 | from .imports import * |
@@ -511,6 +511,15 @@ def asave_iter(g): |
511 | 511 | def _(*args, **kwargs): return _save_iter(g, *args, **kwargs) |
512 | 512 | return _ |
513 | 513 |
|
| 514 | +# %% ../nbs/03_xtras.ipynb |
| 515 | +def unqid(seeded=False): |
| 516 | + "Generate a unique id suitable for use as a Python identifier" |
| 517 | + from base64 import b64encode |
| 518 | + from uuid import uuid4,UUID |
| 519 | + id4 = UUID(int=random.getrandbits(128), version=4) if seeded else uuid4() |
| 520 | + res = b64encode(id4.bytes) |
| 521 | + return '_' + res.decode().rstrip('=').translate(str.maketrans('+/', '_-')) |
| 522 | + |
514 | 523 | # %% ../nbs/03_xtras.ipynb |
515 | 524 | def friendly_name(levels=3, suffix=4): |
516 | 525 | "Generate a random human-readable name with customizable word levels and suffix length" |
|
0 commit comments