1010import os
1111import re
1212from os import path
13- from typing import Any , List , Set
13+ from typing import Any , Set
1414
1515from .cname import CName
1616from .parser import Parser
@@ -67,12 +67,11 @@ def main() -> None:
6767
6868 args = parser .parse_args ()
6969
70- assert bool (args .feature_dir ) or bool (
71- args . release_file
72- ), "Please provide either `--feature_dir` or `--release_file` argument"
70+ assert bool (args .feature_dir ) or bool (args . release_file ), (
71+ "Please provide either `--feature_dir` or `-- release_file` argument"
72+ )
7373
7474 arch = args .arch
75- flavor = None
7675 commit_id_or_hash = args .commit
7776 gardenlinux_root = path .dirname (args .feature_dir )
7877 version = args .version
@@ -97,18 +96,15 @@ def main() -> None:
9796
9897 version = args .default_version
9998
100- if args .cname :
101- cname = CName (
102- args .cname , arch = arch , commit_hash = commit_id_or_hash , version = version
103- )
99+ cname = CName (args .cname , arch = arch , commit_hash = commit_id_or_hash , version = version )
104100
105- if args .release_file is not None :
106- cname .load_from_release_file (args .release_file )
101+ if args .release_file is not None :
102+ cname .load_from_release_file (args .release_file )
107103
108- arch = cname .arch
109- flavor = cname .flavor
110- commit_id_or_hash = cname .commit_id
111- version = cname .version
104+ arch = cname .arch
105+ flavor = cname .flavor
106+ commit_id_or_hash = cname .commit_id
107+ version = cname .version
112108
113109 if (arch is None or arch == "" ) and (
114110 args .type in ("cname" , "container_name" , "arch" )
@@ -152,7 +148,7 @@ def main() -> None:
152148 features_parser = Parser (gardenlinux_root , feature_dir_name )
153149
154150 print_output_from_features_parser (
155- args .type , features_parser , flavor , args .ignore
151+ args .type , cname , features_parser , flavor , args .ignore
156152 )
157153 else :
158154 print_output_from_cname (args .type , cname )
@@ -233,7 +229,11 @@ def graph_as_mermaid_markup(flavor: str | None, graph: Any) -> str:
233229
234230
235231def print_output_from_features_parser (
236- output_type : str , parser : Parser , flavor : str , ignores_list : set
232+ output_type : str ,
233+ cname_instance : CName ,
234+ parser : Parser ,
235+ flavor : str ,
236+ ignores_list : set ,
237237) -> None :
238238 """
239239 Prints output to stdout based on the given features parser and parameters.
@@ -246,15 +246,16 @@ def print_output_from_features_parser(
246246 :since: 0.11.0
247247 """
248248
249- additional_filter_func = lambda node : node not in ignores_list
249+ def additional_filter_func (node ):
250+ return node not in ignores_list
250251
251252 if output_type == "features" :
252253 print (
253254 parser .filter_as_string (
254255 flavor , additional_filter_func = additional_filter_func
255256 )
256257 )
257- elif ( output_type in "platform" , "elements" , "flags" ):
258+ elif output_type in ( "platform" , "elements" , "flags" ):
258259 features_by_type = parser .filter_as_dict (
259260 flavor , additional_filter_func = additional_filter_func
260261 )
@@ -280,11 +281,11 @@ def print_output_from_features_parser(
280281 elif output_type == "cname" :
281282 cname = flavor
282283
283- if arch is not None :
284- cname += f"-{ arch } "
284+ if cname_instance . arch is not None :
285+ cname += f"-{ cname_instance . arch } "
285286
286- if commit_id_or_hash is not None :
287- cname += f"-{ version } - { commit_id_or_hash [: 8 ] } "
287+ if cname_instance . version_and_commit_id is not None :
288+ cname += f"-{ cname_instance . version_and_commit_id } "
288289
289290 print (cname )
290291 elif output_type == "container_name" :
0 commit comments