MCPcopy
hub / github.com/scrapy/scrapy / get_shell_embed_func

Function get_shell_embed_func

scrapy/utils/console.py:101–119  ·  view source on GitHub ↗

Return the first acceptable shell-embed function from a given list of shell names.

(
    shells: Iterable[str] | None = None, known_shells: KnownShellsT | None = None
)

Source from the content-addressed store, hash-verified

99
100
101def get_shell_embed_func(
102 shells: Iterable[str] | None = None, known_shells: KnownShellsT | None = None
103) -> EmbedFuncT | None:
104 """Return the first acceptable shell-embed function
105 from a given list of shell names.
106 """
107 if shells is None: # list, preference order of shells
108 shells = DEFAULT_PYTHON_SHELLS.keys()
109 if known_shells is None: # available embeddable shells
110 known_shells = DEFAULT_PYTHON_SHELLS.copy()
111 for shell in shells:
112 if shell in known_shells:
113 try:
114 # function test: run all setup code (imports),
115 # but dont fall into the shell
116 return known_shells[shell]()
117 except ImportError:
118 continue
119 return None
120
121
122def start_python_console(

Calls 2

keysMethod · 0.80
copyMethod · 0.45