github.com/aws-cloudformation/cloudformation-cli-go-plugin@v1.2.0/python/rpdk/go/utils.py (about)

     1  from typing import Callable
     2  
     3  # https://golang.org/ref/spec#Keywords
     4  LANGUAGE_KEYWORDS = {
     5      "break",
     6      "default",
     7      "func",
     8      "interface",
     9      "select",
    10      "case",
    11      "defer",
    12      "go",
    13      "map",
    14      "struct",
    15      "chan",
    16      "else",
    17      "goto",
    18      "package",
    19      "switch",
    20      "const",
    21      "fallthrough",
    22      "if",
    23      "range",
    24      "type",
    25      "continue",
    26      "for",
    27      "import",
    28      "return",
    29      "var",
    30  }
    31  
    32  
    33  def safe_reserved(string: str) -> str:
    34      if string in LANGUAGE_KEYWORDS:
    35          return string + "_"
    36      return string
    37  
    38  
    39  def validate_path(default: str) -> Callable[[str], str]:
    40      def _validate_namespace(value: str) -> str:
    41          if not value:
    42              return default
    43  
    44          namespace = value
    45  
    46          return namespace
    47  
    48      return _validate_namespace