forked from VoxeLibre/VoxeLibre
basic working script
This commit is contained in:
parent
45965c0799
commit
cbb014ed38
|
@ -7,7 +7,7 @@ end
|
||||||
|
|
||||||
--[[ Manually set in 'buildings.lua'
|
--[[ Manually set in 'buildings.lua'
|
||||||
-- material to replace cobblestone with
|
-- material to replace cobblestone with
|
||||||
wallmaterial = {
|
local wallmaterial = {
|
||||||
"mcl_core:junglewood",
|
"mcl_core:junglewood",
|
||||||
"mcl_core:sprucewood",
|
"mcl_core:sprucewood",
|
||||||
"mcl_core:wood",
|
"mcl_core:wood",
|
||||||
|
|
|
@ -4,8 +4,10 @@ from pathlib import Path
|
||||||
|
|
||||||
path = "./mods/"
|
path = "./mods/"
|
||||||
# pattern = re.compile(r'^(?P<nomtableau>[^ \t\]]+)[ ]*=[ ]*\{')
|
# pattern = re.compile(r'^(?P<nomtableau>[^ \t\]]+)[ ]*=[ ]*\{')
|
||||||
pattern = re.compile(r'^(?P<nomtableau>[^ \t\]]+)[ ]*=[ ]*\{')
|
pattern = re.compile(r'^(?P<nomtableau>[A-Za-z_0-9]+)[ ]*=[ ]*\{')
|
||||||
|
pattern_local = re.compile(r'local (?P<nomvar>[A-Za-z_0-9]+)')
|
||||||
|
|
||||||
|
global_vars = []
|
||||||
|
|
||||||
pathlist = Path(path).rglob('*.lua')
|
pathlist = Path(path).rglob('*.lua')
|
||||||
for path in pathlist:
|
for path in pathlist:
|
||||||
|
@ -13,18 +15,31 @@ for path in pathlist:
|
||||||
# print(path_in_str)
|
# print(path_in_str)
|
||||||
trouve = False
|
trouve = False
|
||||||
with open(path_in_str) as f:
|
with open(path_in_str) as f:
|
||||||
|
variables_locales = []
|
||||||
for i, line in enumerate(f.readlines()):
|
for i, line in enumerate(f.readlines()):
|
||||||
m = pattern.match(line)
|
m = pattern.match(line)
|
||||||
if m:
|
if m:
|
||||||
|
nomtableau = m.group('nomtableau')
|
||||||
|
if nomtableau not in variables_locales:
|
||||||
print(path_in_str, ":", i+1, ":", m.group('nomtableau').strip())
|
print(path_in_str, ":", i+1, ":", m.group('nomtableau').strip())
|
||||||
|
global_vars.append(m.group('nomtableau').strip())
|
||||||
trouve = True
|
trouve = True
|
||||||
break
|
break
|
||||||
if not trouve:
|
|
||||||
print(path_in_str, ": -")
|
|
||||||
|
|
||||||
for subdir, dirs, files in os.walk(path):
|
else:
|
||||||
|
n = pattern_local.match(line)
|
||||||
|
if n:
|
||||||
|
variables_locales.append(n.group('nomvar'))
|
||||||
|
|
||||||
|
if not trouve:
|
||||||
|
nb_varloc = len(variables_locales)
|
||||||
|
#print(path_in_str, ": -", "({} variables locales)".format(nb_varloc) if nb_varloc > 0 else '')
|
||||||
|
|
||||||
|
""" for subdir, dirs, files in os.walk(path):
|
||||||
for file in files:
|
for file in files:
|
||||||
print(os.path.join(subdir, file))
|
print(os.path.join(subdir, file))
|
||||||
filepath = subdir + os.sep + file
|
filepath = subdir + os.sep + file
|
||||||
if filepath.endswith(".lua"):
|
if filepath.endswith(".lua"):
|
||||||
print(filepath)
|
print(filepath) """
|
||||||
|
|
||||||
|
print(', '.join(['"{}"'.format(v) for v in global_vars]))
|
||||||
|
|
Loading…
Reference in New Issue