commit 4e72e985bd74b53a5ed505914efcedae02420469
parent 69bfc326c9db9081988e17969dc752f7e04982e7
Author: krasjet
Date: 2023-04-20 21:24Z
type stability enhancements à la #14. close #14
Diffstat:
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/pdftocgen/filter.py b/pdftocgen/filter.py
@@ -138,13 +138,14 @@ class ToCFilter:
bbox: BoundingBoxFilter
def __init__(self, fltr_dict: dict):
- self.level = fltr_dict.get('level')
+ lvl = fltr_dict.get('level')
- if self.level is None:
+ if lvl is None:
raise ValueError("filter's 'level' is not set")
- if self.level < 1:
+ if lvl < 1:
raise ValueError("filter's 'level' must be >= 1")
+ self.level = lvl
self.greedy = fltr_dict.get('greedy', False)
self.font = FontFilter(fltr_dict.get('font', {}))
self.bbox = BoundingBoxFilter(fltr_dict.get('bbox', {}))
diff --git a/pdftocgen/recipe.py b/pdftocgen/recipe.py
@@ -1,5 +1,5 @@
from dataclasses import dataclass
-from typing import Optional, List, Dict
+from typing import Optional, List, Dict, Iterator
from .filter import ToCFilter
from fitzutils import ToCEntry
from itertools import chain
@@ -44,7 +44,7 @@ class Fragment:
level: int
-def concatFrag(frags: List[Optional[Fragment]], sep: str = " ") -> Dict[int, str]:
+def concatFrag(frags: Iterator[Optional[Fragment]], sep: str = " ") -> Dict[int, str]:
"""Concatenate fragments to strings
Returns