Skip to content

Commit 5fa5956

Browse files
authored
Replace deprecated pyparsing names and arguments (#1974)
Require pyparsing>=3.0.0
1 parent e486f43 commit 5fa5956

File tree

6 files changed

+24
-23
lines changed

6 files changed

+24
-23
lines changed

cadquery/assembly.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,21 @@ def _define_grammar():
5858
Optional,
5959
alphas,
6060
alphanums,
61-
delimitedList,
61+
DelimitedList,
6262
)
6363

6464
Separator = Literal("@").suppress()
6565
TagSeparator = Literal("?").suppress()
6666

67-
Name = delimitedList(
67+
Name = DelimitedList(
6868
Word(alphas, alphanums + "_"), PATH_DELIM, combine=True
69-
).setResultsName("name")
70-
Tag = Word(alphas, alphanums + "_").setResultsName("tag")
71-
Selector = _selector_grammar.setResultsName("selector")
69+
).set_results_name("name")
70+
Tag = Word(alphas, alphanums + "_").set_results_name("tag")
71+
Selector = _selector_grammar.set_results_name("selector")
7272

7373
SelectorType = (
7474
Literal("solids") | Literal("faces") | Literal("edges") | Literal("vertices")
75-
).setResultsName("selector_kind")
75+
).set_results_name("selector_kind")
7676

7777
return (
7878
Name
@@ -331,7 +331,7 @@ def _query(self, q: str) -> Tuple[str, Optional[Shape]]:
331331
tmp: Workplane
332332
res: Workplane
333333

334-
query = _grammar.parseString(q, True)
334+
query = _grammar.parse_string(q, True)
335335
name: str = query.name
336336

337337
obj = self.objects[name].obj

cadquery/selectors.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
nums,
1616
Optional,
1717
Combine,
18-
oneOf,
18+
one_of,
1919
Group,
20-
infixNotation,
20+
infix_notation,
2121
opAssoc,
2222
)
2323
from functools import reduce
@@ -606,23 +606,23 @@ def _makeGrammar():
606606
)
607607

608608
# direction definition
609-
simple_dir = oneOf(["X", "Y", "Z", "XY", "XZ", "YZ"])
609+
simple_dir = one_of(["X", "Y", "Z", "XY", "XZ", "YZ"])
610610
direction = simple_dir("simple_dir") | vector("vector_dir")
611611

612612
# CQ type definition
613-
cqtype = oneOf(
613+
cqtype = one_of(
614614
set(geom_LUT_EDGE.values()) | set(geom_LUT_FACE.values()), caseless=True,
615615
)
616-
cqtype = cqtype.setParseAction(pyparsing_common.upcaseTokens)
616+
cqtype = cqtype.set_parse_action(pyparsing_common.upcase_tokens)
617617

618618
# type operator
619619
type_op = Literal("%")
620620

621621
# direction operator
622-
direction_op = oneOf([">", "<"])
622+
direction_op = one_of([">", "<"])
623623

624624
# center Nth operator
625-
center_nth_op = oneOf([">>", "<<"])
625+
center_nth_op = one_of([">>", "<<"])
626626

627627
# index definition
628628
ix_number = Group(Optional("-") + Word(nums))
@@ -632,10 +632,10 @@ def _makeGrammar():
632632
index = lsqbracket + ix_number("index") + rsqbracket
633633

634634
# other operators
635-
other_op = oneOf(["|", "#", "+", "-"])
635+
other_op = one_of(["|", "#", "+", "-"])
636636

637637
# named view
638-
named_view = oneOf(["front", "back", "left", "right", "top", "bottom"])
638+
named_view = one_of(["front", "back", "left", "right", "top", "bottom"])
639639

640640
return (
641641
direction("only_dir")
@@ -760,14 +760,14 @@ def _makeExpressionGrammar(atom):
760760
# define operators
761761
and_op = Literal("and")
762762
or_op = Literal("or")
763-
delta_op = oneOf(["exc", "except"])
763+
delta_op = one_of(["exc", "except"])
764764
not_op = Literal("not")
765765

766766
def atom_callback(res):
767767
return _SimpleStringSyntaxSelector(res)
768768

769769
# construct a simple selector from every matched
770-
atom.setParseAction(atom_callback)
770+
atom.set_parse_action(atom_callback)
771771

772772
# define callback functions for all operations
773773
def and_callback(res):
@@ -790,7 +790,7 @@ def not_callback(res):
790790
return InverseSelector(right)
791791

792792
# construct the final grammar and set all the callbacks
793-
expr = infixNotation(
793+
expr = infix_notation(
794794
atom,
795795
[
796796
(and_op, 2, opAssoc.LEFT, and_callback),
@@ -862,7 +862,7 @@ def __init__(self, selectorString):
862862
Feed the input string through the parser and construct an relevant complex selector object
863863
"""
864864
self.selectorString = selectorString
865-
parse_result = _expression_grammar.parseString(selectorString, parseAll=True)
865+
parse_result = _expression_grammar.parse_string(selectorString, parse_all=True)
866866
self.mySelector = parse_result.asList()[0]
867867

868868
def filter(self, objectList: Sequence[Shape]):

conda/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ requirements:
1818
- python >=3.10
1919
- ocp=7.8.1
2020
- vtk=*=qt*
21-
- pyparsing >=2.1.9
21+
- pyparsing >=3.0.0
2222
- ezdxf>=1.3.0
2323
- ipython
2424
- typing_extensions

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies:
66
- ipython
77
- ocp=7.8.1
88
- vtk=*=qt*
9-
- pyparsing>=2.1.9
9+
- pyparsing>=3.0.0
1010
- sphinx=9.1.0
1111
# - sphinx_rtd_theme=3.1.0
1212
- mypy

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"path",
3636
"trame",
3737
"trame-vtk",
38+
"pyparsing>=3.0.0",
3839
]
3940

4041

tests/test_selectors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ def testGrammar(self):
11351135
]
11361136

11371137
for e in expressions:
1138-
gram.parseString(e, parseAll=True)
1138+
gram.parse_string(e, parse_all=True)
11391139

11401140
def testShape(self):
11411141
"""

0 commit comments

Comments
 (0)