Simplify Harness.metadata to Dict
This commit is contained in:
parent
fc1ae46b6d
commit
b9a5a8d51d
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from typing import Optional, List, Tuple, Union
|
from typing import Optional, List, Dict, Tuple, Union
|
||||||
from dataclasses import dataclass, field, InitVar
|
from dataclasses import dataclass, field, InitVar
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
@ -32,10 +32,11 @@ OneOrMoreWires = Union[Wire, Tuple[Wire, ...]] # One or a tuple of wires
|
|||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Metadata:
|
class Metadata(Dict):
|
||||||
title: PlainText
|
pass
|
||||||
description: Optional[MultilineHypertext] = None
|
# title: PlainText
|
||||||
notes: Optional[MultilineHypertext] = None
|
# description: Optional[MultilineHypertext] = None
|
||||||
|
# notes: Optional[MultilineHypertext] = None
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
@ -37,10 +37,13 @@ def parse(yaml_input: str, file_out: (str, Path) = None, return_types: (None, st
|
|||||||
|
|
||||||
# Assign default metadata.title here to avoid needing file_out in Metadata.__post_init__().
|
# Assign default metadata.title here to avoid needing file_out in Metadata.__post_init__().
|
||||||
harness = Harness(
|
harness = Harness(
|
||||||
Metadata(**{'title': Path(file_out).stem, **yaml_data.get('metadata', {})}),
|
metadata = yaml_data.get('metadata', {}),
|
||||||
Options(**yaml_data.get('options', {})),
|
options = Options(**yaml_data.get('options', {})),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if not 'title' in harness.metadata:
|
||||||
|
harness.metadata['title'] = Path(file_out).stem
|
||||||
|
|
||||||
# add items
|
# add items
|
||||||
sections = ['connectors', 'cables', 'connections']
|
sections = ['connectors', 'cables', 'connections']
|
||||||
types = [dict, dict, list]
|
types = [dict, dict, list]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user