查询商品信息

        详情请参考
        http://mp.weixin.qq.com/wiki/15/7fa787701295b884410b5163e13313af.html

        :param standard: 商品编码标准
        :param key: 商品编码内容
        :return: 返回的 JSON 数据包
175121
def get_product(self, standard, key):
        
        data = {
            'keystandard': standard,
            'keystr': key,
        }
        return self._post('product/get', data=data)
625003
def _get_code(self, key):
        

        data = self.grid.code_array(key)
        self.grid.code_array.result_cache.clear()

        return data
370346
def key(self, user="", areq=None):
        
        csum = hashlib.new('sha224')
        csum.update(rndstr(32).encode('utf-8'))
        return csum.hexdigest()
24548
def ssh_keys(self):
        
        params = {}
        json = self.request('/ssh_keys', method='GET', params=params)
        status = json.get('status')
        if status == 'OK':
            ssh_keys_json = json.get('ssh_keys', [])
            keys = [SSHKey.from_json(ssh_key) for ssh_key in ssh_keys_json]
            return keys
        else:
            message = json.get('message')
            raise DOPException('[%s]: %s' % (status, message))
951460
def _get(self, q, params=''):
        ''''''
        if (q[-1] == '/'): q = q[:-1]
        headers = {'Content-Type': 'application/json'}
        r = requests.get('{url}{q}?api_key={key}{params}'.format(url=self.url, q=q, key=self.api_key, params=params),
                        headers=headers)
        ret = DotDict(r.json())
        if (not r.ok or ('error' in ret and ret.error == True)):
            raise Exception(r.url, r.reason, r.status_code, r.json())
        return DotDict(r.json())
72742
def getsshkeys(self):
        
        request = requests.get(
            self.keys_url, headers=self.headers, verify=self.verify_ssl, auth=self.auth, timeout=self.timeout)

        if request.status_code == 200:
            return request.json()
        else:
            return False
243018
def valid_api_key(ctx, param, value):
    
    if value is not None and len(value) != 32:
        raise click.BadParameter(
            "API Key must be 32 characters long, not {}".format(str(len(value)))
        )
    else:
        return value
269047
function (key, base) {                                                                            // 477
  if ((typeof key) === "number" || key.match(/^[0-9]+$/))                                                            // 478
    key = "[" + key + "]";                                                                                           // 479
  else if (!key.match(/^[a-z_$][0-9a-z_$]*$/i) || _.contains(_jsKeywords, key))                                      // 480
    key = JSON.stringify([key]);                                                                                     // 481
                                                                                                                     // 482
  if (base && base[0] !== "[")                                                                                       // 483
    return key + '.' + base;                                                                                         // 484
  return key + base;                                                                                                 // 485
}
668466
def key(self, id_num):
        
        json = None
        if int(id_num) > 0:
            url = self._build_url('keys', str(id_num), base_url=self._api)
            json = self._json(self._get(url), 200)
        return Key(json, self) if json else None
1094066
def _json(self, response):
        
        if response.status_code == 204:
            return None
        try:
            return response.json()
        except ValueError as e:
            raise ValueError(
                'Exception: %s\n'
                'request: %s, response code: %s, response: %s' % (
                    str(e), response.request.url, response.status_code,
                    response.content,
                )
            )
943005
def hget(self, key):
        
        data = self.r.hget(self.hash, key)
        if data is not None and not isinstance(data, str):
            data = str(self.r.hget(self.hash, key), 'utf-8')
        return data
25977
def json(self, **kwargs):
        

        if not self.encoding and len(self.content) > 3:
            # No encoding set. JSON RFC 4627 section 3 states we should expect
            # UTF-8, -16 or -32. Detect which one to use; If the detection or
            # decoding fails, fall back to `self.text` (using chardet to make
            # a best guess).
            encoding = guess_json_utf(self.content)
            if encoding is not None:
                try:
                    return json.loads(self.content.decode(encoding), **kwargs)
                except UnicodeDecodeError:
                    # Wrong UTF codec detected; usually because it's not UTF-8
                    # but some other 8-bit codec.  This is an RFC violation,
                    # and the server didn't bother to tell us what codec *was*
                    # used.
                    pass
        return json.loads(self.text, **kwargs)
1190601
private String getJsonKey(String key) {
		String jsonKey = key;
		if (addQuoteToKey) {
			jsonKey = JavascriptStringUtil.quote(key);
		}
		return jsonKey;
	}
1070019
def get_boulder_header(key_bytes):
    
    pub_hex, pub_exp = re.search(
        r"modulus:\n\s+00:([a-f0-9\:\s]+?)\npublicExponent: ([0-9]+)",
        key_bytes.decode('utf8'), re.MULTILINE | re.DOTALL).groups()
    pub_exp = "{0:x}".format(int(pub_exp))
    pub_exp = "0{0}".format(pub_exp) if len(pub_exp) % 2 else pub_exp
    header = {
        "alg": "RS256",
        "jwk": {
            "e": _b64(binascii.unhexlify(pub_exp.encode("utf-8"))),
            "kty": "RSA",
            "n": _b64(binascii.unhexlify(re.sub(r"(\s|:)", "", pub_hex).encode("utf-8"))),
        },
    }

    return header
400976
def json(self, args=None):
        
        names = ['identifier', 'abstract', 'keywords']
        out = {key: getattr(self, key) for key in names}
        out.update(self.cf_attrs)
        out = self.format(out, args)

        out['notes'] = self.notes

        out['parameters'] = str({key: {'default': p.default if p.default != p.empty else None, 'desc': ''}
                                 for (key, p) in self._sig.parameters.items()})

        if six.PY2:
            out = walk_map(out, lambda x: x.decode('utf8') if isinstance(x, six.string_types) else x)

        return out
905650
function Sign(key) {
    var self = this;

    /** default encoding to use in all string operations */
    self.defaultEncoding = undefined;

    if( key instanceof SignKey) {
        self.iKey = key;
    }
    else {
        /** Set of keys used to encrypt and decrypt messages */
        self.iKey = new SignKey();
    }

    /** Size of the generated message signature */
    self.bytes = function() {
        return binding.crypto_sign_BYTES;
    };

    /** String name of the default crypto primitive used in sign operations */
    self.primitive = function() {
        return binding.crypto_sign_PRIMITIVE;
    };

    /**
     * Get the keypair object
     * @returns {SignKey|*}
     */
    self.key = function() {
        return self.iKey;
    };

    /**
     * @return {Number} The size of the message signature
     */
    self.size = function() {
        return binding.crypto_sign_BYTES;
    };

    /**
     * Set the default encoding to use in all string conversions
     * @param {String} encoding  encoding to use
     */
    self.setEncoding = function(encoding) {
        assert(!!encoding.match(/^(?:utf8|ascii|binary|hex|utf16le|ucs2|base64)$/), 'Encoding ' + encoding + ' is currently unsupported.');
        self.defaultEncoding = encoding;
    };

    /**
     * Get the current default encoding
     * @returns {undefined|String}
     */
    self.getEncoding = function() {
        return self.defaultEncoding;
    };

    /**
     * Digitally sign message
     *
     * @param {Buffer|String|Array} message  message to sign
     * @param {String} [encoding]             encoding of message string
     *
     * @returns {Object}                       cipher box
     */
    self.sign = function (message, encoding) {
        encoding = String(encoding) || self.defaultEncoding || 'utf8';

        var buf = toBuffer(message, encoding);

        var signature = binding.crypto_sign(buf, self.iKey.sk().get());
        if( !signature ) {
            return undefined;
        }

        return {
            sign: signature,
            publicKey: self.iKey.pk().get()
        };
    };

    /**
     * Digitally sign message, using detached signature
     *
     * @param {Buffer|String|Array} message  message to sign
     * @param {String} [encoding]            encoding of message string
     *
     * @returns {Object} cipher box
     */
    self.signDetached = function (message, encoding) {
        encoding = String(encoding) || self.defaultEncoding || 'utf8';

        var buf = toBuffer(message, encoding);

        var signature = binding.crypto_sign_detached(buf, self.iKey.sk().get());
        if( !signature ) {
            return undefined;
        }

        return {
            sign: signature,
            publicKey: self.iKey.pk().get()
        };
    };
}
473627
async def _get(self, key: Text) -> Dict[Text, Any]:
        

        try:
            with await self.pool as r:
                return ujson.loads(await r.get(self.register_key(key)))
        except (ValueError, TypeError):
            return {}