Skip to content

Commit

Permalink
fix: resolve the version variable conflicts between format and software
Browse files Browse the repository at this point in the history
  • Loading branch information
joanise committed Jul 12, 2024
1 parent 1b500b6 commit 9f3414e
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 23 deletions.
2 changes: 2 additions & 0 deletions readalongs/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
VERSION = "1.1.0"

READALONG_FILE_FORMAT_VERSION = "1.1"
7 changes: 3 additions & 4 deletions readalongs/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
from pympi.Praat import TextGrid
from webvtt import Caption, WebVTT

from readalongs import VERSION
from readalongs._version import __version__
from readalongs._version import READALONG_FILE_FORMAT_VERSION, VERSION
from readalongs.audio_utils import (
extract_section,
mute_section,
Expand Down Expand Up @@ -1197,8 +1196,8 @@ def create_ras_from_text(lines: Iterable[str], text_languages=Sequence[str]) ->
kwargs = {
"main_lang": text_languages[0],
"fallback_langs": ",".join(text_languages[1:]),
"studio_version": __version__,
"format_version": VERSION,
"studio_version": VERSION,
"format_version": READALONG_FILE_FORMAT_VERSION,
}
pages: List[dict] = []
paragraphs: List[dict] = []
Expand Down
5 changes: 2 additions & 3 deletions readalongs/web_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
from pydantic import BaseModel, Field
from starlette.background import BackgroundTask

from readalongs import VERSION
from readalongs._version import __version__
from readalongs._version import READALONG_FILE_FORMAT_VERSION, VERSION
from readalongs.align import create_ras_from_text, save_label_files, save_subtitles
from readalongs.log import LOGGER, capture_logs
from readalongs.text.add_ids_to_xml import add_ids
Expand Down Expand Up @@ -340,7 +339,7 @@ class ConvertRequest(BaseModel):
</body>
</text>
</read-along>"""
% (VERSION, __version__)
% (READALONG_FILE_FORMAT_VERSION, VERSION)
)
],
)
Expand Down
5 changes: 2 additions & 3 deletions test/test_align_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
from lxml.html import fromstring
from sound_swallower_stub import SoundSwallowerStub

from readalongs import VERSION
from readalongs._version import __version__
from readalongs._version import READALONG_FILE_FORMAT_VERSION, VERSION
from readalongs.cli import align, langs


Expand Down Expand Up @@ -331,8 +330,8 @@ def test_bad_anchors(self):
<anchor /><s>Bonjour.</s><anchor time="invalid"/>
</p></body></text></read-along>
""" % (
READALONG_FILE_FORMAT_VERSION,
VERSION,
__version__,
)
xml_file = join(self.tempdir, "bad-anchor.readalong")
with open(xml_file, "w", encoding="utf8") as f:
Expand Down
8 changes: 3 additions & 5 deletions test/test_make_xml_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,18 @@

from basic_test_case import BasicTestCase

from readalongs import VERSION

# from readalongs.log import LOGGER
from readalongs._version import __version__
from readalongs._version import READALONG_FILE_FORMAT_VERSION, VERSION
from readalongs.align import create_input_ras, create_ras_from_text
from readalongs.cli import align, make_xml


def updateFormatVersion(input):
return input.replace("{{format_version}}", VERSION)
return input.replace("{{format_version}}", READALONG_FILE_FORMAT_VERSION)


def updateStudioVersion(input):
return input.replace("{{studio_version}}", __version__)
return input.replace("{{studio_version}}", VERSION)


class TestMakeXMLCli(BasicTestCase):
Expand Down
4 changes: 2 additions & 2 deletions test/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pep440 import is_canonical
from test_dna_utils import segments_from_pairs

from readalongs._version import VERSION
from readalongs._version import READALONG_FILE_FORMAT_VERSION, VERSION
from readalongs.align import split_silences
from readalongs.log import LOGGER, capture_logs
from readalongs.text.util import (
Expand Down Expand Up @@ -105,8 +105,8 @@ def test_get_attrib_recursive(self):
</text>
</read-along>
""" % (
READALONG_FILE_FORMAT_VERSION,
VERSION,
__version__,
)
xml = parse_xml(raw_xml)

Expand Down
11 changes: 5 additions & 6 deletions test/test_web_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

from basic_test_case import BasicTestCase

from readalongs import VERSION
from readalongs._version import __version__
from readalongs._version import READALONG_FILE_FORMAT_VERSION, VERSION
from readalongs.log import LOGGER
from readalongs.text.add_ids_to_xml import add_ids
from readalongs.text.convert_xml import convert_xml
Expand Down Expand Up @@ -36,8 +35,8 @@ def slurp_data_file(self, filename: str) -> str:
return (
f.read()
.strip()
.replace("{{format_version}}", VERSION)
.replace("{{studio_version}}", __version__)
.replace("{{format_version}}", READALONG_FILE_FORMAT_VERSION)
.replace("{{studio_version}}", VERSION)
)

def test_assemble_from_plain_text(self):
Expand Down Expand Up @@ -222,7 +221,7 @@ def test_debug(self):
</text>
</read-along>
"""
% (VERSION, __version__)
% (READALONG_FILE_FORMAT_VERSION, VERSION)
)

def test_convert_to_TextGrid(self):
Expand Down Expand Up @@ -456,7 +455,7 @@ def test_cleanup_even_if_error(self):
</text>
</read-along>
"""
% (VERSION, __version__)
% (READALONG_FILE_FORMAT_VERSION, VERSION)
)
request = {
"dur": 83.1,
Expand Down

0 comments on commit 9f3414e

Please sign in to comment.