当前位置: 首页>>代码示例>>Python>>正文


Python DocumentStructure.flush_structure方法代码示例

本文整理汇总了Python中botocore.docs.bcdoc.restdoc.DocumentStructure.flush_structure方法的典型用法代码示例。如果您正苦于以下问题:Python DocumentStructure.flush_structure方法的具体用法?Python DocumentStructure.flush_structure怎么用?Python DocumentStructure.flush_structure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在botocore.docs.bcdoc.restdoc.DocumentStructure的用法示例。


在下文中一共展示了DocumentStructure.flush_structure方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _create_docstring

# 需要导入模块: from botocore.docs.bcdoc.restdoc import DocumentStructure [as 别名]
# 或者: from botocore.docs.bcdoc.restdoc.DocumentStructure import flush_structure [as 别名]
 def _create_docstring(self):
     docstring_structure = DocumentStructure('docstring')
     # Call the document method function with the args and kwargs
     # passed to the class.
     self._write_docstring(
         docstring_structure, *self._gen_args,
         **self._gen_kwargs)
     return docstring_structure.flush_structure().decode('utf-8')
开发者ID:monkeysecurity,项目名称:botocore,代码行数:10,代码来源:docstring.py

示例2: document_service

# 需要导入模块: from botocore.docs.bcdoc.restdoc import DocumentStructure [as 别名]
# 或者: from botocore.docs.bcdoc.restdoc.DocumentStructure import flush_structure [as 别名]
    def document_service(self):
        """Documents an entire service.

        :returns: The reStructured text of the documented service.
        """
        doc_structure = DocumentStructure(
            self._service_name, section_names=self.sections)
        self.title(doc_structure.get_section('title'))
        self.table_of_contents(doc_structure.get_section('table-of-contents'))
        self.client_api(doc_structure.get_section('client-api'))
        self.paginator_api(doc_structure.get_section('paginator-api'))
        self.waiter_api(doc_structure.get_section('waiter-api'))
        return doc_structure.flush_structure()
开发者ID:henrysher,项目名称:botocorev063p,代码行数:15,代码来源:service.py

示例3: document_service

# 需要导入模块: from botocore.docs.bcdoc.restdoc import DocumentStructure [as 别名]
# 或者: from botocore.docs.bcdoc.restdoc.DocumentStructure import flush_structure [as 别名]
    def document_service(self):
        """Documents an entire service.

        :returns: The reStructured text of the documented service.
        """
        doc_structure = DocumentStructure(
            self._service_name, section_names=self.sections,
            target='html')
        self._document_title(doc_structure.get_section('title'))
        self._document_table_of_contents(
            doc_structure.get_section('table-of-contents'))
        self._document_client(doc_structure.get_section('client'))
        self._document_paginators(doc_structure.get_section('paginators'))
        self._document_waiters(doc_structure.get_section('waiters'))
        if self._service_resource:
            self._document_service_resource(
                doc_structure.get_section('service-resource'))
            self._document_resources(doc_structure.get_section('resources'))
        return doc_structure.flush_structure()
开发者ID:bstrand,项目名称:boto3,代码行数:21,代码来源:service.py

示例4: BaseDocsTest

# 需要导入模块: from botocore.docs.bcdoc.restdoc import DocumentStructure [as 别名]
# 或者: from botocore.docs.bcdoc.restdoc.DocumentStructure import flush_structure [as 别名]

#.........这里部分代码省略.........
                            "identifiers": [
                                {"target": "Name", "source": "input"}
                            ]
                        }
                    }
                },
                "hasMany": {
                    "Samples": {
                        "request": {"operation": "SampleOperation"},
                        "resource": {
                            "type": "Sample",
                            "identifiers": [
                                {"target": "Name", "source": "response",
                                 "path": "Samples[].Foo"}
                            ]
                        }
                    }
                }
            },
            "resources": {
                "Sample": {
                    "identifiers": [
                        {"name": "Name", "memberName": "Foo"}
                    ],
                    "shape": "SampleOperationInputOutput",
                    "load": {
                        "request": {
                            "operation": "SampleOperation",
                            "params": [
                                {"target": "Foo", "source": "identifier",
                                 "name": "Name"}
                            ]
                        }
                    },
                    "actions": {
                        "Operate": {
                            "request": {
                                "operation": "SampleOperation",
                                "params": [
                                    {"target": "Foo", "source": "identifier",
                                     "name": "Name"}
                                ]
                            }
                        }
                    },
                    "waiters": {
                        "Complete": {
                            "waiterName": "SampleOperationComplete",
                            "params": [
                                {"target": "Foo", "source": "identifier",
                                 "name": "Name"}
                            ]
                        }
                    }
                }
            }
        }

    def _write_models(self):
        with open(self.resource_model_file, 'w') as f:
            json.dump(self.resource_json_model, f)

        with open(self.waiter_model_file, 'w') as f:
            json.dump(self.waiter_json_model, f)

        with open(self.paginator_model_file, 'w') as f:
            json.dump(self.paginator_json_model, f)

        with open(self.model_file, 'w') as f:
            json.dump(self.json_model, f)

    def add_shape(self, shape):
        shape_name = list(shape.keys())[0]
        self.json_model['shapes'][shape_name] = shape[shape_name]

    def add_shape_to_params(self, param_name, shape_name, documentation=None,
                            is_required=False):
        params_shape = self.json_model['shapes']['SampleOperationInputOutput']
        member = {'shape': shape_name}
        if documentation is not None:
            member['documentation'] = documentation
        params_shape['members'][param_name] = member

        if is_required:
            required_list = params_shape.get('required', [])
            required_list.append(param_name)
            params_shape['required'] = required_list

    def assert_contains_lines_in_order(self, lines, contents=None):
        if contents is None:
            contents = self.doc_structure.flush_structure().decode('utf-8')
        for line in lines:
            self.assertIn(line, contents)
            beginning = contents.find(line)
            contents = contents[(beginning + len(line)):]

    def assert_not_contains_lines(self, lines):
        contents = self.doc_structure.flush_structure().decode('utf-8')
        for line in lines:
            self.assertNotIn(line, contents)
开发者ID:jonathanwcrane,项目名称:boto3,代码行数:104,代码来源:__init__.py

示例5: BaseDocsTest

# 需要导入模块: from botocore.docs.bcdoc.restdoc import DocumentStructure [as 别名]
# 或者: from botocore.docs.bcdoc.restdoc.DocumentStructure import flush_structure [as 别名]

#.........这里部分代码省略.........
                    ]
                ),
                "has": {
                    "Sample": {"resource": {"type": "Sample", "identifiers": [{"target": "Name", "source": "input"}]}}
                },
                "hasMany": {
                    "Samples": {
                        "request": {"operation": "SampleOperation"},
                        "resource": {
                            "type": "Sample",
                            "identifiers": [{"target": "Name", "source": "response", "path": "Samples[].Foo"}],
                        },
                    }
                },
            },
            "resources": {
                "Sample": {
                    "identifiers": [{"name": "Name", "memberName": "Foo"}],
                    "shape": "SampleOperationInputOutput",
                    "load": {
                        "request": {
                            "operation": "SampleOperation",
                            "params": [{"target": "Foo", "source": "identifier", "name": "Name"}],
                        }
                    },
                    "actions": {
                        "Operate": {
                            "request": {
                                "operation": "SampleOperation",
                                "params": [{"target": "Foo", "source": "identifier", "name": "Name"}],
                            }
                        }
                    },
                    "batchActions": {
                        "Operate": {
                            "request": {
                                "operation": "SampleOperation",
                                "params": [{"target": "Samples[].Foo", "source": "identifier", "name": "Name"}],
                            }
                        }
                    },
                    "has": {
                        "RelatedSample": {
                            "resource": {
                                "type": "Sample",
                                "identifiers": [{"target": "Name", "source": "data", "path": "Foo"}],
                            }
                        }
                    },
                    "waiters": {
                        "Complete": {
                            "waiterName": "SampleOperationComplete",
                            "params": [{"target": "Foo", "source": "identifier", "name": "Name"}],
                        }
                    },
                }
            },
        }

    def _write_models(self):
        with open(self.resource_model_file, "w") as f:
            json.dump(self.resource_json_model, f)

        with open(self.waiter_model_file, "w") as f:
            json.dump(self.waiter_json_model, f)

        with open(self.paginator_model_file, "w") as f:
            json.dump(self.paginator_json_model, f)

        with open(self.model_file, "w") as f:
            json.dump(self.json_model, f)

    def add_shape(self, shape):
        shape_name = list(shape.keys())[0]
        self.json_model["shapes"][shape_name] = shape[shape_name]

    def add_shape_to_params(self, param_name, shape_name, documentation=None, is_required=False):
        params_shape = self.json_model["shapes"]["SampleOperationInputOutput"]
        member = {"shape": shape_name}
        if documentation is not None:
            member["documentation"] = documentation
        params_shape["members"][param_name] = member

        if is_required:
            required_list = params_shape.get("required", [])
            required_list.append(param_name)
            params_shape["required"] = required_list

    def assert_contains_lines_in_order(self, lines, contents=None):
        if contents is None:
            contents = self.doc_structure.flush_structure().decode("utf-8")
        for line in lines:
            self.assertIn(line, contents)
            beginning = contents.find(line)
            contents = contents[(beginning + len(line)) :]

    def assert_not_contains_lines(self, lines):
        contents = self.doc_structure.flush_structure().decode("utf-8")
        for line in lines:
            self.assertNotIn(line, contents)
开发者ID:thedrow,项目名称:boto3,代码行数:104,代码来源:__init__.py

示例6: TestDocumentStructure

# 需要导入模块: from botocore.docs.bcdoc.restdoc import DocumentStructure [as 别名]
# 或者: from botocore.docs.bcdoc.restdoc.DocumentStructure import flush_structure [as 别名]
class TestDocumentStructure(unittest.TestCase):
    def setUp(self):
        self.name = 'mydoc'
        self.doc_structure = DocumentStructure(self.name)

    def test_name(self):
        self.assertEqual(self.doc_structure.name, self.name)

    def test_path(self):
        self.assertEqual(self.doc_structure.path, [self.name])
        self.doc_structure.path = ['foo']
        self.assertEqual(self.doc_structure.path, ['foo'])

    def test_add_new_section(self):
        section = self.doc_structure.add_new_section('mysection')

        # Ensure the name of the section is correct
        self.assertEqual(section.name, 'mysection')

        # Ensure we can get the section.
        self.assertEqual(
            self.doc_structure.get_section('mysection'), section)

        # Ensure the path is correct
        self.assertEqual(section.path, ['mydoc', 'mysection'])

        # Ensure some of the necessary attributes are passed to the
        # the section.
        self.assertEqual(section.style.indentation,
                         self.doc_structure.style.indentation)
        self.assertEqual(section.translation_map,
                         self.doc_structure.translation_map)
        self.assertEqual(section.hrefs,
                         self.doc_structure.hrefs)

    def test_delete_section(self):
        section = self.doc_structure.add_new_section('mysection')
        self.assertEqual(
            self.doc_structure.get_section('mysection'), section)
        self.doc_structure.delete_section('mysection')
        with self.assertRaises(KeyError):
            section.get_section('mysection')

    def test_create_sections_at_instantiation(self):
        sections = ['intro', 'middle', 'end']
        self.doc_structure = DocumentStructure(
            self.name, section_names=sections)
        # Ensure the sections are attached to the new document structure.
        for section_name in sections:
            section = self.doc_structure.get_section(section_name)
            self.assertEqual(section.name, section_name)

    def test_flush_structure(self):
        section = self.doc_structure.add_new_section('mysection')
        subsection = section.add_new_section('mysubsection')
        self.doc_structure.writeln('1')
        section.writeln('2')
        subsection.writeln('3')
        second_section = self.doc_structure.add_new_section('mysection2')
        second_section.writeln('4')
        contents = self.doc_structure.flush_structure()

        # Ensure the contents were flushed out correctly
        self.assertEqual(contents, six.b('1\n2\n3\n4\n'))

    def test_flush_structure_hrefs(self):
        section = self.doc_structure.add_new_section('mysection')
        section.writeln('section contents')
        self.doc_structure.hrefs['foo'] = 'www.foo.com'
        section.hrefs['bar'] = 'www.bar.com'
        contents = self.doc_structure.flush_structure()
        self.assertIn(six.b('.. _foo: www.foo.com'), contents)
        self.assertIn(six.b('.. _bar: www.bar.com'), contents)

    def test_available_sections(self):
        self.doc_structure.add_new_section('mysection')
        self.doc_structure.add_new_section('mysection2')
        self.assertEqual(
            self.doc_structure.available_sections,
            ['mysection', 'mysection2']
        )

    def test_context(self):
        context = {'Foo': 'Bar'}
        section = self.doc_structure.add_new_section(
            'mysection', context=context)
        self.assertEqual(section.context, context)

        # Make sure if context is not specified it is empty.
        section = self.doc_structure.add_new_section('mysection2')
        self.assertEqual(section.context, {})

    def test_remove_all_sections(self):
        self.doc_structure.add_new_section('mysection2')
        self.doc_structure.remove_all_sections()
        self.assertEqual(self.doc_structure.available_sections, [])

    def test_clear_text(self):
        self.doc_structure.write('Foo')
        self.doc_structure.clear_text()
#.........这里部分代码省略.........
开发者ID:boto,项目名称:botocore,代码行数:103,代码来源:test_document.py

示例7: TestParameterAlias

# 需要导入模块: from botocore.docs.bcdoc.restdoc import DocumentStructure [as 别名]
# 或者: from botocore.docs.bcdoc.restdoc.DocumentStructure import flush_structure [as 别名]
class TestParameterAlias(unittest.TestCase):
    def setUp(self):
        self.original_name = 'original'
        self.alias_name = 'alias'
        self.parameter_alias = handlers.ParameterAlias(
            self.original_name, self.alias_name)

        self.operation_model = mock.Mock()
        request_shape = DenormalizedStructureBuilder().with_members(
            {self.original_name: {'type': 'string'}}).build_model()
        self.operation_model.input_shape = request_shape
        self.sample_section = DocumentStructure('')
        self.event_emitter = HierarchicalEmitter()

    def test_alias_parameter_in_call(self):
        value = 'value'
        params = {self.alias_name: value}
        self.parameter_alias.alias_parameter_in_call(
            params, self.operation_model)
        self.assertEqual(params, {self.original_name: value})

    def test_alias_parameter_and_original_in_call(self):
        params = {
            self.original_name: 'orginal_value',
            self.alias_name: 'alias_value'
        }
        with self.assertRaises(AliasConflictParameterError):
            self.parameter_alias.alias_parameter_in_call(
                params, self.operation_model)

    def test_alias_parameter_in_call_does_not_touch_original(self):
        value = 'value'
        params = {self.original_name: value}
        self.parameter_alias.alias_parameter_in_call(
            params, self.operation_model)
        self.assertEqual(params, {self.original_name: value})

    def test_does_not_alias_parameter_for_no_input_shape(self):
        value = 'value'
        params = {self.alias_name: value}
        self.operation_model.input_shape = None
        self.parameter_alias.alias_parameter_in_call(
            params, self.operation_model)
        self.assertEqual(params, {self.alias_name: value})

    def test_does_not_alias_parameter_for_not_modeled_member(self):
        value = 'value'
        params = {self.alias_name: value}

        request_shape = DenormalizedStructureBuilder().with_members(
            {'foo': {'type': 'string'}}).build_model()
        self.operation_model.input_shape = request_shape
        self.parameter_alias.alias_parameter_in_call(
            params, self.operation_model)
        self.assertEqual(params, {self.alias_name: value})

    def test_alias_parameter_in_documentation_request_params(self):
        RequestParamsDocumenter(
            'myservice', 'myoperation', self.event_emitter).document_params(
                self.sample_section, self.operation_model.input_shape)
        self.parameter_alias.alias_parameter_in_documentation(
            'docs.request-params.myservice.myoperation.complete-section',
            self.sample_section
        )
        contents = self.sample_section.flush_structure().decode('utf-8')
        self.assertIn(':type ' + self.alias_name + ':',  contents)
        self.assertIn(':param ' + self.alias_name + ':',  contents)
        self.assertNotIn(':type ' + self.original_name + ':',  contents)
        self.assertNotIn(':param ' + self.original_name + ':',  contents)

    def test_alias_parameter_in_documentation_request_example(self):
        RequestExampleDocumenter(
            'myservice', 'myoperation', self.event_emitter).document_example(
                self.sample_section, self.operation_model.input_shape)
        self.parameter_alias.alias_parameter_in_documentation(
            'docs.request-example.myservice.myoperation.complete-section',
            self.sample_section
        )
        contents = self.sample_section.flush_structure().decode('utf-8')
        self.assertIn(self.alias_name + '=',  contents)
        self.assertNotIn(self.original_name + '=', contents)
开发者ID:kyleknap,项目名称:botocore,代码行数:83,代码来源:test_handlers.py

示例8: _create_docstring

# 需要导入模块: from botocore.docs.bcdoc.restdoc import DocumentStructure [as 别名]
# 或者: from botocore.docs.bcdoc.restdoc.DocumentStructure import flush_structure [as 别名]
 def _create_docstring(self):
     docstring_structure = DocumentStructure("docstring")
     # Call the document method function with the args and kwargs
     # passed to the class.
     document_model_driven_method(docstring_structure, *self._gen_args, **self._gen_kwargs)
     return docstring_structure.flush_structure().decode("utf-8")
开发者ID:kkung,项目名称:botocore,代码行数:8,代码来源:method.py


注:本文中的botocore.docs.bcdoc.restdoc.DocumentStructure.flush_structure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。