Commit aacfbc0c authored by Franziska Schloesser's avatar Franziska Schloesser

add exporter files

parent 5fbd4b92
#!/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())
#! /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}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment