Seed the cache for filename with module_globals. The module loader will be asked for the source only when getlines is called, not immediately. If there is an entry in the cache already, it is not altered. :return: True if a lazy load is registered in the cache, otherwise F
(filename, module_globals)
| 198 | |
| 199 | |
| 200 | def lazycache(filename, module_globals): |
| 201 | """Seed the cache for filename with module_globals. |
| 202 | |
| 203 | The module loader will be asked for the source only when getlines is |
| 204 | called, not immediately. |
| 205 | |
| 206 | If there is an entry in the cache already, it is not altered. |
| 207 | |
| 208 | :return: True if a lazy load is registered in the cache, |
| 209 | otherwise False. To register such a load a module loader with a |
| 210 | get_source method must be found, the filename must be a cacheable |
| 211 | filename, and the filename must not be already cached. |
| 212 | """ |
| 213 | entry = cache.get(filename, None) |
| 214 | if entry is not None: |
| 215 | return len(entry) == 1 |
| 216 | |
| 217 | lazy_entry = _make_lazycache_entry(filename, module_globals) |
| 218 | if lazy_entry is not None: |
| 219 | cache[filename] = lazy_entry |
| 220 | return True |
| 221 | return False |
| 222 | |
| 223 | |
| 224 | def _make_lazycache_entry(filename, module_globals): |
nothing calls this directly
no test coverage detected
searching dependent graphs…