当前位置: 首页>>代码示例>>Python>>正文


Python MooseDocs.abspath方法代码示例

本文整理汇总了Python中MooseDocs.abspath方法的典型用法代码示例。如果您正苦于以下问题:Python MooseDocs.abspath方法的具体用法?Python MooseDocs.abspath怎么用?Python MooseDocs.abspath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MooseDocs的用法示例。


在下文中一共展示了MooseDocs.abspath方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: check

# 需要导入模块: import MooseDocs [as 别名]
# 或者: from MooseDocs import abspath [as 别名]
def check(config_file=None, locations=None, generate=None):
    """
    Performs checks and optionally generates stub pages for missing documentation.
    """
    # Read the configuration
    app_ext = 'MooseDocs.extensions.app_syntax'
    config = MooseDocs.load_config(config_file)
    if app_ext not in config:
        mooseutils.MooseException("The 'check' utility requires the 'app_syntax' extension.")
    ext_config = config[app_ext]

    # Run the executable
    exe = MooseDocs.abspath(ext_config['executable'])
    if not os.path.exists(exe):
        raise IOError('The executable does not exist: {}'.format(exe))
    else:
        LOG.debug("Executing %s to extract syntax.", exe)
        raw = mooseutils.runExe(exe, '--yaml')
        yaml = mooseutils.MooseYaml(raw)

    # Populate the syntax
    for loc in ext_config['locations']:
        for key, value in loc.iteritems():
            if (locations is None) or (key in locations):
                value['group'] = key
                syntax = common.MooseApplicationSyntax(yaml, generate=generate,
                                                       install=ext_config['install'], **value)
                LOG.info("Checking documentation for '%s'.", key)
                syntax.check()

    return None
开发者ID:mangerij,项目名称:moose,代码行数:33,代码来源:check.py

示例2: __init__

# 需要导入模块: import MooseDocs [as 别名]
# 或者: from MooseDocs import abspath [as 别名]
    def __init__(self, **kwargs):
        super(AppSyntaxExtension, self).__init__(**kwargs)

        # Storage for the MooseLinkDatabase object
        self.syntax = None

        # Create the absolute path to the executable
        self.setConfig('executable', MooseDocs.abspath(self.getConfig('executable')))
开发者ID:mangerij,项目名称:moose,代码行数:10,代码来源:app_syntax.py

示例3: _updateSyntax

# 需要导入模块: import MooseDocs [as 别名]
# 或者: from MooseDocs import abspath [as 别名]
    def _updateSyntax(self, path, objects, actions):
        """
        A helper for populating the syntax/filename/markdown databases. (private)

        Args:
          path[str]: A valid source directory to inspect.
        """
        reg_re = r'(?<!\:)register(?!RecoverableData|edError)\w+?\((?P<key>\w+)\);'
        reg_named_re = r'registerNamed\w+?\((?P<class>\w+),\s*"(?P<key>\w+)"\);'
        action_re = r'(registerActionSyntax|registerSyntax|registerSyntaxTask)\("(?P<action>\w+)"' \
                    r'\s*,\s*"(?P<key>.*?)\"[,\);]'

        # Walk the directory, looking for files with the supplied extension.
        for root, _, files in os.walk(MooseDocs.abspath(path), topdown=False):
            for filename in files:
                fullfile = os.path.join(root, filename)

                # Inspect source files
                if filename.endswith('.C') or filename.endswith('.h'):
                    fid = open(fullfile, 'r')
                    content = fid.read()
                    fid.close()

                    # Update class to source definition map
                    if filename.endswith('.h'):
                        for match in re.finditer(r'class\s*(?P<class>\w+)\b[^;]', content):
                            key = match.group('class')
                            self._filenames[key] = [fullfile]
                            src = fullfile.replace('/include/', '/src/')[:-2] + '.C'
                            if os.path.exists(src) and (src not in self._filenames[key]):
                                self._filenames[key].append(src)

                    # Map of registered objects
                    for match in re.finditer(reg_re, content):
                        key = match.group('key')
                        objects[key] = key

                    # Map of named registered objects
                    for match in re.finditer(reg_named_re, content):
                        name = match.group('class')
                        key = match.group('key')
                        objects[key] = name

                    # Action syntax map
                    for match in re.finditer(action_re, content):
                        key = match.group('key')
                        action = match.group('action')
                        actions[key].add(action)

        for root, _, files in os.walk(path, topdown=False):
            for filename in files:
                fullfile = os.path.join(root, filename)

                # Inspect source files
                name, ext = os.path.splitext(filename)
                if (ext == '.C') and (name in self._filenames):
                    self._filenames[name].append(fullfile)
开发者ID:mangerij,项目名称:moose,代码行数:59,代码来源:MooseApplicationSyntax.py

示例4: parseBibtexFile

# 需要导入模块: import MooseDocs [as 别名]
# 或者: from MooseDocs import abspath [as 别名]
    def parseBibtexFile(self, bibfile):
        """
        Returns parsed bibtex file.  If "macro_files" are supplied in the configuration
        file, then a temporary file will be made that contains the supplied macros
        above the original bib file.  This temporary combined file can then be
        parsed by pybtex.
        """

        if self._macro_files:
            t_bib_path = MooseDocs.abspath("tBib.bib")
            with open(t_bib_path, "wb") as t_bib:
                for t_file in self._macro_files:
                    with open(MooseDocs.abspath(t_file.strip()), "rb") as in_file:
                        shutil.copyfileobj(in_file, t_bib)
                with open(bibfile, "rb") as in_file:
                    shutil.copyfileobj(in_file, t_bib)
            data = parse_file(t_bib_path)
            if os.path.isfile(t_bib_path):
                os.remove(t_bib_path)
        else:
            data = parse_file(bibfile)

        return data
开发者ID:mangerij,项目名称:moose,代码行数:25,代码来源:bibtex.py

示例5: __init__

# 需要导入模块: import MooseDocs [as 别名]
# 或者: from MooseDocs import abspath [as 别名]
    def __init__(self, repo=None, links=None, **kwargs): #pylint: disable=unused-argument
        self._repo = repo
        self.inputs = collections.OrderedDict()
        self.children = collections.OrderedDict()

        for key, paths in links.iteritems():
            self.inputs[key] = dict()
            self.children[key] = dict()

            for path in paths:
                for base, _, files in os.walk(MooseDocs.abspath(path), topdown=False):
                    for filename in files:
                        full_name = os.path.join(base, filename)
                        if filename.endswith('.i'):
                            self.search(full_name, self.INPUT_RE, self.inputs[key])
                        elif filename.endswith('.h'):
                            self.search(full_name, self.HEADER_RE, self.children[key])
开发者ID:mangerij,项目名称:moose,代码行数:19,代码来源:MooseLinkDatabase.py

示例6: run

# 需要导入模块: import MooseDocs [as 别名]
# 或者: from MooseDocs import abspath [as 别名]
    def run(self, lines):
        """
        Create a bibliography from cite commands.
        """

        # Join the content to enable regex searches throughout entire text
        content = '\n'.join(lines)

        # Build the database of bibtex data
        self._citations = []              # member b/c it is used in substitution function
        self._bibtex = BibliographyData() # ""
        bibfiles = []
        match = re.search(self.RE_BIBLIOGRAPHY, content)
        if match:
            for bfile in match.group(1).split(','):
                try:
                    bibfiles.append(MooseDocs.abspath(bfile.strip()))
                    data = self.parseBibtexFile(bibfiles[-1])
                except UndefinedMacro:
                    LOG.error('Undefined macro in bibtex file: %s, specify macro_files arguments ' \
                              'in configuration file (e.g. website.yml)', bfile.strip())
                self._bibtex.add_entries(data.entries.iteritems())
        else:
            return lines

        # Determine the style
        match = re.search(self.RE_STYLE, content)
        if match:
            content = content.replace(match.group(0), '')
            try:
                style = find_plugin('pybtex.style.formatting', match.group(1))
            except PluginNotFound:
                LOG.error('Unknown bibliography style "%s"', match.group(1))
                return lines

        else:
            style = find_plugin('pybtex.style.formatting', 'plain')

        # Replace citations with author date, as an anchor
        content = re.sub(self.RE_CITE, self.authors, content)

        # Create html bibliography
        if self._citations:

            # Generate formatted html using pybtex
            formatted_bibliography = style().format_bibliography(self._bibtex, self._citations)
            backend = find_plugin('pybtex.backends', 'html')
            stream = io.StringIO()
            backend().write_to_stream(formatted_bibliography, stream)

            # Strip the bib items from the formatted html
            html = re.findall(r'\<dd\>(.*?)\</dd\>', stream.getvalue(),
                              flags=re.MULTILINE|re.DOTALL)

            # Produces an ordered list with anchors to the citations
            output = u'<ol class="moose-bibliography" data-moose-bibfiles="{}">\n'
            output = output.format(str(bibfiles))
            for i, item in enumerate(html):
                output += u'<li name="{}">{}</li>\n'.format(self._citations[i], item)
            output += u'</ol>\n'
            content = re.sub(self.RE_BIBLIOGRAPHY,
                             self.markdown.htmlStash.store(output, safe=True),
                             content)

        return content.split('\n')
开发者ID:mangerij,项目名称:moose,代码行数:67,代码来源:bibtex.py

示例7: __init__

# 需要导入模块: import MooseDocs [as 别名]
# 或者: from MooseDocs import abspath [as 别名]
    def __init__(self, yaml_data, paths=None, doxygen=None, name=None, doxygen_name_style='upper',
                 group=None, install=None, generate=False, hide=None):

        # Defaults
        if paths is None:
            paths = []
        if hide is None:
            hide = []

        # Public member for syntax object name (i.e., the location name in the configuration file)
        self._name = name
        self._group = group

        self._yaml_data = yaml_data
        self._hide = hide
        install = MooseDocs.abspath(install) if install else None
        self._doxygen = doxygen
        self._doxygen_name_style = doxygen_name_style

        self._filenames = dict()
        self._objects = dict()
        self._actions = dict()

        # Update the syntax maps
        actions = collections.defaultdict(set)
        objects = dict()
        for path in paths:
            full_path = MooseDocs.abspath(path)
            if not os.path.exists(full_path):
                LOG.critical("Unknown source directory supplied: %s", full_path)
                raise IOError(full_path)
            self._updateSyntax(path, objects, actions)

        # Create MooseObjectInfo objects
        for key, value in objects.iteritems():
            for node in self._yaml_data['/' + key]:

                # Skip this node if it has subblocks, which is not possible for MooseObjects
                if node['subblocks']:
                    continue

                obj_info = MooseObjectInfo(node,
                                           code=self._filenames[value],
                                           install=install,
                                           group=self._group,
                                           generate=generate,
                                           hidden=self.hidden(node['name']))
                self._objects[obj_info.key] = obj_info

        # Create MooseActionInfo objects
        for key, value in actions.iteritems():
            for node in self._yaml_data['/' + key]:
                code = []
                for a in value:
                    if a in self._filenames:
                        code += self._filenames[a]
                info = MooseActionInfo(node,
                                       code=code,
                                       install=install,
                                       group=self._group,
                                       generate=generate,
                                       hidden=self.hidden(node['name']))
                self._actions[info.key] = info

        # Create MooseActionInfo objects from the MooseObjectInfo
        # This is needed to allow for the !systems pages to be complete for apps that
        # do not also include the framework
        for obj_info in self._objects.itervalues():
            action_key = os.path.dirname(obj_info.key)
            if action_key not in self._actions:
                for node in self._yaml_data[action_key]:
                    info = MooseActionInfo(node,
                                           code=[],
                                           install=install,
                                           group=self._group,
                                           generate=generate,
                                           hidden=self.hidden(node['name']),
                                           check=False)
                    self._actions[info.key] = info
开发者ID:mangerij,项目名称:moose,代码行数:81,代码来源:MooseApplicationSyntax.py


注:本文中的MooseDocs.abspath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。