Skip to content

Commit

Permalink
Try fixing Python < 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
behdad committed Dec 18, 2023
1 parent aaab754 commit 87dc659
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions Lib/fontTools/misc/iterTools.py
@@ -0,0 +1,14 @@
from itertools import *

# Python 3.12:
if "batched" not in globals():
abort

Check warning on line 5 in Lib/fontTools/misc/iterTools.py

View check run for this annotation

Codecov / codecov/patch

Lib/fontTools/misc/iterTools.py#L5

Added line #L5 was not covered by tests

# https://docs.python.org/3/library/itertools.html#itertools.batched
def batched(iterable, n):

Check warning on line 8 in Lib/fontTools/misc/iterTools.py

View check run for this annotation

Codecov / codecov/patch

Lib/fontTools/misc/iterTools.py#L8

Added line #L8 was not covered by tests
# batched('ABCDEFG', 3) --> ABC DEF G
if n < 1:
raise ValueError("n must be at least one")
it = iter(iterable)

Check warning on line 12 in Lib/fontTools/misc/iterTools.py

View check run for this annotation

Codecov / codecov/patch

Lib/fontTools/misc/iterTools.py#L11-L12

Added lines #L11 - L12 were not covered by tests
while batch := tuple(islice(it, n)):
yield batch

Check warning on line 14 in Lib/fontTools/misc/iterTools.py

View check run for this annotation

Codecov / codecov/patch

Lib/fontTools/misc/iterTools.py#L14

Added line #L14 was not covered by tests
2 changes: 1 addition & 1 deletion Lib/fontTools/ttLib/scaleUpem.py
Expand Up @@ -14,7 +14,7 @@
from fontTools.varLib.multiVarStore import OnlineMultiVarStoreBuilder
from fontTools.misc.vector import Vector
from fontTools.misc.fixedTools import otRound
from itertools import batched
from fontTools.misc.iterTools import batched


__all__ = ["scale_upem", "ScalerVisitor"]
Expand Down
2 changes: 1 addition & 1 deletion Lib/fontTools/varLib/multiVarStore.py
Expand Up @@ -10,7 +10,7 @@
buildMultiVarStore,
buildMultiVarData,
)
from itertools import batched
from fontTools.misc.iterTools import batched
from functools import partial
from collections import defaultdict
from heapq import heappush, heappop
Expand Down

0 comments on commit 87dc659

Please sign in to comment.