Exemplo n.º 1
0
    def load_config(self, config_path):
        """Load config file from file
        """
        configs.pwd = self.curdir
        if not config_path:
            logging.debug('No config path is specified, try default ones')
            for file_name in self.default_config:
                p = os.path.join(self.curdir, file_name)
                if os.path.isfile(p):
                    logging.debug('Find config file named %s', file_name)
                    config_path = file_name
                    break
            else:
                logging.debug('Config file with default names not found')
                raise FileNotFoundError('Config file not found at directory \
{}'.format(self.curdir))
        else:
            if not os.path.isfile(os.path.join(self.curdir, config_path)):
                logging.debug('%s is not a file', config_path)
                raise FileNotFoundError('Config file not found at path {}'\
                        .format(config_path))

        logging.debug('Load config file {}'.format(config_path))
        load_configs(config_path)

        logging.info('Verifing configurations...')
        verify_configs()

        self.template = Template(
                configs.theme_path,
                filters=get_filters(configs),
                site=configs.site,
                author=configs.author)
Exemplo n.º 2
0
 def test_load(self):
     configs.pwd = os.path.join(PWD, 'test_site')
     load_configs('config.yml')
     self.assertEqual(configs.site['title'], "Peanut Demo")
     self.assertEqual(configs.path['draft'], 'drafts')
Exemplo n.º 3
0
 def test_load(self):
     configs.pwd = os.path.join(PWD, 'test_site')
     load_configs('config.yml')
     self.assertEqual(configs.site['title'], "Peanut Demo")
     self.assertEqual(configs.path['draft'], 'drafts')