MCPcopy Index your code
hub / github.com/slackapi/python-slack-sdk / parse

Method parse

slack_sdk/models/blocks/blocks.py:65–116  ·  view source on GitHub ↗
(cls, block: Union[dict, "Block"])

Source from the content-addressed store, hash-verified

63
64 @classmethod
65 def parse(cls, block: Union[dict, "Block"]) -> Optional["Block"]:
66 if block is None:
67 return None
68 elif isinstance(block, Block):
69 return block
70 else:
71 if "type" in block:
72 type = block["type"]
73 if type == SectionBlock.type:
74 return SectionBlock(**block)
75 elif type == DividerBlock.type:
76 return DividerBlock(**block)
77 elif type == ImageBlock.type:
78 return ImageBlock(**block)
79 elif type == ActionsBlock.type:
80 return ActionsBlock(**block)
81 elif type == ContextBlock.type:
82 return ContextBlock(**block)
83 elif type == ContextActionsBlock.type:
84 return ContextActionsBlock(**block)
85 elif type == InputBlock.type:
86 return InputBlock(**block)
87 elif type == FileBlock.type:
88 return FileBlock(**block)
89 elif type == CallBlock.type:
90 return CallBlock(**block)
91 elif type == HeaderBlock.type:
92 return HeaderBlock(**block)
93 elif type == MarkdownBlock.type:
94 return MarkdownBlock(**block)
95 elif type == VideoBlock.type:
96 return VideoBlock(**block)
97 elif type == RichTextBlock.type:
98 return RichTextBlock(**block)
99 elif type == TableBlock.type:
100 return TableBlock(**block)
101 elif type == TaskCardBlock.type:
102 return TaskCardBlock(**block)
103 elif type == PlanBlock.type:
104 return PlanBlock(**block)
105 elif type == CardBlock.type:
106 return CardBlock(**block)
107 elif type == AlertBlock.type:
108 return AlertBlock(**block)
109 elif type == CarouselBlock.type:
110 return CarouselBlock(**block)
111 else:
112 cls.logger.warning(f"Unknown block detected and skipped ({block})")
113 return None
114 else:
115 cls.logger.warning(f"Unknown block detected and skipped ({block})")
116 return None
117
118 @classmethod
119 def parse_all(cls, blocks: Optional[Sequence[Union[dict, "Block"]]]) -> List["Block"]:

Callers 15

test_parse_from_dictMethod · 0.45
test_parse_noneMethod · 0.45
test_confirm_styleMethod · 0.45
test_parseMethod · 0.45
test_parse_timepickerMethod · 0.45
test_parseMethod · 0.45
test_documentMethod · 0.45
test_documentMethod · 0.45

Calls 15

SectionBlockClass · 0.85
DividerBlockClass · 0.85
ImageBlockClass · 0.85
ActionsBlockClass · 0.85
ContextBlockClass · 0.85
ContextActionsBlockClass · 0.85
InputBlockClass · 0.85
FileBlockClass · 0.85
CallBlockClass · 0.85
HeaderBlockClass · 0.85
MarkdownBlockClass · 0.85
VideoBlockClass · 0.85

Tested by 15

test_parse_from_dictMethod · 0.36
test_parse_noneMethod · 0.36
test_confirm_styleMethod · 0.36
test_parseMethod · 0.36
test_parse_timepickerMethod · 0.36
test_parseMethod · 0.36
test_documentMethod · 0.36
test_documentMethod · 0.36