From a110140d5b5e04eeee273e0b5dd70e4afc60abe4 Mon Sep 17 00:00:00 2001 From: geens Date: Sat, 26 Oct 2024 12:49:32 +0200 Subject: [PATCH] Fix for python 3.8 --- requirements.txt | 1 + sia/context_template.py | 4 ++-- test.sh | 1 - test/context_template_test.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index 93b42c2..ec4f350 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +bs4 docker torch transformers \ No newline at end of file diff --git a/sia/context_template.py b/sia/context_template.py index f099c39..d428661 100644 --- a/sia/context_template.py +++ b/sia/context_template.py @@ -1,3 +1,4 @@ +from bs4 import BeautifulSoup from typing import List, Dict import xml.etree.ElementTree as ET @@ -12,8 +13,7 @@ def generate_context(containers: List[Dict[str, any]]) -> str: """ context_elem = ET.Element("context") context_elem.append(format_containers_xml(containers)) - ET.indent(context_elem, space="\t") - return ET.tostring(context_elem, encoding='unicode') + return BeautifulSoup(ET.tostring(context_elem, encoding='unicode'), "xml").prettify() def format_containers_xml(containers: List[Dict[str, any]]) -> ET.Element: """Format container statuses as XML string. diff --git a/test.sh b/test.sh index 906082f..b9bc85f 100755 --- a/test.sh +++ b/test.sh @@ -22,6 +22,5 @@ docker run \ -v /$(pwd)/model/:/root/model/ \ $TAG - # Clean up image [ ! -z "$TAG" ] && docker rmi $TAG \ No newline at end of file diff --git a/test/context_template_test.py b/test/context_template_test.py index 0f5bfb5..bb9577a 100644 --- a/test/context_template_test.py +++ b/test/context_template_test.py @@ -7,7 +7,7 @@ class TestContextTemplate(unittest.TestCase): """Test context generation with no containers.""" context = generate_context([]) self.assertIn("", context) - self.assertIn("", context) + self.assertIn("", context) self.assertIn("", context) def test_single_container(self):