27
27
28
28
import os
29
29
30
+ displayNames = {}
31
+ classification = {}
30
32
31
- class AlgorithmDecorator :
32
-
33
- classification = {}
34
-
35
- @staticmethod
36
- def loadClassification ():
37
- if not os .path .isfile (AlgorithmDecorator .classificationFile ()):
38
- return
39
- lines = open (AlgorithmDecorator .classificationFile ())
33
+ def loadClassification ():
34
+ global classification
35
+ if not os .path .isfile (classificationFile ()):
36
+ return
37
+ lines = open (classificationFile ())
38
+ line = lines .readline ().strip ('\n ' )
39
+ while line != '' :
40
+ tokens = line .split (',' )
41
+ subtokens = tokens [1 ].split ('/' )
42
+ try :
43
+ classification [tokens [0 ]] = subtokens
44
+ except :
45
+ raise Exception (line )
40
46
line = lines .readline ().strip ('\n ' )
41
- while line != '' :
42
- tokens = line .split (',' )
43
- subtokens = tokens [2 ].split ('/' )
44
- try :
45
- AlgorithmDecorator .classification [tokens [0 ]] = (subtokens [0 ],
46
- subtokens [1 ], tokens [1 ])
47
- except :
48
- raise Exception (line )
49
- line = lines .readline ().strip ('\n ' )
50
- lines .close ()
47
+ lines .close ()
48
+
49
+ def loadDisplayNames ():
50
+ global displayNames
51
+ if not os .path .isfile (displayNamesFile ()):
52
+ return
53
+ lines = open (displayNamesFile ())
54
+ line = lines .readline ().strip ('\n ' )
55
+ while line != '' :
56
+ tokens = line .split (',' )
57
+ try :
58
+ displayNames [tokens [0 ]] = tokens [1 ]
59
+ except :
60
+ raise Exception (line )
61
+ line = lines .readline ().strip ('\n ' )
62
+ lines .close ()
63
+
64
+ def classificationFile ():
65
+ return os .path .join (os .path .dirname (__file__ ), 'algclasssification.txt' )
51
66
52
- @staticmethod
53
- def classificationFile ():
54
- return os .path .join (os .path .dirname (__file__ ), 'algclasssification.txt' )
67
+ def displayNamesFile ():
68
+ return os .path .join (os .path .dirname (__file__ ), 'algnames.txt' )
55
69
56
- @staticmethod
57
- def getGroupsAndName (alg ):
58
- if alg .commandLineName ().lower () in AlgorithmDecorator .classification :
59
- (group , subgroup , name ) = \
60
- AlgorithmDecorator .classification [alg .commandLineName ()]
61
- if name == 'USE_ORIGINAL_NAME' :
62
- name = alg .name
63
- return (group , subgroup , name )
64
- else :
65
- return (None , None , alg .name )
70
+ def getClassification (alg ):
71
+ if alg .commandLineName ().lower () in classification :
72
+ group , subgroup = classification [alg .commandLineName ()]
73
+ return group , subgroup
74
+ else :
75
+ return None , None
76
+
77
+ def getDisplayName (alg ):
78
+ return displayNames .get (alg .commandLineName ().lower (), alg .name )
0 commit comments