Files
Danik Klimuk 38906581c4 Add gitcliff and reuse fix (#633)
* add git-cliff and reuse

Files that do not support comments or that have problems adding comments
at the first line should have a separate .license file or a rule inside
REUSE.toml (in case there are a lot of such files).

.robot files generally support comments at the first line, but robotidy
does not want comments to start at first line. It wants so, that everything
that is located before first section should be placed inside "Comments"
section. But reuse does not support license headers in any sections. So
reuse and robotidy have a conflict here.

Because there are a lot of .robot files, I have decided to add them into
REUSE.toml instead of separate .license files or robotidy exceptions.

Signed-off-by: Daniil Klimuk <daniil.klimuk@3mdeb.com>

* add LICENSES and license headers to files

Files that does not have license headers have either .license file or a
rule inside REUSE.toml.

Signed-off-by: Daniil Klimuk <daniil.klimuk@3mdeb.com>

* .github: ISSUE_TEMPLATE: fix markdownlint

Signed-off-by: Daniil Klimuk <daniil.klimuk@3mdeb.com>

* README: add git-cliff and reuse

Signed-off-by: Daniil Klimuk <daniil.klimuk@3mdeb.com>

---------

Signed-off-by: Daniil Klimuk <daniil.klimuk@3mdeb.com>
2024-12-17 18:49:05 +01:00

41 lines
1.2 KiB
Python
Executable File

#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2024 3mdeb <contact@3mdeb.com>
#
# SPDX-License-Identifier: Apache-2.0
import os
import re
import sys
lib_dir = "lib"
output_resource = sys.argv[1] if len(sys.argv) > 1 else "all-keywords.robot"
# Collect all .robot files
robot_files = ["keywords.robot"]
for root, dirs, files in os.walk(lib_dir):
for file in files:
if file.endswith(".robot"):
robot_files.append(os.path.join(root, file))
# Regex pattern to detect keyword definitions
keyword_pattern = re.compile(
r"^(?:(?!Library|Resource|Variables|Documentation)[A-Z][a-z0-9_]+[\ ]+.*)"
)
delimiter = "." # Between filename and the keyword
# Create the combined resource file with prefixed keywords
with open(output_resource, "w", encoding="utf8") as res_file:
for robot_file in robot_files:
file_prefix = os.path.splitext(os.path.basename(robot_file))[0] + delimiter
index_offset = 0
with open(robot_file, "r", encoding="utf8") as read_file:
for line in read_file:
if re.match(keyword_pattern, line):
res_file.write(file_prefix + line)
else:
res_file.write(line)