Compare commits

..

No commits in common. "09f39befa72dc7cf551cdb5f8f37508d5b988c5c" and "0562772dc877bc9dc707af7cf62cc47320c567e9" have entirely different histories.

2 changed files with 21 additions and 23 deletions

View file

@ -1,4 +1,4 @@
__version__ = "v0.2.5-6" __version__ = "0.2.5-5"
__author__ = "Reid D. 'arrdem' McKenzie <me@arrdem.com>" __author__ = "Reid D. 'arrdem' McKenzie <me@arrdem.com>"
__copyright__ = "Copyright 2020" __copyright__ = "Copyright 2020"
__license__ = "https://anticapitalist.software/" __license__ = "https://anticapitalist.software/"

View file

@ -17,14 +17,11 @@ if sys.version_info <= (3, 9, 0):
Path.readlink = lambda p: Path(os.readlink(str(p))) Path.readlink = lambda p: Path(os.readlink(str(p)))
def sh(global_config, cmd: List[str], /, env: Optional[dict] = None): def sh(global_config,
shell = ( cmd: List[str], /,
(global_config or {}) env: Optional[dict] = None):
.get("cram", {})
.get("task", {}) shell = (global_config or {}).get("cram", {}).get("task", {}).get("apply", {}).get("shell", SHELL)
.get("apply", {})
.get("shell", SHELL)
)
prefix = [] prefix = []
if env: if env:
@ -96,20 +93,21 @@ class Package(object):
def expandvars(s: str) -> str: def expandvars(s: str) -> str:
def _repl(m: re.Match) -> str: def _repl(m: re.Match) -> str:
var = m.group(0).lower() var = m.group(0).lower()
if var == "${hostname}": match var:
return os.uname()[1].split(".")[0] case "${hostname}":
elif var == "${fqdn}": return os.uname()[1].split(".")[0]
return os.uname()[1] case "${fqdn}":
elif var == "${home}": return os.uname()[1]
return os.path.expanduser("~") case "${home}":
elif var == "${uname}" | "${sysname}": return os.path.expanduser("~")
return platform.system().lower() case "${uname}" | "${sysname}":
elif var == "${arch}": return platform.system().lower()
return platform.machine() case "${arch}":
elif var == "${release}": return platform.machine()
return platform.release() case "${release}":
else: return platform.release()
return os.path.expandvars(m.group(0)) case _:
return os.path.expandvars(m.group(0))
s = re.sub(r"\${?([^\s}]+)}?", "${\\1}", s) s = re.sub(r"\${?([^\s}]+)}?", "${\\1}", s)
return re.sub(r"\$\{.*?\}", _repl, s) return re.sub(r"\$\{.*?\}", _repl, s)