Simplify Harness.metadata to Dict

This commit is contained in:
Daniel Rojas 2021-03-27 13:36:31 +01:00
parent fc1ae46b6d
commit b9a5a8d51d
2 changed files with 11 additions and 7 deletions

View File

@ -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

View File

@ -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]