sbdl 1.18.10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sbdl-1.18.10/PKG-INFO +9 -0
- sbdl-1.18.10/csv-to-sbdl.py +68 -0
- sbdl-1.18.10/sbdl +5 -0
- sbdl-1.18.10/sbdl.egg-info/PKG-INFO +9 -0
- sbdl-1.18.10/sbdl.egg-info/SOURCES.txt +10 -0
- sbdl-1.18.10/sbdl.egg-info/dependency_links.txt +1 -0
- sbdl-1.18.10/sbdl.egg-info/requires.txt +7 -0
- sbdl-1.18.10/sbdl.egg-info/top_level.txt +3 -0
- sbdl-1.18.10/sbdl.py +3107 -0
- sbdl-1.18.10/sbdl_server.py +92 -0
- sbdl-1.18.10/setup.cfg +4 -0
- sbdl-1.18.10/setup.py +15 -0
sbdl-1.18.10/PKG-INFO
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
_I='remark'
|
|
3
|
+
_H='pragma'
|
|
4
|
+
_G='child'
|
|
5
|
+
_F='parent'
|
|
6
|
+
_E='aspect'
|
|
7
|
+
_D='description'
|
|
8
|
+
_C='identifier'
|
|
9
|
+
_B=None
|
|
10
|
+
_A=' '
|
|
11
|
+
import argparse,csv,re,sys,sbdl
|
|
12
|
+
__NAME='cs2sbdl'
|
|
13
|
+
__VERSION='0.2.3'
|
|
14
|
+
def null_handler(content):return sbdl.SBDL_Parser.sanitize(content)
|
|
15
|
+
def doors_link_san(content):
|
|
16
|
+
B=content;A=B;C='{LINK';D='}';F=C+'.*?'+D
|
|
17
|
+
def G(link_string_body):
|
|
18
|
+
E='NO_LINK_NAME';A=link_string_body[len(C):-len(D)].strip();A=A.split('=')
|
|
19
|
+
for B in range(len(A)):
|
|
20
|
+
if A[B].endswith('title')and len(A)>B+1:E=A[B+1][1:-5]+_A;break
|
|
21
|
+
return E
|
|
22
|
+
for E in re.finditer(F,B):H=G(E.group());A=A.replace(E.group(),H)
|
|
23
|
+
return A
|
|
24
|
+
def null_handler_doors(content):return null_handler(doors_link_san(content))
|
|
25
|
+
def id_handler(content):return null_handler('_'.join(content.split()))
|
|
26
|
+
def doors_req_id_san(content):return id_handler(content.rstrip('.'))
|
|
27
|
+
def doors_parent_child_id_san(content):
|
|
28
|
+
B=content.splitlines();A=''
|
|
29
|
+
try:
|
|
30
|
+
C=[]
|
|
31
|
+
for D in B:C.append(D.split()[1])
|
|
32
|
+
A=sbdl.SBDL_Parser.Attributes.separator.join(C)
|
|
33
|
+
except Exception as E:A=sbdl.SBDL_Parser.Attributes.separator.join(B)
|
|
34
|
+
return null_handler(A)
|
|
35
|
+
column_handlers={_C:id_handler,_E:id_handler,_D:null_handler,_F:id_handler,_G:id_handler,_H:null_handler,_I:null_handler}
|
|
36
|
+
column_handlers_doors={_C:doors_req_id_san,_E:id_handler,_D:null_handler_doors,_F:doors_parent_child_id_san,_G:doors_parent_child_id_san,_H:null_handler_doors,_I:null_handler_doors}
|
|
37
|
+
def csv2sbdl(table,id_col,aspect_col,desc_col,remark_col,parent_col,child_col,pragma_col,element_type,write_aspect_placeholders,column_handlers=column_handlers):
|
|
38
|
+
W='{description}';M=pragma_col;L=child_col;K=parent_col;J=remark_col;I=desc_col;H=aspect_col;G=id_col;B=column_handlers;E=[];N={};A=sbdl.SBDL_Parser.Tokens;O=sbdl.SBDL_Parser.Types;D=sbdl.SBDL_Parser.Attributes;X='custom:extended';Y='{rid} '+A.declaration+_A+element_type+_A+A.declaration_group_delimeters[0].replace('{','{{')+_A+D.description+A.declaration_attribute_assign+A.declaration_attribute_delimeter+W+A.declaration_attribute_delimeter+_A+X+A.declaration_attribute_assign+A.declaration_attribute_delimeter+'{remark}'+A.declaration_attribute_delimeter+_A+O.aspect+A.declaration_attribute_assign+A.declaration_attribute_delimeter+'{aspect}'+A.declaration_attribute_delimeter+_A+D.parent+A.declaration_attribute_assign+A.declaration_attribute_delimeter+'{parent}'+A.declaration_attribute_delimeter+_A+D.child+A.declaration_attribute_assign+A.declaration_attribute_delimeter+'{child}'+A.declaration_attribute_delimeter+_A+D.pragma+A.declaration_attribute_assign+A.declaration_attribute_delimeter+'{pragma}'+A.declaration_attribute_delimeter+_A+A.declaration_group_delimeters[1].replace('}','}}');Z='{aid} '+A.declaration+_A+O.aspect+_A+A.declaration_group_delimeters[0].replace('{','{{')+_A+D.description+A.declaration_attribute_assign+A.declaration_attribute_delimeter+W+A.declaration_attribute_delimeter+_A+A.declaration_group_delimeters[1].replace('}','}}')
|
|
39
|
+
for C in table:
|
|
40
|
+
P='';F='';Q='';R='';S='';T='';U=''
|
|
41
|
+
if G!=_B:P=B[_C](C[int(G)])
|
|
42
|
+
if H!=_B:
|
|
43
|
+
F=B[_E](C[int(H)])
|
|
44
|
+
for a in F.split(sbdl.SBDL_Parser.Attributes.separator):N[a]=True
|
|
45
|
+
if I!=_B:Q=B[_D](C[int(I)])
|
|
46
|
+
if J!=_B:U=B[_I](C[int(J)])
|
|
47
|
+
if K!=_B:R=B[_F](C[int(K)])
|
|
48
|
+
if L!=_B:S=B[_G](C[int(L)])
|
|
49
|
+
if M!=_B:T=B[_H](C[int(M)])
|
|
50
|
+
b=Y.format(rid=P,description=Q,remark=U,aspect=F,parent=R,child=S,pragma=T);E.append(b)
|
|
51
|
+
if write_aspect_placeholders:
|
|
52
|
+
for V in N:c=Z.format(aid=B[_C](V),description=B[_D](V));E.append(c)
|
|
53
|
+
return E
|
|
54
|
+
def main(arguments):
|
|
55
|
+
A=arguments;F=0;C=[]
|
|
56
|
+
for G in A.source_files:
|
|
57
|
+
with open(G,'r')as H:
|
|
58
|
+
I=csv.reader(H,delimiter=A.delimiter);B=[A for A in I]
|
|
59
|
+
if A.skipheader:B=B[1:]
|
|
60
|
+
D=column_handlers
|
|
61
|
+
if A.doors:D=column_handlers_doors
|
|
62
|
+
C.extend(csv2sbdl(B,A.identifier,A.aspect,A.description,A.extended,A.parent,A.child,A.pragma,A.sbdl_type,A.placeholder_aspects,D))
|
|
63
|
+
with sbdl.open_output_file(A.output,append=A.append)as E:
|
|
64
|
+
if not A.append:E.write('#!sbdl\n')
|
|
65
|
+
for J in C:E.write(J+'\n')
|
|
66
|
+
return F
|
|
67
|
+
def handle_arguments(args_l):C=False;B='store_true';A=argparse.ArgumentParser(description='{} Version {}. Convert a CSV sheet into SBDL. Author: michael@mahicks.org.'.format(__NAME.upper(),__VERSION),epilog='e.g. "'+sys.argv[0]+' <file 1> <file 2> <file n>"',formatter_class=argparse.ArgumentDefaultsHelpFormatter);A.add_argument('source_files',help='List of files to compile',nargs='+');A.add_argument('--identifier',help="Column containing element's identifier",default=_B);A.add_argument('--aspect',help="Column containing element's aspect",default=_B);A.add_argument('--description',help="Column containing element's description",default=_B);A.add_argument('--parent',help="Column containing element's parent identifiers",default=_B);A.add_argument('--child',help="Column containing element's child identifiers",default=_B);A.add_argument('--extended',help="Column containing element's extended information",default=_B);A.add_argument('--pragma',help="Column containing element's pragma content",default=_B);A.add_argument('--skipheader',help='Treat the first line as header (and skip it)',action=B,default=C);A.add_argument('--doors',help='Treat the CSV data as having been exported from DOORS',action=B,default=C);A.add_argument('--placeholder_aspects',help='Write placeholder aspects into output SBDL',action=B,default=C);A.add_argument('-o','--output',help='Specify the name of the output file',default='output.sbdl');A.add_argument('-a','--append',help='Append to the output file instead of truncating it',action=B,default=C);A.add_argument('--delimiter',help='CSV column delimiter',default=',');A.add_argument('--sbdl_type',help='SBDL Element-type for generated ouptut',default=sbdl.SBDL_Parser.Types.requirement);return A.parse_args(args_l)
|
|
68
|
+
if __name__=='__main__':sys.exit(main(handle_arguments(sys.argv[1:])))
|
sbdl-1.18.10/sbdl
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|