Return curve name matching specified OID, or raise KeyError.
428197
def get_curve_name_by_oid(oid):
    """"""
    for curve_name, info in SUPPORTED_CURVES.items():
        if info['oid'] == oid:
            return curve_name
    raise KeyError('Unknown OID: {!r}'.format(oid))
209681
public static String getName(ObjectIdentifier oid) {
        OIDInfo info = oidMap.get(oid);
        return (info == null) ? null : info.name;
    }
818735
private static JsonWebKeyCurveName getCurveFromKeyPair(KeyPair keyPair, Provider provider) {

        try {
            ECPublicKey key = (ECPublicKey) keyPair.getPublic();
            ECParameterSpec spec = key.getParams();
            EllipticCurve crv = spec.getCurve();

            List<JsonWebKeyCurveName> curveList = Arrays.asList(JsonWebKeyCurveName.P_256, JsonWebKeyCurveName.P_384,
                    JsonWebKeyCurveName.P_521, JsonWebKeyCurveName.P_256K);

            for (JsonWebKeyCurveName curve : curveList) {
                ECGenParameterSpec gps = new ECGenParameterSpec(CURVE_TO_SPEC_NAME.get(curve));
                KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC", provider);
                kpg.initialize(gps);

                // Generate dummy keypair to get parameter spec.
                KeyPair apair = kpg.generateKeyPair();
                ECPublicKey apub = (ECPublicKey) apair.getPublic();
                ECParameterSpec aspec = apub.getParams();
                EllipticCurve acurve = aspec.getCurve();

                // Matches the parameter spec
                if (acurve.equals(crv)) {
                    return curve;
                }
            }

            // Did not find a supported curve.
            throw new NoSuchAlgorithmException("Curve not supported.");
        } catch (GeneralSecurityException e) {
            throw new IllegalStateException(e);
        }
    }
458248
def getLipdNames(D=None):
    
    _names = []
    try:
        if not D:
            print("Error: LiPD data not provided. Pass LiPD data into the function.")
        else:
            _names = D.keys()
    except Exception:
        pass
    return _names
426467
def oid2name(self, oid):
        ""
        if not self._oid_lookup:
            for name, data in self._parameters.items():
                self._oid_lookup[data['OID']] = data['Name']
        return self._oid_lookup[oid]
946430
def get_shape(self, ds_id, ds_info):
        """"""
        var_path = ds_info['file_key']
        shape = self[var_path + '/shape']
        if ((ds_info.get('standard_name') == "longitude" or ds_info.get('standard_name') == "latitude") and
                ds_id.resolution == 10000):
            return shape[0], int(shape[1] / 2)
        return shape
1226150
def convert(self, imtls, idx=0):
        
        curve = numpy.zeros(1, imtls.dt)
        for imt in imtls:
            curve[imt] = self.array[imtls(imt), idx]
        return curve[0]
830185
def origin_id_to_name(self, origin):
        
        try:
            oid = int(origin)
        except (ValueError, TypeError):
            return None

        return self.origins.get(oid)
1193604
def walk_oid(self, oid):
        """"""
        var = netsnmp.Varbind(oid)
        varlist = netsnmp.VarList(var)
        data = self.walk(varlist)
        if len(data) == 0:
            raise SnmpException("SNMP walk response incomplete")
        return varlist
490094
def _key(self, ch):
        """"""

        if ch in self.D:
            return ch

        if isinstance(ch, int):
            raise KeyError(ch)  # dont accept integers as custom names

        if self.chnames:
            for item in self.chnames.items():
                if item[1] == ch:
                    return item[0]
        for item in self.chnames_0.items():
            if item[1] == ch:
                return item[0]

        # If we got here, ch can be an int represented by a string if it comes
        # from a condition string:
        try:
            chint = int(ch)
            if chint in self.D:
                return chint
        except ValueError:
            pass

        raise KeyError(ch)
30944
def _get_nd_basic_indexing(self, key):
        """"""
        shape = self.shape
        if isinstance(key, integer_types):
            if key > shape[0] - 1:
                raise IndexError(
                    'index {} is out of bounds for axis 0 with size {}'.format(
                        key, shape[0]))
            return self._at(key)
        elif isinstance(key, py_slice):
            if key.step is not None and key.step != 1:
                if key.step == 0:
                    raise ValueError("slice step cannot be zero")
                return op.slice(self, begin=(key.start,), end=(key.stop,), step=(key.step,))
            elif key.start is not None or key.stop is not None:
                return self._slice(key.start, key.stop)
            else:
                return self

        if not isinstance(key, tuple):
            raise ValueError('index=%s must be a slice, or an ineger, or a tuple'
                             ' of slices and integers to use basic indexing, received type=%s'
                             % (str(key), str(type(key))))
        assert len(key) != 0, 'basic index cannot be an empty tuple'
        begin = []
        end = []
        step = []
        kept_axes = []  # axes where slice_i is a slice
        i = -1
        for i, slice_i in enumerate(key):
            if isinstance(slice_i, integer_types):
                begin.append(slice_i)
                end.append(slice_i+1 if slice_i != -1 else self.shape[i])
                step.append(1)
            elif isinstance(slice_i, py_slice):
                if slice_i.step == 0:
                    raise ValueError('basic index=%s cannot have slice=%s with step = 0'
                                     % (str(key), str(slice_i)))
                begin.append(slice_i.start)
                end.append(slice_i.stop)
                step.append(slice_i.step)
                kept_axes.append(i)
            else:
                raise ValueError('basic_indexing does not support slicing with '
                                 'index=%s of type=%s.' % (str(slice_i), str(type(slice_i))))
        kept_axes.extend(range(i+1, len(shape)))
        sliced_nd = op.slice(self, begin, end, step)
        if len(kept_axes) == len(shape):
            return sliced_nd
        # squeeze sliced_shape to remove the axes indexed by integers
        oshape = []
        sliced_shape = sliced_nd.shape
        for axis in kept_axes:
            oshape.append(sliced_shape[axis])
        # if key is a tuple of integers, still need to keep 1 dim
        # while in Numpy, the output will become an value instead of an ndarray
        if len(oshape) == 0:
            oshape.append(1)
        oshape = tuple(oshape)
        assert np.prod(oshape) == np.prod(sliced_shape), 'oshape=%s has different size'\
                                                         ' than sliced_shape=%s'\
                                                         % (oshape, sliced_shape)
        return sliced_nd.reshape(oshape)
417992
def safe_filename(self, otype, oid):
        """"""
        permitted = set(['_', '-', '(', ')'])
        oid = ''.join([c for c in oid if c.isalnum() or c in permitted])
        while oid.find('--') != -1:
            oid = oid.replace('--', '-')
        ext = 'json'
        ts = datetime.now().strftime("%Y%m%dT%H%M%S")
        fname = ''
        is_new = False
        while not is_new:
            oid_len = 255 - len('%s--%s.%s' % (otype, ts, ext))
            fname = '%s-%s-%s.%s' % (otype, oid[:oid_len], ts, ext)
            is_new = True
            if os.path.exists(fname):
                is_new = False
                ts += '-bck'
        return fname
534080
def key(self):
        """"""
        if self.curie is None:
            return self.name
        return ":".join((self.curie.name, self.name))
100186
def count_curves(self, keys=None, alias=None):
        
        if keys is None:
            keys = [k for k, v in self.data.items() if isinstance(v, Curve)]
        else:
            keys = utils.flatten_list(keys)

        return len(list(filter(None, [self.get_mnemonic(k, alias=alias) for k in keys])))
628151
def lookup_subclass(cls, d):
        
        try:
            typeid = d["typeid"]
        except KeyError:
            raise FieldError("typeid not present in keys %s" % list(d))

        subclass = cls._subcls_lookup.get(typeid, None)
        if not subclass:
            raise FieldError("'%s' not a valid typeid" % typeid)
        else:
            return subclass
1290677
def create_identity(user_id, curve_name):
    """"""
    result = interface.Identity(identity_str='gpg://', curve_name=curve_name)
    result.identity_dict['host'] = user_id
    return result
119095
def get(self,oid):
		""""""
		try:
			self.lock.acquire()
			if oid not in self.data:
				return "NONE"
			else:
				return self.base_oid + oid + '\n' + self.data[oid]['type'] + '\n' +	str(self.data[oid]['value'])
		finally:
			self.lock.release()