snu-quiqcl / qiwis

QuIqcl Widget Integration Software
MIT License
5 stars 2 forks source link

Global constant namespace #189

Closed kangz12345 closed 1 year ago

kangz12345 commented 1 year ago

This closes #185.

As discussed in #185, I used namedtuple for the namespace. Moreover, to make it constant, or immutable, I converted all the lists and dicts to tuples and MappingPrxoyTypes, respectively.

Since they become immutable, I decided to share a single namedtuple object across all the apps, by assigning it as an internal (protected) class attribute _constants. For the access, BaseApp now provides a read-only property constants.

Since the global constant namespace is independent to Qiwis object, the setter function set_global_constant_namespace() is defined in module-level.

For the naming convention of namedtuples, I mimicked the Python built-in type name styles, e.g., contextmanager, unittest, namedtuple, defaultdict, etc.

Now the setup.json can contain "constant" section as well.

kangz12345 commented 1 year ago

It seems the GitHub action cannot install the dependencies well. I tried several times to pass.