a | b/codesys-ide/scripts/export-documentation.py | ||
---|---|---|---|
1 | import sys, os, re, shutil |
||
2 | import helper |
||
3 | |||
4 | def get_artifacts(path, libdir): |
||
5 | artifacts = list() |
||
6 | # ziph is zipfile handle |
||
7 | for root, dirs, files in os.walk(path): |
||
8 | if "doc_unzip" in root: |
||
9 | for file in files: |
||
10 | filename=os.path.join(root, file) |
||
11 | dirname=re.split("doc_unzip[^\\\\]*", root)[1].lstrip("\\") |
||
12 | print(dirname) |
||
13 | destdir=os.path.join(libdir + ".doc", dirname) |
||
14 | print("parsing file: %s (%s)" % (filename, destdir)) |
||
15 | if not os.path.exists(destdir): |
||
16 | os.mkdir(destdir) |
||
17 | shutil.copy2(filename, destdir) |
||
18 | artifacts.append(os.path.join(destdir, file)) |
||
19 | return artifacts |
||
20 | |||
21 | |||
22 | class SearchBuildDo(helper.SearchBuild): |
||
23 | # Build rules for: |
||
24 | # - *.library -> *.compiled-library |
||
25 | def doit(self, filename): |
||
26 | artifacts = list() |
||
27 | |||
28 | if filename.endswith(".library"): |
||
29 | destination = filename.replace(".library", ".compiled-library") |
||
30 | artifacts.append(destination) |
||
31 | |||
32 | print("%s -> %s\n" % (filename, destination)) |
||
33 | |||
34 | proj = projects.open(filename) |
||
35 | proj.save_as_compiled_library(destination) |
||
36 | print(os.environ) |
||
37 | artifacts = get_artifacts(os.path.join("c:", "users", "Public", "Application Data", "CODESYS", "Temporary Files"), filename) |
||
38 | proj.close() |
||
39 | |||
40 | return artifacts |
||
41 | |||
42 | scriptpath = os.path.abspath(os.path.dirname(sys.argv[0])) |
||
43 | |||
44 | sb = SearchBuildDo() |
||
45 | sb.search(".library", ".") |
||
46 | sb.save(".", ".drone-artifacts") |