File: features.py

package info (click to toggle)
freenub 0.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,168 kB
  • sloc: python: 10,664; makefile: 7; sh: 6
file content (20 lines) | stat: -rw-r--r-- 506 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from os import getenv

from pubnub.exceptions import PubNubException

flags = {"PN_ENABLE_ENTITIES": getenv("PN_ENABLE_ENTITIES", False)}


def feature_flag(flag):
    def not_implemented(*args, **kwargs):
        raise PubNubException(errormsg="This feature is not enabled")

    def inner(method):
        if flag not in flags.keys():
            raise PubNubException(errormsg="Flag not supported")

        if not flags[flag]:
            return not_implemented
        return method

    return inner