VoxeLibre/tools/create_luacheck.py

30 lines
870 B
Python
Raw Normal View History

2021-04-26 20:16:27 +03:00
import os
import re
from pathlib import Path
2021-04-27 20:16:08 +03:00
path = "./mods/"
# pattern = re.compile(r'^(?P<nomtableau>[^ \t\]]+)[ ]*=[ ]*\{')
pattern = re.compile(r'^(?P<nomtableau>[^ \t\]]+)[ ]*=[ ]*\{')
2021-04-26 20:16:27 +03:00
pathlist = Path(path).rglob('*.lua')
for path in pathlist:
path_in_str = str(path)
2021-04-27 20:16:08 +03:00
# print(path_in_str)
trouve = False
2021-04-26 20:16:27 +03:00
with open(path_in_str) as f:
2021-04-27 20:16:08 +03:00
for i, line in enumerate(f.readlines()):
m = pattern.match(line)
if m:
print(path_in_str, ":", i+1, ":", m.group('nomtableau').strip())
trouve = True
break
if not trouve:
print(path_in_str, ": -")
2021-04-26 20:16:27 +03:00
for subdir, dirs, files in os.walk(path):
for file in files:
print(os.path.join(subdir, file))
filepath = subdir + os.sep + file
if filepath.endswith(".lua"):
print(filepath)