Returns chunk signature calculated using given arguments.
773913
public static String getChunkSignature(String chunkSha256, DateTime date, String region, String secretKey,
                                         String prevSignature)
    throws NoSuchAlgorithmException, InvalidKeyException {
    Signer signer = new Signer(null, chunkSha256, date, region, null, secretKey, prevSignature);
    signer.setScope();
    signer.setChunkStringToSign();
    signer.setSigningKey();
    signer.setSignature();

    return signer.signature;
  }
1105684
def _build_signature(self, run_args):
    """"""
    return (id(run_args.fct), run_args.input.dtype, run_args.input.shape)
661202
def _signature(self, cmd):
        '''
        
        '''
        result = {}

        client = cmd.get('client', 'minion')
        if client == 'minion':
            cmd['fun'] = 'sys.argspec'
            cmd['kwarg'] = dict(module=cmd['module'])
            result = self.run(cmd)
        elif client == 'master':
            parts = cmd['module'].split('.')
            client = parts[0]
            module = '.'.join(parts[1:])  # strip prefix
            if client == 'wheel':
                functions = self.wheelClient.functions
            elif client == 'runner':
                functions = self.runnerClient.functions
            result = {'master': salt.utils.args.argspec_report(functions, module)}
        return result
320584
def str2actfunc(act_func):
    """"""
    if act_func == 'sigmoid':
        return tf.nn.sigmoid

    elif act_func == 'tanh':
        return tf.nn.tanh

    elif act_func == 'relu':
        return tf.nn.relu
1111579
def get_chunk_path_from_string(string, chunk=3):
    """"""
    return os.path.join(
        *list(generate_chunks(
            string,
            chunk
        ))
    )
1048218
def _get_md5sum(self, fpath):
        """"""
        try:
            current_md5 = hashlib.md5()
            if isinstance(fpath, six.string_types) and os.path.exists(fpath):
                with open(fpath, "rb") as fh:
                    for chunk in self._read_chunks(fh):
                        current_md5.update(chunk)

            elif (fpath.__class__.__name__ in ["StringIO", "StringO"] or
                  isinstance(fpath, IOBase)):
                for chunk in self._read_chunks(fpath):
                    current_md5.update(chunk)
            else:
                return ""
            return current_md5.hexdigest()
        except Exception:
            msg = ("Failed to calculate the image's md5sum")
            LOG.error(msg)
            raise exception.SDKImageOperationError(rs=3)
592453
def getargsfromtext(text, objname):
    """"""
    signature = getsignaturefromtext(text, objname)
    if signature:
        argtxt = signature[signature.find('(')+1:-1]
        return argtxt.split(',')
265693
def write_chunks(out, chunks):
    """"""
    out.write(png_signature)
    for chunk in chunks:
        write_chunk(out, *chunk)
225844
def write_chunks(out, chunks):
    """"""

    out.write(_signature)
    for chunk in chunks:
        write_chunk(out, *chunk)
463945
def get_args(method_or_func):
    """"""
    try:
        # Python 3.0+
        args = list(inspect.signature(method_or_func).parameters.keys())
    except AttributeError:
        # Python 2.7
        args = inspect.getargspec(method_or_func).args
    return args
116638
def _compute_signature(parameters, access_key_secret, method, path):
    '''
    
    '''
    parameters['signature_method'] = 'HmacSHA256'

    string_to_sign = '{0}\n{1}\n'.format(method.upper(), path)

    keys = sorted(parameters.keys())
    pairs = []
    for key in keys:
        val = six.text_type(parameters[key]).encode('utf-8')
        pairs.append(_quote(key, safe='') + '=' + _quote(val, safe='-_~'))
    qs = '&'.join(pairs)
    string_to_sign += qs

    h = hmac.new(access_key_secret, digestmod=sha256)
    h.update(string_to_sign)

    signature = base64.b64encode(h.digest()).strip()

    return signature
715883
def nchunks_initialized(self):
        """"""

        # key pattern for chunk keys
        prog = re.compile(r'\.'.join([r'\d+'] * min(1, self.ndim)))

        # count chunk keys
        return sum(1 for k in listdir(self.chunk_store, self._path) if prog.match(k))
1226650
def compute(self):
        """"""
        if "Signature" in self.params:
            raise RuntimeError("Existing signature in parameters")
        if self.signature_version is not None:
            version = self.signature_version
        else:
            version = self.params["SignatureVersion"]
        if str(version) == "1":
            bytes = self.old_signing_text()
            hash_type = "sha1"
        elif str(version) == "2":
            bytes = self.signing_text()
            if self.signature_method is not None:
                signature_method = self.signature_method
            else:
                signature_method = self.params["SignatureMethod"]
            hash_type = signature_method[len("Hmac"):].lower()
        else:
            raise RuntimeError("Unsupported SignatureVersion: '%s'" % version)
        return self.creds.sign(bytes, hash_type)
362417
def signature(self):
        """"""
        if self.usage is not None:
            return self.usage


        params = self.clean_params
        if not params:
            return ''

        result = []
        for name, param in params.items():
            greedy = isinstance(param.annotation, converters._Greedy)

            if param.default is not param.empty:
                # We don't want None or '' to trigger the [name=value] case and instead it should
                # do [name] since [name=None] or [name=] are not exactly useful for the user.
                should_print = param.default if isinstance(param.default, str) else param.default is not None
                if should_print:
                    result.append('[%s=%s]' % (name, param.default) if not greedy else
                                  '[%s=%s]...' % (name, param.default))
                    continue
                else:
                    result.append('[%s]' % name)

            elif param.kind == param.VAR_POSITIONAL:
                result.append('[%s...]' % name)
            elif greedy:
                result.append('[%s]...' % name)
            elif self._is_typing_optional(param.annotation):
                result.append('[%s]' % name)
            else:
                result.append('<%s>' % name)

        return ' '.join(result)
759206
def _function_signature(func):
    
    if sys.version_info.major > 2:
        # Python 3 already implements this functionality
        return func.__name__ + str(inspect.signature(func))

    # In Python 2 we have to do it manually, unfortunately
    spec = inspect.getargspec(func)
    posargs = spec.args
    defaults = spec.defaults if spec.defaults is not None else []
    varargs = spec.varargs
    kwargs = spec.keywords
    deflen = 0 if defaults is None else len(defaults)
    nodeflen = 0 if posargs is None else len(posargs) - deflen

    args = ['{}'.format(arg) for arg in posargs[:nodeflen]]
    args.extend('{}={}'.format(arg, dval)
                for arg, dval in zip(posargs[nodeflen:], defaults))
    if varargs:
        args.append('*{}'.format(varargs))
    if kwargs:
        args.append('**{}'.format(kwargs))

    argstr = ', '.join(args)

    return '{}({})'.format(func.__name__, argstr)
1279320
def chunked(l, n):
    """"""
    return [l[i:i + n] for i in range(0, len(l), n)]
386195
def get_chunk(self, chunk_id):
        
        if chunk_id in self.idx:
            return Cchunk(self.idx[chunk_id], self.type)
        else:
            return None