-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathASCncConfig.py
44 lines (34 loc) · 1.09 KB
/
ASCncConfig.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
'''
* File: ASCncConfig.py
* Copyright (c) 2023 Loupe
* https://loupe.team
*
* This file is part of ASPython, licensed under the MIT License.
'''
'''
AS Tools - Cnc Config
This package contains functions necessary to perform actions on
AS Cnc Configuration files outside of Automation Studio.
Requires lxml
'''
import os.path
# import xml.etree.ElementTree as ET
import lxml.etree as ET
__version__ = '0.0.0.1'
def listOfProcs(tree, include_comments=False):
procs = []
for node in tree.xpath('//BuiltInProcs'):
for child in node:
if child.tag is not ET.Comment:
if include_comments and child.getprevious() is not None and child.getprevious().tag is ET.Comment:
print("<!-- " + child.getprevious().text + "-->")
procs.append(child.getprevious())
print(child.tag)
procs.append(child)
return procs
def main():
tree = ET.parse('test/gmcipubr.cnc')
# print(ET.tostring(tree, pretty_print=True))
listOfProcs(tree, include_comments=True)
if __name__ == "__main__":
main()