software-store-developers team mailing list archive
-
software-store-developers team
-
Mailing list archive
-
Message #00057
enums style proposal
Hi folks,
I have just pushed a branch 'enums-style-idea' and thought i should explain
myself.
The main reason i did it was to make our enums imports go from something
akin to this (as seen in appdetailsview_gtk.py):
from softwarecenter.enums import (PKG_STATE_INSTALLING_PURCHASED,
PKG_STATE_INSTALLED,
PKG_STATE_PURCHASED_BUT_REPO_MUST_BE_ENABLED,
PKG_STATE_NEEDS_PURCHASE,
PKG_STATE_NEEDS_SOURCE,
PKG_STATE_UNINSTALLED,
PKG_STATE_REINSTALLABLE,
PKG_STATE_UPGRADABLE,
PKG_STATE_INSTALLING,
PKG_STATE_UPGRADING,
PKG_STATE_REMOVING,
PKG_STATE_NOT_FOUND,
PKG_STATE_UNKNOWN,
APP_ACTION_APPLY,
PKG_STATE_ERROR,
SOFTWARE_CENTER_PKGNAME,
MISSING_APP_ICON,
)
to this:
from softwarecenter.enums import AppActions, PkgStates, Icons,
SOFTWARE_CENTER_PKGNAME
Usage of enums within code would look something like this:
if state == PkgStates.INSTALLED:
Besides the import clarity it makes browsing enums.py easier when using a
python class-browser and i think going forward it makes the enums style
similar to both qml, pyside (Qt.LeftButton for example) and also the gi
enums style.
The downside is we obviously lose a some granularity as far as importing
specific enums but i doubt this is a major.
Enums that dont really fit into a logical group i have left separate, i.e.
SOFTWARE_CENTER_PKGNAME remains an 'ungrouped' enum. There are a few other
examples.
So is this a good idea or not?
Cheers,
Matt
--
>From the mind of me!
Follow ups