(self)
| 1019 | return False |
| 1020 | |
| 1021 | def run(self): |
| 1022 | debug = False |
| 1023 | |
| 1024 | # gh-9339: skip execution when inside an excluded only block. |
| 1025 | if self._is_inside_excluded_only(): |
| 1026 | return [] |
| 1027 | |
| 1028 | #TODO, any reason block_parser can't be a method of embeddable shell |
| 1029 | # then we wouldn't have to carry these around |
| 1030 | rgxin, rgxout, promptin, promptout = self.setup() |
| 1031 | |
| 1032 | options = self.options |
| 1033 | self.shell.is_suppress = 'suppress' in options |
| 1034 | self.shell.is_doctest = 'doctest' in options |
| 1035 | self.shell.is_verbatim = 'verbatim' in options |
| 1036 | self.shell.is_okexcept = 'okexcept' in options |
| 1037 | self.shell.is_okwarning = 'okwarning' in options |
| 1038 | |
| 1039 | # handle pure python code |
| 1040 | if 'python' in self.arguments: |
| 1041 | content = self.content |
| 1042 | self.content = self.shell.process_pure_python(content) |
| 1043 | |
| 1044 | # parts consists of all text within the ipython-block. |
| 1045 | # Each part is an input/output block. |
| 1046 | parts = '\n'.join(self.content).split('\n\n') |
| 1047 | |
| 1048 | lines = ['.. code-block:: ipython', ''] |
| 1049 | figures = [] |
| 1050 | |
| 1051 | # Use sphinx logger for warnings |
| 1052 | logger = logging.getLogger(__name__) |
| 1053 | |
| 1054 | for part in parts: |
| 1055 | block = block_parser(part, rgxin, rgxout, promptin, promptout) |
| 1056 | if len(block): |
| 1057 | rows, figure = self.shell.process_block(block) |
| 1058 | for row in rows: |
| 1059 | lines.extend([' {0}'.format(line) |
| 1060 | for line in row.split('\n')]) |
| 1061 | |
| 1062 | if figure is not None: |
| 1063 | figures.append(figure) |
| 1064 | else: |
| 1065 | message = 'Code input with no code at {}, line {}'\ |
| 1066 | .format( |
| 1067 | self.state.document.current_source, |
| 1068 | self.state.document.current_line) |
| 1069 | if self.shell.warning_is_error: |
| 1070 | raise RuntimeError(message) |
| 1071 | else: |
| 1072 | logger.warning(message) |
| 1073 | |
| 1074 | for figure in figures: |
| 1075 | lines.append('') |
| 1076 | lines.extend(figure.split('\n')) |
| 1077 | lines.append('') |
| 1078 |
nothing calls this directly
no test coverage detected