Search is not available for this dataset
text stringlengths 75 104k |
|---|
def reduce(self, func, axis=(0,), keepdims=False):
"""
Reduce an array along an axis.
Applies a commutative/associative function of two
arguments cumulatively to all arrays along an axis.
Array will be aligned so that the desired set of axes
are in the keys, which may in... |
def _stat(self, axis=None, func=None, name=None, keepdims=False):
"""
Compute a statistic over an axis.
Can provide either a function (for use in a reduce)
or a name (for use by a stat counter).
Parameters
----------
axis : tuple or int, optional, default=None
... |
def mean(self, axis=None, keepdims=False):
"""
Return the mean of the array over the given axis.
Parameters
----------
axis : tuple or int, optional, default=None
Axis to compute statistic over, if None
will compute over all axes
keepdims : boole... |
def var(self, axis=None, keepdims=False):
"""
Return the variance of the array over the given axis.
Parameters
----------
axis : tuple or int, optional, default=None
Axis to compute statistic over, if None
will compute over all axes
keepdims : bo... |
def std(self, axis=None, keepdims=False):
"""
Return the standard deviation of the array over the given axis.
Parameters
----------
axis : tuple or int, optional, default=None
Axis to compute statistic over, if None
will compute over all axes
kee... |
def sum(self, axis=None, keepdims=False):
"""
Return the sum of the array over the given axis.
Parameters
----------
axis : tuple or int, optional, default=None
Axis to compute statistic over, if None
will compute over all axes
keepdims : boolean... |
def max(self, axis=None, keepdims=False):
"""
Return the maximum of the array over the given axis.
Parameters
----------
axis : tuple or int, optional, default=None
Axis to compute statistic over, if None
will compute over all axes
keepdims : boo... |
def min(self, axis=None, keepdims=False):
"""
Return the minimum of the array over the given axis.
Parameters
----------
axis : tuple or int, optional, default=None
Axis to compute statistic over, if None
will compute over all axes
keepdims : boo... |
def concatenate(self, arry, axis=0):
"""
Join this array with another array.
Paramters
---------
arry : ndarray, BoltArrayLocal, or BoltArraySpark
Another array to concatenate with
axis : int, optional, default=0
The axis along which arrays will ... |
def _getbasic(self, index):
"""
Basic indexing (for slices or ints).
"""
key_slices = index[0:self.split]
value_slices = index[self.split:]
def key_check(key):
def inrange(k, s):
if s.step > 0:
return s.start <= k < s.stop
... |
def _getadvanced(self, index):
"""
Advanced indexing (for sets, lists, or ndarrays).
"""
index = [asarray(i) for i in index]
shape = index[0].shape
if not all([i.shape == shape for i in index]):
raise ValueError("shape mismatch: indexing arrays could not be br... |
def _getmixed(self, index):
"""
Mixed indexing (combines basic and advanced indexes)
Assumes that only a single advanced index is used, due to the complicated
behavior needed to be compatible with NumPy otherwise.
"""
# find the single advanced index
loc = where(... |
def chunk(self, size="150", axis=None, padding=None):
"""
Chunks records of a distributed array.
Chunking breaks arrays into subarrays, using an specified
size of chunks along each value dimension. Can alternatively
specify an average chunk byte size (in kilobytes) and the size ... |
def swap(self, kaxes, vaxes, size="150"):
"""
Swap axes from keys to values.
This is the core operation underlying shape manipulation
on the Spark bolt array. It exchanges an arbitrary set of axes
between the keys and the valeus. If either is None, will only
move axes in... |
def transpose(self, *axes):
"""
Return an array with the axes transposed.
This operation will incur a swap unless the
desiured permutation can be obtained
only by transpoing the keys or the values.
Parameters
----------
axes : None, tuple of ints, or n i... |
def swapaxes(self, axis1, axis2):
"""
Return the array with two axes interchanged.
Parameters
----------
axis1 : int
The first axis to swap
axis2 : int
The second axis to swap
"""
p = list(range(self.ndim))
p[axis1] = axis... |
def reshape(self, *shape):
"""
Return an array with the same data but a new shape.
Currently only supports reshaping that independently
reshapes the keys, or the values, or both.
Parameters
----------
shape : tuple of ints, or n ints
New shape
... |
def _reshapebasic(self, shape):
"""
Check if the requested reshape can be broken into independant reshapes
on the keys and values. If it can, returns the index in the new shape
separating keys from values, otherwise returns -1
"""
new = tupleize(shape)
old_key_siz... |
def squeeze(self, axis=None):
"""
Remove one or more single-dimensional axes from the array.
Parameters
----------
axis : tuple or int
One or more singleton axes to remove.
"""
if not any([d == 1 for d in self.shape]):
return self
... |
def astype(self, dtype, casting='unsafe'):
"""
Cast the array to a specified type.
Parameters
----------
dtype : str or dtype
Typecode or data-type to cast the array to (see numpy)
"""
rdd = self._rdd.mapValues(lambda v: v.astype(dtype, 'K', casting))... |
def clip(self, min=None, max=None):
"""
Clip values above and below.
Parameters
----------
min : scalar or array-like
Minimum value. If array, will be broadcasted
max : scalar or array-like
Maximum value. If array, will be broadcasted.
""... |
def toarray(self):
"""
Returns the contents as a local array.
Will likely cause memory problems for large objects.
"""
rdd = self._rdd if self._ordered else self._rdd.sortByKey()
x = rdd.values().collect()
return asarray(x).reshape(self.shape) |
def tupleize(arg):
"""
Coerce singletons and lists and ndarrays to tuples.
Parameters
----------
arg : tuple, list, ndarray, or singleton
Item to coerce
"""
if arg is None:
return None
if not isinstance(arg, (tuple, list, ndarray, Iterable)):
return tuple((arg,))... |
def argpack(args):
"""
Coerce a list of arguments to a tuple.
Parameters
----------
args : tuple or nested tuple
Pack arguments into a tuple, converting ((,...),) or (,) -> (,)
"""
if isinstance(args[0], (tuple, list, ndarray)):
return tupleize(args[0])
elif isinstance(a... |
def inshape(shape, axes):
"""
Checks to see if a list of axes are contained within an array shape.
Parameters
----------
shape : tuple[int]
the shape of a BoltArray
axes : tuple[int]
the axes to check against shape
"""
valid = all([(axis < len(shape)) and (axis >= 0) fo... |
def allclose(a, b):
"""
Test that a and b are close and match in shape.
Parameters
----------
a : ndarray
First array to check
b : ndarray
First array to check
"""
from numpy import allclose
return (a.shape == b.shape) and allclose(a, b) |
def listify(lst, dim):
"""
Flatten lists of indices and ensure bounded by a known dim.
Parameters
----------
lst : list
List of integer indices
dim : tuple
Bounds for indices
"""
if not all([l.dtype == int for l in lst]):
raise ValueError("indices must be intege... |
def slicify(slc, dim):
"""
Force a slice to have defined start, stop, and step from a known dim.
Start and stop will always be positive. Step may be negative.
There is an exception where a negative step overflows the stop needs to have
the default value set to -1. This is the only case of a negativ... |
def istransposeable(new, old):
"""
Check to see if a proposed tuple of axes is a valid permutation
of an old set of axes. Checks length, axis repetion, and bounds.
Parameters
----------
new : tuple
tuple of proposed axes
old : tuple
tuple of old axes
"""
new, old =... |
def isreshapeable(new, old):
"""
Check to see if a proposed tuple of axes is a valid reshaping of
the old axes by ensuring that they can be factored.
Parameters
----------
new : tuple
tuple of proposed axes
old : tuple
tuple of old axes
"""
new, old = tupleize(new)... |
def allstack(vals, depth=0):
"""
If an ndarray has been split into multiple chunks by splitting it along
each axis at a number of locations, this function rebuilds the
original array from chunks.
Parameters
----------
vals : nested lists of ndarrays
each level of nesting of the list... |
def iterexpand(arry, extra):
"""
Expand dimensions by iteratively append empty axes.
Parameters
----------
arry : ndarray
The original array
extra : int
The number of empty axes to append
"""
for d in range(arry.ndim, arry.ndim+extra):
arry = expand_dims(arry, a... |
def zip_with_index(rdd):
"""
Alternate version of Spark's zipWithIndex that eagerly returns count.
"""
starts = [0]
if rdd.getNumPartitions() > 1:
nums = rdd.mapPartitions(lambda it: [sum(1 for _ in it)]).collect()
count = sum(nums)
for i in range(len(nums) - 1):
... |
def wrapped(f):
"""
Decorator to append routed docstrings
"""
import inspect
def extract(func):
append = ""
args = inspect.getargspec(func)
for i, a in enumerate(args.args):
if i < (len(args) - len(args.defaults)):
append += str(a) + ", "
... |
def lookup(*args, **kwargs):
"""
Use arguments to route constructor.
Applies a series of checks on arguments to identify constructor,
starting with known keyword arguments, and then applying
constructor-specific checks
"""
if 'mode' in kwargs:
mode = kwargs['mode']
if mode n... |
def reshape(self, *shape):
"""
Reshape just the keys of a BoltArraySpark, returning a
new BoltArraySpark.
Parameters
----------
shape : tuple
New proposed axes.
"""
new = argpack(shape)
old = self.shape
isreshapeable(new, old... |
def transpose(self, *axes):
"""
Transpose just the keys of a BoltArraySpark, returning a
new BoltArraySpark.
Parameters
----------
axes : tuple
New proposed axes.
"""
new = argpack(axes)
old = range(self.ndim)
istransposeable(... |
def reshape(self, *shape):
"""
Reshape just the values of a BoltArraySpark, returning a
new BoltArraySpark.
Parameters
----------
shape : tuple
New proposed axes.
"""
new = argpack(shape)
old = self.shape
isreshapeable(new, o... |
def transpose(self, *axes):
"""
Transpose just the values of a BoltArraySpark, returning a
new BoltArraySpark.
Parameters
----------
axes : tuple
New proposed axes.
"""
new = argpack(axes)
old = range(self.ndim)
istransposeabl... |
def ones(shape, dtype=float64, order='C'):
"""
Create a local bolt array of ones.
Parameters
----------
shape : tuple
Dimensions of the desired array
dtype : data-type, optional, default=float64
The desired data-type for the array. (see numpy)
... |
def zeros(shape, dtype=float64, order='C'):
"""
Create a local bolt array of zeros.
Parameters
----------
shape : tuple
Dimensions of the desired array.
dtype : data-type, optional, default=float64
The desired data-type for the array. (see numpy)... |
def concatenate(arrays, axis=0):
"""
Join a sequence of arrays together.
Parameters
----------
arrays : tuple
A sequence of array-like e.g. (a1, a2, ...)
axis : int, optional, default=0
The axis along which the arrays will be joined.
Ret... |
def plfit_lsq(x,y):
"""
Returns A and B in y=Ax^B
http://mathworld.wolfram.com/LeastSquaresFittingPowerLaw.html
"""
n = len(x)
btop = n * (log(x)*log(y)).sum() - (log(x)).sum()*(log(y)).sum()
bbottom = n*(log(x)**2).sum() - (log(x).sum())**2
b = btop / bbottom
a = ( log(y).sum() - b ... |
def plfit(x,nosmall=False,finite=False):
"""
A Python implementation of the Matlab code http://www.santafe.edu/~aaronc/powerlaws/plfit.m
from http://www.santafe.edu/~aaronc/powerlaws/
See A. Clauset, C.R. Shalizi, and M.E.J. Newman, "Power-law distributions
in empirical data" SIAM Review, to appear... |
def plotcdf(x,xmin,alpha):
"""
Plots CDF and powerlaw
"""
x=sort(x)
n=len(x)
xcdf = arange(n,0,-1,dtype='float')/float(n)
q = x[x>=xmin]
fcdf = (q/xmin)**(1-alpha)
nc = xcdf[argmax(x>=xmin)]
fcdf_norm = nc*fcdf
loglog(x,xcdf)
loglog(q,fcdf_norm) |
def plotpdf(x,xmin,alpha,nbins=30,dolog=False):
"""
Plots PDF and powerlaw....
"""
x=sort(x)
n=len(x)
if dolog:
hb = hist(x,bins=logspace(log10(min(x)),log10(max(x)),nbins),log=True)
alpha += 1
else:
hb = hist(x,bins=linspace((min(x)),(max(x)),nbins))
h,b=hb[0],... |
def plexp(x,xm=1,a=2.5):
"""
CDF(x) for the piecewise distribution exponential x<xmin, powerlaw x>=xmin
This is the CDF version of the distributions drawn in fig 3.4a of Clauset et al.
"""
C = 1/(-xm/(1 - a) - xm/a + math.exp(a)*xm/a)
Ppl = lambda X: 1+C*(xm/(1-a)*(X/xm)**(1-a))
Pexp = lamb... |
def plexp_inv(P,xm,a):
"""
Inverse CDF for a piecewise PDF as defined in eqn. 3.10
of Clauset et al.
"""
C = 1/(-xm/(1 - a) - xm/a + math.exp(a)*xm/a)
Pxm = 1+C*(xm/(1-a))
pp = P
x = xm*(pp-1)*(1-a)/(C*xm)**(1/(1-a)) if pp >= Pxm else (math.log( ((C*xm/a)*math.exp(a)-pp)/(C*xm/a)) - a... |
def alpha_(self,x):
""" Create a mappable function alpha to apply to each xmin in a list of xmins.
This is essentially the slow version of fplfit/cplfit, though I bet it could
be speeded up with a clever use of parellel_map. Not intended to be used by users."""
def alpha(xmin,x=x):
... |
def plfit(self,nosmall=True,finite=False,quiet=False,silent=False,
xmin=None, verbose=False):
"""
A pure-Python implementation of the Matlab code http://www.santafe.edu/~aaronc/powerlaws/plfit.m
from http://www.santafe.edu/~aaronc/powerlaws/
See A. Clauset, C.R. Shalizi, a... |
def alpha_gen(x):
""" Create a mappable function alpha to apply to each xmin in a list of xmins.
This is essentially the slow version of fplfit/cplfit, though I bet it could
be speeded up with a clever use of parellel_map. Not intended to be used by users.
Docstring for the generated alpha function::
... |
def plexp_cdf(x,xmin=1,alpha=2.5, pl_only=False, exp_only=False):
"""
CDF(x) for the piecewise distribution exponential x<xmin, powerlaw x>=xmin
This is the CDF version of the distributions drawn in fig 3.4a of Clauset et al.
The constant "C" normalizes the PDF
"""
x = np.array(x)
C = 1/(-x... |
def plexp_inv(P, xmin, alpha, guess=1.):
"""
Inverse CDF for a piecewise PDF as defined in eqn. 3.10
of Clauset et al.
(previous version was incorrect and lead to weird discontinuities in the
distribution function)
"""
def equation(x,prob):
return plexp_cdf(x, xmin, alpha)-prob
... |
def discrete_likelihood(data, xmin, alpha):
"""
Equation B.8 in Clauset
Given a data set, an xmin value, and an alpha "scaling parameter", computes
the log-likelihood (the value to be maximized)
"""
if not scipyOK:
raise ImportError("Can't import scipy. Need scipy for zeta function.")
... |
def discrete_likelihood_vector(data, xmin, alpharange=(1.5,3.5), n_alpha=201):
"""
Compute the likelihood for all "scaling parameters" in the range (alpharange)
for a given xmin. This is only part of the discrete value likelihood
maximization problem as described in Clauset et al
(Equation B.8)
... |
def discrete_max_likelihood_arg(data, xmin, alpharange=(1.5,3.5), n_alpha=201):
"""
Returns the *argument* of the max of the likelihood of the data given an input xmin
"""
likelihoods = discrete_likelihood_vector(data, xmin, alpharange=alpharange, n_alpha=n_alpha)
Largmax = np.argmax(likelihoods)
... |
def discrete_max_likelihood(data, xmin, alpharange=(1.5,3.5), n_alpha=201):
"""
Returns the *argument* of the max of the likelihood of the data given an input xmin
"""
likelihoods = discrete_likelihood_vector(data, xmin, alpharange=alpharange, n_alpha=n_alpha)
Lmax = np.max(likelihoods)
return L... |
def most_likely_alpha(data, xmin, alpharange=(1.5,3.5), n_alpha=201):
"""
Return the most likely alpha for the data given an xmin
"""
alpha_vector = np.linspace(alpharange[0],alpharange[1],n_alpha)
return alpha_vector[discrete_max_likelihood_arg(data, xmin,
... |
def discrete_alpha_mle(data, xmin):
"""
Equation B.17 of Clauset et al 2009
The Maximum Likelihood Estimator of the "scaling parameter" alpha in the
discrete case is similar to that in the continuous case
"""
# boolean indices of positive data
gexmin = (data>=xmin)
nn = gexmin.sum()
... |
def discrete_best_alpha(data, alpharangemults=(0.9,1.1), n_alpha=201, approximate=True, verbose=True):
"""
Use the maximum L to determine the most likely value of alpha
*alpharangemults* [ 2-tuple ]
Pair of values indicating multiplicative factors above and below the
approximate alpha from ... |
def discrete_ksD(data, xmin, alpha):
"""
given a sorted data set, a minimum, and an alpha, returns the power law ks-test
D value w/data
The returned value is the "D" parameter in the ks test
(this is implemented differently from the continuous version because there
are potentially multiple ide... |
def plfit(self, nosmall=True, finite=False, quiet=False, silent=False,
usefortran=False, usecy=False, xmin=None, verbose=False,
discrete=None, discrete_approx=True, discrete_n_alpha=1000,
skip_consistency_check=False):
"""
A Python implementation of the Matlab c... |
def discrete_best_alpha(self, alpharangemults=(0.9,1.1), n_alpha=201,
approximate=True, verbose=True, finite=True):
"""
Use the maximum likelihood to determine the most likely value of alpha
*alpharangemults* [ 2-tuple ]
Pair of values indicating multipli... |
def xminvsks(self, **kwargs):
"""
Plot xmin versus the ks value for derived alpha. This plot can be used
as a diagnostic of whether you have derived the 'best' fit: if there are
multiple local minima, your data set may be well suited to a broken
powerlaw or a different function.... |
def alphavsks(self,autozoom=True,**kwargs):
"""
Plot alpha versus the ks value for derived alpha. This plot can be used
as a diagnostic of whether you have derived the 'best' fit: if there are
multiple local minima, your data set may be well suited to a broken
powerlaw or a diff... |
def plotcdf(self, x=None, xmin=None, alpha=None, pointcolor='k',
dolog=True, zoom=True, pointmarker='+', **kwargs):
"""
Plots CDF and powerlaw
"""
if x is None: x=self.data
if xmin is None: xmin=self._xmin
if alpha is None: alpha=self._alpha
x=np.... |
def plotpdf(self, x=None, xmin=None, alpha=None, nbins=50, dolog=True,
dnds=False, drawstyle='steps-post', histcolor='k', plcolor='r',
fill=False, dohist=True, **kwargs):
"""
Plots PDF and powerlaw.
kwargs is passed to pylab.hist and pylab.plot
"""
... |
def plotppf(self,x=None,xmin=None,alpha=None,dolog=True,**kwargs):
"""
Plots the power-law-predicted value on the Y-axis against the real
values along the X-axis. Can be used as a diagnostic of the fit
quality.
"""
if not(xmin): xmin=self._xmin
if not(alpha): alp... |
def lognormal(self,doprint=True):
"""
Use the maximum likelihood estimator for a lognormal distribution to
produce the best-fit lognormal parameters
"""
# N = float(self.data.shape[0])
# mu = log(self.data).sum() / N
# sigmasquared = ( ( log(self.data) - mu )**2 )... |
def plot_lognormal_pdf(self,**kwargs):
"""
Plot the fitted lognormal distribution
"""
if not hasattr(self,'lognormal_dist'):
return
normalized_pdf = self.lognormal_dist.pdf(self.data)/self.lognormal_dist.pdf(self.data).max()
minY,maxY = pylab.gca().get_ylim()... |
def plot_lognormal_cdf(self,**kwargs):
"""
Plot the fitted lognormal distribution
"""
if not hasattr(self,'lognormal_dist'):
return
x=np.sort(self.data)
n=len(x)
xcdf = np.arange(n,0,-1,dtype='float')/float(n)
lcdf = self.lognormal_dist.sf(x)
... |
def sanitize_turbo(html, allowed_tags=TURBO_ALLOWED_TAGS, allowed_attrs=TURBO_ALLOWED_ATTRS):
"""Sanitizes HTML, removing not allowed tags and attributes.
:param str|unicode html:
:param list allowed_tags: List of allowed tags.
:param dict allowed_attrs: Dictionary with attributes allowed for tags.
... |
def configure_analytics_yandex(self, ident, params=None):
"""Configure Yandex Metrika analytics counter.
:param str|unicode ident: Metrika counter ID.
:param dict params: Additional params.
"""
params = params or {}
data = {
'type': 'Yandex',
'... |
def tag_list(self, tags):
"""
Generates a list of tags identifying those previously selected.
Returns a list of tuples of the form (<tag name>, <CSS class name>).
Uses the string names rather than the tags themselves in order to work
with tag lists built from forms not fully su... |
def gcd(self, lon1, lat1, lon2, lat2):
"""
Calculate the great circle distance between two points
on the earth (specified in decimal degrees)
"""
# convert decimal degrees to radians
lon1, lat1, lon2, lat2 = map(math.radians, [lon1, lat1, lon2, lat2])
# haversine... |
def hash_md5(self):
"""Calculate md5 fingerprint.
Shamelessly copied from http://stackoverflow.com/questions/6682815/deriving-an-ssh-fingerprint-from-a-public-key-in-python
For specification, see RFC4716, section 4."""
fp_plain = hashlib.md5(self._decoded_key).hexdigest()
retur... |
def hash_sha256(self):
"""Calculate sha256 fingerprint."""
fp_plain = hashlib.sha256(self._decoded_key).digest()
return (b"SHA256:" + base64.b64encode(fp_plain).replace(b"=", b"")).decode("utf-8") |
def hash_sha512(self):
"""Calculates sha512 fingerprint."""
fp_plain = hashlib.sha512(self._decoded_key).digest()
return (b"SHA512:" + base64.b64encode(fp_plain).replace(b"=", b"")).decode("utf-8") |
def _unpack_by_int(self, data, current_position):
"""Returns a tuple with (location of next data field, contents of requested data field)."""
# Unpack length of data field
try:
requested_data_length = struct.unpack('>I', data[current_position:current_position + self.INT_LEN])[0]
... |
def _parse_long(cls, data):
"""Calculate two's complement."""
if sys.version < '3':
# this does not exist in python 3 - undefined-variable disabled to make pylint happier.
ret = long(0) # pylint:disable=undefined-variable
for byte in data:
ret = (ret ... |
def decode_key(cls, pubkey_content):
"""Decode base64 coded part of the key."""
try:
decoded_key = base64.b64decode(pubkey_content.encode("ascii"))
except (TypeError, binascii.Error):
raise MalformedDataError("Unable to decode the key")
return decoded_key |
def parse_options(self, options):
"""Parses ssh options string."""
quote_open = False
parsed_options = {}
def parse_add_single_option(opt):
"""Parses and validates a single option, and adds it to parsed_options field."""
if "=" in opt:
opt_name, o... |
def _process_ssh_rsa(self, data):
"""Parses ssh-rsa public keys."""
current_position, raw_e = self._unpack_by_int(data, 0)
current_position, raw_n = self._unpack_by_int(data, current_position)
unpacked_e = self._parse_long(raw_e)
unpacked_n = self._parse_long(raw_n)
sel... |
def _process_ssh_dss(self, data):
"""Parses ssh-dsa public keys."""
data_fields = {}
current_position = 0
for item in ("p", "q", "g", "y"):
current_position, value = self._unpack_by_int(data, current_position)
data_fields[item] = self._parse_long(value)
q... |
def _process_ecdsa_sha(self, data):
"""Parses ecdsa-sha public keys."""
current_position, curve_information = self._unpack_by_int(data, 0)
if curve_information not in self.ECDSA_CURVE_DATA:
raise NotImplementedError("Invalid curve type: %s" % curve_information)
curve, hash_al... |
def _process_ed25516(self, data):
"""Parses ed25516 keys.
There is no (apparent) way to validate ed25519 keys. This only
checks data length (256 bits), but does not try to validate
the key in any way."""
current_position, verifying_key = self._unpack_by_int(data, 0)
ver... |
def parse(self, keydata=None):
"""Validates SSH public key.
Throws exception for invalid keys. Otherwise returns None.
Populates key_type, bits and bits fields.
For rsa keys, see field "rsa" for raw public key data.
For dsa keys, see field "dsa".
For ecdsa keys, see fi... |
def status_list(maj_status, min_status, status_type=C.GSS_C_GSS_CODE, mech_type=C.GSS_C_NO_OID):
"""
Creates a "friendly" error message from a GSS status code. This is used to create the
:attr:`GSSCException.message` of a :class:`GSSCException`.
:param maj_status: The major status reported by the C GSS... |
def canonicalize(self, mech):
"""
Create a canonical mechanism name (MechName) from an arbitrary internal name. The canonical
MechName would be set as the :attr:`~gssapi.ctx.AcceptContext.peer_name` property on an
acceptor's :class:`~gssapi.ctx.AcceptContext` if an initiator performed a ... |
def export(self):
"""
Returns a representation of the Mechanism Name which is suitable for direct string
comparison against other exported Mechanism Names. Its form is defined in the GSSAPI
specification (RFC 2743). It can also be re-imported by constructing a :class:`Name` with
... |
def integrity_negotiated(self):
"""
After :meth:`step` has been called, this property will be set to
True if integrity protection (signing) has been negotiated in this context, False
otherwise. If this property is True, you can use :meth:`get_mic` to sign messages with a
message ... |
def confidentiality_negotiated(self):
"""
After :meth:`step` has been called, this property will be set to
True if confidentiality (encryption) has been negotiated in this context, False otherwise.
If this property is True, you can use :meth:`wrap` with the `conf_req` param set to True t... |
def replay_detection_negotiated(self):
"""
After :meth:`step` has been called, this property will be set to
True if the security context can use replay detection for messages protected by
:meth:`get_mic` and :meth:`wrap`. False if replay detection cannot be used.
"""
retu... |
def sequence_detection_negotiated(self):
"""
After :meth:`step` has been called, this property will be set to
True if the security context can use out-of-sequence message detection for messages
protected by :meth:`get_mic` and :meth:`wrap`. False if OOS detection cannot be used.
... |
def get_mic(self, message, qop_req=C.GSS_C_QOP_DEFAULT):
"""
Calculates a cryptographic message integrity code (MIC) over an application message, and
returns that MIC in a token. This is in contrast to :meth:`wrap` which calculates a MIC
over a message, optionally encrypts it and returns... |
def verify_mic(self, message, mic, supplementary=False):
"""
Takes a message integrity code (MIC) that has been generated by the peer application for a
given message, and verifies it against a message, using this security context's
cryptographic keys.
The `supplementary` paramet... |
def wrap(self, message, conf_req=True, qop_req=C.GSS_C_QOP_DEFAULT):
"""
Wraps a message with a message integrity code, and if `conf_req` is True, encrypts the
message. The message can be decrypted and the MIC verified by the peer by passing the
token returned from this method to :meth:`... |
def unwrap(self, message, conf_req=True, qop_req=None, supplementary=False):
"""
Takes a token that has been generated by the peer application with :meth:`wrap`, verifies
and optionally decrypts it, using this security context's cryptographic keys.
The `supplementary` parameter determin... |
def get_wrap_size_limit(self, output_size, conf_req=True, qop_req=C.GSS_C_QOP_DEFAULT):
"""
Calculates the maximum size of message that can be fed to :meth:`wrap` so that the size of
the resulting wrapped token (message plus wrapping overhead) is no more than a given
maximum output size.... |
def process_context_token(self, context_token):
"""
Provides a way to pass an asynchronous token to the security context, outside of the normal
context-establishment token passing flow. This method is not normally used, but some
example uses are:
* when the initiator's context i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.