View a single prefix.
198704
def view_prefix(arg, opts, shell_opts):
    
    # Internally, this function searches in the prefix column which means that
    # hosts have a prefix length of 32/128 while they are normally displayed
    # with the prefix length of the network they are in. To allow the user to
    # input either, e.g. 1.0.0.1 or 1.0.0.1/31 we strip the prefix length bits
    # to assume /32 if the address is not a network address. If it is the
    # network address we always search using the specified mask. In certain
    # cases there is a host with the network address, typically when /31 or /127
    # prefix lengths are used, for example 1.0.0.0/31 and 1.0.0.0/32 (first host
    # in /31 network) in which case it becomes necessary to distinguish between
    # the two using the mask.
    try:
        # this fails if bits are set on right side of mask
        ip = IPy.IP(arg)
    except ValueError:
        arg = arg.split('/')[0]

    q = { 'prefix': arg }

    v = get_vrf(opts.get('vrf_rt'), abort=True)
    if v.rt != 'all':
        q['vrf_rt'] = v.rt

    res = Prefix.list(q)

    if len(res) == 0:
        vrf_text = 'any VRF'
        if v.rt != 'all':
            vrf_text = vrf_format(v)
        print("Address %s not found in %s." % (arg, vrf_text), file=sys.stderr)
        sys.exit(1)

    p = res[0]
    vrf = p.vrf.rt

    print("-- Address ")
    print("  %-26s : %s" % ("Prefix", p.prefix))
    print("  %-26s : %s" % ("Display prefix", p.display_prefix))
    print("  %-26s : %s" % ("Type", p.type))
    print("  %-26s : %s" % ("Status", p.status))
    print("  %-26s : IPv%s" % ("Family", p.family))
    print("  %-26s : %s" % ("VRF", vrf))
    print("  %-26s : %s" % ("Description", p.description))
    print("  %-26s : %s" % ("Node", p.node))
    print("  %-26s : %s" % ("Country", p.country))
    print("  %-26s : %s" % ("Order", p.order_id))
    print("  %-26s : %s" % ("Customer", p.customer_id))
    print("  %-26s : %s" % ("VLAN", p.vlan))
    print("  %-26s : %s" % ("Alarm priority", p.alarm_priority))
    print("  %-26s : %s" % ("Monitor", p.monitor))
    print("  %-26s : %s" % ("Added", p.added))
    print("  %-26s : %s" % ("Last modified", p.last_modified))
    print("  %-26s : %s" % ("Expires", p.expires or '-'))
    if p.family == 4:
        print("  %-26s : %s / %s (%.2f%% of %s)" % ("Addresses Used / Free", p.used_addresses,
                p.free_addresses, (float(p.used_addresses)/p.total_addresses)*100,
                p.total_addresses))
    else:
        print("  %-26s : %.4e / %.4e (%.2f%% of %.4e)" % ("Addresses Used / Free", p.used_addresses,
                p.free_addresses, (float(p.used_addresses)/p.total_addresses)*100,
                p.total_addresses))
    print("-- Extra Attributes")
    if p.avps is not None:
        for key in sorted(p.avps, key=lambda s: s.lower()):
            print("  %-26s : %s" % (key, p.avps[key]))
    print("-- Tags")
    for tag_name in sorted(p.tags, key=lambda s: s.lower()):
        print("  %s" % tag_name)
    print("-- Inherited Tags")
    for tag_name in sorted(p.inherited_tags, key=lambda s: s.lower()):
        print("  %s" % tag_name)
    print("-- Comment")
    print(p.comment or '')
1190772
def _remove_prefix(name):
    """"""
    if isinstance(name, str):
        return _do_remove_prefix(name)
    return [_do_remove_prefix(nm) for nm in name]
611502
def index(self, prefix):
        
        # Any web domain will be handled by the standard URLField.
        if self.is_external_url_prefix(prefix):
            prefix = 'http'

        for i, urltype in enumerate(self._url_types):
            if urltype.prefix == prefix:
                return i
        return None
1238407
def delete_prefix(self, key_prefix):
        """"""
        return self.delete(
            key_prefix, range_end=_encode(_increment_last_byte(key_prefix)))
1190993
def prefix(prefix):
    

    d = {}
    e = lower_dict(environ.copy())

    prefix = prefix.lower()

    for k, v in e.items():
        try:
            if k.startswith(prefix):
                k = k[len(prefix):]
                d[k] = v
        except AttributeError:
            pass

    return d
569223
def get_same_indent_prefix(lines):
    
    if not lines:
        return ""
    prefix = get_indent_prefix(lines[0])
    if not prefix:
        return ""
    if all([l.startswith(prefix) for l in lines]):
        return prefix
    return None
180437
def with_prefix(self, root_path):
        """"""
        return Conflict(self.conflict_type, root_path + self.path, self.body)
382868
def prefix_fragment(self, nid):
        
        sep=':'
        if nid.startswith('http'):
            if '#' in nid:
               sep='#'
            else:
                sep='/'
        parts = nid.split(sep)
        frag = parts.pop()
        prefix = sep.join(parts)
        return prefix, frag
188602
def namespaced_view_name(view_name, metric_prefix):
    
    metric_prefix = metric_prefix or "custom.googleapis.com/opencensus"
    return os.path.join(metric_prefix, view_name).replace('\\', '/')
294656
def get_stripped_prefix(source, prefix):
    
    cut = len(prefix)
    return {
        k[cut:]: v for k, v in source.items()
        if k.startswith(prefix)
    }
800520
def get_prefix(self, key_prefix, sort_order=None, sort_target=None):
        
        return self.get(key_prefix,
                        metadata=True,
                        range_end=_encode(_increment_last_byte(key_prefix)),
                        sort_order=sort_order,
                        sort_target=sort_target)
952063
String prefix(String s) {
         return prefix(s, feedback.getPre(), feedback.getPost());
    }
798605
function (value, prefix) {
        return angular.isString(value)  &&
          angular.isString(prefix) &&
          value.lastIndexOf(prefix, 0) === 0;
      }
1020175
public String lookupNamespace(String prefix)
    {
        String uri = null;
        final Stack stack = getPrefixStack(prefix);
        if (stack != null && !stack.isEmpty()) {
            uri = ((MappingRecord) stack.peek()).m_uri;
        }
        if (uri == null)
            uri = EMPTYSTRING;
        return uri;
    }
162698
function () {
        var prefix = 'INFO';
        this.output(prefix, prefix.green, Array.prototype.slice.call(arguments));
    }
147902
def _common_prefix(names):
    """"""
    if not names:
        return ''
    prefix = names[0]
    for name in names:
        i = 0
        while i < len(prefix) and i < len(name) and prefix[i] == name[i]:
            i += 1
        prefix = prefix[:i]
    return prefix
438529
def _remove_builtin_prefix(name):
    """"""
    if name.startswith('builtins.'):
        return name[len('builtins.'):]
    elif name.startswith('__builtin__.'):
        return name[len('__builtin__.'):]
    return name