We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 3339766 + b6231f8 commit 5f5e291Copy full SHA for 5f5e291
1 file changed
pyinfra_windows/facts/winget.py
@@ -0,0 +1,33 @@
1
+from __future__ import annotations
2
+
3
+from typing_extensions import override
4
5
+from pyinfra.api import FactBase
6
7
+from pyinfra.facts.util.packaging import parse_packages
8
9
+WINGET_REGEX = r"([^\s]+)\s+([^\s]+)"
10
11
12
+class WingetPackages(FactBase):
13
+ """ Returns a dict of installed winget packages:
14
15
+ .. code:: python
16
17
+ {
18
+ "package_name": ["version"],
19
+ }
20
+ """
21
22
+ @override
23
+ def command(self) -> str:
24
+ return "Get-WingetPackage | Select -Property Id, InstalledVersion"
25
26
+ shell_executable = "ps"
27
28
+ default = dict
29
30
31
+ def process(self, output):
32
+ packages = parse_packages(WINGET_REGEX, output)
33
+ return packages
0 commit comments