summaryrefslogtreecommitdiff
path: root/scripts/py/gen_default_input_cpp.py
diff options
context:
space:
mode:
authorRichard Burton <richard.burton@arm.com>2022-03-17 10:54:26 +0000
committerRichard <richard.burton@arm.com>2022-03-17 15:19:16 +0000
commit17069628a7f28198652a296ac16dc83529c7eaae (patch)
treeadff78b64954e67dc4e29f6f039c63c8c18cde2c /scripts/py/gen_default_input_cpp.py
parent624dafd2a206d88da979453442fe5a8d4c05ad51 (diff)
downloadml-embedded-evaluation-kit-17069628a7f28198652a296ac16dc83529c7eaae.tar.gz
MLECO-3036: Update to use Pathlib in Python scripts
* Pathlib used in Python scripts over os * Bug fix for build_default.py * Minor code style updates Signed-off-by: Richard Burton <richard.burton@arm.com> Change-Id: I5fc2e582a84443c3fb79250eb711b960d63ed8fd
Diffstat (limited to 'scripts/py/gen_default_input_cpp.py')
-rw-r--r--scripts/py/gen_default_input_cpp.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/scripts/py/gen_default_input_cpp.py b/scripts/py/gen_default_input_cpp.py
index c091fd1..e42f4ae 100644
--- a/scripts/py/gen_default_input_cpp.py
+++ b/scripts/py/gen_default_input_cpp.py
@@ -17,9 +17,9 @@
Utility script to generate the minimum InputFiles.hpp and cpp files required by an application.
"""
import datetime
-import os
-
+from pathlib import Path
from argparse import ArgumentParser
+
from jinja2 import Environment, FileSystemLoader
parser = ArgumentParser()
@@ -28,7 +28,7 @@ parser.add_argument("--license_template", type=str, help="Header template file",
default="header_template.txt")
args = parser.parse_args()
-env = Environment(loader=FileSystemLoader(os.path.join(os.path.dirname(__file__), 'templates')),
+env = Environment(loader=FileSystemLoader(Path(__file__).parent / 'templates'),
trim_blocks=True,
lstrip_blocks=True)
@@ -36,7 +36,7 @@ env = Environment(loader=FileSystemLoader(os.path.join(os.path.dirname(__file__)
def write_hpp_file(header_file_path, header_template_file):
print(f"++ Generating {header_file_path}")
header_template = env.get_template(header_template_file)
- hdr = header_template.render(script_name=os.path.basename(__file__),
+ hdr = header_template.render(script_name=Path(__file__).name,
gen_time=datetime.datetime.now(),
year=datetime.datetime.now().year)
env.get_template('default.hpp.template').stream(common_template_header=hdr) \
@@ -45,7 +45,7 @@ def write_hpp_file(header_file_path, header_template_file):
def main(args):
header_filename = "InputFiles.hpp"
- header_filepath = os.path.join(args.header_folder_path, header_filename)
+ header_filepath = Path(args.header_folder_path) / header_filename
write_hpp_file(header_filepath, args.license_template)