blob: 9cc9f6ee7f591393334a4dc70023843134943794 (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#Author: Shu Shi
#emaiL: shushi@research.att.com
from toscalib.templates.constant import *
import logging
class RequirementDefinition(object):
def __init__(self, content):
self.name = None
self.parsed = False
self.raw_content = content
self.req_type = None
self.req_capability = None
self.relationship = None
self.occurrence = [1,1]
def _parse_content(self, db):
if self.parsed is True:
return
content = self.raw_content
if content is None:
logging.warning( 'Construct None requirement section')
self.parsed = True
return
if len(content.keys()) != 1:
logging.warning( 'Requirement section does not have exact one element: ' + len(content.keys()))
return
self.name = list(content.keys())[0]
requirement_def = content[self.name]
if type(requirement_def) is not dict:
logging.warning( 'Cannot parse requirement definition: '+ self.name)
return
# if requirement_def.has_key(REQ_NODE):
if REQ_NODE in requirement_def:
self.req_type = requirement_def[REQ_NODE]
else:
self.req_type = None
# if requirement_def.has_key(REQ_CAPABILITY):
if REQ_CAPABILITY in requirement_def:
self.req_capability = requirement_def[REQ_CAPABILITY]
else:
self.req_capability = None
# if requirement_def.has_key(REQ_RELATIONSHIP):
if REQ_RELATIONSHIP in requirement_def:
self.relationship = requirement_def[REQ_RELATIONSHIP]
else:
self.relationship = None
# if requirement_def.has_key(REQ_OCCURRENCE):
if REQ_OCCURRENCE in requirement_def:
self.occurrence = requirement_def[REQ_OCCURRENCE]
if type(self.occurrence) is not list:
logging.warning( 'Requirement occurrence expects a list of two numbers but provided with: '+ self.occurrence)
self.parsed = True
|