unbox.recipes¶
Recipes using unbox
Functions
|
|
|
Generates (module_dotpath, imported_module_dotpaths) pairs from a package, recursively. |
|
Generates (k, line) pairs for every line of every k that has a pattern match |
|
Generates (k, pattern_counts) pairs from scanning a store of .py files it scans, counting pattern matches |
|
Prints (module_dotpath, imported_module_dotpaths) pairs from a package, recursively. |
|
Print (k, line) pairs for every line of every k that has a pattern match |
|
|
|
Generator of builtin names that don't have a signature |
Classes
|
Keys are module dotpaths and values are modules |
- class unbox.recipes.ModuleStrings(*args, read_retry=None, strict_key_errors=False, **kwargs)[source]¶
Bases:
StoreKeys are module dotpaths and values are modules
- is_valid_key(k, *args, __name='is_valid_key', **kwargs)¶
is_valid_keyon the inner key – seemk_relative_path_store.
- validate_key(k, *args, __name='validate_key', **kwargs)¶
validate_keyon the inner key – seemk_relative_path_store.
- unbox.recipes.imports_of_package(package, module_dotpath_filt=None, imported_module_dotpath_filt=None, depth=None)[source]¶
Generates (module_dotpath, imported_module_dotpaths) pairs from a package, recursively.
- Parameters:
package – Module, file, folder, or dotpath of package to root the generation from
module_dotpath_filt – Filter function for module dotpaths
imported_module_dotpath_filt – Filter function for imported module dotpaths
depth – How deep the recursion should be
- Returns:
A generator of (module_dotpath, imported_module_dotpaths) pairs
>>> import unbox >>> for module_dotpath, imported_module_dotpaths in imports_of_package( ... unbox, ... module_dotpath_filt = lambda x: '__init__' not in x, ... depth=1): ... print(f"{module_dotpath}: {sorted(imported_module_dotpaths)[:3]}" ... ) _acquire_builtin_names: ['bs4', 'contextlib', 'dol.filesys'] missing_install_names: ['collections', 'config2py', 'json'] recipes: ['dol', 'dol.filesys', 'importlib'] base: ['builtins', 'collections', 'contextlib']
- unbox.recipes.key_and_matched_lines(files, pattern)[source]¶
Generates (k, line) pairs for every line of every k that has a pattern match
- Parameters:
- Returns:
A generator of (k, pattern_counts) pairs
See also
key_and_pattern_counts
- unbox.recipes.key_and_pattern_counts(files, pattern)[source]¶
Generates (k, pattern_counts) pairs from scanning a store of .py files it scans, counting pattern matches
- Parameters:
- Returns:
A generator of (k, pattern_counts) pairs
In order to be able to replicate this test we’ll mention a word that has little chance of showing up in an uncontrolled matter in this this unbox package. This word: supercalifragilisticexpialidocious It should appear only twice in this current recipes.py – once above, and once when we ask for key_and_pattern_counts to match it.
Now, let’s see:
>>> import unbox >>> sorted(key_and_pattern_counts(unbox, 'supercalifragilisticexpialidocious')) [('__init__.py', 0), ('_acquire_builtin_names.py', 0), ('base.py', 0), ('dependencies.py', 0), ('missing_install_names.py', 0), ('recipes.py', 2)]
- unbox.recipes.print_imports_of_package(package, module_dotpath_filt=None, imported_module_dotpath_filt=None, depth=None)[source]¶
Prints (module_dotpath, imported_module_dotpaths) pairs from a package, recursively.
- Parameters:
package – Module, file, folder, or dotpath of package to root the generation from
module_dotpath_filt – Filter function for module dotpaths
imported_module_dotpath_filt – Filter function for imported module dotpaths
depth – How deep the recursion should be
- Returns:
prints the (module_dotpath, imported_module_dotpaths) pairs