Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
revised-submissions-final
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
miplib2017
revised-submissions-final
Commits
ab8f2ec7
Commit
ab8f2ec7
authored
Nov 06, 2018
by
Gregor Hendel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'add-exporter-file'
parents
0ce66249
966b8491
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
0 deletions
+68
-0
export_models.py
export_models.py
+44
-0
export_models_table.sh
export_models_table.sh
+24
-0
No files found.
export_models.py
0 → 100755
View file @
ab8f2ec7
#!/usr/bin/env python3
import
dicttoxml
import
os
import
sys
if
len
(
sys
.
argv
)
==
2
:
submissions_dir
=
sys
.
argv
[
1
]
else
:
print
(
"Please provide the revised-submissions folder as argument."
)
sys
.
exit
(
1
)
submissions_dir
=
os
.
path
.
abspath
(
submissions_dir
)
folders
=
os
.
listdir
(
submissions_dir
)
submissions
=
[]
for
folder
in
folders
:
folder_abspath
=
os
.
path
.
join
(
submissions_dir
,
folder
)
# skip nonfolder files and hidden files
if
not
os
.
path
.
isdir
(
folder
)
or
folder
[
0
]
==
"."
:
continue
info
=
{}
submission_elements
=
os
.
listdir
(
folder_abspath
)
for
element
in
submission_elements
:
element_abspath
=
os
.
path
.
join
(
folder_abspath
,
element
)
if
element
==
"models"
:
info
[
"models"
]
=
element_abspath
if
element
==
"instances"
:
instance_files
=
os
.
listdir
(
element_abspath
)
instances
=
[
instance
.
replace
(
".mps.gz"
,
''
)
for
instance
in
instance_files
]
info
[
"instances"
]
=
instances
if
"models"
in
info
.
keys
():
submissions
.
append
(
info
)
xml
=
dicttoxml
.
dicttoxml
(
submissions
,
custom_root
=
"models"
,
attr_type
=
False
)
from
xml.dom.minidom
import
parseString
dom
=
parseString
(
xml
)
print
(
dom
.
toprettyxml
())
export_models_table.sh
0 → 100755
View file @
ab8f2ec7
#! /bin/bash
if
[
-z
$1
]
then
tablename
=
"models_table.xml"
else
tablename
=
"
$1
"
fi
if
[
!
-f
venv/bin/python
]
then
virtualenv
--python
=
python3 venv
source
venv/bin/activate
pip
install
dicttoxml
deactivate
fi
echo
"Exporting models table to '
${
tablename
}
'"
venv/bin/python export_models.py
.
>
${
tablename
}
echo
"Zipping models archive."
zip
-ur
models.zip
*
/models
echo
"Done zipping models archive."
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment