1 | """ |
||
2 | Enarksh |
||
3 | |||
4 | Copyright 2013-2016 Set Based IT Consultancy |
||
5 | |||
6 | Licence MIT |
||
7 | """ |
||
8 | import abc |
||
9 | |||
10 | from enarksh.controller.StateChange import StateChange |
||
11 | |||
12 | |||
13 | class Resource(StateChange, metaclass=abc.ABCMeta): |
||
14 | """ |
||
15 | Class for objects in the controller of type 'Resource'. |
||
16 | """ |
||
17 | |||
18 | # ------------------------------------------------------------------------------------------------------------------ |
||
19 | def __init__(self, data): |
||
20 | """ |
||
21 | Object constructor. |
||
22 | |||
23 | :param dict[str,*] data: |
||
24 | """ |
||
25 | StateChange.__init__(self) |
||
26 | |||
27 | self._name = str(data['rsc_name'], 'utf-8') # @todo XXX pystratum |
||
28 | """ |
||
29 | The name of this resource. |
||
30 | |||
31 | :type: int |
||
32 | """ |
||
33 | |||
34 | self._rsc_id = data['rsc_id'] |
||
35 | """ |
||
36 | The ID of this resource. |
||
37 | |||
38 | :type: int |
||
39 | """ |
||
40 | |||
41 | # ------------------------------------------------------------------------------------------------------------------ |
||
42 | @property |
||
43 | def name(self): |
||
44 | """ |
||
45 | Returns the name of this resource. |
||
46 | |||
47 | :rtype: str |
||
48 | """ |
||
49 | return self._name |
||
50 | |||
51 | # ------------------------------------------------------------------------------------------------------------------ |
||
52 | def rsc_id(self): |
||
53 | """ |
||
54 | Returns the ID of this resource. |
||
55 | |||
56 | :rtype: str |
||
57 | """ |
||
58 | return self._rsc_id |
||
59 | |||
60 | # ------------------------------------------------------------------------------------------------------------------ |
||
61 | @abc.abstractmethod |
||
62 | def acquire(self, *args): |
||
0 ignored issues
–
show
|
|||
63 | raise NotImplementedError() |
||
64 | |||
65 | # ------------------------------------------------------------------------------------------------------------------ |
||
66 | @abc.abstractmethod |
||
67 | def inquire(self, *args): |
||
0 ignored issues
–
show
This method should have a docstring.
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods: class SomeClass:
def some_method(self):
"""Do x and return foo."""
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions. ![]() |
|||
68 | raise NotImplementedError() |
||
69 | |||
70 | # ------------------------------------------------------------------------------------------------------------------ |
||
71 | @abc.abstractmethod |
||
72 | def release(self, *args): |
||
0 ignored issues
–
show
This method should have a docstring.
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods: class SomeClass:
def some_method(self):
"""Do x and return foo."""
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions. ![]() |
|||
73 | raise NotImplementedError() |
||
74 | |||
75 | # ------------------------------------------------------------------------------------------------------------------ |
||
76 | @abc.abstractmethod |
||
77 | def sync_state(self): |
||
0 ignored issues
–
show
This method should have a docstring.
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods: class SomeClass:
def some_method(self):
"""Do x and return foo."""
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions. ![]() |
|||
78 | raise NotImplementedError() |
||
79 | |||
80 | # ------------------------------------------------------------------------------------------------------------------ |
||
81 | @abc.abstractmethod |
||
82 | def get_type(self): |
||
0 ignored issues
–
show
This method should have a docstring.
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods: class SomeClass:
def some_method(self):
"""Do x and return foo."""
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions. ![]() |
|||
83 | raise NotImplementedError() |
||
84 | |||
85 | # ---------------------------------------------------------------------------------------------------------------------- |
||
86 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.