提交 450efff6 authored 作者: Ricardo Vieira's avatar Ricardo Vieira 提交者: Ricardo Vieira

Use more specialized imports in config utils

上级 35992576
...@@ -3,10 +3,10 @@ import logging ...@@ -3,10 +3,10 @@ import logging
import os import os
import platform import platform
import re import re
import shutil
import sys import sys
import textwrap import textwrap
from pathlib import Path from pathlib import Path
from shutil import which
import numpy as np import numpy as np
...@@ -348,7 +348,7 @@ def add_compile_configvars(): ...@@ -348,7 +348,7 @@ def add_compile_configvars():
# Try to find the full compiler path from the name # Try to find the full compiler path from the name
if param != "": if param != "":
newp = shutil.which(param) newp = which(param)
if newp is not None: if newp is not None:
param = newp param = newp
del newp del newp
......
import logging import logging
import os import os
import shlex
import sys import sys
import warnings import warnings
from collections.abc import Callable, Sequence from collections.abc import Callable, Sequence
...@@ -14,6 +13,7 @@ from configparser import ( ...@@ -14,6 +13,7 @@ from configparser import (
from functools import wraps from functools import wraps
from io import StringIO from io import StringIO
from pathlib import Path from pathlib import Path
from shlex import shlex
from pytensor.utils import hash_from_code from pytensor.utils import hash_from_code
...@@ -541,7 +541,7 @@ def parse_config_string( ...@@ -541,7 +541,7 @@ def parse_config_string(
Parses a config string (comma-separated key=value components) into a dict. Parses a config string (comma-separated key=value components) into a dict.
""" """
config_dict = {} config_dict = {}
my_splitter = shlex.shlex(config_string, posix=True) my_splitter = shlex(config_string, posix=True)
my_splitter.whitespace = "," my_splitter.whitespace = ","
my_splitter.whitespace_split = True my_splitter.whitespace_split = True
for kv_pair in my_splitter: for kv_pair in my_splitter:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论