MCPcopy Create free account
hub / github.com/917Dhj/DeepPaperNote / shell_config_value

Function shell_config_value

scripts/common.py:223–243  ·  view source on GitHub ↗
(name: str)

Source from the content-addressed store, hash-verified

221
222
223def shell_config_value(name: str) -> str:
224 pattern = re.compile(rf"^\s*(?:export\s+)?{re.escape(name)}=(.*)$")
225 for path in SHELL_CONFIG_FILES:
226 if not path.exists() or not path.is_file():
227 continue
228 try:
229 lines = path.read_text(encoding="utf-8").splitlines()
230 except Exception:
231 continue
232 for raw_line in reversed(lines):
233 line = raw_line.strip()
234 if not line or line.startswith("#"):
235 continue
236 match = pattern.match(line)
237 if not match:
238 continue
239 value = match.group(1).strip()
240 if len(value) >= 2 and value[0] == value[-1] and value[0] in {'"', "'"}:
241 value = value[1:-1]
242 return value.strip()
243 return ""
244
245
246def env_config_value(*names: str, default: str = "") -> str:

Callers 1

env_config_valueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected