Skip to content

Commit 7e24a91

Browse files
committed
update_ini: get the included files in the INI file
1 parent 1928c17 commit 7e24a91

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/emc/ini/update_ini.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ def find_section(section, inistring):
8181
# We want to work with the base INI file here, not the expanded version if #include is used
8282
filename = re.sub(r'\.expanded', '', filename)
8383

84+
# Search for included files
85+
base_dir = os.path.dirname(filename)
86+
included_files = []
87+
# included_files.append(filename)
88+
pattern = re.compile(r"^#INCLUDE[ \t]+(\S+)")
89+
with open(filename, "r", encoding="utf-8") as f:
90+
for line in f:
91+
match = pattern.match(line.strip())
92+
if match:
93+
file = os.path.join(base_dir, match.group(1))
94+
included_files.append(file)
95+
8496
try:
8597
ini = linuxcnc.ini(filename)
8698
except:

0 commit comments

Comments
 (0)