Overview¶
Library Reference¶
Packages
Internal Packages¶
Packages
Main Classes (Summary)¶
Filesystem¶
Object Parser¶
Shell¶
Main Classes (Expanded)¶
- class mash.filesystem.FileSystem(root: dict = None, home: ~typing.List[str | int] | str | int = None, get_hook: ~typing.Callable[[str | int, ~mash.filesystem.view.View], str | int] = <function first>, post_cd_hook: ~typing.Callable = <function none>, **dict_kwds)[source]¶
A filesystem-like interface for static and dynamic data. This can be used to e.g. browse REST APIs.
- cp(*references: str | int)[source]¶
Copy references.
Usage¶
cp(a, b) # Let b point to the value referenced by a. cp(*a, b) # let b contain the pointers *a.
- foreach(path: List[str | int] | str | int) List[List[str | int] | str | int] [source]¶
List all objects in the dir associated with each path, recursively.
Usage:
# GET repository/users/{id}/email foreach repository users email >>= echo 'email:' $
- get(path: List[str | int] | str | int, relative=True)[source]¶
Return the value of the file associated with path.
- ll(*path: str, delimiter='\n', include_list_indices=False) str [source]¶
Return a formatted result of ls().
- ls(*paths: List[str | int] | str | int) List[str | int] [source]¶
List all objects in the dir associated with each path. If this dir is a path, then its properties are returned. Objects that start with HIDE_PREFIX are ignored.
- class mash.filesystem.Discoverable(*args, get_value_method: Callable[[FileSystem, str | int, dict | list, View], dict | list] | str = None, **kwds)[source]¶
- class mash.filesystem.view.View(tree: dict | list, _trace: ~typing.List[~typing.Tuple[str | int, dict | list]] = <factory>)[source]¶
A tree of dict’s. Tree traversal is exposed through the methods up and down.
- class mash.filesystem.Option(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Filesystem traversal options.
default = '~' home = '~' root = '/' stay = '.' switch = '-' up = '..' upup = '...' upupup = '....'
- mash.filesystem.OPTIONS = ['~', '/', '.', '-', '..', '...', '....']¶
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
- class mash.object_parser.OAS(*args, **kwds)[source]¶
A key-value map that represents an OAS. It that can be converted to JSON or YAML and viewed in: https://editor.swagger.io/
- extend(obj: object)[source]¶
Generate OAS/Swagger components from a class See: [OAS](https://swagger.io/specification/) E.g.
components: schemas: User: properties: id: type: integer name: type: string
- class mash.shell.ShellWithFileSystem(data={}, repository: FileSystem = None, **kwds)[source]¶
- cd(*path: str)[source]¶
Change directory and finally reset the current directory. Stay in the current directory by default.
- class mash.shell.Shell(*args, env: ~typing.Dict[str, ~typing.Any] = None, use_model=True, save_session_prehook=<function identity>, load_session_posthook=<function identity>, **kwds)[source]¶
Extend BaseShell with a language model: Support multiline statements, pipes, conditions, variables and inline function definitions.
The language grammer is based on a BNF-based grammer, which is defined in shell.grammer.parser
The AST is implemented here: shell.ast
The language implementation is defined in shell.ast.
- class mash.shell.base.BaseShell(*args, env: ~typing.Dict[str, ~typing.Any] = None, use_model=True, save_session_prehook=<function identity>, load_session_posthook=<function identity>, **kwds)[source]¶
Extend Cmd with various capabilities. This class is restricted to functionality that requires Cmd methods to be overrriden.
Features:
An environment with local and global variable scopes.
Save/load sessions.
Decoration with functions, both at runtime and compile time.
- add_functions(functions: Dict[str, ShellFunction], group_key=None)[source]¶
Add functions to this instance at runtime. Use a key to select a group of functions.
Parameters¶
- functionsdict
A dictionary of functions to add.
- group_keystr
A key to select a group of functions.
Check whether k is an existing hidden function.
- is_inline_function(k: str) bool [source]¶
Check whether k is an existing inline (user-defined) function.
- last_method()[source]¶
Find the method corresponding to the last command run in shell. It has the form: do_{cmd}
Return a the last method if it exists and None otherwise.
- load_session(session: str, strict=True)[source]¶
Load a session.
arameters¶
- sessionstr
The session file to load.
- strictbool
If True, raise an error if the session file is not found.
- postcmd(stop, _)[source]¶
Display the shell_ready_signal to indicate termination to a parent process.
- remove_functions(group_key=None)[source]¶
Remove functions to this instance at runtime. Use a key to select a group of functions
Run a hidden function. See base.is_hidden_function