From 50243907ebd0facf649e75275280fffc6622fbc6 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Fri, 2 Feb 2024 07:54:14 +0000 Subject: [PATCH 1/3] add get_env function to jinja utils --- src/ibek/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ibek/utils.py b/src/ibek/utils.py index 06a2be862..0be485d4d 100644 --- a/src/ibek/utils.py +++ b/src/ibek/utils.py @@ -7,6 +7,7 @@ we pass a single instance of this class into all Jinja contexts. """ +import os from dataclasses import dataclass from pathlib import Path from typing import Any, Dict @@ -62,6 +63,12 @@ def set_ioc_name(self: "Utils", name: str): """ self.ioc_name = name + def get_env(self, key: str) -> str: + """ + Get an environment variable + """ + return os.environ.get(key, "") + def set_var(self, key: str, value: Any): """create a global variable for our jinja context""" self.variables[key] = value From b21c769226b67d9909b68dacc698d5d6742fa406 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Fri, 2 Feb 2024 07:56:05 +0000 Subject: [PATCH 2/3] update linting and dependencies --- .vscode/settings.json | 6 ------ src/ibek/gen_scripts.py | 1 + src/ibek/ioc.py | 1 + src/ibek/support.py | 1 + tests/samples/outputs/index.bob | 10 +++++----- tests/samples/outputs/simple.pvi.bob | 10 +++++----- tests/test_cli.py | 1 + tests/test_error.py | 1 + tests/test_render.py | 1 + tests/test_support.py | 1 + 10 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 003c771d8..8cd0fbd66 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,7 +6,6 @@ ], "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true, - "python.languageServer": "Pylance", "editor.formatOnSave": true, "[python]": { "editor.codeActionsOnSave": { @@ -14,10 +13,5 @@ "source.organizeImports.ruff": "explicit", "source.black": "explicit" } - }, - "workbench.colorCustomizations": { - "activityBar.background": "#01333D", - "titleBar.activeBackground": "#014756", - "titleBar.activeForeground": "#F1FDFF" } } \ No newline at end of file diff --git a/src/ibek/gen_scripts.py b/src/ibek/gen_scripts.py index fb11bbad8..19fb0b384 100644 --- a/src/ibek/gen_scripts.py +++ b/src/ibek/gen_scripts.py @@ -1,6 +1,7 @@ """ Functions for building the db and boot scripts """ + import logging import re from pathlib import Path diff --git a/src/ibek/ioc.py b/src/ibek/ioc.py index 6b1c804f3..82c83d470 100644 --- a/src/ibek/ioc.py +++ b/src/ibek/ioc.py @@ -2,6 +2,7 @@ Functions for generating an IocInstance derived class from a support module definition YAML file """ + from __future__ import annotations import builtins diff --git a/src/ibek/support.py b/src/ibek/support.py index 6df327867..80037d65c 100644 --- a/src/ibek/support.py +++ b/src/ibek/support.py @@ -1,6 +1,7 @@ """ The Support Class represents a deserialized .ibek.support.yaml file. """ + from __future__ import annotations import json diff --git a/tests/samples/outputs/index.bob b/tests/samples/outputs/index.bob index c4cc00f77..b425043bc 100644 --- a/tests/samples/outputs/index.bob +++ b/tests/samples/outputs/index.bob @@ -2,7 +2,7 @@ Display 0 0 - 273 + 388 55 4 4 @@ -12,7 +12,7 @@ ibek-mo-ioc-01 - Index 0 0 - 273 + 388 25 @@ -30,7 +30,7 @@ Simple 23 30 - 115 + 150 20 @@ -46,9 +46,9 @@ Simple - 143 + 178 30 - 125 + 205 20 $(actions) diff --git a/tests/samples/outputs/simple.pvi.bob b/tests/samples/outputs/simple.pvi.bob index 61c53372c..545d4633f 100644 --- a/tests/samples/outputs/simple.pvi.bob +++ b/tests/samples/outputs/simple.pvi.bob @@ -2,7 +2,7 @@ Display 0 0 - 273 + 388 55 4 4 @@ -12,7 +12,7 @@ Simple Device - ${prefix} 0 0 - 273 + 388 25 @@ -30,15 +30,15 @@ Simple PV 23 30 - 115 + 150 20 TextUpdate ${prefix}Simple - 143 + 178 30 - 125 + 205 20 diff --git a/tests/test_cli.py b/tests/test_cli.py index 55bf2f68b..b64851e35 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -2,6 +2,7 @@ System tests that run the CLI commands and compare the output to expected results. """ + import json import subprocess import sys diff --git a/tests/test_error.py b/tests/test_error.py index 56d20126a..ed49a153e 100644 --- a/tests/test_error.py +++ b/tests/test_error.py @@ -1,6 +1,7 @@ """ Tests to verify that the error handling works as expected. """ + from pathlib import Path import pytest diff --git a/tests/test_render.py b/tests/test_render.py index 804d7d52c..b22c2c39a 100644 --- a/tests/test_render.py +++ b/tests/test_render.py @@ -2,6 +2,7 @@ Unit tests for the rendering of scripts and database entries from generated Entity classes """ + from typing import Literal from ibek.ioc import IOC, clear_entity_model_ids diff --git a/tests/test_support.py b/tests/test_support.py index b3607c120..da5920935 100644 --- a/tests/test_support.py +++ b/tests/test_support.py @@ -1,4 +1,5 @@ """Unit tests for the support subcommand""" + from pathlib import Path from ibek.support_cmds.files import symlink_files From 44d4a622d494e348fdefee073ec14d771630f7d3 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Fri, 2 Feb 2024 08:05:48 +0000 Subject: [PATCH 3/3] fix #173 --- src/ibek/dev_cmds/commands.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ibek/dev_cmds/commands.py b/src/ibek/dev_cmds/commands.py index 8882fe29b..f0c32716e 100644 --- a/src/ibek/dev_cmds/commands.py +++ b/src/ibek/dev_cmds/commands.py @@ -19,6 +19,7 @@ def instance( file_okay=False, exists=True, autocompletion=lambda: [], # Forces path autocompletion + resolve_path=True, ), ): """