##// END OF EJS Templates
core.magics.packaging: improve re usage
Blazej Michalik -
Show More
@@ -32,12 +32,14 b' def _get_conda_executable():'
32 32
33 33 # Otherwise, attempt to extract the executable from conda history.
34 34 # This applies in any conda environment.
35 R = re.compile(r"^#\s*cmd:\s*(?P<command>.*conda)\s[create|install]")
36 with open(Path(sys.prefix, "conda-meta", "history")) as f:
37 for line in f:
38 match = R.match(line)
39 if match:
40 return match.groupdict()['command']
35 history = Path(sys.prefix, "conda-meta", "history").read_text()
36 match = re.search(
37 r"^#\s*cmd:\s*(?P<command>.*conda)\s[create|install]",
38 history,
39 flags=re.MULTILINE,
40 )
41 if match:
42 return match.groupdict()["command"]
41 43
42 44 # Fallback: assume conda is available on the system path.
43 45 return "conda"
General Comments 0
You need to be logged in to leave comments. Login now