Skip to content

DevNotes_Projects_categories

Ricardo M. Ferraz Leal edited this page Apr 11, 2019 · 4 revisions

Categories in Sansview

Description

Categories in Sansview is a new project to categorise the SANS models for easy selection from the GUI. In the fitpanel brought up are two listboxes - on containing relevant categories, the other containing the models belonging to the selected category.

Categories of a given model can be modified and the model shown/hidden from the UI using the Category Manager. This can be accessed via View ⇒ CategoryManager? . A model can also belong to multiple categories.

Architecture

Categories are stored in a dictionary that links categories to model names. The setup script was modified to scan the Sansview installation to find all installed models. The categorisation is stored in a python defaultdict linking each category name to a list of models. These are then serialized to file using the python library cPickle which provides fast data access and reading for a python data structure.

There are three different data containers needed for smooth operator of the category model - master category dict, by model dict and model enabled dict. The first of these, master category dict is a defaultdict linking each cate- gory name (a string) to a python list of tuples, the first entry being the model name, and the second entry being whether the model has enabled or not by the user in the UI. Obviously the entire informational content of the category mechanism is stored here.

The other two data structures exist to provide fast access in the opposite direction. Say, for example, we want to find all the categories a given model is in. We would need to trawl through the dictionary picking out all the (key, value) pairs corresponding to a particular model. Instead we use by model dict whose keys are the model name and whose values are lists of categories that contain a certain model. The same applies to finding whether a model is enabled. We have model enabed dict whose keys are model names and whose values are bools corresponding to whether the model should be shown in the GUI or not.

Two methods exist to generate the structures from each other. regenerate master dict will create master category dict from by model dict and model enabled dict. regenerate model dict will create by model dict and model enabled dict from master category dict. These methods are implemented in different places depending on the exact usage. A good place to start is with the methods and docs in CategoryManager? . They’re also implemented in basepage.py and CategoryInstaller? .

Contact

kieranrcampbell {AT} gmail.com for details

Clone this wiki locally