本文整理汇总了Python中nikola.utils.LOGGER.warning方法的典型用法代码示例。如果您正苦于以下问题:Python LOGGER.warning方法的具体用法?Python LOGGER.warning怎么用?Python LOGGER.warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nikola.utils.LOGGER
的用法示例。
在下文中一共展示了LOGGER.warning方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_gen_tasks
# 需要导入模块: from nikola.utils import LOGGER [as 别名]
# 或者: from nikola.utils.LOGGER import warning [as 别名]
def test_gen_tasks(self):
hw = HelloWorld()
hw.site = MockObject()
hw.site.config = {}
for i in hw.gen_tasks():
self.assertEqual(i['basename'], 'hello_world')
self.assertEqual(i['uptodate'], [False])
try:
self.assertIsInstance(i['actions'][0][1][0], bool)
except AttributeError:
LOGGER.warning('Python 2.6 is missing assertIsInstance()')
示例2: run
# 需要导入模块: from nikola.utils import LOGGER [as 别名]
# 或者: from nikola.utils.LOGGER import warning [as 别名]
def run(self):
if 'alt' in self.options and self.ignore_alt:
LOGGER.warning("Graphviz: the :alt: option is ignored, it's better to set the title of your graph.")
if self.arguments:
if self.content:
LOGGER.warning("Graphviz: this directive can't have both content and a filename argument. Ignoring content.")
f_name = self.arguments[0]
# TODO: be smart about where exactly that file is located
with open(f_name, 'rb') as inf:
data = inf.read().decode('utf-8')
else:
data = '\n'.join(self.content)
node_list = []
try:
p = Popen([self.dot_path, '-Tsvg'], stdin=PIPE, stdout=PIPE, stderr=PIPE)
svg_data, errors = p.communicate(input=data.encode('utf8'))
code = p.wait()
if code: # Some error
document = self.state.document
return [document.reporter.error(
'Error processing graph: {0}'.format(errors), line=self.lineno)]
if self.embed_graph: # SVG embedded in the HTML
if 'inline' in self.options:
svg_data = '<span class="graphviz">{0}</span>'.format(svg_data)
else:
svg_data = '<p class="graphviz">{0}</p>'.format(svg_data)
else: # External SVG file
# TODO: there is no reason why this branch needs to be a raw
# directive. It could generate regular docutils nodes and
# be useful for any writer.
makedirs(self.output_folder)
f_name = hashlib.md5(svg_data).hexdigest() + '.svg'
img_path = self.graph_path + f_name
f_path = os.path.join(self.output_folder, f_name)
alt = self.options.get('alt', '')
with open(f_path, 'wb+') as outf:
outf.write(svg_data)
self.state.document.settings.record_dependencies.add(f_path)
if 'inline' in self.options:
svg_data = '<span class="graphviz"><img src="{0}" alt="{1}"></span>'.format(img_path, alt)
else:
svg_data = '<p class="graphviz"><img src="{0}" alt="{1}"></p>'.format(img_path, alt)
node_list.append(nodes.raw('', svg_data, format='html'))
if 'caption' in self.options and 'inline' not in self.options:
node_list.append(
nodes.raw('', '<p class="caption">{0}</p>'.format(self.options['caption']),
format='html'))
return node_list
except OSError:
LOGGER.error("Can't execute 'dot'")
raise
示例3: compile_html
# 需要导入模块: from nikola.utils import LOGGER [as 别名]
# 或者: from nikola.utils.LOGGER import warning [as 别名]
def compile_html(self, source, dest, is_two_file=True):
"""Compile reSt into HTML."""
if not has_docutils:
raise Exception('To build this site, you need to install the '
'"docutils" package.')
makedirs(os.path.dirname(dest))
error_level = 100
with codecs.open(dest, "w+", "utf8") as out_file:
with codecs.open(source, "r", "utf8") as in_file:
data = in_file.read()
if not is_two_file:
data = data.split('\n\n', 1)[-1]
output, error_level, deps = rst2html(
data, settings_overrides={
'initial_header_level': 2,
'record_dependencies': True,
'stylesheet_path': None,
'link_stylesheet': True,
'syntax_highlight': 'short',
'math_output': 'mathjax',
})
out_file.write(output)
deps_path = dest + '.dep'
if deps.list:
with codecs.open(deps_path, "wb+", "utf8") as deps_file:
deps_file.write('\n'.join(deps.list))
else:
if os.path.isfile(deps_path):
os.unlink(deps_path)
if error_level == 2:
LOGGER.warning('Docutils reports warnings on {0}'.format(source))
if error_level < 3:
return True
else:
return False