コード例 #1
0
    def process(self, uris: List[str], package: str):
        """
        Run main processes.

        :param uris: list of uris to process
        :param package: package name eg foo.bar.xxx
        """

        collections.apply(uris, self.process_schema)

        classes = [
            cls for classes in self.class_map.values() for cls in classes
        ]
        class_num, inner_num = self.count_classes(classes)
        if class_num:
            logger.info("Analyzer input: %d main and %d inner classes",
                        class_num, inner_num)
            self.assign_packages(package)

            classes = self.analyze_classes(classes)
            class_num, inner_num = self.count_classes(classes)
            logger.info("Analyzer output: %d main and %d inner classes",
                        class_num, inner_num)

            writer.designate(classes, self.output)
            if self.print:
                writer.print(classes, self.output)
            else:
                writer.write(classes, self.output)
        else:
            logger.warning("Analyzer returned zero classes!")
コード例 #2
0
    def test_write_skip_empty_output(self):
        cls = ClassFactory.create()
        with TemporaryDirectory() as tmpdir:
            writer.register_format(self.FAKE_NAME, EmptyGenerator(tmpdir))
            writer.write([cls], "fake")

            self.assertFalse(Path(f"{tmpdir}/{cls.name}.txt").exists())
コード例 #3
0
ファイル: test_writer.py プロジェクト: rmr1154/xsdata
    def test_write(self):
        classes = ClassFactory.list(2)
        with TemporaryDirectory() as tmpdir:
            writer.register_format(self.FAKE_NAME, FakeGenerator(tmpdir))
            writer.write(classes, "fake")

            for obj in classes:
                self.assertEqual(obj.name,
                                 Path(f"{tmpdir}/{obj.name}.txt").read_text())