a | b/codesys-ide/scripts/helper.py | ||
---|---|---|---|
1 | ########################################################################################### |
||
2 | # Helper classes for the different CI commands |
||
3 | ########################################################################################### |
||
4 | import sys, os |
||
5 | import shutil |
||
6 | |||
7 | class SearchBuild: |
||
8 | def __init__(self): |
||
9 | self.artifacts = list() |
||
10 | |||
11 | # search for files with a given file-ending, and call the method |
||
12 | # doit() for every occurance |
||
13 | def search(self, ending, folder): |
||
14 | for root, dirs, files in os.walk(folder): |
||
15 | for file in files: |
||
16 | if file.endswith(ending): |
||
17 | self.artifacts += self.doit(os.path.join(root, file)) |
||
18 | print("%u artifact(s) created" % len(self.artifacts)) |
||
19 | |||
20 | def save(self, basepath, destination): |
||
21 | for filename in self.artifacts: |
||
22 | print("filename: %s" % filename) |
||
23 | dirname = os.path.relpath(os.path.dirname(filename), basepath) |
||
24 | destdir = os.path.join(destination, dirname) |
||
25 | print("dest dir: %s\n" % destdir) |
||
26 | if not os.path.exists(destdir): |
||
27 | os.mkdir(destdir) |
||
28 | shutil.copyfile(filename, destdir) |
||
29 | print("%s => %s" % (filename, destdir)) |
||
30 | |||
31 | # dummy rule |
||
32 | def doit(self, filename): |
||
33 | artifacts = list() |
||
34 | return artifacts |