예제 #1
0
파일: sqa.py 프로젝트: FHilty/moose
    def createToken(self, info, parent):

        #TODO: make root path a config item in extension
        location = os.path.join(MooseDocs.MOOSE_DIR, 'framework', 'doc', 'templates', 'sqa',
                                self.settings['template'])

        if not os.path.exists(location):
            msg = "The template file does not exist: {}."
            raise exceptions.TokenizeException(msg, location)

        with codecs.open(location, 'r', encoding='utf-8') as fid:
            content = fid.read()


        # Replace key/value arguments
        template_args = info['inline'] if 'inline' in info else info['block']
        _, key_values = common.match_settings(dict(), template_args)

        def sub(match):
            key = match.group('key')
            if key not in key_values:
                msg = "The template argument '{}' was not defined in the !sqa load command."
                raise exceptions.TokenizeException(msg, key)

            return key_values[key]

        content = re.sub(r'{{(?P<key>.*?)}}', sub, content)

        # Tokenize the template
        self.translator.reader.parse(parent, content)

        return parent
예제 #2
0
    def createToken(self, info, parent):

        #TODO: make root path a config item in extension
        location = os.path.join(MooseDocs.ROOT_DIR, 'framework', 'doc',
                                'templates', 'sqa', self.settings['template'])

        if not os.path.exists(location):
            msg = "The template file does not exist: {}."
            raise exceptions.TokenizeException(msg, location)

        with codecs.open(location, 'r', encoding='utf-8') as fid:
            content = fid.read()

        # Replace key/value arguments
        template_args = info['inline'] if 'inline' in info else info['block']
        _, key_values = common.match_settings(dict(), template_args)

        def sub(match):
            key = match.group('key')
            if key not in key_values:
                msg = "The template argument '{}' was not defined in the !sqa load command."
                raise exceptions.TokenizeException(msg, key)

            return key_values[key]

        content = re.sub(r'{{(?P<key>.*?)}}', sub, content)

        # Tokenize the template
        self.translator.reader.parse(parent, content)

        return parent
예제 #3
0
파일: config.py 프로젝트: aashiquear/moose
 def postRead(self, content, page, meta):
     """Updates configuration items."""
     if content:
         for match in command.BlockInlineCommand.RE.finditer(content):
             if match.group('command') == 'config':
                 subcommand = match.group('subcommand')
                 _, settings = common.match_settings(dict(), match.group('settings'))
                 self.__configurations[page.uid][subcommand] = settings
예제 #4
0
 def postRead(self, content, page, meta):
     """Updates configuration items."""
     if content:
         for match in command.BlockInlineCommand.RE.finditer(content):
             if match.group('command') == 'config':
                 subcommand = match.group('subcommand')
                 _, settings = common.match_settings(
                     dict(), match.group('settings'))
                 self.__configurations[page.uid][subcommand] = settings
예제 #5
0
파일: template.py 프로젝트: crazy-ian/moose
    def createToken(self, parent, info, page):
        settings, t_args = common.match_settings(self.defaultSettings(),
                                                 info['settings'])

        location = self.translator.findPage(settings['file'])
        self.extension.addDependency(location)
        content = common.read(location.source)

        content = self.extension.applyTemplateArguments(content, **t_args)
        self.reader.tokenize(parent, content, page, line=info.line)
        return parent
예제 #6
0
파일: template.py 프로젝트: wesleyzzz/moose
    def createToken(self, parent, info, page):
        settings, template_args = common.match_settings(
            self.defaultSettings(), info['settings'])

        location = self.translator.findPage(settings['file'])
        self.extension.addDependency(location)
        with codecs.open(location.source, 'r', encoding='utf-8') as fid:
            content = fid.read()

        def sub(match):
            key = match.group('key')
            arg = template_args.get(key, None)
            if key is None:
                msg = "The template argument '{}' was not defined in the !sqa load command."
                raise exceptions.MooseDocsException(msg, key)
            return arg

        content = re.sub(r'{{(?P<key>.*?)}}', sub, content)

        self.reader.tokenize(parent, content, page, line=info.line)
        return parent
예제 #7
0
 def createToken(self, info, parent):
     defaults = self.translator.renderer.getConfig()
     known, _ = common.match_settings(defaults, info['settings'])
     self.extension.local_config = known
     return parent
예제 #8
0
파일: config.py 프로젝트: huangh-inl/moose
 def createToken(self, info, parent):
     defaults = self.translator.renderer.getConfig()
     known, _ = common.match_settings(defaults, info['settings'])
     self.extension.local_config = known
     return parent