示例#1
0
文件: engine.py 项目: luckypoem/wok
    def read_options(self):
        """Load options from the config file."""
        self.options = Engine.default_options.copy()

        if os.path.isfile('config'):
            with open('config') as f:
                yaml_config = yaml.load(f)

            if yaml_config:
                self.options.update(yaml_config)

        # Make authors a list, even only a single author was specified.
        authors = self.options.get('authors', self.options.get('author', None))
        if isinstance(authors, list):
            self.options['authors'] = [Author.parse(a) for a in authors]
        elif isinstance(authors, str):
            csv = authors.split(',')
            self.options['authors'] = [Author.parse(a) for a in csv]
            if len(self.options['authors']) > 1:
                logging.warn(
                    'Deprecation Warning: Use YAML lists instead of '
                    'CSV for multiple authors. i.e. ["John Doe", "Jane '
                    'Smith"] instead of "John Doe, Jane Smith". In config '
                    'file.')

        if '{type}' in self.options['url_pattern']:
            logging.warn(
                'Deprecation Warning: You should use {ext} instead '
                'of {type} in the url pattern specified in the config '
                'file.')
示例#2
0
文件: engine.py 项目: ngokevin/wok
    def read_options(self):
        """Load options from the config file."""
        self.options = Engine.default_options.copy()

        if os.path.isfile('config'):
            with open('config') as f:
                yaml_config = yaml.load(f)

            if yaml_config:
                self.options.update(yaml_config)

        # Make authors a list, even only a single author was specified.
        authors = self.options.get('authors', self.options.get('author', None))
        if isinstance(authors, list):
            self.options['authors'] = [Author.parse(a) for a in authors]
        elif isinstance(authors, str):
            csv = authors.split(',')
            self.options['authors'] = [Author.parse(a) for a in csv]
            if len(self.options['authors']) > 1:
                logging.warn('Deprecation Warning: Use YAML lists instead of '
                        'CSV for multiple authors. i.e. ["John Doe", "Jane '
                        'Smith"] instead of "John Doe, Jane Smith". In config '
                        'file.')

        if '{type}' in self.options['url_pattern']:
            logging.warn('Deprecation Warning: You should use {ext} instead '
                    'of {type} in the url pattern specified in the config '
                    'file.')
示例#3
0
文件: test_page.py 项目: 5y/wok
    def test_author(self):
        a = Author.parse('Bob Smith')
        self.assertEqual(a.raw, 'Bob Smith')
        self.assertEqual(a.name, 'Bob Smith')

        a = Author.parse('Bob Smith <*****@*****.**>')
        self.assertEqual(a.raw, 'Bob Smith <*****@*****.**>')
        self.assertEqual(a.name, 'Bob Smith')
        self.assertEqual(a.email, '*****@*****.**')

        a = Author.parse('<*****@*****.**>')
        self.assertEqual(a.raw, '<*****@*****.**>')
        self.assertEqual(a.email, '*****@*****.**')
示例#4
0
    def test_author(self):
        a = Author.parse('Bob Smith')
        self.assertEqual(a.raw, 'Bob Smith')
        self.assertEqual(a.name, 'Bob Smith')

        a = Author.parse('Bob Smith <*****@*****.**>')
        self.assertEqual(a.raw, 'Bob Smith <*****@*****.**>')
        self.assertEqual(a.name, 'Bob Smith')
        self.assertEqual(a.email, '*****@*****.**')

        a = Author.parse('<*****@*****.**>')
        self.assertEqual(a.raw, '<*****@*****.**>')
        self.assertEqual(a.email, '*****@*****.**')
示例#5
0
文件: engine.py 项目: moreati/wok
    def read_options(self):
        """Load options from the config file."""
        self.options = Engine.default_options.copy()

        if os.path.isfile('config'):
            with open('config') as f:
                yaml_config = yaml.load(f)

            if yaml_config:
                self.options.update(yaml_config)

        # Make authors a list, even only a single author was specified.
        authors = self.options.get('authors', self.options.get('author', None))
        if isinstance(authors, list):
            self.options['authors'] = [Author.parse(a) for a in authors]
        elif isinstance(authors, str):
            csv = authors.split(',')
            self.options['authors'] = [Author.parse(a) for a in csv]
            if len(self.options['authors']) > 1:
                logging.warn(
                    'Deprecation Warning: Use YAML lists instead of '
                    'CSV for multiple authors. i.e. ["John Doe", "Jane '
                    'Smith"] instead of "John Doe, Jane Smith". In config '
                    'file.')

        if '{type}' in self.options['url_pattern']:
            logging.warn(
                'Deprecation Warning: You should use {ext} instead '
                'of {type} in the url pattern specified in the config '
                'file.')

        # Set locale if needed
        wanted_locale = self.options.get('locale')
        if wanted_locale is not None:
            try:
                locale.setlocale(locale.LC_TIME, wanted_locale)
            except locale.Error as err:
                logging.warn('Unable to set locale to `%s`: %s', wanted_locale,
                             err)

        # add a subdir prefix to the output_dir, if present in the config
        self.options['server_root'] = self.options['output_dir']
        self.options['output_dir'] = os.path.join(
            self.options['output_dir'], self.options.get('url_subdir', ''))
示例#6
0
文件: engine.py 项目: jneves/wok
    def read_options(self):
        """Load options from the config file."""
        self.options = Engine.default_options.copy()

        if os.path.isfile('config'):
            with open('config') as f:
                yaml_config = yaml.load(f)

            if yaml_config:
                self.options.update(yaml_config)

        # Make authors a list, even only a single author was specified.
        authors = self.options.get('authors', self.options.get('author', None))
        if isinstance(authors, list):
            self.options['authors'] = [Author.parse(a) for a in authors]
        elif isinstance(authors, str):
            csv = authors.split(',')
            self.options['authors'] = [Author.parse(a) for a in csv]
            if len(self.options['authors']) > 1:
                logging.warn('Deprecation Warning: Use YAML lists instead of '
                        'CSV for multiple authors. i.e. ["John Doe", "Jane '
                        'Smith"] instead of "John Doe, Jane Smith". In config '
                        'file.')

        if '{type}' in self.options['url_pattern']:
            logging.warn('Deprecation Warning: You should use {ext} instead '
                    'of {type} in the url pattern specified in the config '
                    'file.')

        # Set locale if needed
        wanted_locale = self.options.get('locale')
        if wanted_locale is not None:
            try:
                locale.setlocale(locale.LC_TIME, wanted_locale)
            except locale.Error as err:
                logging.warn('Unable to set locale to `%s`: %s',
                    wanted_locale, err
                )

        # add a subdir prefix to the output_dir, if present in the config
        self.options['server_root'] = self.options['output_dir']
        self.options['output_dir'] = os.path.join(self.options['output_dir'], self.options.get('url_subdir', ''))
示例#7
0
文件: engine.py 项目: stachern/wok
    def read_options(self):
        """Load options from the config file."""
        self.options = Engine.default_options.copy()

        if os.path.isfile("config"):
            with open("config") as f:
                yaml_config = yaml.load(f)

            if yaml_config:
                self.options.update(yaml_config)

        # Make authors a list, even only a single author was specified.
        authors = self.options.get("authors", self.options.get("author", None))
        if isinstance(authors, list):
            self.options["authors"] = [Author.parse(a) for a in authors]
        elif isinstance(authors, str):
            csv = authors.split(",")
            self.options["authors"] = [Author.parse(a) for a in csv]
            if len(self.options["authors"]) > 1:
                logging.warn(
                    "Deprecation Warning: Use YAML lists instead of "
                    'CSV for multiple authors. i.e. ["John Doe", "Jane '
                    'Smith"] instead of "John Doe, Jane Smith". In config '
                    "file."
                )

        if "{type}" in self.options["url_pattern"]:
            logging.warn(
                "Deprecation Warning: You should use {ext} instead "
                "of {type} in the url pattern specified in the config "
                "file."
            )

        # add a subdir prefix to the output_dir, if present in the config
        self.options["server_root"] = self.options["output_dir"]
        self.options["output_dir"] = os.path.join(self.options["output_dir"], self.options.get("url_subdir", ""))