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


Python error.err_add函数代码示例

本文整理汇总了Python中pyang.error.err_add函数的典型用法代码示例。如果您正苦于以下问题:Python err_add函数的具体用法?Python err_add怎么用?Python err_add使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了err_add函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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