-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
48 lines (39 loc) · 1.27 KB
/
main.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
import os
import xml.dom
from xml.dom import minidom
import xml.etree.ElementTree as ET
import powerdesigner
CURRWD = os.getcwd()
PDFILES = []
FIRST = True
#Find all pdfiles
for file in os.listdir(CURRWD):
if file.endswith(".pdm") or file.endswith(".cdm"):
PDFILES.append(file)
# Process file
fid = "{"+"amogus"+"}"
tid = "TID"
name = "WorkspaceProject"
currfile = "Filename.cdm"
# Create xml container to add to
data = ET.Element('Workspace')
local = ET.SubElement(data, 'Local')
local.set('Expanded', "Yes")
# Set some other stuff??
browsermodule = ET.SubElement(data, 'BrowserModule')
browsermodule.set('Name', "Repository")
for cfile in PDFILES:
lines = tuple(open(cfile, 'r')) # Get all lines
header= lines[1] # Get the first line with Important stuff
fid = powerdesigner.getFID(header) # Get Fid from header
tid = powerdesigner.getTID(header) # Get Tid from header
pfile = ET.SubElement(local, 'Model')# create one model
pfile.set('Expanded', 'Yes')
pfile.set('ID', "{"+fid+ "}")
pfile.set('Name', cfile[:len(str(cfile))-4])
pfile.set('Type', "{"+ tid+ "}")
pfile.set('URL', cfile)
if FIRST == True:
pfile.set("Selected", "Yes")
FIRST = False
powerdesigner.makeSWS(data=data, wsname="WorkspaceNew.sws")