aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/resources/scripts/sdcBePy/common/properties.py
blob: 8426f344645ed1548a89a6be79156a1985cdc4a0 (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
46
47
class Properties:

    def __init__(self, retry_time=0,
                 retry_attempts=0, resource_len=0):
        self.retry_time = retry_time
        self.retry_attempts = retry_attempts
        self.resource_len = resource_len

    @property
    def retry_time(self):
        return self._retry_time

    @retry_time.setter
    def retry_time(self, value):
        self._validate(value)
        self._retry_time = value

    @property
    def retry_attempts(self):
        return self._retry_attempts

    @retry_attempts.setter
    def retry_attempts(self, value):
        self._validate(value)
        self._retry_attempts = value

    @property
    def resource_len(self):
        return self._resource_len

    @resource_len.setter
    def resource_len(self, value):
        self._validate(value)
        self._resource_len = value

    @staticmethod
    def _validate(value):
        if value < 0:
            raise ValueError("Properties below 0 is not possible")


def init_properties(retry_time, retry_attempts, resource_len=0):
    from sdcBePy import properties

    properties.retry_time = retry_time
    properties.retry_attempts = retry_attempts
    properties.resource_len = resource_len