From 7de40a2d687d84028a013a89a2a4491b61ddfc5d Mon Sep 17 00:00:00 2001 From: David C Ellis Date: Fri, 7 Jun 2024 16:50:57 +0100 Subject: [PATCH] Slight tweaks to field handling in tutorial. --- docs/tutorial.md | 4 ++-- docs_code/tutorial_code.py | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/docs/tutorial.md b/docs/tutorial.md index e0120df..679ba6b 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -101,8 +101,8 @@ Demonstrate the output of this gatherer: class GathererTest: __fields__ = { "field_1": "First Field", - "field_2": dtbuild.Field(default="Second Field"), - "field_3": CustomField(default="Third Field", report=False) + "field_2": CustomField(default="Second Field"), + "field_3": CustomField(default="Third Field", report=False), } pp(fields_attribute_gatherer(GathererTest)) diff --git a/docs_code/tutorial_code.py b/docs_code/tutorial_code.py index 9345996..861ff17 100644 --- a/docs_code/tutorial_code.py +++ b/docs_code/tutorial_code.py @@ -27,11 +27,9 @@ def fields_attribute_gatherer(cls_or_ns): gathered_fields = {} - # Field or CustomField instances will be copied and converted if needed - # Plain values will be made into CustomField instances for k, v in cls_fields_attrib.items(): - if isinstance(v, dtbuild.Field): - gathered_fields[k] = CustomField.from_field(v) + if isinstance(v, CustomField): + gathered_fields[k] = v else: gathered_fields[k] = CustomField(default=v) @@ -47,8 +45,8 @@ def fields_attribute_gatherer(cls_or_ns): class GathererTest: __fields__ = { "field_1": "First Field", - "field_2": dtbuild.Field(default="Second Field"), - "field_3": CustomField(default="Third Field", report=False) + "field_2": CustomField(default="Second Field"), + "field_3": CustomField(default="Third Field", report=False), } pp(fields_attribute_gatherer(GathererTest))