File tree 3 files changed +33
-8
lines changed
3 files changed +33
-8
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ python3 ./build_docs.py --quick --build-root ./build_root --www-root ./www --log
17
17
```
18
18
19
19
If you don't need to build all translations of all branches, add
20
- ` --language en --branch main ` .
20
+ ` --language en --branches main ` .
21
21
22
22
23
23
## Check current version
Original file line number Diff line number Diff line change @@ -86,16 +86,18 @@ def from_json(cls, data) -> Versions:
86
86
)
87
87
return cls (versions )
88
88
89
- def filter (self , branch : str = "" ) -> Sequence [Version ]:
89
+ def filter (self , branches : list [ str ] = None ) -> Sequence [Version ]:
90
90
"""Filter the given versions.
91
91
92
- If *branch * is given, only *versions* matching *branch * are returned.
92
+ If *branches * is given, only *versions* matching *branches * are returned.
93
93
94
94
Else all live versions are returned (this means no EOL and no
95
95
security-fixes branches).
96
96
"""
97
- if branch :
98
- return [v for v in self if branch in (v .name , v .branch_or_tag )]
97
+ if branches :
98
+ return [
99
+ v for v in self if v .name in branches or v .branch_or_tag in branches
100
+ ]
99
101
return [v for v in self if v .status not in {"EOL" , "security-fixes" }]
100
102
101
103
@property
@@ -935,9 +937,11 @@ def parse_args():
935
937
)
936
938
parser .add_argument (
937
939
"-b" ,
938
- "--branch" ,
940
+ "--branch" , # Deprecated
941
+ "--branches" ,
942
+ nargs = "*" ,
939
943
metavar = "3.12" ,
940
- help = "Version to build (defaults to all maintained branches)." ,
944
+ help = "Versions to build (defaults to all maintained branches)." ,
941
945
)
942
946
parser .add_argument (
943
947
"-r" ,
Original file line number Diff line number Diff line change @@ -35,7 +35,28 @@ def test_filter_one() -> None:
35
35
])
36
36
37
37
# Act
38
- filtered = versions .filter ("3.13" )
38
+ filtered = versions .filter ([ "3.13" ] )
39
39
40
40
# Assert
41
41
assert filtered == [Version ("3.13" , status = "security" )]
42
+
43
+
44
+ def test_filter_multiple () -> None :
45
+ # Arrange
46
+ versions = Versions ([
47
+ Version ("3.14" , status = "feature" ),
48
+ Version ("3.13" , status = "bugfix" ),
49
+ Version ("3.12" , status = "bugfix" ),
50
+ Version ("3.11" , status = "security" ),
51
+ Version ("3.10" , status = "security" ),
52
+ Version ("3.9" , status = "security" ),
53
+ ])
54
+
55
+ # Act
56
+ filtered = versions .filter (["3.13" , "3.14" ])
57
+
58
+ # Assert
59
+ assert filtered == [
60
+ Version ("3.14" , status = "feature" ),
61
+ Version ("3.13" , status = "security" ),
62
+ ]
You can’t perform that action at this time.
0 commit comments