| 10 | Categories are stored in a dictionary that links categories to model names. |
| 11 | The setup script was modified to scan the Sansview installation to find all |
| 12 | installed models. The categorisation is stored in a python defaultdict linking |
| 13 | each category name to a list of models. These are then serialized to file using |
| 14 | the python library cPickle which provides fast data access and reading for a |
| 15 | python data structure. |
| 16 | |
| 17 | There are three different data containers needed for smooth operator of the |
| 18 | category model - master category dict, by model dict and model enabled dict. |
| 19 | The first of these, master category dict is a defaultdict linking each cate- |
| 20 | gory name (a string) to a python list of tuples, the first entry being the model |
| 21 | name, and the second entry being whether the model has enabled or not by |
| 22 | the user in the UI. Obviously the entire informational content of the category |
| 23 | mechanism is stored here. |
| 24 | |
| 25 | The other two data structures exist to provide fast access in the opposite |
| 26 | direction. Say, for example, we want to find all the categories a given model is |
| 27 | in. We would need to trawl through the dictionary picking out all the (key, value) |
| 28 | pairs corresponding to a particular model. Instead we use by model dict whose |
| 29 | keys are the model name and whose values are lists of categories that contain |
| 30 | a certain model. The same applies to finding whether a model is enabled. We |
| 31 | have model enabed dict whose keys are model names and whose values are |
| 32 | bools corresponding to whether the model should be shown in the GUI or not. |
| 33 | |
| 34 | Two methods exist to generate the structures from each other. regenerate master dict |
| 35 | will create master category dict from by model dict and model enabled dict. |
| 36 | regenerate model dict will create by model dict and model enabled dict |
| 37 | from master category dict. These methods are implemented in different places |
| 38 | depending on the exact usage. A good place to start is with the methods |
| 39 | and docs in CategoryManager. They’re also implemented in basepage.py and |
| 40 | CategoryInstaller. |
| 41 | |
| 42 | |