Example #1
0
    def generate(self, modules):
        """
            Generates and returns the packages for the list of modules supplied.

            This is the function that converts the list of pyang modules to
            Packages in the api_model

            :param list of `pyang.statements.Statement`

        """

        d_modules = [
            module for module in modules
            if hasattr(module, 'is_deviation_module')
        ]
        modules = [
            module for module in modules
            if not hasattr(module, 'is_deviation_module')
        ]
        only_modules = [
            module for module in modules if module.keyword == 'module'
        ]

        packages = []
        deviation_packages = []

        for module in d_modules:
            package = Package(self.iskeyword)
            module.i_package = package
            package.stmt = module

            if self.language == 'go':
                package.name = get_go_package_name(package.name,
                                                   self.bundle_name)
            deviation_packages.append(package)

        for module in only_modules:
            package = Package(self.iskeyword)
            module.i_package = package
            package.stmt = module

            if self.language == 'go':
                package.name = get_go_package_name(package.name,
                                                   self.bundle_name)
            self._create_expanded_api_model(module, package,
                                            deviation_packages)
            packages.append(package)

        packages.extend(deviation_packages)
        # resolve cross references
        for package in packages:
            self._resolve_expanded_cross_references(package)
        return packages
Example #2
0
 def generate(self, submodules, iskeyword):
     packages = []
     for sub in submodules:
         package = Package(iskeyword)
         sub.i_package = package
         package.stmt = sub
         packages.append(package)
     return packages
 def generate(self, submodules):
     packages = []
     for sub in submodules:
         package = Package()
         sub.i_package = package
         package.stmt = sub
         packages.append(package)
     return packages
Example #4
0
    def generate(self, modules):
        """
            Generates and returns the packages for the list of modules supplied.

            This is the function that converts the list of pyang modules to
            Packages in the api_model

            :param list of `pyang.statements.Statement`

        """

        d_modules = [module for module in modules if hasattr(module, 'is_deviation_module')]
        modules = [module for module in modules if not hasattr(module, 'is_deviation_module')]
        only_modules = [module for module in modules if module.keyword == 'module']

        packages = []
        deviation_packages = []

        for module in d_modules:
            package = Package(self.iskeyword)
            module.i_package = package
            package.stmt = module

            if self.language == 'go':
                package.name = get_go_package_name(package.name, self.bundle_name)
            deviation_packages.append(package)

        for module in only_modules:
            package = Package(self.iskeyword)
            module.i_package = package
            package.stmt = module

            if self.language == 'go':
                package.name = get_go_package_name(package.name, self.bundle_name)
            self._create_expanded_api_model(module, package, deviation_packages)
            packages.append(package)

        packages.extend(deviation_packages)
        # resolve cross references
        for package in packages:
            self._resolve_expanded_cross_references(package)
        return packages
Example #5
0
    def generate(self, submodules, iskeyword, language, bundle_name):
        packages = []
        for sub in submodules:
            package = Package(iskeyword)
            sub.i_package = package
            package.stmt = sub

            if language == 'go':
                package.name = get_go_package_name(package.name, bundle_name)
            packages.append(package)

        return packages
Example #6
0
    def generate(self, submodules, iskeyword, language, bundle_name):
        packages = []
        for sub in submodules:
            package = Package(iskeyword)
            sub.i_package = package
            package.stmt = sub

            if language == 'go':
                package.name = get_go_package_name(package.name, bundle_name)
            packages.append(package)

        return packages
Example #7
0
    def emit(self, packages, submodules):
        self.ypy_ctx = None
        self.packages = []
        self.models_dir = ''
        self.test_dir = ''
        
        self.packages = packages
        self.packages = sorted(self.packages, key=lambda package: package.name)
        self.deviation_packages = [p for p in self.packages if hasattr(p, 'is_deviation')]
        self.packages = [p for p in self.packages if not hasattr(p, 'is_deviation')]

        self.submodules = []
        for sub in submodules:
            package = Package()
            sub.i_package = package
            package.stmt = sub
            self.submodules.append(package)
        
        self.initialize_print_environment()
        self.print_files()
Example #8
0
    def generate(self, modules):
        """
            Generates and returns the packages for the list of modules supplied.

            This is the function that converts the list of pyang modules to
            Packages in the api_model for the grouping as classes strategy.

            :param list of `pyang.statements.Statement`

        """
        only_modules = [m for m in modules if m.keyword == 'module']
        packages = []
        for m in only_modules:
            p = Package(self.iskeyword)
            m.i_package = p
            p.stmt = m
            self._create_grouping_class_api_model(m, p)
            packages.append(p)

        # resolve cross references
        for p in packages:
            self._resolve_grouping_class_cross_references(p)
        return packages
    def generate(self, modules):
        """
            Generates and returns the packages for the list of modules supplied.

            This is the function that converts the list of pyang modules to
            Packages in the api_model for the grouping as classes strategy.

            :param list of `pyang.statements.Statement`

        """
        only_modules = [m for m in modules if m.keyword == 'module']
        packages = []
        for m in only_modules:
            p = Package()
            m.i_package = p
            p.stmt = m
            self._create_grouping_class_api_model(m, p)
            packages.append(p)

        # resolve cross references
        for p in packages:
            self._resolve_grouping_class_cross_references(p)
        return packages
Example #10
0
    def emit(self, packages, submodules):
        self.ypy_ctx = None
        self.packages = []
        self.models_dir = ''
        self.test_dir = ''

        self.packages = packages
        self.packages = sorted(self.packages, key=lambda package: package.name)
        self.deviation_packages = [
            p for p in self.packages if hasattr(p, 'is_deviation')
        ]
        self.packages = [
            p for p in self.packages if not hasattr(p, 'is_deviation')
        ]

        self.submodules = []
        for sub in submodules:
            package = Package()
            sub.i_package = package
            package.stmt = sub
            self.submodules.append(package)

        self.initialize_print_environment()
        self.print_files()