本文整理汇总了Python中pyang.error.err_add函数的典型用法代码示例。如果您正苦于以下问题:Python err_add函数的具体用法?Python err_add怎么用?Python err_add使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了err_add函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: v_chk_namespace
def v_chk_namespace(ctx, stmt, namespace_prefixes):
if namespace_prefixes != []:
for prefix in namespace_prefixes:
if stmt.arg == prefix + stmt.i_module.arg:
return
err_add(ctx.errors, stmt.pos, 'LINT_BAD_NAMESPACE_VALUE',
namespace_prefixes[0] + stmt.i_module.arg)
开发者ID:SDTN,项目名称:Test,代码行数:7,代码来源:lint.py
示例2: v_chk_path_refs
def v_chk_path_refs(ctx, statement):
"""
Check path references for absolute / relative paths as appropriate.
This function is called with the following statements:
* path
* augment
"""
path = statement.arg
if path[0] == '/':
abspath = True
else:
abspath = False
components = yangpath.split_paths(path)
# consider the namespace in the first component
# assumes that if the namespace matches the module namespace, then
# relative path should be used (intra-module )
if ":" in components[0]:
(namespace, barepath) = components[0].split(':')
else:
namespace = statement.i_module.i_prefix
barepath = components[0]
mod_prefix = statement.i_module.i_prefix
if namespace == mod_prefix and abspath:
err_add(ctx.errors, statement.pos, 'OC_RELATIVE_PATH',
(statement.keyword, statement.arg))
开发者ID:kverma,项目名称:oc-pyang,代码行数:25,代码来源:openconfig.py
示例3: chk_revision
def chk_revision(oldmod, newmod, ctx):
oldrev = get_latest_revision(oldmod)
newrev = get_latest_revision(newmod)
if newrev is None:
err_add(ctx.errors, newmod.pos, 'CHK_NO_REVISION', ())
elif (oldrev is not None) and (oldrev >= newrev):
err_add(ctx.errors, newmod.pos, 'CHK_BAD_REVISION', (newrev, oldrev))
开发者ID:BroadbandForum,项目名称:pyang,代码行数:7,代码来源:check_update.py
示例4: chk_i_children
def chk_i_children(old, new, ctx):
for oldch in old.i_children:
chk_child(oldch, new, ctx)
# chk_child removes all old children
for newch in new.i_children:
if statements.is_mandatory_node(newch):
err_add(ctx.errors, newch.pos, 'CHK_NEW_MANDATORY', newch.arg)
开发者ID:BroadbandForum,项目名称:pyang,代码行数:7,代码来源:check_update.py
示例5: chk_children
def chk_children(oldch, newchs, newp, ctx):
newch = None
for ch in newchs:
if ch.arg == oldch.arg:
newch = ch
break
if newch is None:
err_def_removed(oldch, newp, ctx)
return
newchs.remove(newch)
if newch.keyword != oldch.keyword:
err_add(ctx.errors, newch.pos, 'CHK_CHILD_KEYWORD_CHANGED',
(oldch.keyword, newch.arg, newch.keyword))
return
chk_status(oldch, newch, ctx)
chk_if_feature(oldch, newch, ctx)
chk_config(oldch, newch, ctx)
chk_must(oldch, newch, ctx)
chk_when(oldch, newch, ctx)
if newch.keyword == 'leaf':
chk_leaf(oldch, newch, ctx)
elif newch.keyword == 'leaf-list':
chk_leaf_list(oldch, newch, ctx)
elif newch.keyword == 'container':
chk_container(oldch, newch, ctx)
elif newch.keyword == 'list':
chk_list(oldch, newch, ctx)
elif newch.keyword == 'choice':
chk_choice(oldch, newch, ctx)
elif newch.keyword == 'case':
chk_case(oldch, newch, ctx)
elif newch.keyword == 'input':
chk_input_output(oldch, newch, ctx)
elif newch.keyword == 'output':
chk_input_output(oldch, newch, ctx)
开发者ID:BroadbandForum,项目名称:pyang,代码行数:35,代码来源:check_update.py
示例6: v_chk_leaf_mirroring
def v_chk_leaf_mirroring(ctx, statement):
"""
Check that all config leaves are included in the state container
"""
# Skip the check if the container is not a parent of other containers
if statement.search_one('container') is None:
return
containers = statement.search('container')
# Only perform this check if this is a container that has both a config
# and state container
c_config, c_state = None, None
for c in containers:
if c.arg == 'config':
c_config = c
elif c.arg == 'state':
c_state = c
if not None in [c_config, c_state]:
break
if None in [c_config, c_state]:
return
config_elem_names = [i.arg for i in c_config.substmts
if not i.arg == 'config' and
i.keyword in INSTANTIATED_DATA_KEYWORDS]
state_elem_names = [i.arg for i in c_state.substmts
if not i.arg == 'state' and
i.keyword in INSTANTIATED_DATA_KEYWORDS]
for elem in config_elem_names:
if not elem in state_elem_names:
err_add(ctx.errors, statement.parent.pos, 'OC_OPSTATE_APPLIED_CONFIG',
(elem, statements.mk_path_str(statement, False)))
开发者ID:kverma,项目名称:oc-pyang,代码行数:35,代码来源:openconfig.py
示例7: v_chk_recommended_substmt
def v_chk_recommended_substmt(ctx, stmt):
if stmt.keyword in _recommended_substatements:
for r in _recommended_substatements[stmt.keyword]:
if stmt.search_one(r) is None:
err_add(ctx.errors, stmt.pos,
'IETF_MISSING_RECOMMENDED_SUBSTMT',
(stmt.keyword, r))
开发者ID:OpenNetworkingFoundation,项目名称:configuration,代码行数:7,代码来源:ietf.py
示例8: v_chk_required_substmt
def v_chk_required_substmt(ctx, stmt):
if stmt.keyword in _required_substatements:
(required, s) = _required_substatements[stmt.keyword]
for r in required:
if stmt.search_one(r) is None:
err_add(ctx.errors, stmt.pos,
'IETF_MISSING_REQUIRED_SUBSTMT',
(s, stmt.keyword, r))
开发者ID:rponczkowski,项目名称:pyang,代码行数:8,代码来源:ietf.py
示例9: cmp_node
def cmp_node(optr, nptr):
if optr.parent is None:
return
if (optr.i_module.i_modulename == nptr.i_module.i_modulename and
optr.arg == nptr.arg):
return cmp_node(optr.parent, nptr.parent)
else:
err_add(ctx.errors, new.pos, 'CHK_LEAFREF_PATH_CHANGED', ())
开发者ID:BroadbandForum,项目名称:pyang,代码行数:8,代码来源:check_update.py
示例10: chk_decimal64
def chk_decimal64(old, new, oldts, newts, ctx):
oldbasets = get_base_type(oldts)
newbasets = get_base_type(newts)
if newbasets.fraction_digits != oldbasets.fraction_digits:
err_add(ctx.errors, new.pos, 'CHK_DEF_CHANGED',
('fraction-digits', newts.fraction_digits,
oldts.fraction_digits))
# a decimal64 can only be restricted with range
chk_range(old, new, oldts, newts, ctx)
开发者ID:BroadbandForum,项目名称:pyang,代码行数:9,代码来源:check_update.py
示例11: chk_enumeration
def chk_enumeration(old, new, oldts, newts, ctx):
# verify that all old enums are still in new, with the same values
for (name, val) in oldts.enums:
n = util.keysearch(name, 0, newts.enums)
if n is None:
err_add(ctx.errors, new.pos, 'CHK_DEF_REMOVED',
('enum', name, old.pos))
elif n[1] != val:
err_add(ctx.errors, new.pos, 'CHK_ENUM_VALUE_CHANGED',
(name, val, n[1]))
开发者ID:BroadbandForum,项目名称:pyang,代码行数:10,代码来源:check_update.py
示例12: chk_bits
def chk_bits(old, new, oldts, newts, ctx):
# verify that all old bits are still in new, with the same positions
for (name, pos) in oldts.bits:
n = util.keysearch(name, 0, newts.bits)
if n is None:
err_add(ctx.errors, new.pos, 'CHK_DEF_REMOVED',
('bit', name, old.pos))
elif n[1] != pos:
err_add(ctx.errors, new.pos, 'CHK_BIT_POSITION_CHANGED',
(name, pos, n[1]))
开发者ID:BroadbandForum,项目名称:pyang,代码行数:10,代码来源:check_update.py
示例13: chk_range
def chk_range(old, new, oldts, newts, ctx):
ots = old.i_type_spec
nts = new.i_type_spec
if (type(ots) == types.RangeTypeSpec and
type(nts) == types.RangeTypeSpec):
tmperrors = []
types.validate_ranges(tmperrors, new.pos, ots.ranges, new)
if tmperrors != []:
err_add(ctx.errors, new.pos, 'CHK_RESTRICTION_CHANGED',
'range')
开发者ID:Trilliant,项目名称:pyang,代码行数:10,代码来源:check_update.py
示例14: v_chk_module_name
def v_chk_module_name(ctx, stmt, modulename_prefixes):
if modulename_prefixes != []:
for prefix in modulename_prefixes:
if stmt.arg.find(prefix + '-') == 0:
return
err_add(ctx.errors, stmt.pos, 'LINT_BAD_MODULENAME_PREFIX',
(modulename_prefixes[0], stmt.arg))
elif stmt.arg.find('-') == -1:
# can't check much, but we can check that a prefix is used
err_add(ctx.errors, stmt.pos, 'LINT_NO_MODULENAME_PREFIX', ())
开发者ID:ashanker2286,项目名称:pyang,代码行数:10,代码来源:lint.py
示例15: chk_presence
def chk_presence(old, new, ctx):
oldpresence = old.search_one('presence')
newpresence = new.search_one('presence')
if oldpresence is None and newpresence is None:
pass
elif oldpresence is None and newpresence is not None:
err_def_added(newpresence, ctx)
elif oldpresence is not None and newpresence is None:
err_def_removed(oldpresence, new, ctx)
elif oldpresence.arg != newpresence.arg:
err_add(ctx.errors, newpresence.pos, 'CHK_UNDECIDED_PRESENCE', ())
开发者ID:BroadbandForum,项目名称:pyang,代码行数:11,代码来源:check_update.py
示例16: check_top_level_data_definitions
def check_top_level_data_definitions(ctx, stmt):
"""Check that the module has no data elements at the root.
Args:
ctx: pyang.Context for the validation
stmt: pyang.Statement for the matching module
"""
data_definitions = [i.arg for i in stmt.substmts if i.keyword
in INSTANTIATED_DATA_KEYWORDS]
if data_definitions:
err_add(ctx.errors, stmt.pos, "OC_MODULE_DATA_DEFINITIONS",
(stmt.arg, ", ".join(data_definitions)))
开发者ID:openconfig,项目名称:oc-pyang,代码行数:12,代码来源:openconfig.py
示例17: chk_identityref
def chk_identityref(old, new, oldts, newts, ctx):
# verify that the bases are the same
extra = [n for n in newts.idbases]
for oidbase in oldts.idbases:
for nidbase in newts.idbases:
if (nidbase.i_module.i_modulename ==
oidbase.i_module.i_modulename and
nidbase.arg.split(':')[-1] == oidbase.arg.split(':')[-1]):
extra.remove(nidbase)
for n in extra:
err_add(ctx.errors, n.pos, 'CHK_DEF_ADDED',
('base', n.arg))
开发者ID:BroadbandForum,项目名称:pyang,代码行数:12,代码来源:check_update.py
示例18: v_chk_include
def v_chk_include(ctx, stmt):
latest = stmt.i_orig_module.i_latest_revision
if latest is None:
return
submodulename = stmt.arg
r = stmt.search_one("revision-date")
if r is not None:
rev = r.arg
else:
rev = None
subm = ctx.get_module(submodulename, rev)
if subm is not None and subm.i_latest_revision is not None and subm.i_latest_revision > latest:
err_add(ctx.errors, stmt.pos, "LINT_BAD_REVISION", (latest, submodulename, subm.i_latest_revision))
开发者ID:XiuzhongChen,项目名称:pyang,代码行数:13,代码来源:lint.py
示例19: chk_status
def chk_status(old, new, ctx):
oldstatus = old.search_one('status')
newstatus = new.search_one('status')
if oldstatus is None or oldstatus.arg == 'current':
# any new status is ok
return
if newstatus is None:
err_add(ctx.errors, new.pos, 'CHK_INVALID_STATUS',
("(implicit) current", oldstatus.arg))
elif ((newstatus.arg == 'current') or
(oldstatus.arg == 'obsolete' and newstatus.arg != 'obsolete')):
err_add(ctx.errors, newstatus.pos, 'CHK_INVALID_STATUS',
(newstatus.arg, oldstatus.arg))
开发者ID:BroadbandForum,项目名称:pyang,代码行数:13,代码来源:check_update.py
示例20: v_chk_opstate_paths
def v_chk_opstate_paths(ctx, statement):
"""
Check elements for compliance with the opstate structure. Called for leaves
and leaf-lists.
Particularly:
* Skip checks for YANG list keys
* Check that there is a single 'config' and 'state' container in the
path
* Check that elements in a 'config' container are r/w, and 'state' are ro
"""
pathstr = statements.mk_path_str(statement, False)
# print "examining path to %s: %s" % (statement.arg, pathstr)
# leaves that are list keys are exempt from this check. YANG
# requires them at the top level of the list, i.e., not allowed
# in a descendent container
if statement.keyword == 'leaf' and hasattr(statement, 'i_is_key'):
keytype = statement.search_one ('type')
if keytype.arg != 'leafref':
err_add(ctx.errors, statement.pos, 'OC_OPSTATE_KEY_LEAFREF',
statement.arg)
# print "leaf %s is a key, skipping" % statement.arg
return
#path_elements = [c.encode('ascii', 'ignore') for c in yangpath.split_paths(pathstr)]
path_elements = yangpath.split_paths(pathstr)
# count number of 'config' and 'state' elements in the path
confignum = path_elements.count('config')
statenum = path_elements.count('state')
if confignum != 1 and statenum != 1:
err_add(ctx.errors, statement.pos, 'OC_OPSTATE_CONTAINER_COUNT',
(pathstr))
# for elements in a config or state container, make sure they have the
# correct config property
if statement.parent.keyword == 'container':
# print "%s %s in container: %s (%s)" % (statement.keyword, pathstr,
# str(statement.parent.arg), statement.i_config)
if statement.parent.arg == 'config':
if statement.i_config is False:
err_add(ctx.errors, statement.pos, 'OC_OPSTATE_CONFIG_PROPERTY',
(statement.arg, 'config', 'true'))
elif statement.parent.arg == 'state' or statement.parent.arg == 'counters':
if statement.i_config is True:
err_add(ctx.errors, statement.parent.pos, 'OC_OPSTATE_CONFIG_PROPERTY',
(statement.arg, 'state', 'false'))
else:
err_add(ctx.errors, statement.pos, 'OC_OPSTATE_CONTAINER_NAME',
(statement.arg, pathstr))
开发者ID:kverma,项目名称:oc-pyang,代码行数:51,代码来源:openconfig.py
注:本文中的pyang.error.err_add函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论