Page Menu
Home
Wildfire Games
Search
Configure Global Search
Log In
Paste
P278
Script to find merged gathering and carry units.
Active
Public
Actions
Authored by
Stan
on Jun 19 2022, 10:15 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Subscribers
None
#!/usr/bin/env python3
# -*- mode: python-mode; python-indent-offset: 4; -*-
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: © 2022 Stanislas Daniel Claude Dolcini
import
xml.etree.ElementTree
as
ET
from
os
import
path
,
walk
,
listdir
from
pathlib
import
Path
def
checkFile
(
file_path
):
tree
=
ET
.
parse
(
file_path
)
root
=
tree
.
getroot
()
for
group
in
root
.
findall
(
'./group'
):
files
=
[]
for
variant
in
group
:
if
'file'
in
variant
.
attrib
:
files
.
append
(
variant
.
attrib
[
'file'
])
if
'biped/gather_grain.xml'
in
files
and
'biped/carry_food.xml'
in
files
:
print
(
file_path
)
def
convert_recursively
(
folder
):
for
file_name
in
listdir
(
folder
):
file_path
=
path
.
join
(
folder
,
file_name
)
if
path
.
isfile
(
file_path
):
name
,
ext
=
path
.
splitext
(
file_name
)
if
ext
.
lower
()
in
[
'.xml'
]:
checkFile
(
file_path
)
elif
path
.
isdir
(
file_path
):
convert_recursively
(
file_path
)
vfs_root
=
Path
(
'.'
)
print
(
f
"Analysing '{vfs_root}'"
)
convert_recursively
(
vfs_root
)
Event Timeline
Stan
created this paste.
Jun 19 2022, 10:15 PM
Stan
created this object with visibility "Public (No Login Required)".
Log In to Comment