Simplify Harness.metadata to Dict
This commit is contained in:
parent
fc1ae46b6d
commit
b9a5a8d51d
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- 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 pathlib import Path
|
||||
|
||||
@ -32,10 +32,11 @@ OneOrMoreWires = Union[Wire, Tuple[Wire, ...]] # One or a tuple of wires
|
||||
|
||||
|
||||
@dataclass
|
||||
class Metadata:
|
||||
title: PlainText
|
||||
description: Optional[MultilineHypertext] = None
|
||||
notes: Optional[MultilineHypertext] = None
|
||||
class Metadata(Dict):
|
||||
pass
|
||||
# title: PlainText
|
||||
# description: Optional[MultilineHypertext] = None
|
||||
# notes: Optional[MultilineHypertext] = None
|
||||
|
||||
|
||||
@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__().
|
||||
harness = Harness(
|
||||
Metadata(**{'title': Path(file_out).stem, **yaml_data.get('metadata', {})}),
|
||||
Options(**yaml_data.get('options', {})),
|
||||
metadata = yaml_data.get('metadata', {}),
|
||||
options = Options(**yaml_data.get('options', {})),
|
||||
)
|
||||
|
||||
if not 'title' in harness.metadata:
|
||||
harness.metadata['title'] = Path(file_out).stem
|
||||
|
||||
# add items
|
||||
sections = ['connectors', 'cables', 'connections']
|
||||
types = [dict, dict, list]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user