Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects, and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
AVADSA25
codec
Repository navigation
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
codec
/
codec_config_path.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
30 lines (23 loc) · 1.36 KB
main
Breadcrumbs
codec
/
codec_config_path.py
Copy path
Top
File metadata and controls
Code
Blame
30 lines (23 loc) · 1.36 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""Where CODEC's config.json is (docs/TEST-CONFIG-ISOLATION-DESIGN.md).
Every module that reads or writes the config calls `config_path()` when it opens the
file. It answers `codec_config.CONFIG_PATH` when codec_config is loaded (the one name
tests patch) and otherwise the same rule codec_config uses, without importing it: a
process that never loaded codec_config (the watchdog, the observer) does not start
reading the Keychain just to find the file, and modules codec_config itself imports
(codec_models) get no import cycle. Standard library only.
CODEC_CONFIG_PATH is for the test suite only (tests/conftest.py points it at a
missing temp file); nothing in CODEC sets it. Unset, the path is
os.path.expanduser("~/.codec/config.json"), the path every module built before.
"""
import os
import sys
DEFAULT_CONFIG_PATH = os.path.expanduser("~/.codec/config.json")
def from_env() -> str:
"""CODEC_CONFIG_PATH when set (tests only), else ~/.codec/config.json."""
override = os.environ.get("CODEC_CONFIG_PATH", "")
return os.path.expanduser(override) if override else DEFAULT_CONFIG_PATH
def config_path() -> str:
"""The config.json to open now: codec_config.CONFIG_PATH when loaded, else from_env()."""
mod = sys.modules.get("codec_config")
path = getattr(mod, "CONFIG_PATH", None) if mod is not None else None
return str(path) if path else from_env()
You can’t perform that action at this time.