API

digitout_silent(target, config=None, context=None)

Show source code in digitout/app.py
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
def digitout_silent(target, config=None, context=None):
    """
    Silent version of [digitout_verbose][digitout.app.digitout_verbose]. It is dedicated to the users
    who don't want the results to get printed in the console. This is a good choice
    if one would like to integrate digitout with his application.

    Arguments and returned value are the same as for [digitout_verbose][digitout.app.digitout_verbose].
    """
    if config is None:
        config = DEFAULT_CONFIG
    elif isinstance(config, str):
        config = load_config(config)

    findall = False
    interactive = False
    verbose = False

    dio = DigItOut(config, findall, interactive, verbose, context)
    return dio.search(target)

Silent version of digitout_verbose. It is dedicated to the users who don't want the results to get printed in the console. This is a good choice if one would like to integrate digitout with his application.

Arguments and returned value are the same as for digitout_verbose.

digitout_verbose(target, config=None, context=None)

Show source code in digitout/app.py
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
def digitout_verbose(target: Any,
                     config: Union[type(None), str, dict] =None,
                     context: Union[type(None), dict] =None) -> Tuple[str, dict]:
    """
    Traverses through the Python structures until constraint defined in the
    config is met. This function is designed for finding path to the objects
    that you don't know how to get to.

    This function can be called by calling `digitout` module itself. E.g.

    ```python
    import digitout
    digitout(foobar)
    ```

    Arguments:
        target: Top-level object where searching should start from.
        config: `None` - Open TUI if TTY available, or load default config otherwise.
                `str` instance - name of the config to get loaded.
                `dict` instance - config given explicitly.
        context: Variables that should be accessible to the lambda expressions
          defined in the config. Usually `locals()` is passed.

    Returns:
        `(path, match)` pair, where `path` - expressions that evaluates to the
          match, or `None` if match not found. `match` - `dict` of the keys
          which are args of the *Target Constraint* and values corresponding
          the the match, or `None` if match not found.
    """
    if config is None:
        if sys.stdout.isatty():
            config = open_tui()
        else:
            config = DEFAULT_CONFIG
    elif isinstance(config, str):
        config = load_config(config)

    findall = True
    interactive = sys.stdout.isatty()
    verbose = True

    dio = DigItOut(config, findall, interactive, verbose, context)
    return dio.search(target)

Traverses through the Python structures until constraint defined in the config is met. This function is designed for finding path to the objects that you don't know how to get to.

This function can be called by calling digitout module itself. E.g.

import digitout
digitout(foobar)

Parameters

Name Type Description Default
target Any Top-level object where searching should start from. required
config Union[NoneType, str, dict] None - Open TUI if TTY available, or load default config otherwise. str instance - name of the config to get loaded. dict instance - config given explicitly. None
context Union[NoneType, dict] Variables that should be accessible to the lambda expressions defined in the config. Usually locals() is passed. None

Returns

Type Description
Tuple[str, dict] (path, match) pair, where path - expressions that evaluates to the match, or None if match not found. match - dict of the keys which are args of the Target Constraint and values corresponding the the match, or None if match not found.