download

        High-level api: Download a module schema.

        Parameters
        ----------

        module : `str`
            Module name that will be downloaded.

        Returns
        -------

        None
            Nothing returns.

def download(self, module):
        '''download

        High-level api: Download a module schema.

        Parameters
        ----------

        module : `str`
            Module name that will be downloaded.

        Returns
        -------

        None
            Nothing returns.
        '''

        import_r = '^[ |\t]+import[ |\t]+([a-zA-Z0-9-]+)[ |\t]+[;{][ |\t]*$'
        include_r = '^[ |\t]+include[ |\t]+([a-zA-Z0-9-]+)[ |\t]*[;{][ |\t]*$'

        logger.debug('Downloading {}.yang...'.format(module))
        try:
            from .device import ModelDevice
            reply = super(ModelDevice, self.device) \
                    .execute(operations.retrieve.GetSchema, module)
        except operations.rpc.RPCError:
            logger.warning("Module or submodule '{}' cannot be downloaded" \
                           .format(module))
            return
        if reply.ok:
            fname = self.dir_yang + '/' + module + '.yang'
            with open(fname, 'w') as f:
                f.write(reply.data)
            self.downloaded.add(module)
            imports = set()
            includes = set()
            for line in reply.data.splitlines():
                match = re.search(import_r, line)
                if match:
                    imports.add(match.group(1).strip())
                    continue
                match = re.search(include_r, line)
                if match:
                    includes.add(match.group(1).strip())
                    continue
            s = (imports | includes) - self.downloaded - self.to_be_downloaded
            if s:
                logger.info('{} requires submodules: {}' \
                            .format(module, ', '.join(s)))
                self.to_be_downloaded.update(s)
        else:
            logger.warning("module or submodule '{}' cannot be downloaded:\n{}" \
                           .format(module, reply._raw))