Skip to content

Commit 652f9a1

Browse files
committed
chore: refactor configuration profiles
1 parent 0b27713 commit 652f9a1

File tree

14 files changed

+338
-218
lines changed

14 files changed

+338
-218
lines changed

.vscode/launch.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"name": "Python: Debug in terminal",
1010
"type": "python",
1111
"request": "launch",
12-
"purpose": ["debug-in-terminal"],
12+
"purpose": [
13+
"debug-in-terminal"
14+
],
1315
"justMyCode": false
1416
},
1517
{
@@ -43,6 +45,9 @@
4345
"justMyCode": false,
4446
"cwd": "${workspaceFolder}/tests/robotcode/language_server/robotframework/parts/data",
4547
"args": [
48+
49+
"-p",
50+
"firefox",
4651
"--dry",
4752
"run"
4853
]

etc/robot.json renamed to etc/robot.toml.json

Lines changed: 96 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,28 @@
33
"$schema": "http://json-schema.org/draft-07/schema#",
44
"additionalProperties": false,
55
"definitions": {
6-
"DetachableConfiguration": {
6+
"ConsoleType": {
7+
"description": "Run mode for Robot Framework.",
8+
"enum": [
9+
"verbose",
10+
"dotted",
11+
"quiet",
12+
"none"
13+
],
14+
"title": "ConsoleType",
15+
"type": "string"
16+
},
17+
"Mode": {
18+
"description": "Run mode for Robot Framework.",
19+
"enum": [
20+
"default",
21+
"rpa",
22+
"norpa"
23+
],
24+
"title": "Mode",
25+
"type": "string"
26+
},
27+
"Profile": {
728
"additionalProperties": false,
829
"properties": {
930
"args": {
@@ -15,15 +36,29 @@
1536
"type": "array"
1637
},
1738
"console": {
18-
"title": "Console",
19-
"type": "string"
39+
"anyOf": [
40+
{
41+
"$ref": "#/definitions/ConsoleType"
42+
},
43+
{
44+
"type": "string"
45+
}
46+
],
47+
"description": "Console output type.",
48+
"title": "Console"
2049
},
2150
"debug-file": {
2251
"title": "Debug-File",
2352
"type": "string"
2453
},
54+
"description": {
55+
"description": "Description of the profile.",
56+
"title": "Description",
57+
"type": "string"
58+
},
2559
"detached": {
2660
"default": false,
61+
"description": "If the profile should be detached.\"\nDetached means it is not inherited from the main profile.\n",
2762
"title": "Detached",
2863
"type": "boolean"
2964
},
@@ -68,11 +103,9 @@
68103
"type": "string"
69104
},
70105
"meta-data": {
71-
"items": {
72-
"type": "string"
73-
},
106+
"description": "Set metadata of the top level suite. Value can\ncontain formatting and be read from a file similarly\n\nExamples:\n```toml\n[meta-data]\nVersion = \"1.2\"\nRelease = \"release.txt\"\n```\n",
74107
"title": "Meta-Data",
75-
"type": "array"
108+
"type": "object"
76109
},
77110
"mode": {
78111
"$ref": "#/definitions/Mode"
@@ -94,11 +127,19 @@
94127
"type": "object"
95128
},
96129
"paths": {
97-
"items": {
98-
"type": "string"
99-
},
100-
"title": "Paths",
101-
"type": "array"
130+
"anyOf": [
131+
{
132+
"type": "string"
133+
},
134+
{
135+
"items": {
136+
"type": "string"
137+
},
138+
"type": "array"
139+
}
140+
],
141+
"description": "Paths to test data. If no paths are given at the command line this value is used.\n",
142+
"title": "Paths"
102143
},
103144
"pre-rebot-modifiers": {
104145
"additionalProperties": {
@@ -117,7 +158,7 @@
117158
"type": "object"
118159
},
119160
"python-path": {
120-
"description": "Additional locations directories where\nto search test libraries and other extensions when\nthey are imported. Given path can also be a glob\npattern matching multiple paths.\n\nExamples:\n```toml\npython_path = [\"./lib\", \"./resources\"]\n```\n",
161+
"description": "Additional locations directories where\nto search test libraries and other extensions when\nthey are imported. Given path can also be a glob\npattern matching multiple paths.\n\nExamples:\n```toml\npython-path = [\"./lib\", \"./resources\"]\n```\n",
121162
"items": {
122163
"type": "string"
123164
},
@@ -139,15 +180,6 @@
139180
},
140181
"title": "robot.toml",
141182
"type": "object"
142-
},
143-
"Mode": {
144-
"description": "Run mode for Robot Framework.",
145-
"enum": [
146-
"default",
147-
"rpa",
148-
"norpa"
149-
],
150-
"title": "Mode"
151183
}
152184
},
153185
"description": "Configuration for Robot Framework.",
@@ -161,13 +193,36 @@
161193
"type": "array"
162194
},
163195
"console": {
164-
"title": "Console",
165-
"type": "string"
196+
"anyOf": [
197+
{
198+
"$ref": "#/definitions/ConsoleType"
199+
},
200+
{
201+
"type": "string"
202+
}
203+
],
204+
"description": "Console output type.",
205+
"title": "Console"
166206
},
167207
"debug-file": {
168208
"title": "Debug-File",
169209
"type": "string"
170210
},
211+
"default-profile": {
212+
"anyOf": [
213+
{
214+
"type": "string"
215+
},
216+
{
217+
"items": {
218+
"type": "string"
219+
},
220+
"type": "array"
221+
}
222+
],
223+
"description": "Selects the Default profile if no profile is given at command line.\n\nExamples:\n```toml\ndefault_profile = \"default\"\n```\n\n```toml\ndefault_profile = [\"default\", \"Firefox\"]\n```\n",
224+
"title": "Default-Profile"
225+
},
171226
"doc": {
172227
"description": "Set the documentation of the top level suite.\nSimple formatting is supported (e.g. *bold*). If the\ndocumentation contains spaces, it must be quoted.\nIf the value is path to an existing file, actual\ndocumentation is read from that file.\n\nExamples:\n```toml\ndoc = \"\"\"Very *good* example\n\nThis is a second paragraph.\n\"\"\"\n```\n",
173228
"title": "Doc",
@@ -209,11 +264,9 @@
209264
"type": "string"
210265
},
211266
"meta-data": {
212-
"items": {
213-
"type": "string"
214-
},
267+
"description": "Set metadata of the top level suite. Value can\ncontain formatting and be read from a file similarly\n\nExamples:\n```toml\n[meta-data]\nVersion = \"1.2\"\nRelease = \"release.txt\"\n```\n",
215268
"title": "Meta-Data",
216-
"type": "array"
269+
"type": "object"
217270
},
218271
"mode": {
219272
"$ref": "#/definitions/Mode"
@@ -235,11 +288,19 @@
235288
"type": "object"
236289
},
237290
"paths": {
238-
"items": {
239-
"type": "string"
240-
},
241-
"title": "Paths",
242-
"type": "array"
291+
"anyOf": [
292+
{
293+
"type": "string"
294+
},
295+
{
296+
"items": {
297+
"type": "string"
298+
},
299+
"type": "array"
300+
}
301+
],
302+
"description": "Paths to test data. If no paths are given at the command line this value is used.\n",
303+
"title": "Paths"
243304
},
244305
"pre-rebot-modifiers": {
245306
"additionalProperties": {
@@ -259,14 +320,14 @@
259320
},
260321
"profiles": {
261322
"additionalProperties": {
262-
"$ref": "#/definitions/DetachableConfiguration"
323+
"$ref": "#/definitions/Profile"
263324
},
264325
"description": "Execution Profiles.",
265326
"title": "Profiles",
266327
"type": "object"
267328
},
268329
"python-path": {
269-
"description": "Additional locations directories where\nto search test libraries and other extensions when\nthey are imported. Given path can also be a glob\npattern matching multiple paths.\n\nExamples:\n```toml\npython_path = [\"./lib\", \"./resources\"]\n```\n",
330+
"description": "Additional locations directories where\nto search test libraries and other extensions when\nthey are imported. Given path can also be a glob\npattern matching multiple paths.\n\nExamples:\n```toml\npython-path = [\"./lib\", \"./resources\"]\n```\n",
270331
"items": {
271332
"type": "string"
272333
},

hatch.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ dependencies = [
2121
"GitPython",
2222
"semantic-version",
2323
"robotremoteserver",
24+
"pydantic",
2425
]
2526
features = ["yaml", "rest", "lint", "tidy"]
2627
pre-install-commands = ["python ./scripts/install_packages.py"]
@@ -32,6 +33,7 @@ no-cov = "cov --no-cov {args}"
3233
test = "pytest {args}"
3334
test-reset = "test --regtest-reset"
3435
install-bundled-editable = "python ./scripts/install_bundled_editable.py"
36+
create_json_schema = "python ./scripts/create_robot_toml_json_schema.py"
3537

3638
[envs.devel]
3739
python = "38"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"tomlValidation": [
7878
{
7979
"fileMatch": "robot.toml",
80-
"url": "https://raw.githubusercontent.com/d-biehl/robotcode/main/etc/robot.json"
80+
"url": "http://raw.githubusercontent.com/d-biehl/robotcode/main/etc/robot.toml.json"
8181
}
8282
],
8383
"configurationDefaults": {

packages/analyze/robotcode/analyze/cli/__init__.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
from typing import Tuple, Union
1+
from typing import Union
22

33
import click
4-
from robot.run import USAGE
5-
from robot.version import get_full_version
64

75
from ..__version__ import __version__
86

@@ -19,13 +17,11 @@
1917
version=__version__,
2018
package_name="robotcode.analyze",
2119
prog_name="RobotCode Analyze",
22-
message=f"%(prog)s %(version)s\n{USAGE.splitlines()[0].split(' -- ')[0].strip()} {get_full_version()}",
2320
)
24-
@click.argument("robot_options_and_args", nargs=-1, type=click.Path())
2521
@click.pass_context
2622
def analyze(
2723
ctx: click.Context,
28-
robot_options_and_args: Tuple[str, ...],
2924
) -> Union[str, int, None]:
30-
"""Analyzes Robot Framework test data."""
25+
"""Analyzes Robot Framework Tests."""
26+
click.echo("Not implemented yet")
3127
return 0

packages/robot/robotcode/robot/config/loader.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
else:
88
import tomli as tomllib
99

10-
from .model import Configuration
1110

11+
from .model import MainProfile
1212

13-
def create_from_toml(__s: str) -> Configuration:
13+
14+
def create_from_toml(__s: str) -> MainProfile:
1415
dict_data = tomllib.loads(__s)
15-
return from_dict(dict_data, Configuration)
16+
return from_dict(dict_data, MainProfile)

0 commit comments

Comments
 (0)