本文整理汇总了Python中docutils.ApplicationError方法的典型用法代码示例。如果您正苦于以下问题:Python docutils.ApplicationError方法的具体用法?Python docutils.ApplicationError怎么用?Python docutils.ApplicationError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类docutils
的用法示例。
在下文中一共展示了docutils.ApplicationError方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_target
# 需要导入模块: import docutils [as 别名]
# 或者: from docutils import ApplicationError [as 别名]
def add_target(self, targetname, refuri, target, lineno):
target.line = lineno
if targetname:
name = normalize_name(unescape(targetname))
target['names'].append(name)
if refuri:
uri = self.inliner.adjust_uri(refuri)
if uri:
target['refuri'] = uri
else:
raise ApplicationError('problem with URI: %r' % refuri)
self.document.note_explicit_target(target, self.parent)
else: # anonymous target
if refuri:
target['refuri'] = refuri
target['anonymous'] = 1
self.document.note_anonymous_target(target)
示例2: find_theme
# 需要导入模块: import docutils [as 别名]
# 或者: from docutils import ApplicationError [as 别名]
def find_theme(name):
# Where else to look for a theme?
# Check working dir? Destination dir? Config dir? Plugins dir?
path = os.path.join(themes_dir_path, name)
if not os.path.isdir(path):
raise docutils.ApplicationError(
'Theme directory not found: %r (path: %r)' % (name, path))
return path
示例3: setup_theme
# 需要导入模块: import docutils [as 别名]
# 或者: from docutils import ApplicationError [as 别名]
def setup_theme(self):
if self.document.settings.theme:
self.copy_theme()
elif self.document.settings.theme_url:
self.theme_file_path = self.document.settings.theme_url
else:
raise docutils.ApplicationError(
'No theme specified for S5/HTML writer.')
示例4: phrase_ref
# 需要导入模块: import docutils [as 别名]
# 或者: from docutils import ApplicationError [as 别名]
def phrase_ref(self, before, after, rawsource, escaped, text):
match = self.patterns.embedded_link.search(escaped)
if match: # embedded <URI> or <alias_>
text = unescape(escaped[:match.start(0)])
aliastext = match.group(2)
underscore_escaped = aliastext.endswith('\x00_')
aliastext = unescape(aliastext)
if aliastext.endswith('_') and not (underscore_escaped
or self.patterns.uri.match(aliastext)):
aliastype = 'name'
alias = normalize_name(aliastext[:-1])
target = nodes.target(match.group(1), refname=alias)
target.indirect_reference_name = aliastext[:-1]
else:
aliastype = 'uri'
alias = ''.join(aliastext.split())
alias = self.adjust_uri(alias)
if alias.endswith(r'\_'):
alias = alias[:-2] + '_'
target = nodes.target(match.group(1), refuri=alias)
target.referenced = 1
if not aliastext:
raise ApplicationError('problem with embedded link: %r'
% aliastext)
if not text:
text = alias
else:
target = None
refname = normalize_name(text)
reference = nodes.reference(rawsource, text,
name=whitespace_normalize_name(text))
node_list = [reference]
if rawsource[-2:] == '__':
if target and (aliastype == 'name'):
reference['refname'] = alias
self.document.note_refname(reference)
# self.document.note_indirect_target(target) # required?
elif target and (aliastype == 'uri'):
reference['refuri'] = alias
else:
reference['anonymous'] = 1
else:
if target:
target['names'].append(refname)
if aliastype == 'name':
reference['refname'] = alias
self.document.note_indirect_target(target)
self.document.note_refname(reference)
else:
reference['refuri'] = alias
self.document.note_explicit_target(target, self.parent)
# target.note_referenced_by(name=refname)
node_list.append(target)
else:
reference['refname'] = refname
self.document.note_refname(reference)
return before, node_list, after, []