Compare commits
3 commits
f2259653f7
...
87b24e7367
| Author | SHA1 | Date | |
|---|---|---|---|
| 87b24e7367 | |||
| 68c4baa634 | |||
| af6d11f457 |
22 changed files with 186 additions and 14 deletions
|
|
@ -1,3 +1,12 @@
|
|||
## 0.1.0a16 (2025-09-29)
|
||||
|
||||
### Feat
|
||||
|
||||
- variable with an index is an integer variable
|
||||
- default value for a calculated variable with an unknown optional variable
|
||||
- **#26**: convert cidr and network_cidr format
|
||||
- add integer type which will replace number type
|
||||
|
||||
## 0.1.0a15 (2025-09-22)
|
||||
|
||||
### Fix
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
|
|||
|
||||
[project]
|
||||
name = "rougail.output_formatter"
|
||||
version = "0.1.0a15"
|
||||
version = "0.1.0a16"
|
||||
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
||||
readme = "README.md"
|
||||
description = "Rougail output formatter"
|
||||
|
|
|
|||
|
|
@ -238,8 +238,7 @@ class RougailOutputFormatter:
|
|||
continue
|
||||
if attr in children:
|
||||
attr = f"_{attr}"
|
||||
value = self.object_to_yaml(attr, type_, value, False, path)
|
||||
family[attr] = value
|
||||
family[attr] = self.object_to_yaml(attr, type_, value, False, path)
|
||||
if type_ == "dynamic" or (children and type_ == "family"):
|
||||
if "_type" in family:
|
||||
del family["_type"]
|
||||
|
|
@ -323,6 +322,18 @@ class RougailOutputFormatter:
|
|||
):
|
||||
del variable["mandatory"]
|
||||
if "default" in variable:
|
||||
if isinstance(obj.default, VariableCalculation):
|
||||
is_multi = "multi" in variable and variable["multi"] is True
|
||||
if "type" in variable or is_multi:
|
||||
other_path = self.rougail.paths.get_full_path(obj.default.variable, path)
|
||||
if other_path in self.rougail.paths:
|
||||
other_obj = self.rougail.paths[other_path]
|
||||
if "type" in variable and variable["type"] == other_obj.type:
|
||||
del variable["type"]
|
||||
if is_multi and obj.multi:
|
||||
del variable["multi"]
|
||||
if "type" in variable and isinstance(obj.default, IndexCalculation) and variable["type"] == "integer":
|
||||
del variable["type"]
|
||||
if "type" in variable and variable["type"] in [
|
||||
"string",
|
||||
"boolean",
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
__version__ = "0.1.0a15"
|
||||
__version__ = "0.1.0a16"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
%YAML 1.2
|
||||
---
|
||||
version: 1.1
|
||||
|
||||
var1:
|
||||
description: a first variable
|
||||
type: domainname
|
||||
params:
|
||||
allow_ip: true
|
||||
multi: true
|
||||
|
||||
var2:
|
||||
description: a second variable
|
||||
default:
|
||||
variable: _.var1
|
||||
...
|
||||
25
tests/results/00_6ip/rougail/00-base.yml
Normal file
25
tests/results/00_6ip/rougail/00-base.yml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
%YAML 1.2
|
||||
---
|
||||
version: 1.1
|
||||
|
||||
var1:
|
||||
description: an IP
|
||||
type: ip
|
||||
default: 1.1.1.1
|
||||
|
||||
var2:
|
||||
description: an IP in CIDR format
|
||||
examples:
|
||||
- 192.168.0.128/25
|
||||
type: ip
|
||||
params:
|
||||
cidr: true
|
||||
default: 1.1.1.1/24
|
||||
|
||||
var3:
|
||||
description: an IP in CIDR format with obsolete CIDR type
|
||||
type: ip
|
||||
params:
|
||||
cidr: true
|
||||
default: 1.1.1.1/24
|
||||
...
|
||||
23
tests/results/00_6network/rougail/00-base.yml
Normal file
23
tests/results/00_6network/rougail/00-base.yml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
%YAML 1.2
|
||||
---
|
||||
version: 1.1
|
||||
|
||||
var1:
|
||||
description: an network
|
||||
type: network
|
||||
default: 1.1.1.0
|
||||
|
||||
var2:
|
||||
description: an network in CIDR format
|
||||
type: network
|
||||
params:
|
||||
cidr: true
|
||||
default: 1.1.1.0/24
|
||||
|
||||
var3:
|
||||
description: an network in CIDR format with obsolete CIDR type
|
||||
type: network
|
||||
params:
|
||||
cidr: true
|
||||
default: 1.1.1.0/24
|
||||
...
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
%YAML 1.2
|
||||
---
|
||||
version: 1.1
|
||||
|
||||
my_variable: val1
|
||||
|
||||
my_calculated_variable:
|
||||
- variable: _.my_variable
|
||||
optional: true
|
||||
- variable: _.my_variable_unexists
|
||||
optional: true
|
||||
default: value
|
||||
...
|
||||
|
|
@ -7,7 +7,6 @@ my_variable:
|
|||
- val2
|
||||
|
||||
my_calculated_variable:
|
||||
multi: true
|
||||
default:
|
||||
variable: _.my_variable
|
||||
optional: true
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
%YAML 1.2
|
||||
---
|
||||
version: 1.1
|
||||
|
||||
variable:
|
||||
description: a variable
|
||||
choices:
|
||||
variable: _.unknown_variable
|
||||
optional: true
|
||||
default:
|
||||
- a
|
||||
- b
|
||||
- c
|
||||
default: c
|
||||
...
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
%YAML 1.2
|
||||
---
|
||||
version: 1.1
|
||||
|
||||
condition: false # a condition
|
||||
|
||||
var1:
|
||||
description: a first variable
|
||||
mandatory: false
|
||||
hidden:
|
||||
variable: _.unknown
|
||||
optional: true
|
||||
|
||||
var2:
|
||||
description: a first variable
|
||||
mandatory: false
|
||||
hidden:
|
||||
variable: _.unknown
|
||||
optional: true
|
||||
default: true
|
||||
|
||||
var3:
|
||||
description: a second variable
|
||||
mandatory: false
|
||||
hidden:
|
||||
variable: _.condition
|
||||
optional: true
|
||||
default: true
|
||||
|
||||
var4:
|
||||
description: a forth variable
|
||||
mandatory: false
|
||||
hidden:
|
||||
variable: _.condition
|
||||
optional: true
|
||||
...
|
||||
|
|
@ -14,7 +14,6 @@ leader:
|
|||
|
||||
follower2:
|
||||
description: the follower2
|
||||
multi: true
|
||||
default:
|
||||
variable: _.follower1
|
||||
...
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ leader:
|
|||
|
||||
follower1:
|
||||
description: a follower
|
||||
type: integer
|
||||
default:
|
||||
type: index
|
||||
...
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
%YAML 1.2
|
||||
---
|
||||
version: 1.1
|
||||
|
||||
leader:
|
||||
description: a leadership
|
||||
type: leadership
|
||||
|
||||
leader: # a leader
|
||||
- a
|
||||
- b
|
||||
- c
|
||||
|
||||
follower1:
|
||||
description: a follower
|
||||
default:
|
||||
type: index
|
||||
...
|
||||
|
|
@ -16,7 +16,6 @@ leader:
|
|||
|
||||
calculate:
|
||||
description: a calculated variable
|
||||
multi: true
|
||||
default:
|
||||
variable: _.leader.follower1
|
||||
unique: false
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
%YAML 1.2
|
||||
---
|
||||
version: 1.1
|
||||
|
||||
dyn{{ identifier }}:
|
||||
description: a dynamic family
|
||||
dynamic:
|
||||
variable: _.unknown_var
|
||||
optional: true
|
||||
default:
|
||||
- a
|
||||
- b
|
||||
|
||||
var: val # a variable inside dynamic family
|
||||
...
|
||||
|
|
@ -19,7 +19,6 @@ my_dyn_family_{{ identifier }}:
|
|||
|
||||
var2:
|
||||
description: a variable
|
||||
multi: true
|
||||
default:
|
||||
variable: _.my_dyn_family_{{ identifier }}.var
|
||||
...
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ version: 1.1
|
|||
|
||||
var2:
|
||||
description: a variable
|
||||
multi: true
|
||||
default:
|
||||
variable: _.my_dyn_family_{{ identifier }}.var
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ version: 1.1
|
|||
|
||||
var2:
|
||||
description: a variable
|
||||
multi: true
|
||||
default:
|
||||
variable: _.my_dyn_family_{{ identifier }}.var
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ my_dyn_family_{{ identifier }}:
|
|||
|
||||
var2:
|
||||
description: a variable
|
||||
multi: true
|
||||
default:
|
||||
variable: _.my_dyn_family_{{ identifier }}.var
|
||||
...
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ my_dyn_family_{{ identifier }}:
|
|||
|
||||
var2:
|
||||
description: a variable
|
||||
multi: true
|
||||
default:
|
||||
variable: _.my_dyn_family_{{ identifier }}.var
|
||||
...
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ excludes = [
|
|||
]
|
||||
|
||||
test_ok = get_structures_list(excludes)
|
||||
test_ok = [Path('../rougail-tests/structures/00_2default_calculated_variable')]
|
||||
# test_ok = [Path('../rougail-tests/structures/40_2leadership_calculation_index')]
|
||||
|
||||
|
||||
def idfn(fixture_value):
|
||||
|
|
|
|||
Loading…
Reference in a new issue