forked from Homegateway/SDTTool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSDTPrinter.py
129 lines (102 loc) · 3.43 KB
/
SDTPrinter.py
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# SDTPrinter.py
#
# Print an SDT in various formats
import os, pathlib
from sdtv2.SDT2PrintMarkdown import print2DomainMarkdown
from sdtv2.SDT2PrintOPML import print2DomainOPML
from sdtv2.SDT2PrintPlain import print2DomainPlain
from sdtv2.SDT2PrintSDT3 import print2DomainSDT3
from sdtv3.SDT3PrintMarkdown import print3DomainMarkdown
from sdtv3.SDT3PrintOPML import print3DomainOPML
from sdtv3.SDT3PrintPlain import print3DomainPlain
from sdtv3.SDT3PrintJava import print3JavaClasses
from sdtv3.SDT3PrintVortoDSL import print3VortoDSL
from sdtv3.SDT3PrintOneM2MSVG import print3OneM2MSVG
from sdtv3.SDT3PrintOneM2MXSD import print3OneM2MXSD
from sdtv3.SDT3PrintSwagger import print3Swagger
from sdtv3.SDT3Templates import print3SDT
def printPlain(domain, options):
if (domain == None):
return
if (domain._version == '2'):
return print2DomainPlain(domain, options)
elif (domain._version == '3'):
return print3DomainPlain(domain, options)
def printOPML(domain, options):
if (domain == None):
return
if (domain._version == '2'):
return print2DomainOPML(domain, options)
elif (domain._version == '3'):
return print3DomainOPML(domain, options)
def printMarkdown(domain, options):
if (domain == None):
return
if (domain._version == '2'):
return print2DomainMarkdown(domain, options)
elif (domain._version == '3'):
#return print3DomainMarkdown(domain, options)
return print3SDT(domain, options)
def printSDT3(domain, inputFormat, options):
if (domain == None):
return
if (domain._version == '2' and inputFormat == 'sdt2'):
return print2DomainSDT3(domain, options)
else:
print('Conversion is not supported')
return ''
def printJava(domain, inputFormat, directory, options):
if (inputFormat != 'sdt3'):
print('Only the input format "sdt3" is supported yet')
return
if (directory == None):
print('-o <directory> must be specified')
return
_makeDir(directory)
print3JavaClasses(domain, directory, options)
def printVortoDSL(domain, inputFormat, directory, options):
if (inputFormat != 'sdt3'):
print('Only the input format "sdt3" is supported yet')
return
if (directory == None):
print('-o <directory> must be specified')
return
_makeDir(directory)
print3VortoDSL(domain, directory, options)
def printOneM2MSVG(domain, inputFormat, directory, options):
if (inputFormat != 'sdt3'):
print('Only the input format "sdt3" is supported yet')
return
if (directory == None):
print('-o <directory> must be specified')
return
_makeDir(directory)
#SDT3PrintOneM2MSVG.print3OneM2MSVG(domain, directory, options)
print3OneM2MSVG(domain, directory, options)
def printOneM2MXSD(domain, inputFormat, directory, options):
if (inputFormat != 'sdt3'):
print('Only the input format "sdt3" is supported yet')
return
if (directory == None):
print('-o <directory> must be specified')
return
_makeDir(directory)
#print3OneM2MXSD(domain, directory, options)
print3SDT(domain,options, directory)
def printSwagger(domain, inputFormat, directory, options):
if (inputFormat != 'sdt3'):
print('Only the input format "sdt3" is supported yet')
return
if (directory == None):
print('-o <directory> must be specified')
return
_makeDir(directory)
print3Swagger(domain, directory, options)
##############################################################################
def _makeDir(directory):
try:
path = pathlib.Path(directory)
path.mkdir(parents=True)
except FileExistsError as e:
# ignore existing directory for now
pass