Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
spnati
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SPNATI Utilities Bot
spnati
Commits
adc817e1
Commit
adc817e1
authored
5 years ago
by
FarawayVision
Browse files
Options
Downloads
Patches
Plain Diff
Add a CI step for automatically filling in linecount and posecount metadata
parent
9e54a0fd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+2
-0
2 additions, 0 deletions
.gitlab-ci.yml
opponents/fill_linecount_metadata.py
+60
-0
60 additions, 0 deletions
opponents/fill_linecount_metadata.py
with
62 additions
and
0 deletions
.gitlab-ci.yml
+
2
−
0
View file @
adc817e1
...
...
@@ -9,7 +9,9 @@ pages:
-
sed "s/__CI_COMMIT_SHA/${CI_COMMIT_SHA}/g" prod-config.xml > .public/config.xml
-
cp opponents/listing.xml .public/opponents
-
cp opponents/general_collectibles.xml .public/opponents
-
pip install beautifulsoup4
-
find `python opponents/list_opponents.py` -iname "*.png" -o -iname "*.gif" -o -iname "*.jpg" -o -iname "*.xml" -o -iname "*.js" -o -iname "*.css" | tar -cT - | tar -C .public -x
-
python3 opponents/fill_linecount_metadata.py .public/opponents
-
python opponents/gzip_dialogue.py .public/opponents/*/behaviour.xml
-
python opponents/analyze_image_space.py .public/opponents
-
python opponents/copy_event_alts.py .public/ ./ easter
...
...
This diff is collapsed.
Click to expand it.
opponents/fill_linecount_metadata.py
0 → 100644
+
60
−
0
View file @
adc817e1
from
__future__
import
print_function
import
os
import
os.path
as
osp
from
bs4
import
BeautifulSoup
import
shutil
import
stat
import
sys
def
process
(
opponent_folder_path
):
opponent
=
osp
.
basename
(
opponent_folder_path
)
behaviour_path
=
osp
.
join
(
opponent_folder_path
,
'
behaviour.xml
'
)
meta_path
=
osp
.
join
(
opponent_folder_path
,
'
meta.xml
'
)
if
not
osp
.
exists
(
behaviour_path
)
or
not
osp
.
exists
(
meta_path
):
return
with
open
(
meta_path
,
'
r
'
,
encoding
=
'
utf-8
'
)
as
f
:
meta_soup
=
BeautifulSoup
(
f
.
read
())
if
meta_soup
.
opponent
.
lines
is
not
None
or
meta_soup
.
opponent
.
poses
is
not
None
:
return
with
open
(
behaviour_path
,
'
r
'
,
encoding
=
'
utf-8
'
)
as
f
:
soup
=
BeautifulSoup
(
f
.
read
())
all_lines
=
set
()
all_poses
=
set
()
for
state
in
soup
.
find_all
(
'
state
'
,
recursive
=
True
):
pose
=
state
.
get
(
'
img
'
,
''
)
all_poses
.
add
(
pose
)
dialogue
=
''
.
join
(
str
(
child
)
for
child
in
state
.
stripped_strings
).
strip
()
all_lines
.
add
(
dialogue
)
n_unique_lines
=
len
(
all_lines
)
n_poses
=
len
(
all_poses
)
print
(
opponent
+
"
:
"
)
print
(
"
-
"
+
str
(
n_unique_lines
)
+
"
lines
"
)
print
(
"
-
"
+
str
(
n_poses
)
+
"
poses
"
)
linecount_tag
=
soup
.
new_tag
(
'
lines
'
)
linecount_tag
.
string
=
str
(
n_unique_lines
)
posecount_tag
=
soup
.
new_tag
(
'
poses
'
)
posecount_tag
.
string
=
str
(
n_poses
)
meta_soup
.
opponent
.
append
(
linecount_tag
)
meta_soup
.
opponent
.
append
(
posecount_tag
)
with
open
(
meta_path
,
'
w
'
,
encoding
=
'
utf-8
'
)
as
f
:
f
.
write
(
str
(
meta_soup
))
for
arg
in
sys
.
argv
[
1
:]:
for
name
in
os
.
listdir
(
arg
):
path
=
osp
.
join
(
arg
,
name
)
if
osp
.
isdir
(
path
):
process
(
path
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment