1515from datetime import datetime
1616from continuous_delivery_scripts .utils .configuration import configuration , ConfigurationVariable
1717from continuous_delivery_scripts .utils .logging import set_log_level , log_exception
18- from continuous_delivery_scripts .utils .python_helpers import flatten_dictionary
18+ from continuous_delivery_scripts .utils .python .python_helpers import flatten_dictionary
19+ from continuous_delivery_scripts .language_specifics import get_language_specifics
1920from pathlib import Path
2021
2122logger = logging .getLogger (__name__ )
2223
23- LICENCE_HEADER_TEMPLATE = """Copyright (C) {date} {author}. All rights reserved.
24- SPDX-License-Identifier: {licence_identifier}
25- """
26-
2724FILES_TO_IGNORE = ["*.yml" , "*.yaml" ]
2825
2926
@@ -34,7 +31,9 @@ def add_licence_header(verbose_count: int) -> None:
3431 """
3532 # copyright (https://github.com/knipknap/copyright) was first considered but
3633 # comprises quite a few bugs and does not seem active anymore.
37- template_string = _generate_header_template ()
34+ if not get_language_specifics ().can_add_licence_headers ():
35+ return
36+ template_string = get_language_specifics ().generate_source_licence_header_template ()
3837 with tempfile .NamedTemporaryFile (suffix = ".tmpl" , delete = False ) as template_file :
3938 template_file_path = Path (template_file .name )
4039 logger .debug (f"Creates template file in { str (template_file_path )} " )
@@ -44,15 +43,6 @@ def add_licence_header(verbose_count: int) -> None:
4443 _call_licensehearders (copyright_config , verbose_count )
4544
4645
47- def _generate_header_template () -> str :
48- """Generates the header template which is put at the top of source files."""
49- return LICENCE_HEADER_TEMPLATE .format (
50- licence_identifier = configuration .get_value (ConfigurationVariable .FILE_LICENCE_IDENTIFIER ),
51- author = "${owner}" ,
52- date = "${years}" ,
53- )
54-
55-
5646def _call_licensehearders (config : dict , verbose_count : int ) -> None :
5747 """Runs licenseheaders tool."""
5848 args = ["licenseheaders" ]
@@ -83,7 +73,7 @@ def get_tool_config(template_file: Path) -> dict:
8373 "projname" : configuration .get_value (ConfigurationVariable .PROJECT_NAME ),
8474 "tmpl" : str (template_file ),
8575 "years" : copyright_dates ,
86- "additional-extensions" : "python=.toml" ,
76+ "additional-extensions" : "python=.toml c=.go " ,
8777 "exclude" : FILES_TO_IGNORE ,
8878 }
8979
0 commit comments