File tree Expand file tree Collapse file tree 2 files changed +14
-13
lines changed Expand file tree Collapse file tree 2 files changed +14
-13
lines changed Original file line number Diff line number Diff line change 6
6
from __future__ import absolute_import
7
7
8
8
import bson
9
- from enum import Enum , unique
10
9
import pymongo
11
10
import datetime
12
11
from collections import namedtuple
13
12
14
13
from . import base
15
14
from . import config
15
+ from . import util
16
16
17
17
log = config .log
18
18
38
38
def valid_transition (from_state , to_state ):
39
39
return (from_state + ' --> ' + to_state ) in JOB_TRANSITIONS or from_state == to_state
40
40
41
- # Represet the general categories of gear function
42
- @unique
43
- class Category (Enum ):
44
- classifier = 'classifier' # discover metadata
45
- converter = 'converter' # translate between formats
46
- qa = 'qa' # quality assurance
47
- analytical = 'analytical' # general purpose
48
-
49
- # Enum strings are prefixed by their class: "Category.classifier".
50
- # This overrides that behaviour and removes the prefix.
51
- def __str__ (self ):
52
- return str (self .value )
41
+ Category = util .Enum ('Category' , {
42
+ 'classifier' : 'classifier' , # discover metadata
43
+ 'converter' : 'converter' , # translate between formats
44
+ 'qa' : 'qa' , # quality assurance
45
+ 'analytical' : 'analytical' , # general purpose
46
+ })
53
47
54
48
Gear = namedtuple ('gear' , ['name' , 'category' , 'input' ])
55
49
Original file line number Diff line number Diff line change 5
5
import mimetypes
6
6
import bson .objectid
7
7
import tempdir as tempfile
8
+ import enum as baseEnum
8
9
9
10
MIMETYPES = [
10
11
('.bvec' , 'text' , 'bvec' ),
@@ -110,3 +111,9 @@ def custom_json_serializer(obj):
110
111
elif isinstance (obj , datetime .datetime ):
111
112
return pytz .timezone ('UTC' ).localize (obj ).isoformat ()
112
113
raise TypeError (repr (obj ) + " is not JSON serializable" )
114
+
115
+ class Enum (baseEnum .Enum ):
116
+ # Enum strings are prefixed by their class: "Category.classifier".
117
+ # This overrides that behaviour and removes the prefix.
118
+ def __str__ (self ):
119
+ return str (self .name )
You can’t perform that action at this time.
0 commit comments