fix tests
authorRadek Czajka <rczajka@rczajka.pl>
Mon, 28 Apr 2025 12:04:42 +0000 (14:04 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Mon, 28 Apr 2025 12:04:42 +0000 (14:04 +0200)
setup.py
src/librarian/builders/daisy.py
src/librarian/elements/base.py
src/librarian/html.py
tests/files/text/asnyk_miedzy_nami_expected.legacy.html
tox.ini

index df8212c..41fa6a4 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -40,11 +40,11 @@ setup(
         'Pillow>=9.1.0',
         'texml',
         'ebooklib',
-        'aeneas',
         'mutagen',
         'qrcode',
         'requests',
         'fonttools',
+        'python-bidi',
     ],
     entry_points = {
         "console_scripts": [
index c706cbd..bdfc306 100644 (file)
@@ -5,8 +5,6 @@ from copy import deepcopy
 import subprocess
 import tempfile
 import zipfile
-from aeneas.executetask import ExecuteTask
-from aeneas.task import Task
 from lxml import etree
 import mutagen
 from librarian import OutputFile, get_resource
@@ -117,7 +115,7 @@ class DaisyBuilder:
                 directory + "book%d.mp3" % i,
             )
 
-            config_string = "task_language=pol|is_text_type=unparsed|is_text_unparsed_id_regex=sec\d+$|is_text_unparsed_id_sort=numeric|os_task_file_format=tab"
+            config_string = "task_language=pol|is_text_type=unparsed|is_text_unparsed_id_regex=sec\\d+$|is_text_unparsed_id_sort=numeric|os_task_file_format=tab"
             task = Task(config_string=config_string)
 
             with tempfile.TemporaryDirectory() as temp:
index b0d16ed..f430c23 100644 (file)
@@ -136,7 +136,7 @@ class WLElement(etree.ElementBase):
         for i, child in enumerate(self):
             if isinstance(child, WLElement):
                 getattr(child, build_method)(builder)
-            elif getattr(builder, 'debug') and child.tag is etree.Comment:
+            elif getattr(builder, 'debug', False) and child.tag is etree.Comment:
                 builder.process_comment(child)
             if self.CAN_HAVE_TEXT and child.tail:
                 text = self.normalize_text(child.tail, builder)
index d6482dc..73ea15d 100644 (file)
@@ -113,7 +113,10 @@ def transform(wldoc, stylesheet='legacy', options=None, flags=None, css=None, ga
                 document.edoc.getroot().set(flag, 'yes')
 
         ltag = document.edoc.find('//' + DCNS('language'))
-        lang = functions.lang_code_3to2(ltag.text) or 'pl'
+        if ltag is not None:
+            lang = functions.lang_code_3to2(ltag.text)
+        else:
+            lang = 'pl'
         document.edoc.getroot().set('lang', lang)
 
         document.clean_ed_note()
index 7004f5a..64fea81 100644 (file)
@@ -1,4 +1,4 @@
-<div xmlns:wl="http://wolnelektury.pl/functions" xmlns:dc="http://purl.org/dc/elements/1.1/" id="book-text">
+<div xmlns:wl="http://wolnelektury.pl/functions" xmlns:dc="http://purl.org/dc/elements/1.1/" id="book-text" lang="pl">
 <div id="toc">
 <h2>Spis treści</h2>
 <ol></ol>
 <div class="stanza">
 <a name="sec7"></a><div class="verse">Prócz tych wspólnych, jasnych zdrojów,</div>
 <div class="verse">Z których serce zachwyt piło;</div>
-<a name="f15" class="target"> </a><a href="#f15" class="anchor">15</a><div class="verse">Prócz pierwiosnków<a name="anchor-idmNNN"></a><a href="#footnote-idmNNN" class="annotation">[1]</a><a class="reference" data-uri="https://www.wikidata.org/wiki/Q158974"></a> i powojów,—</div>
+<a name="f15" class="target"> </a><a href="#f15" class="anchor">15</a><div class="verse">Prócz pierwiosnków<a name="anchor-id1"></a><a href="#footnote-id1" class="annotation">[1]</a><a class="reference" data-uri="https://www.wikidata.org/wiki/Q158974"></a> i powojów,—</div>
 <div class="verse">Między nami nic nie było!<span class="theme-end" fid="1189062528872"></span><span class="theme-end" fid="1189062500041"></span>
 </div>
 </div>
 <div id="footnotes">
 <h3>Przypisy</h3>
 <div class="fn-pe">
-<a name="footnote-idmNNN"></a><a href="#anchor-idmNNN" class="annotation">[1]</a><p><em class="foreign-word">pierwiosnek</em> — taki kwiatek [przypis edytorski]</p>
+<a name="footnote-id1"></a><a href="#anchor-id1" class="annotation">[1]</a><p><em class="foreign-word">pierwiosnek</em> — taki kwiatek [przypis edytorski]</p>
 </div>
 </div>
 </div>
diff --git a/tox.ini b/tox.ini
index ecf3ecc..489be44 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -1,26 +1,27 @@
 [tox]
 envlist =
     clean,
-    py{37,38,39,310,311},
+    py{38,39,310,311,312},
     stats
 
 [testenv]
 deps =
     coverage
-passenv = HOME  ; Needed to find locally installed fonts when testing PDF production.
+; Needed to find locally installed fonts when testing PDF production.
+passenv = HOME
 download = true
 commands =
     coverage run
-install_command = pip install numpy; pip install --extra-index-url https://py.mdrn.pl/simple {packages}
+install_command = pip install --extra-index-url https://py.mdrn.pl/simple {packages}
 
 [testenv:clean]
-basepython = python3
+basepython = python312
 commands =
     coverage erase
 deps = coverage
 
 [testenv:stats]
-basepython = python3
+basepython = python312
 commands =
     coverage combine
     coverage report