Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions aws_doc_sdk_examples_tools/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ class Person:
alias: str


@dataclass
class FeedbackCti:
category: str
type: str
item: str


@dataclass
class Excerpt:
description: Optional[str]
Expand Down Expand Up @@ -75,7 +68,7 @@ class Version:
# List of people who have contributed to this example.
authors: List[Person] = field(default_factory=list)
# Feedback and maintenance owner. Primarily for internal use.
owner: Optional[FeedbackCti] = field(default=None)
owner: Optional[str] = field(default=None)
# Link to the original tributary that contributed this version.
source: Optional[Url] = field(default=None)

Expand Down
18 changes: 8 additions & 10 deletions aws_doc_sdk_examples_tools/metadata_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ def message(self):
return f"missing field {self.field}"


@dataclass
class InvalidFieldType(FieldError):
reason: str = "unknown"

def message(self):
return f"invalid field type {self.field} ({self.reason})"


@dataclass
class AwsNotEntity(FieldError):
check_err: str = ""
Expand Down Expand Up @@ -241,16 +249,6 @@ def message(self):
return "lists version which is not listed in sdks.yaml."


@dataclass
class InvalidFeedbackCti(SdkVersionError):
feedback_cti: str = ""

def message(self):
return (
f"has feedback CTI that is missing at least one field: {self.feedback_cti}"
)


@dataclass
class InvalidGithubLink(SdkVersionError):
link: str = ""
Expand Down
4 changes: 2 additions & 2 deletions aws_doc_sdk_examples_tools/metadata_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,12 +749,12 @@ def test_verify_load_successful():
name="None",
alias="[email protected]",
),
metadata_errors.InvalidFeedbackCti(
metadata_errors.InvalidFieldType(
file=ERRORS_METADATA_PATH,
id="sqs_InvalidOwner",
language="Java",
sdk_version=2,
feedback_cti="AWS|Documentation|None",
reason="must be string",
),
],
[
Expand Down
25 changes: 3 additions & 22 deletions aws_doc_sdk_examples_tools/yaml_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
# SPDX-License-Identifier: Apache-2.0

from typing import Dict, Set, Tuple, Any, List, Optional, Union
from pathlib import Path
from .metadata import (
Example,
Language,
Url,
Version,
Excerpt,
Person,
FeedbackCti,
)
from .sdks import Sdk
from .services import Service
Expand Down Expand Up @@ -220,23 +218,6 @@ def person_from_yaml(
return Person(name, alias)


def feedback_cti_from_yaml(
yaml: Union[None, Dict[str, Optional[str]]]
) -> Optional[Union[FeedbackCti, MetadataParseError]]:
if yaml is None:
return None
category = yaml.get("category")
type = yaml.get("type")
item = yaml.get("item")

if category is None or type is None or item is None:
return metadata_errors.InvalidFeedbackCti(
feedback_cti="|".join([str(category), str(type), str(item)])
)

return FeedbackCti(category, type, item)


def version_from_yaml(
yaml: Dict[str, Any],
cross_content_blocks: Set[str],
Expand Down Expand Up @@ -284,9 +265,9 @@ def version_from_yaml(
elif author is not None:
errors.append(author)

owner = feedback_cti_from_yaml(yaml.get("owner"))
if owner is not None and not isinstance(owner, FeedbackCti):
errors.append(owner)
owner = yaml.get("owner")
if owner and not isinstance(owner, str):
errors.append(metadata_errors.InvalidFieldType(reason="must be string"))
owner = None

add_services = parse_services(yaml.get("add_services", {}), errors)
Expand Down
Loading