File: DescriptionsIndex.py

package info (click to toggle)
mobyle 1.5.5%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 8,288 kB
  • sloc: python: 22,709; makefile: 35; sh: 33; ansic: 10; xml: 6
file content (47 lines) | stat: -rw-r--r-- 1,665 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#############################################################
#                                                           #
#   Author: Herve Menager                                   #
#   Organization:'Biological Software and Databases' Group, #
#                Institut Pasteur, Paris.                   #
#   Distributed under GPLv2 Licence. Please refer to the    #
#   COPYING.LIB document.                                   #
#                                                           #
#############################################################
"""
Mobyle.Index

This module manages the list of available programs to:
 - search them (using search fields)
 - classify them (building the categories tree)
 - cache this information (on disk as a JSON file)
"""
from Mobyle.Registry import registry

from logging import getLogger
r_log = getLogger(__name__)

from Mobyle import IndexBase

queries = {
           'description': '/*/head/doc/description//text()',
          }

class DescriptionsIndex(IndexBase.Index):
    
    indexFileName = 'descriptions.dat'
    
    def fillRegistry(self):
        for url, description in self.index.items():
            if registry.programsByUrl.has_key(url):
                registry.programsByUrl[url].description = description
            if registry.workflowsByUrl.has_key(url):
                registry.workflowsByUrl[url].description = description
    
    @classmethod
    def getIndexEntry(cls, doc, program):
        """
        Return an description index entry value
        @return: the index entry: value
        @rtype: object
        """
        return IndexBase._XPathQuery(doc, queries['description'])