Summary: | sys-apps/portage: improve make.conf parser | ||
---|---|---|---|
Product: | Portage Development | Reporter: | Zac Medico <zmedico> |
Component: | Core - Configuration | Assignee: | Portage team <dev-portage> |
Status: | CONFIRMED --- | ||
Severity: | enhancement | CC: | gentoo, sam |
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | All | ||
See Also: | https://bugs.gentoo.org/show_bug.cgi?id=338555 | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- |
Description
Zac Medico
2021-04-09 21:41:31 UTC
(In reply to Zac Medico from comment #0) > The variable expansion support in this library could be useful: > > https://github.com/sloria/environs#variable-expansion 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_]+)(:-[^\}:]*)?\}") python-dotenv might be usable, and supports default values with this regex: _posix_variable = re.compile( r""" \$\{ (?P<name>[^\}:]*) (?::- (?P<default>[^\}]*) )? \} """, re.VERBOSE, ) # type: Pattern[Text] https://github.com/theskumar/python-dotenv/blob/master/src/dotenv/variables.py 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. |