index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | Anton Hvornum <anton.feeds@gmail.com> | 2021-03-25 15:07:49 +0100 |
---|---|---|
committer | Anton Hvornum <anton.feeds@gmail.com> | 2021-03-25 15:07:49 +0100 |
commit | 99dd9b1fb7856b864d816119f0742950941e97a8 (patch) | |
tree | 23677aa0cb498a954160a8569d1889a344f31ef1 /archinstall/lib/profiles.py | |
parent | b521f8028c0074811029f8b294f5c6a50064a630 (diff) |
-rw-r--r-- | archinstall/lib/profiles.py | 22 |
diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py index 08b1d618..8198ff11 100644 --- a/archinstall/lib/profiles.py +++ b/archinstall/lib/profiles.py @@ -178,6 +178,28 @@ class Profile(Script): return True return False + @property + def packages(self) -> list: + """ + Returns a list of packages baked into the profile definition. + If no package definition has been done, .packages() will return None. + """ + with open(self.path, 'r') as source: + source_data = source.read() + + # Some crude safety checks, make sure the imported profile has + # a __name__ check before importing. + # + # If the requirements are met, import with .py in the namespace to not + # trigger a traditional: + # if __name__ == 'moduleName' + if '__name__' in source_data and '__packages__' in source_data: + with self.load_instructions(namespace=f"{self.namespace}.py") as imported: + if hasattr(imported, '__packages__'): + return imported.__packages__ + return None + + class Application(Profile): def __repr__(self, *args, **kwargs): return f'Application({os.path.basename(self.profile)})' |