index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | Anton Hvornum <anton@hvornum.se> | 2021-03-09 23:39:11 +0100 |
---|---|---|
committer | Anton Hvornum <anton@hvornum.se> | 2021-03-09 23:39:11 +0100 |
commit | e2aeb3a32faa397db899f4105a16f31a095387be (patch) | |
tree | 007129425274e4efee38622c8cf5f912074a5531 /archinstall/lib/profiles.py | |
parent | 48e9f13f0105e449c95e52672d1bf98e6e6b5d65 (diff) | |
parent | cfbaaedb17e9ad6975a5bb37095e2b4ebe8e6797 (diff) |
-rw-r--r-- | archinstall/lib/profiles.py | 17 |
diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py index f9aa206c..01c3288c 100644 --- a/archinstall/lib/profiles.py +++ b/archinstall/lib/profiles.py @@ -157,6 +157,23 @@ class Profile(Script): def install(self): return self.execute() + def has_prep_function(self): + with open(self.path, 'r') as source: + source_data = source.read() + + # Some crude safety checks, make sure the imported profile has + # a __name__ check and if so, check if it's got a _prep_function() + # we can call to ask for more user input. + # + # 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 '_prep_function' in source_data: + with self.load_instructions(namespace=f"{self.namespace}.py") as imported: + if hasattr(imported, '_prep_function'): + return True + return False + class Application(Profile): def __repr__(self, *args, **kwargs): return f'Application({os.path.basename(self.profile)})' |