Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 781875 - sys-apps/portage: improve make.conf parser
Summary: sys-apps/portage: improve make.conf parser
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Configuration (show other bugs)
Hardware: All All
: Normal enhancement (vote)
Assignee: Portage team
Depends on:
Reported: 2021-04-09 21:41 UTC by Zac Medico
Modified: 2021-04-09 22:47 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Note You need to log in before you can comment on or make changes to this bug.
Description Zac Medico gentoo-dev 2021-04-09 21:41:31 UTC
The variable expansion support in this library could be useful:

We can use it when available, and otherwise fallback to our existing portage.util.getconfig() implementation.
Comment 1 Zac Medico gentoo-dev 2021-04-09 22:05:41 UTC
(In reply to Zac Medico from comment #0)
> The variable expansion support in this library could be useful:

I've checked the code, and it actually uses this regular expression to search for variable references and expand them on-demand (portage can't use it):

_EXPANDED_VAR_PATTERN = re.compile(r"(?<!\\)\$\{([A-Za-z0-9_]+)(:-[^\}:]*)?\}")
Comment 2 Zac Medico gentoo-dev 2021-04-09 22:11:05 UTC
python-dotenv might be usable, and supports default values with this regex:

_posix_variable = re.compile(
)  # type: Pattern[Text]
Comment 3 Zac Medico gentoo-dev 2021-04-09 22:19:35 UTC
Since python-dotenv requires { and } to surround variables names, it's only useful in the sense that we can copy and modify its _posix_variable regex.