def _print_entity_lookup_files(self, packages, path): self.print_file(get_entity_lookup_source_file_name(path), emit_entity_lookup_source, _EmitArgs(self.ypy_ctx, packages, self.bundle_name)) self.print_file(get_entity_lookup_header_file_name(path), emit_entity_lookup_header, _EmitArgs(self.ypy_ctx, packages, self.bundle_name))
def _print_meta_module(self, package, path): self._print_init_file(path) extra_args = {'one_class_per_module': self.one_class_per_module, 'identity_subclasses': self.identity_subclasses} self.print_file(get_meta_module_file_name(path, package), emit_meta, _EmitArgs(self.ypy_ctx, package, extra_args))
def print_python_module(self, package, index, path, size, sub): self.print_init_file(path) package.parent_pkg_name = sub self.print_file(get_python_module_file_name(path, package), emit_module, _EmitArgs(self.ypy_ctx, package, self.sort_clazz))
def print_yang_ns_file(self): packages = self.packages + self.deviation_packages target_dir = self.models_dir if self.sub_dir == '' else self.sub_dir self.print_file(get_yang_ns_file_name(target_dir), emit_yang_ns, _EmitArgs(self.ypy_ctx, packages))
def _print_deviate_file(self): self._print_nmsp_declare_init(self.deviation_dir) for package in self.deviation_packages: self.print_file( get_meta_module_file_name(self.deviation_dir, package), emit_deviation, _EmitArgs(self.ypy_ctx, package, self.sort_clazz))
def _print_tests(self, package, path): self._print_init_file(self.test_dir) empty = self.is_empty_package(package) if not empty: self.print_file(get_test_module_file_name(path, package), emit_test_module, _EmitArgs(self.ypy_ctx, package, self.identity_subclasses))
def _print_yang_ns_file(self): packages = self.packages self.print_file( get_yang_ns_file_name(self.models_dir), emit_yang_ns, _EmitArgs(self.ypy_ctx, packages, (self.bundle_name, self.one_class_per_module)))
def print_python_module(self, package, index, path, size, sub): self.print_init_file(path) package.parent_pkg_name = sub self.print_file(get_python_module_file_name(path, package), emit_module, _EmitArgs(self.ypy_ctx, package))
def _print_cmake_file(self, packages, bundle_name, path): args = { 'bundle_name': bundle_name, 'identity_subclasses': self.identity_subclasses } self.print_file(get_testcase_cmake_file_name(path), emit_cmake_file, _EmitArgs(self.ypy_ctx, packages, args))
def _print_python_rst_ydk_models(self): if self.ydk_doc_dir is None: return packages = [p for p in self.packages if len(p.owned_elements) > 0] self.print_file(get_table_of_contents_file_name(self.ydk_doc_dir), emit_table_of_contents, _EmitArgs(self.ypy_ctx, packages, (self.bundle_name, self.bundle_version)))
def _print_cpp_rst_toc(self): if self.ydk_doc_dir is None: return packages = [p for p in self.packages if len(p.owned_elements) > 0] self.print_file(get_table_of_contents_file_name(self.ydk_doc_dir), emit_table_of_contents, _EmitArgs(self.ypy_ctx, packages, self.bundle_name))
def _walk_n_print(named_element, p): self.print_file(get_go_doc_file_name(p, named_element), emit_go_doc, _EmitArgs(self.ypy_ctx, named_element, (self.identity_subclasses, self.bundle_name))) for owned_element in named_element.owned_elements: if isinstance(owned_element, (Class, Enum)): _walk_n_print(owned_element, p)
def _walk_n_print(named_element, p): self.print_file(get_python_module_documentation_file_name(p, named_element), emit_module_documentation, _EmitArgs(self.ypy_ctx, named_element)) for owned_element in named_element.owned_elements: if isinstance(owned_element, Class) or isinstance(owned_element, Enum): _walk_n_print(owned_element, p)
def _walk_n_print(named_element, p): self.print_file(get_python_module_documentation_file_name(p, named_element), emit_module_documentation, _EmitArgs(self.ypy_ctx, named_element, self.identity_subclasses)) for owned_element in named_element.owned_elements: if isinstance(owned_element, Class) or isinstance(owned_element, Enum): _walk_n_print(owned_element, p)
def print_python_rst_ydk_models(self): if self.ydk_doc_dir is None: return packages = [p for p in self.packages if len(p.owned_elements) > 0] self.print_file(get_table_of_contents_file_name(self.ydk_doc_dir), emit_table_of_contents, _EmitArgs(self.ypy_ctx, packages, self.bundle_name))
def _walk_n_print(named_element, p): self.print_file(get_cpp_doc_file_name(p, named_element), emit_cpp_doc, _EmitArgs(self.ypy_ctx, named_element, self.identity_subclasses)) for owned_element in named_element.owned_elements: if isinstance(owned_element, (Class, Enum)): _walk_n_print(owned_element, p)
def _print_go_rst_toc(self): if self.ydk_doc_dir is None: return packages = [p for p in self.packages if len(p.owned_elements) > 0] self.print_file(get_table_of_contents_file_name(self.ydk_doc_dir), emit_table_of_contents, _EmitArgs(self.ypy_ctx, packages, (self.bundle_name, self.bundle_version)))
def _print_python_module(self, package, index, path, size, sub): self._print_init_file(path) package.parent_pkg_name = sub extra_args = {'sort_clazz': False, 'identity_subclasses': self.identity_subclasses} self.print_file(get_python_module_file_name(path, package), emit_module, _EmitArgs(self.ypy_ctx, package, extra_args))
def _walk_n_print(named_element, p): self.print_file(get_python_module_documentation_file_name(p, named_element), emit_module_documentation, _EmitArgs(self.ypy_ctx, named_element, self.identity_subclasses)) for owned_element in named_element.owned_elements: if any((isinstance(owned_element, Bits), isinstance(owned_element, Class), isinstance(owned_element, Enum))): _walk_n_print(owned_element, p)
def _print_python_module(self, package, index, path, size, sub): if self.one_class_per_module: self.initialize_output_directory(path, True) self._print_init_file(path) package.parent_pkg_name = sub extra_args = { 'one_class_per_module': self.one_class_per_module, 'identity_subclasses': self.identity_subclasses, 'module_namespace_lookup': self.module_namespace_lookup } self.print_file(get_python_module_file_name(path, package), emit_module, _EmitArgs(self.ypy_ctx, package, extra_args)) if self.one_class_per_module: self._print_python_modules(package, index, path, size, sub)
def _print_python_module(self, package, index, path, size, sub): if self.one_class_per_module: self.initialize_output_directory(path, True) self._print_init_file(path) self._print_init_file(path) package.parent_pkg_name = sub extra_args = {'one_class_per_module': self.one_class_per_module, 'generate_meta': self.generate_meta, 'identity_subclasses': self.identity_subclasses, 'module_namespace_lookup' : self.module_namespace_lookup} self.print_file(get_python_module_file_name(path, package), emit_module, _EmitArgs(self.ypy_ctx, package, extra_args)) if self.one_class_per_module: self._print_python_modules(package, index, path, size, sub)
def _print_module(self, index, package, size): print('Processing %d of %d %s' % (index + 1, size, package.stmt.pos.ref)) # Skip generating module for empty modules if len(package.owned_elements) == 0: return sub = package.sub_name if package.aug_bundle_name != '': package.augments_other = True module_dir = self.initialize_output_directory( '%s/%s/%s' % (self.models_dir, self.bundle_name, '_aug')) else: module_dir = self.initialize_output_directory(self.models_dir) meta_dir = self.initialize_output_directory(module_dir + '/_meta') test_output_dir = self.initialize_output_directory( '%s/%s' % (self.test_dir, sub)) if self.one_class_per_module: path = os.path.join(self.models_dir, package.name) self.initialize_output_directory(path, True) self._print_init_file(path) extra_args = { 'one_class_per_module': self.one_class_per_module, 'identity_subclasses': self.identity_subclasses } self.print_file(get_python_module_file_name(path, package), emit_module, _EmitArgs(self.ypy_ctx, package, extra_args)) self._print_python_modules(package, index, path, size, sub) else: # RST Documentation self._print_python_module(package, index, module_dir, size, sub) self._print_meta_module(package, meta_dir) if self.generate_tests: self._print_tests(package, test_output_dir)
def _print_python_module(self, package, index, path, size, sub): if self.one_class_per_module: self.initialize_output_directory(path, True) self._print_init_file(path) self._print_init_file(path) package.parent_pkg_name = sub extra_args = {'one_class_per_module': self.one_class_per_module, 'generate_meta': self.generate_meta, 'identity_subclasses': self.identity_subclasses, 'module_namespace_lookup' : self.module_namespace_lookup} python_module_file_name = get_python_module_file_name(path, package) logger.debug(" Printing python module %s" % python_module_file_name) self.print_file(python_module_file_name, emit_module, _EmitArgs(self.ypy_ctx, package, extra_args)) if self.one_class_per_module: self._print_python_modules(package, index, path, size, sub)
def _print_module(self, index, package, size): print('Processing %d of %d %s' % (index + 1, size, package.stmt.pos.ref)) # Skip generating module for empty modules if len(package.owned_elements) == 0: return sub = package.sub_name test_output_dir = self.initialize_output_directory(self.test_dir) if self.one_class_per_module: path = os.path.join(self.models_dir, package.name) self.initialize_output_directory(path, True) self._print_init_file(path) extra_args = { 'one_class_per_module': self.one_class_per_module, 'identity_subclasses': self.identity_subclasses, 'generate_meta': self.generate_meta, 'module_namespace_lookup': self.module_namespace_lookup } self.print_file(get_python_module_file_name(path, package), emit_module, _EmitArgs(self.ypy_ctx, package, extra_args)) self._print_python_modules(package, index, path, size, sub) else: # RST Documentation self._print_python_module(package, index, self.models_dir, size, sub) if self.generate_meta: meta_dir = self.initialize_output_directory(self.models_dir + '/_meta') self._print_meta_module(package, meta_dir) if self.generate_tests: self._print_tests(package, test_output_dir) if self.ydk_doc_dir is not None: self._print_python_rst_module(package)
def _print_module(self, index, package, size): print('Processing %d of %d %s' % (index + 1, size, package.stmt.pos.ref)) # Skip generating module for empty modules if len(package.owned_elements) == 0: return sub = package.sub_name test_output_dir = self.initialize_output_directory(self.test_dir) if self.generate_meta: meta_dir = self.initialize_output_directory(self.models_dir + '/_meta') if self.one_class_per_module: path = os.path.join(self.models_dir, package.name) self.initialize_output_directory(path, True) self._print_init_file(path) extra_args = {'one_class_per_module': self.one_class_per_module, 'identity_subclasses': self.identity_subclasses, 'generate_meta': self.generate_meta, 'module_namespace_lookup': self.module_namespace_lookup} self.print_file(get_python_module_file_name(path, package), emit_module, _EmitArgs(self.ypy_ctx, package, extra_args)) self._print_python_modules(package, index, path, size, sub) else: # RST Documentation self._print_python_module(package, index, self.models_dir, size, sub) if self.generate_meta: self._print_meta_module(package, meta_dir) if self.generate_tests: self._print_tests(package, test_output_dir) if self.ydk_doc_dir is not None: self._print_python_rst_module(package)
def _print_yang_ns_file(self): packages = self.packages self.print_file(get_yang_ns_file_name(self.models_dir), emit_yang_ns, _EmitArgs(self.ypy_ctx, packages, self.bundle_name))
def _print_source_file(self, package, path): self.print_file(get_source_file_name(path, package), emit_source, _EmitArgs(self.ypy_ctx, package, self.sort_clazz))
def print_nmsp_declare_init(self, path): file_name = get_init_file_name(path) self.print_file(file_name, emit_nmsp_declare_init, _EmitArgs(self.ypy_ctx, self.packages))
def print_deviate_file(self): self.print_nmsp_declare_init(self.deviation_dir) for package in self.deviation_packages: self.print_file(get_meta_module_file_name(self.deviation_dir, package), emit_deviation, _EmitArgs(self.ypy_ctx, package, self.sort_clazz))
def print_test_module(self, package, path): self.print_init_file(self.test_dir) self.print_file(get_test_module_file_name(path, package), emit_test_module, _EmitArgs(self.ypy_ctx, package, self.identity_subclasses))
def print_deviate_file(self): self.print_init_file(self.deviation_dir) for package in self.deviation_packages: self.print_file(get_meta_module_file_name(self.deviation_dir, package), emit_deviation, _EmitArgs(self.ypy_ctx, package))
def _print_meta_module(self, package, path): self._print_init_file(path) self.print_file(get_meta_module_file_name(path, package), emit_meta, _EmitArgs(self.ypy_ctx, package, self.sort_clazz))
def _print_yang_ns_file(self): packages = self.packages + self.deviation_packages self.print_file(get_yang_ns_file_name(self.models_dir), emit_yang_ns, _EmitArgs(self.ypy_ctx, packages))
def _print_header_file(self, package, path): self.print_file( get_header_file_name(path, package), emit_header, _EmitArgs(self.ypy_ctx, package, (self.sort_clazz, self.identity_subclasses)))
def _print_nmsp_augment_finder_init(self, path, is_meta=False): file_name = get_init_file_name(path) self.print_file(file_name, emit_nmsp_augment_finder_init, _EmitArgs(self.ypy_ctx, self.packages, is_meta))
def _print_yang_ns_file(self): packages = self.packages self.print_file(get_yang_ns_file_name(self.models_dir), emit_yang_ns, _EmitArgs(self.ypy_ctx, packages, (self.bundle_name, self.one_class_per_module)))
def print_yang_ns_file(self): packages = self.packages + self.deviation_packages self.print_file(get_yang_ns_file_name(self.models_dir), emit_yang_ns, _EmitArgs(self.ypy_ctx, packages))
def print_meta_module(self, package, path): self.print_init_file(path) self.print_file(get_meta_module_file_name(path, package), emit_meta, _EmitArgs(self.ypy_ctx, package, self.sort_clazz))
def print_test_module(self, package, path): self.print_file(get_test_module_file_name(path, package), emit_test_module, _EmitArgs(self.ypy_ctx, package))
def _print_import_tests_file(self): self.print_file(get_import_test_file_name(self.test_dir), emit_importests, _EmitArgs(self.ypy_ctx, self.packages))
def _print_nmsp_declare_init(self, path): file_name = get_init_file_name(path) self.print_file(file_name, emit_nmsp_declare_init, _EmitArgs(self.ypy_ctx, self.packages))
def print_import_tests_file(self): self.print_file(get_import_test_file_name(self.test_dir), emit_importests, _EmitArgs(self.ypy_ctx, self.packages))
def _print_tests(self, package, path): empty = self.is_empty_package(package) if not empty: self.print_file( get_testcase_file_name(path, package), emit_test_cases, _EmitArgs(self.ypy_ctx, package, self.identity_subclasses))
def print_nmsp_augment_finder_init(self, path, is_meta=False): file_name = get_init_file_name(path) self.print_file(file_name, emit_nmsp_augment_finder_init, _EmitArgs(self.ypy_ctx, self.packages, is_meta))
def _print_header_file(self, package, path): self.print_file(get_header_file_name(path, package), emit_header, _EmitArgs(self.ypy_ctx, package))