diff --git a/Makefile b/Makefile index 9ece544..f172148 100644 --- a/Makefile +++ b/Makefile @@ -57,7 +57,7 @@ test: cat requirements.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \ cat requirements-dev.txt | xargs -L 1 .$(PYTHON)/bin/pip install PYTHONPATH=. .$(PYTHON)/bin/python -m unittest discover - -.$(PYTHON)/bin/pycodestyle subaligner tests examples misc bin/subaligner bin/subaligner_1pass bin/subaligner_2pass bin/subaligner_train bin/subaligner_tune setup.py --ignore=E203,E501,W503 + -.$(PYTHON)/bin/pycodestyle subaligner tests examples misc bin/subaligner bin/subaligner_1pass bin/subaligner_2pass bin/subaligner_train bin/subaligner_tune setup.py --ignore=E203,E501,W503 --exclude="subaligner/lib" test-all: ## run tests on every Python version with tox .$(PYTHON)/bin/tox diff --git a/subaligner/subtitle.py b/subaligner/subtitle.py index aa0e043..daba64e 100644 --- a/subaligner/subtitle.py +++ b/subaligner/subtitle.py @@ -3,6 +3,7 @@ import os import re import xml.etree.ElementTree as ElementTree +import inspect from typing import Optional, List from pysrt import SubRipFile, SubRipItem from copy import deepcopy @@ -367,15 +368,13 @@ def export_subtitle(source_file_path: str, subs: List[SubRipItem], target_file_p # Change single quotes in the XML header to double quotes with open(target_file_path, "w", encoding=encoding) as target: - normalised = ( - ElementTree.tostring(tt, xml_declaration=True, method="xml") - .decode(encoding) - .replace( - "= python 3.8 + encoded = ElementTree.tostring(tt, encoding=encoding, method="xml", xml_declaration=True) + else: + encoded = ElementTree.tostring(tt, encoding=encoding, method="xml") + normalised = encoded.decode(encoding) \ + .replace("", '"?>') - ) target.write(normalised) elif file_extension in Subtitle.WEBVTT_EXTENSIONS: try: diff --git a/subaligner/utils.py b/subaligner/utils.py index a3c144f..4c6d91e 100644 --- a/subaligner/utils.py +++ b/subaligner/utils.py @@ -18,6 +18,7 @@ from .exception import TerminalException from subaligner.lib.to_srt import STL, SRT + class Utils(object): """Utility functions """ diff --git a/tests/subaligner/resource/test.dfxp b/tests/subaligner/resource/test.dfxp index 200808b..18695cc 100644 --- a/tests/subaligner/resource/test.dfxp +++ b/tests/subaligner/resource/test.dfxp @@ -1,4 +1,4 @@ - + diff --git a/tests/subaligner/resource/test.ttml b/tests/subaligner/resource/test.ttml index 200808b..18695cc 100644 --- a/tests/subaligner/resource/test.ttml +++ b/tests/subaligner/resource/test.ttml @@ -1,4 +1,4 @@ - + diff --git a/tests/subaligner/resource/test.xml b/tests/subaligner/resource/test.xml index 200808b..18695cc 100644 --- a/tests/subaligner/resource/test.xml +++ b/tests/subaligner/resource/test.xml @@ -1,4 +1,4 @@ - +