MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / parse_env_file

Function parse_env_file

vmm/src/vmm-cli.py:1278–1298  ·  view source on GitHub ↗

Parse an environment file into a dictionary of key-value pairs. Each line should be formatted as KEY=Value. Lines that are empty or start with '#' are ignored.

(file_path: str)

Source from the content-addressed store, hash-verified

1276
1277
1278def parse_env_file(file_path: str) -> Dict[str, str]:
1279 """Parse an environment file into a dictionary of key-value pairs.
1280
1281 Each line should be formatted as KEY=Value.
1282 Lines that are empty or start with '#' are ignored.
1283
1284 """
1285 if not file_path:
1286 return {}
1287
1288 envs = {}
1289 with open(file_path, "r") as f:
1290 for line in f:
1291 line = line.strip()
1292 if not line or line.startswith("#"):
1293 continue
1294 if "=" not in line:
1295 continue
1296 key, value = line.split("=", 1)
1297 envs[key.strip()] = value.strip()
1298 return envs
1299
1300
1301def parse_size(s: str, target_unit: str) -> int:

Callers 4

create_app_composeMethod · 0.85
create_vmMethod · 0.85
update_vmMethod · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected