Skip to content

Add .env (dotenv) parsing and serialisation#287

Merged
JE-Chen merged 1 commit into
devfrom
feat/dotenv-batch
Jun 21, 2026
Merged

Add .env (dotenv) parsing and serialisation#287
JE-Chen merged 1 commit into
devfrom
feat/dotenv-batch

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 21, 2026

Copy link
Copy Markdown
Member

What

Adds .env ingestion — load_vars_from_json only read flat JSON, and nothing read the de-facto 12-factor .env file. No python-dotenv dependency.

  • parse_dotenv(text) → ordered {key: value}; honours export prefixes, single-quote literals, double-quote \n/\t/\/\" escapes, unquoted inline # comments, key validation.
  • dotenv_values(path) reads + parses a file.
  • load_dotenv(path, env, *, override=False) merges into a caller-supplied mapping (never os.environ implicitly).
  • dump_dotenv(mapping) serialises back, quoting when needed.

Layers

  • Headless core: utils/dotenv/ (pure stdlib re, zero PySide6).
  • Facade: 4 symbols + __all__.
  • Executor: AC_parse_dotenv, AC_load_dotenv.
  • MCP: ac_parse_dotenv, ac_load_dotenv (read-only).
  • Script Builder: both under Data.
  • Tests: test/unit_test/headless/test_dotenv_batch.py (9 tests, no Qt).
  • Docs: v79_features_doc.rst (EN + Zh) + toctrees + 3 README What's-new sections.

Verification

  • pytest test/unit_test/headless/test_dotenv_batch.py → 9 passed.
  • ruff check je_auto_control/ clean; pylint 10.00/10; bandit clean; radon CC clean.
  • Package stays Qt-free.

load_vars_from_json ingested flat JSON, but nothing read the de-facto
12-factor .env file. Add parse_dotenv / load_dotenv / dotenv_values /
dump_dotenv (export prefixes, single/double quoting, escapes, inline
comments) with no python-dotenv dependency. The loader merges into a
caller-supplied mapping rather than mutating os.environ. Wired through
facade, executor (AC_parse_dotenv / AC_load_dotenv), MCP, and the Script
Builder with a headless test batch and EN/Zh docs.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 48 complexity · 0 duplication

Metric Results
Complexity 48
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@JE-Chen JE-Chen merged commit 7b86ac0 into dev Jun 21, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/dotenv-batch branch June 21, 2026 14:31
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant