diff --git a/nuldc/helpers.py b/nuldc/helpers.py index 5d4bb7c..1bdcabf 100644 --- a/nuldc/helpers.py +++ b/nuldc/helpers.py @@ -12,7 +12,7 @@ retries = urllib3.Retry(total=5, backoff_factor=1, status_forcelist=[429, 500, 502, 503, 504], - method_whitelist=['GET', 'POST']) + allowed_methods=['GET', 'POST']) session = requests.Session() adapter = HTTPAdapter(max_retries=retries) @@ -176,8 +176,17 @@ def save_as_csv(headers, values, output_file): def save_xml(data, output_file): """takes results as a list of dicts and writes them out to xml""" + + # TODO DRY up this bit and sort_fields_and_values + + ignore_fields = ['embedding', 'embedding_model'] + + data = [{key: value + for (key, value) in sorted(d.items()) + if key not in ignore_fields} for d in data.get('data')] xml = dicttoxml.dicttoxml(data, attr_type=False) + with open(output_file, 'wb') as xmlfile: xmlfile.write(xml) diff --git a/pyproject.toml b/pyproject.toml index 82d80ce..d05a1da 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "nuldc" -version = "0.10.0" +version = "0.10.1" description = "" authors = ["davidschober "] license = "MIT"