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


Python utils.get_source_line方法代码示例

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


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

示例1: _warn_node

# 需要导入模块: from docutils import utils [as 别名]
# 或者: from docutils.utils import get_source_line [as 别名]
def _warn_node(self, msg, node, **kwargs):
    if not msg.startswith('nonlocal image URI found:'):
        self._warnfunc(msg, '%s:%s' % get_source_line(node)) 
开发者ID:jantman,项目名称:python-wifi-survey-heatmap,代码行数:5,代码来源:conf.py

示例2: _warn_node

# 需要导入模块: from docutils import utils [as 别名]
# 或者: from docutils.utils import get_source_line [as 别名]
def _warn_node(self, msg, node, **kwargs):
    if not msg.startswith('nonlocal image URI found:'):
        self._warnfunc(msg, '%s:%s' % get_source_line(node), **kwargs) 
开发者ID:nodev-io,项目名称:pytest-nodev,代码行数:5,代码来源:conf.py

示例3: _warn_node

# 需要导入模块: from docutils import utils [as 别名]
# 或者: from docutils.utils import get_source_line [as 别名]
def _warn_node(self, msg, node, **kwargs):
    if msg.startswith('nonlocal image URI found:'):
        return
    self._warnfunc(msg, '%s:%s' % get_source_line(node)) 
开发者ID:jantman,项目名称:awslimitchecker,代码行数:6,代码来源:conf.py

示例4: visit_image

# 需要导入模块: from docutils import utils [as 别名]
# 或者: from docutils.utils import get_source_line [as 别名]
def visit_image(self, node):
        # Capture the image file.
        if 'uri' in node.attributes:
            source = node.attributes['uri']
            if not (source.startswith('http:') or source.startswith('https:')):
                if not source.startswith(os.sep):
                    docsource, line = utils.get_source_line(node)
                    if docsource:
                        dirname = os.path.dirname(docsource)
                        if dirname:
                            source = '%s%s%s' % (dirname, os.sep, source, )
                if not self.check_file_exists(source):
                    self.document.reporter.warning(
                        'Cannot find image file %s.' % (source, ))
                    return
        else:
            return
        if source in self.image_dict:
            filename, destination = self.image_dict[source]
        else:
            self.image_count += 1
            filename = os.path.split(source)[1]
            destination = 'Pictures/1%08x%s' % (self.image_count, filename, )
            if source.startswith('http:') or source.startswith('https:'):
                try:
                    imgfile = urllib2.urlopen(source)
                    content = imgfile.read()
                    imgfile.close()
                    imgfile2 = tempfile.NamedTemporaryFile('wb', delete=False)
                    imgfile2.write(content)
                    imgfile2.close()
                    imgfilename = imgfile2.name
                    source = imgfilename
                except urllib2.HTTPError, e:
                    self.document.reporter.warning(
                        "Can't open image url %s." % (source, ))
                spec = (source, destination,)
            else: 
开发者ID:jmwright,项目名称:cadquery-freecad-module,代码行数:40,代码来源:__init__.py

示例5: _warn_node

# 需要导入模块: from docutils import utils [as 别名]
# 或者: from docutils.utils import get_source_line [as 别名]
def _warn_node(self, msg, node, **kwargs):
    if not (
        msg.startswith('nonlocal image URI found:') or
        'Unexpected indentation' in msg or
        'Definition list ends without a blank line' in msg or
        'document isn\'t included in any toctree' in msg
    ):
        self._warnfunc(msg, '%s:%s' % get_source_line(node)) 
开发者ID:manheim,项目名称:manheim-c7n-tools,代码行数:10,代码来源:conf.py

示例6: _warn_node

# 需要导入模块: from docutils import utils [as 别名]
# 或者: from docutils.utils import get_source_line [as 别名]
def _warn_node(self, msg, node):
    if not msg.startswith('nonlocal image URI found:'):
        self._warnfunc(msg, '%s:%s' % get_source_line(node)) 
开发者ID:uber,项目名称:tchannel-python,代码行数:5,代码来源:conf.py

示例7: visit_image

# 需要导入模块: from docutils import utils [as 别名]
# 或者: from docutils.utils import get_source_line [as 别名]
def visit_image(self, node):
        # Capture the image file.
        if 'uri' in node.attributes:
            source = node.attributes['uri']
            if not source.startswith('http:'):
                if not source.startswith(os.sep):
                    docsource, line = utils.get_source_line(node)
                    if docsource:
                        dirname = os.path.dirname(docsource)
                        if dirname:
                            source = '%s%s%s' % (dirname, os.sep, source, )
                if not self.check_file_exists(source):
                    self.document.reporter.warning(
                        'Cannot find image file %s.' % (source, ))
                    return
        else:
            return
        if source in self.image_dict:
            filename, destination = self.image_dict[source]
        else:
            self.image_count += 1
            filename = os.path.split(source)[1]
            destination = 'Pictures/1%08x%s' % (self.image_count, filename, )
            if source.startswith('http:'):
                try:
                    imgfile = urllib.request.urlopen(source)
                    content = imgfile.read()
                    imgfile.close()
                    imgfile2 = tempfile.NamedTemporaryFile('wb', delete=False)
                    imgfile2.write(content)
                    imgfile2.close()
                    imgfilename = imgfile2.name
                    source = imgfilename
                except urllib.error.HTTPError as e:
                    self.document.reporter.warning(
                        "Can't open image url %s." % (source, ))
                spec = (source, destination,)
            else:
                spec = (os.path.abspath(source), destination,)
            self.embedded_file_list.append(spec)
            self.image_dict[source] = (source, destination,)
        # Is this a figure (containing an image) or just a plain image?
        if self.in_paragraph:
            el1 = self.current_element
        else:
            el1 = SubElement(self.current_element, 'text:p',
                attrib={'text:style-name': self.rststyle('textbody')})
        el2 = el1
        if isinstance(node.parent, docutils.nodes.figure):
            el3, el4, el5, caption = self.generate_figure(node, source,
                destination, el2)
            attrib = {}
            el6, width = self.generate_image(node, source, destination,
                el5, attrib)
            if caption is not None:
                el6.tail = caption
        else:   #if isinstance(node.parent, docutils.nodes.image):
            el3 = self.generate_image(node, source, destination, el2) 
开发者ID:skarlekar,项目名称:faces,代码行数:60,代码来源:__init__.py

示例8: visit_image

# 需要导入模块: from docutils import utils [as 别名]
# 或者: from docutils.utils import get_source_line [as 别名]
def visit_image(self, node):
        # Capture the image file.
        if 'uri' in node.attributes:
            source = node.attributes['uri']
            if not (source.startswith('http:') or source.startswith('https:')):
                if not source.startswith(os.sep):
                    docsource, line = utils.get_source_line(node)
                    if docsource:
                        dirname = os.path.dirname(docsource)
                        if dirname:
                            source = '%s%s%s' % (dirname, os.sep, source, )
                if not self.check_file_exists(source):
                    self.document.reporter.warning(
                        'Cannot find image file %s.' % (source, ))
                    return
        else:
            return
        if source in self.image_dict:
            filename, destination = self.image_dict[source]
        else:
            self.image_count += 1
            filename = os.path.split(source)[1]
            destination = 'Pictures/1%08x%s' % (self.image_count, filename, )
            if source.startswith('http:') or source.startswith('https:'):
                try:
                    imgfile = urllib.request.urlopen(source)
                    content = imgfile.read()
                    imgfile.close()
                    imgfile2 = tempfile.NamedTemporaryFile('wb', delete=False)
                    imgfile2.write(content)
                    imgfile2.close()
                    imgfilename = imgfile2.name
                    source = imgfilename
                except urllib.error.HTTPError as e:
                    self.document.reporter.warning(
                        "Can't open image url %s." % (source, ))
                spec = (source, destination,)
            else:
                spec = (os.path.abspath(source), destination,)
            self.embedded_file_list.append(spec)
            self.image_dict[source] = (source, destination,)
        # Is this a figure (containing an image) or just a plain image?
        if self.in_paragraph:
            el1 = self.current_element
        else:
            el1 = SubElement(self.current_element, 'text:p',
                attrib={'text:style-name': self.rststyle('textbody')})
        el2 = el1
        if isinstance(node.parent, docutils.nodes.figure):
            el3, el4, el5, caption = self.generate_figure(node, source,
                destination, el2)
            attrib = {}
            el6, width = self.generate_image(node, source, destination,
                el5, attrib)
            if caption is not None:
                el6.tail = caption
        else:   #if isinstance(node.parent, docutils.nodes.image):
            el3 = self.generate_image(node, source, destination, el2) 
开发者ID:QData,项目名称:deepWordBug,代码行数:60,代码来源:__init__.py

示例9: visit_image

# 需要导入模块: from docutils import utils [as 别名]
# 或者: from docutils.utils import get_source_line [as 别名]
def visit_image(self, node):
        # Capture the image file.
        if 'uri' in node.attributes:
            source = node.attributes['uri']
            if not (source.startswith('http:') or source.startswith('https:')):
                if not source.startswith(os.sep):
                    docsource, line = utils.get_source_line(node)
                    if docsource:
                        dirname = os.path.dirname(docsource)
                        if dirname:
                            source = '%s%s%s' % (dirname, os.sep, source, )
                if not self.check_file_exists(source):
                    self.document.reporter.warning(
                        'Cannot find image file %s.' % (source, ))
                    return
        else:
            return
        if source in self.image_dict:
            filename, destination = self.image_dict[source]
        else:
            self.image_count += 1
            filename = os.path.split(source)[1]
            destination = 'Pictures/1%08x%s' % (self.image_count, filename, )
            if source.startswith('http:') or source.startswith('https:'):
                try:
                    imgfile = urlopen(source)
                    content = imgfile.read()
                    imgfile.close()
                    imgfile2 = tempfile.NamedTemporaryFile('wb', delete=False)
                    imgfile2.write(content)
                    imgfile2.close()
                    imgfilename = imgfile2.name
                    source = imgfilename
                except HTTPError:
                    self.document.reporter.warning(
                        "Can't open image url %s." % (source, ))
                spec = (source, destination,)
            else:
                spec = (os.path.abspath(source), destination,)
            self.embedded_file_list.append(spec)
            self.image_dict[source] = (source, destination,)
        # Is this a figure (containing an image) or just a plain image?
        if self.in_paragraph:
            el1 = self.current_element
        else:
            el1 = SubElement(
                self.current_element, 'text:p',
                attrib={'text:style-name': self.rststyle('textbody')})
        el2 = el1
        if isinstance(node.parent, docutils.nodes.figure):
            el3, el4, el5, caption = self.generate_figure(
                node, source,
                destination, el2)
            attrib = {}
            el6, width = self.generate_image(
                node, source, destination,
                el5, attrib)
            if caption is not None:
                el6.tail = caption
        else:   # if isinstance(node.parent, docutils.nodes.image):
            self.generate_image(node, source, destination, el2) 
开发者ID:aws-samples,项目名称:aws-builders-fair-projects,代码行数:63,代码来源:__init__.py


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