summaryrefslogtreecommitdiff
path: root/qface/idl/profile.py
blob: 24c6be2705e2d1493e7122ee9d6af18fa5f2f8d4 (plain)
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
# Copyright (c) Pelagicore AB 2016
"""
A profile is a set of features describing a qface language profile.
The language profile tells the parser which language aspects are
supported for the particular choosen profile.

from profile import get_features, EProfile, EFeature

features = get_features(EProfile.ADVANCED)

if EFeature.CONST_OPERATION in features:
    # parse this aspect of the language

"""

from enum import Enum


class EFeature(Enum):
    CONST_OPERATION = 'const_operation'
    EXTEND_INTERFACE = 'extend_interface'
    IMPORT = 'import'
    MAPS = 'maps'


class EProfile(Enum):
    BASIC = 'basic'
    ADVANCED = 'advanced'
    ALL = 'all'


_profiles = {
    EProfile.BASIC: set(),
    EProfile.ADVANCED: set([
        EFeature.EXTEND_INTERFACE,
        EFeature.IMPORT,
        EFeature.MAPS
    ]),
    EProfile.ALL: set(EFeature)
}


def get_features(name):
    return _profiles.get(name, set())