'Generate fresh site from templates.'

def build(self):

    logger.debug('***    BUILD    %s', self.path)
    self.verify_url()
    self._static = None
    self._static_resources_dict = None
    self.plugin_manager.reload()
    self.plugin_manager.preBuild(self)
    logger.debug('Plugins:                %s', ',    '.join([p.plugin_name for p in self.plugin_manager.plugins]))
    logger.debug('Processors:    %s', ',    '.join([p.__name__ for p in self.external_manager.processors]))
    logger.debug('Optimizers:    %s', ',    '.join([p.__name__ for p in self.external_manager.optimizers]))
    if (not os.path.exists(self.build_path)):
        os.mkdir(self.build_path)
    if (self.locale is not None):
        self.compile_messages()
    self.buildStatic()
    build_static_path = os.path.join(self.build_path, 'static')
    for path in os.listdir(self.build_path):
        path = os.path.join(self.build_path, path)
        if (path != build_static_path):
            if os.path.isdir(path):
                shutil.rmtree(path)
            else:
                os.remove(path)
    mapper = (multiMap if (self._parallel >= PARALLEL_AGGRESSIVE) else map_apply)
    mapper((lambda p: p.build()), self.pages())
    self.plugin_manager.postBuild(self)
    for static in self.static():
        if os.path.isdir(static.pre_dir):
            shutil.rmtree(static.pre_dir)
