File tree Expand file tree Collapse file tree 3 files changed +33
-8
lines changed Expand file tree Collapse file tree 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
1717```
1818
1919If you don't need to build all translations of all branches, add
20- ` --language en --branch main ` .
20+ ` --language en --branches main ` .
2121
2222
2323## Check current version
Original file line number Diff line number Diff line change @@ -86,16 +86,18 @@ def from_json(cls, data) -> Versions:
8686 )
8787 return cls (versions )
8888
89- def filter (self , branch : str = "" ) -> Sequence [Version ]:
89+ def filter (self , branches : list [ str ] = None ) -> Sequence [Version ]:
9090 """Filter the given versions.
9191
92- If *branch * is given, only *versions* matching *branch * are returned.
92+ If *branches * is given, only *versions* matching *branches * are returned.
9393
9494 Else all live versions are returned (this means no EOL and no
9595 security-fixes branches).
9696 """
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+ ]
99101 return [v for v in self if v .status not in {"EOL" , "security-fixes" }]
100102
101103 @property
@@ -935,9 +937,11 @@ def parse_args():
935937 )
936938 parser .add_argument (
937939 "-b" ,
938- "--branch" ,
940+ "--branch" , # Deprecated
941+ "--branches" ,
942+ nargs = "*" ,
939943 metavar = "3.12" ,
940- help = "Version to build (defaults to all maintained branches)." ,
944+ help = "Versions to build (defaults to all maintained branches)." ,
941945 )
942946 parser .add_argument (
943947 "-r" ,
Original file line number Diff line number Diff line change @@ -35,7 +35,28 @@ def test_filter_one() -> None:
3535 ])
3636
3737 # Act
38- filtered = versions .filter ("3.13" )
38+ filtered = versions .filter ([ "3.13" ] )
3939
4040 # Assert
4141 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