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


Python utils.SystemMessage方法代码示例

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


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

示例1: test

# 需要导入模块: from docutils import utils [as 别名]
# 或者: from docutils.utils import SystemMessage [as 别名]
def test(self, data):
        content_type = data.get("long_description_content_type", None)
        if content_type in ("text/plain", "text/markdown"):
            # These can't fail. Markdown will just assume everything
            # it doesn't understand is plain text.
            return True

        # This should be ReStructuredText
        source = data.get("long_description", "")
        stream = io.StringIO()
        settings = {"warning_stream": stream}

        try:
            publish_parts(
                source=source, writer_name="html4css1", settings_overrides=settings
            )
        except SystemMessage as e:
            self._message = e.args[0]
        errors = stream.getvalue().strip()
        if not errors:
            return True

        self._message = "\n" + errors
        return False 
开发者ID:regebro,项目名称:pyroma,代码行数:26,代码来源:ratings.py

示例2: report_Exception

# 需要导入模块: from docutils import utils [as 别名]
# 或者: from docutils.utils import SystemMessage [as 别名]
def report_Exception(self, error):
        if isinstance(error, utils.SystemMessage):
            self.report_SystemMessage(error)
        elif isinstance(error, UnicodeEncodeError):
            self.report_UnicodeError(error)
        elif isinstance(error, io.InputError):
            self._stderr.write('Unable to open source file for reading:\n'
                               '  %s\n' % ErrorString(error))
        elif isinstance(error, io.OutputError):
            self._stderr.write(
                'Unable to open destination file for writing:\n'
                '  %s\n' % ErrorString(error))
        else:
            print('%s' % ErrorString(error), file=self._stderr)
            print(("""\
Exiting due to error.  Use "--traceback" to diagnose.
Please report errors to <docutils-users@lists.sf.net>.
Include "--traceback" output, Docutils version (%s [%s]),
Python version (%s), your OS type & version, and the
command line used.""" % (__version__, __version_details__,
                         sys.version.split()[0])), file=self._stderr) 
开发者ID:skarlekar,项目名称:faces,代码行数:23,代码来源:core.py

示例3: report_Exception

# 需要导入模块: from docutils import utils [as 别名]
# 或者: from docutils.utils import SystemMessage [as 别名]
def report_Exception(self, error):
        if isinstance(error, utils.SystemMessage):
            self.report_SystemMessage(error)
        elif isinstance(error, UnicodeEncodeError):
            self.report_UnicodeError(error)
        elif isinstance(error, io.InputError):
            self._stderr.write(u'Unable to open source file for reading:\n'
                               u'  %s\n' % ErrorString(error))
        elif isinstance(error, io.OutputError):
            self._stderr.write(
                u'Unable to open destination file for writing:\n'
                u'  %s\n' % ErrorString(error))
        else:
            print >>self._stderr, u'%s' % ErrorString(error)
            print >>self._stderr, ("""\
Exiting due to error.  Use "--traceback" to diagnose.
Please report errors to <docutils-users@lists.sf.net>.
Include "--traceback" output, Docutils version (%s [%s]),
Python version (%s), your OS type & version, and the
command line used.""" % (__version__, __version_details__,
                         sys.version.split()[0])) 
开发者ID:skarlekar,项目名称:faces,代码行数:23,代码来源:core.py

示例4: render

# 需要导入模块: from docutils import utils [as 别名]
# 或者: from docutils.utils import SystemMessage [as 别名]
def render(raw, stream=None, **kwargs):
    if stream is None:
        # Use a io.StringIO as the warning stream to prevent warnings from
        # being printed to sys.stderr.
        stream = io.StringIO()

    settings = SETTINGS.copy()
    settings["warning_stream"] = stream

    writer = Writer()
    writer.translator_class = ReadMeHTMLTranslator

    try:
        parts = publish_parts(raw, writer=writer, settings_overrides=settings)
    except SystemMessage:
        rendered = None
    else:
        rendered = parts.get("docinfo", "") + parts.get("fragment", "")

    if rendered:
        return clean(rendered)
    else:
        return None 
开发者ID:pypa,项目名称:readme_renderer,代码行数:25,代码来源:rst.py

示例5: report_Exception

# 需要导入模块: from docutils import utils [as 别名]
# 或者: from docutils.utils import SystemMessage [as 别名]
def report_Exception(self, error):
        if isinstance(error, utils.SystemMessage):
            self.report_SystemMessage(error)
        elif isinstance(error, UnicodeEncodeError):
            self.report_UnicodeError(error)
        elif isinstance(error, io.InputError):
            self._stderr.write('Unable to open source file for reading:\n'
                               '  %s\n' % ErrorString(error))
        elif isinstance(error, io.OutputError):
            self._stderr.write(
                'Unable to open destination file for writing:\n'
                '  %s\n' % ErrorString(error))
        else:
            print('%s' % ErrorString(error), file=self._stderr)
            print(("""\
Exiting due to error.  Use "--traceback" to diagnose.
Please report errors to <docutils-users@lists.sf.net>.
Include "--traceback" output, Docutils version (%s%s),
Python version (%s), your OS type & version, and the
command line used.""" % (__version__,
                         docutils.__version_details__ and
                         ' [%s]'%docutils.__version_details__ or '',
                         sys.version.split()[0])), file=self._stderr) 
开发者ID:QData,项目名称:deepWordBug,代码行数:25,代码来源:core.py

示例6: report_Exception

# 需要导入模块: from docutils import utils [as 别名]
# 或者: from docutils.utils import SystemMessage [as 别名]
def report_Exception(self, error):
        if isinstance(error, utils.SystemMessage):
            self.report_SystemMessage(error)
        elif isinstance(error, UnicodeEncodeError):
            self.report_UnicodeError(error)
        elif isinstance(error, io.InputError):
            self._stderr.write(u'Unable to open source file for reading:\n'
                               u'  %s\n' % ErrorString(error))
        elif isinstance(error, io.OutputError):
            self._stderr.write(
                u'Unable to open destination file for writing:\n'
                u'  %s\n' % ErrorString(error))
        else:
            print >>self._stderr, u'%s' % ErrorString(error)
            print >>self._stderr, ("""\
Exiting due to error.  Use "--traceback" to diagnose.
Please report errors to <docutils-users@lists.sf.net>.
Include "--traceback" output, Docutils version (%s%s),
Python version (%s), your OS type & version, and the
command line used.""" % (__version__,
                         docutils.__version_details__ and
                         ' [%s]'%docutils.__version_details__ or '',
                         sys.version.split()[0])) 
开发者ID:jmwright,项目名称:cadquery-freecad-module,代码行数:25,代码来源:core.py

示例7: render

# 需要导入模块: from docutils import utils [as 别名]
# 或者: from docutils.utils import SystemMessage [as 别名]
def render(raw, stream=None):
    if stream is None:
        # Use a io.StringIO as the warning stream to prevent warnings from
        # being printed to sys.stderr.
        stream = io.StringIO()

    settings = SETTINGS.copy()
    settings["warning_stream"] = stream

    writer = Writer()
    writer.translator_class = ReadMeHTMLTranslator

    try:
        parts = publish_parts(raw, writer=writer, settings_overrides=settings)
    except SystemMessage:
        rendered = None
    else:
        rendered = parts.get("fragment")

    if rendered:
        return clean(rendered)
    else:
        return None 
开发者ID:holzschu,项目名称:Carnets,代码行数:25,代码来源:rst.py

示例8: _get_part

# 需要导入模块: from docutils import utils [as 别名]
# 或者: from docutils.utils import SystemMessage [as 别名]
def _get_part(self, part):
        try:
            return getattr(self.markup_, part)(self.raw)
        except SystemMessage:
            return '' 
开发者ID:mgaitan,项目名称:waliki,代码行数:7,代码来源:models.py

示例9: _sphinx_run

# 需要导入模块: from docutils import utils [as 别名]
# 或者: from docutils.utils import SystemMessage [as 别名]
def _sphinx_run(self):
        if not self.verbose:
            status_stream = cStringIO.StringIO()
        else:
            status_stream = sys.stdout
        confoverrides = {}
        if self.version:
            confoverrides['version'] = self.version
        if self.release:
            confoverrides['release'] = self.release
        if self.today:
            confoverrides['today'] = self.today
        sphinx_config = config.Config(self.config_dir, 'conf.py', {}, [])
        sphinx_ver = pkg_resources.get_distribution("sphinx").version
        if pkg_resources.parse_version(sphinx_ver) > \
                pkg_resources.parse_version('1.2.3'):
            sphinx_config.init_values(warnings.warn)
        else:
            sphinx_config.init_values()
        if self.builder == 'man' and len(sphinx_config.man_pages) == 0:
            return
        app = application.Sphinx(
            self.source_dir, self.config_dir,
            self.builder_target_dir, self.doctree_dir,
            self.builder, confoverrides, status_stream,
            freshenv=self.fresh_env, warningiserror=False)

        try:
            app.build(force_all=self.all_files)
        except Exception as err:
            from docutils import utils
            if isinstance(err, utils.SystemMessage):
                sys.stder.write('reST markup error:\n')
                sys.stderr.write(err.args[0].encode('ascii',
                                                    'backslashreplace'))
                sys.stderr.write('\n')
            else:
                raise

        if self.link_index:
            src = app.config.master_doc + app.builder.out_suffix
            dst = app.builder.get_outfilename('index')
            os.symlink(src, dst) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:45,代码来源:builddoc.py

示例10: sphinxify

# 需要导入模块: from docutils import utils [as 别名]
# 或者: from docutils.utils import SystemMessage [as 别名]
def sphinxify(docstring, context, buildername='html', img_path=''):
    """
    Largely modified Spyder's sphinxify.
    """
#    if not img_path:
#        img_path = os.path.join(CONFDIR, "_images")
    if img_path:
        if os.name == 'nt':
            img_path = img_path.replace('\\', '/')
        leading = '/' if os.name.startswith('posix') else ''
        docstring = docstring.replace('_images', leading+img_path)

    srcdir = osp.join(CONFDIR, '_sources')
    if not os.path.exists(srcdir):
        os.makedirs(srcdir)
#    srcdir = encoding.to_unicode_from_fs(srcdir)
    base_name = osp.join(srcdir, xrtQookPageName)
    rst_name = base_name + '.rst'

    # This is needed so users can type \\ on latex eqnarray envs inside raw
    # docstrings
    docstring = docstring.replace('\\\\', '\\\\\\\\')

    # Add a class to several characters on the argspec. This way we can
    # highlight them using css, in a similar way to what IPython does.
    # NOTE: Before doing this, we escape common html chars so that they
    # don't interfere with the rest of html present in the page
    argspec = escape(context['argspec'])
    for char in ['=', ',', '(', ')', '*', '**']:
        argspec = argspec.replace(
            char, '<span class="argspec-highlight">' + char + '</span>')
    context['argspec'] = argspec

    doc_file = codecs.open(rst_name, 'w', encoding='utf-8')
    doc_file.write(docstring)
    doc_file.close()

    confoverrides = {'html_context': context,
                     'extensions': ['sphinx.ext.mathjax']}

    doctreedir = osp.join(CONFDIR, 'doctrees')
    sphinx_app = Sphinx(srcdir, CONFDIR, CONFDIR, doctreedir, buildername,
                        confoverrides, status=None, warning=None,
                        freshenv=True, warningiserror=False, tags=None)
    try:
        sphinx_app.build(None, [rst_name])
    except SystemMessage:
        pass
#        output = ("It was not possible to generate rich text help for this "
#                  "object.</br>Please see it in plain text.") 
开发者ID:kklmn,项目名称:xrt,代码行数:52,代码来源:ext.py

示例11: run

# 需要导入模块: from docutils import utils [as 别名]
# 或者: from docutils.utils import SystemMessage [as 别名]
def run(self):
        try:
            from sphinx.application import Sphinx
            from docutils.utils import SystemMessage
        except ImportError:
            raise SystemExit('This command requires Sphinx to be installed.') from None

        fix_docutils()

        dest_dir = os.path.join(basedir, 'doc')
        src_dir = os.path.join(basedir, 'rst')

        confoverrides = {}
        confoverrides['version'] = s3ql.VERSION
        confoverrides['release'] = s3ql.RELEASE

        for builder in ('html', 'latex', 'man'):
            print('Running %s builder...' % builder)
            self.mkpath(os.path.join(dest_dir, builder))
            app = Sphinx(srcdir=src_dir, confdir=src_dir,
                         outdir=os.path.join(dest_dir, builder),
                         doctreedir=os.path.join(dest_dir, 'doctrees'),
                         buildername=builder, confoverrides=confoverrides,
                         freshenv=self.fresh_env)
            self.fresh_env = False
            self.all_files = False

            try:
                if self.all_files:
                    app.builder.build_all()
                else:
                    app.builder.build_update()
            except SystemMessage as err:
                print('reST markup error:',
                      err.args[0].encode('ascii', 'backslashreplace'),
                      file=sys.stderr)

        # These shouldn't be installed by default
        for name in ('expire_backups.1', 'pcp.1'):
            os.rename(os.path.join(dest_dir, 'man', name),
                      os.path.join(basedir, 'contrib', name))

        print('Running pdflatex...')
        for _ in range(3):
            with open('/dev/null', 'wb') as null:
                subprocess.check_call(['pdflatex', '-interaction', 'batchmode', 'manual.tex'],
                                      cwd=os.path.join(dest_dir, 'latex'), stdout=null)
        os.rename(os.path.join(dest_dir, 'latex', 'manual.pdf'),
                  os.path.join(dest_dir, 'manual.pdf')) 
开发者ID:s3ql,项目名称:s3ql,代码行数:51,代码来源:setup.py


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