As already discussed with Brian on IRC, the patch removes a * import of Pykickstart constants into the Anaconda constants module and imports all Pykickstart constants directly where needed.
This should result in more readable & robust code and eliminate the possibility of some very easy to do mistakes.
Martin Kolman (1): Import Pykickstart constants directly
anaconda | 2 +- pyanaconda/constants.py | 4 +--- pyanaconda/packaging/__init__.py | 4 +++- pyanaconda/packaging/dnfpayload.py | 7 ++++--- 4 files changed, 9 insertions(+), 8 deletions(-)
This gets rid of a import * of all constants from Pykickstart in out constants module, which has a quite big potential for breakage.
Also split a long import line in packaging.
Signed-off-by: Martin Kolman mkolman@redhat.com --- anaconda | 2 +- pyanaconda/constants.py | 4 +--- pyanaconda/packaging/__init__.py | 4 +++- pyanaconda/packaging/dnfpayload.py | 7 ++++--- 4 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/anaconda b/anaconda index a725e09..027a55b 100755 --- a/anaconda +++ b/anaconda @@ -1095,7 +1095,7 @@ if __name__ == "__main__": if anaconda.displayMode != 'g': if not anaconda.ksdata.xconfig.startX: anaconda.ksdata.skipx.skipx = True - from pyanaconda.constants import DISPLAY_MODE_CMDLINE, DISPLAY_MODE_TEXT + from pykickstart.constants import DISPLAY_MODE_CMDLINE, DISPLAY_MODE_TEXT if anaconda.displayMode == 'c': anaconda.ksdata.displaymode.displayMode = DISPLAY_MODE_CMDLINE else: diff --git a/pyanaconda/constants.py b/pyanaconda/constants.py index 4f9b64a..219bfe3 100644 --- a/pyanaconda/constants.py +++ b/pyanaconda/constants.py @@ -30,9 +30,7 @@ SELINUX_DEFAULT = -1 # where to look for 3rd party addons ADDON_PATHS = ["/usr/share/anaconda/addons"]
-# pull in kickstart constants as well -# pylint: disable=wildcard-import -from pykickstart.constants import * +from pykickstart.constants import AUTOPART_TYPE_LVM
# common string needs to be easy to change from pyanaconda import product diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py index 273467f..c101fba 100644 --- a/pyanaconda/packaging/__init__.py +++ b/pyanaconda/packaging/__init__.py @@ -39,7 +39,9 @@ if __name__ == "__main__": from pyanaconda import anaconda_log anaconda_log.init()
-from pyanaconda.constants import DRACUT_ISODIR, DRACUT_REPODIR, GROUP_ALL, GROUP_DEFAULT, GROUP_REQUIRED, DD_ALL, DD_FIRMWARE, DD_RPMS, INSTALL_TREE, ISO_DIR, THREAD_STORAGE, THREAD_WAIT_FOR_CONNECTING_NM +from pyanaconda.constants import DRACUT_ISODIR, DRACUT_REPODIR, DD_ALL, DD_FIRMWARE, DD_RPMS, INSTALL_TREE, ISO_DIR +from pyanaconda.constants import THREAD_STORAGE, THREAD_WAIT_FOR_CONNECTING_NM +from pykickstart.constants import GROUP_ALL, GROUP_DEFAULT, GROUP_REQUIRED from pyanaconda.flags import flags
from pyanaconda import iutil diff --git a/pyanaconda/packaging/dnfpayload.py b/pyanaconda/packaging/dnfpayload.py index 2995b98..a7e23c3 100644 --- a/pyanaconda/packaging/dnfpayload.py +++ b/pyanaconda/packaging/dnfpayload.py @@ -31,6 +31,7 @@ import logging import multiprocessing import operator import pyanaconda.constants as constants +from pykickstart.constants import GROUP_ALL, GROUP_DEFAULT import pyanaconda.errors as errors import pyanaconda.iutil import pyanaconda.localization @@ -220,9 +221,9 @@ class DNFPayload(packaging.PackagePayload):
for group in self.data.packages.groupList: try: - default = group.include in (constants.GROUP_ALL, - constants.GROUP_DEFAULT) - optional = group.include == constants.GROUP_ALL + default = group.include in (GROUP_ALL, + GROUP_DEFAULT) + optional = group.include == GROUP_ALL self._select_group(group.name, default=default, optional=optional) except packaging.NoSuchGroup as e: self._miss(e)
On Thu, 2014-06-26 at 11:12 +0200, Martin Kolman wrote:
This gets rid of a import * of all constants from Pykickstart in out constants module, which has a quite big potential for breakage.
Also split a long import line in packaging.
Signed-off-by: Martin Kolman mkolman@redhat.com
anaconda | 2 +- pyanaconda/constants.py | 4 +--- pyanaconda/packaging/__init__.py | 4 +++- pyanaconda/packaging/dnfpayload.py | 7 ++++--- 4 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/anaconda b/anaconda index a725e09..027a55b 100755 --- a/anaconda +++ b/anaconda @@ -1095,7 +1095,7 @@ if __name__ == "__main__": if anaconda.displayMode != 'g': if not anaconda.ksdata.xconfig.startX: anaconda.ksdata.skipx.skipx = True
from pyanaconda.constants import DISPLAY_MODE_CMDLINE, DISPLAY_MODE_TEXT
from pykickstart.constants import DISPLAY_MODE_CMDLINE, DISPLAY_MODE_TEXT
Oh yeez. Thanks for this patch! Big ACK.
anaconda-patches@lists.fedorahosted.org