repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_documentation_string stringlengths 1 47.2k | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|
sods/paramz | paramz/core/indexable.py | Indexable._offset_for | def _offset_for(self, param):
"""
Return the offset of the param inside this parameterized object.
This does not need to account for shaped parameters, as it
basically just sums up the parameter sizes which come before param.
"""
if param.has_parent():
p = par... | python | def _offset_for(self, param):
"""
Return the offset of the param inside this parameterized object.
This does not need to account for shaped parameters, as it
basically just sums up the parameter sizes which come before param.
"""
if param.has_parent():
p = par... | Return the offset of the param inside this parameterized object.
This does not need to account for shaped parameters, as it
basically just sums up the parameter sizes which come before param. | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/indexable.py#L130-L141 |
sods/paramz | paramz/core/indexable.py | Indexable._raveled_index_for | def _raveled_index_for(self, param):
"""
get the raveled index for a param
that is an int array, containing the indexes for the flattened
param inside this parameterized logic.
!Warning! be sure to call this method on the highest parent of a hierarchy,
as it uses the fix... | python | def _raveled_index_for(self, param):
"""
get the raveled index for a param
that is an int array, containing the indexes for the flattened
param inside this parameterized logic.
!Warning! be sure to call this method on the highest parent of a hierarchy,
as it uses the fix... | get the raveled index for a param
that is an int array, containing the indexes for the flattened
param inside this parameterized logic.
!Warning! be sure to call this method on the highest parent of a hierarchy,
as it uses the fixes to do its work | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/indexable.py#L150-L162 |
sods/paramz | paramz/core/indexable.py | Indexable._raveled_index_for_transformed | def _raveled_index_for_transformed(self, param):
"""
get the raveled index for a param for the transformed parameter array
(optimizer array).
that is an int array, containing the indexes for the flattened
param inside this parameterized logic.
!Warning! be sure to call ... | python | def _raveled_index_for_transformed(self, param):
"""
get the raveled index for a param for the transformed parameter array
(optimizer array).
that is an int array, containing the indexes for the flattened
param inside this parameterized logic.
!Warning! be sure to call ... | get the raveled index for a param for the transformed parameter array
(optimizer array).
that is an int array, containing the indexes for the flattened
param inside this parameterized logic.
!Warning! be sure to call this method on the highest parent of a hierarchy,
as it uses ... | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/indexable.py#L164-L184 |
sods/paramz | paramz/core/indexable.py | Indexable._parent_changed | def _parent_changed(self, parent):
"""
From Parentable:
Called when the parent changed
update the constraints and priors view, so that
constraining is automized for the parent.
"""
from .index_operations import ParameterIndexOperationsView
#if getattr(sel... | python | def _parent_changed(self, parent):
"""
From Parentable:
Called when the parent changed
update the constraints and priors view, so that
constraining is automized for the parent.
"""
from .index_operations import ParameterIndexOperationsView
#if getattr(sel... | From Parentable:
Called when the parent changed
update the constraints and priors view, so that
constraining is automized for the parent. | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/indexable.py#L220-L239 |
sods/paramz | paramz/core/indexable.py | Indexable._add_to_index_operations | def _add_to_index_operations(self, which, reconstrained, what, warning):
"""
Helper preventing copy code.
This adds the given what (transformation, prior etc) to parameter index operations which.
reconstrained are reconstrained indices.
warn when reconstraining parameters if warn... | python | def _add_to_index_operations(self, which, reconstrained, what, warning):
"""
Helper preventing copy code.
This adds the given what (transformation, prior etc) to parameter index operations which.
reconstrained are reconstrained indices.
warn when reconstraining parameters if warn... | Helper preventing copy code.
This adds the given what (transformation, prior etc) to parameter index operations which.
reconstrained are reconstrained indices.
warn when reconstraining parameters if warning is True.
TODO: find out which parameters have changed specifically | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/indexable.py#L241-L254 |
sods/paramz | paramz/core/indexable.py | Indexable._remove_from_index_operations | def _remove_from_index_operations(self, which, transforms):
"""
Helper preventing copy code.
Remove given what (transform prior etc) from which param index ops.
"""
if len(transforms) == 0:
transforms = which.properties()
removed = np.empty((0,), dtype=int)
... | python | def _remove_from_index_operations(self, which, transforms):
"""
Helper preventing copy code.
Remove given what (transform prior etc) from which param index ops.
"""
if len(transforms) == 0:
transforms = which.properties()
removed = np.empty((0,), dtype=int)
... | Helper preventing copy code.
Remove given what (transform prior etc) from which param index ops. | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/indexable.py#L256-L270 |
sods/paramz | paramz/core/observable_array.py | ObsAr.copy | def copy(self):
"""
Make a copy. This means, we delete all observers and return a copy of this
array. It will still be an ObsAr!
"""
from .lists_and_dicts import ObserverList
memo = {}
memo[id(self)] = self
memo[id(self.observers)] = ObserverList()
... | python | def copy(self):
"""
Make a copy. This means, we delete all observers and return a copy of this
array. It will still be an ObsAr!
"""
from .lists_and_dicts import ObserverList
memo = {}
memo[id(self)] = self
memo[id(self.observers)] = ObserverList()
... | Make a copy. This means, we delete all observers and return a copy of this
array. It will still be an ObsAr! | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/observable_array.py#L91-L100 |
sods/paramz | paramz/core/updateable.py | Updateable.update_model | def update_model(self, updates=None):
"""
Get or set, whether automatic updates are performed. When updates are
off, the model might be in a non-working state. To make the model work
turn updates on again.
:param bool|None updates:
bool: whether to do updates
... | python | def update_model(self, updates=None):
"""
Get or set, whether automatic updates are performed. When updates are
off, the model might be in a non-working state. To make the model work
turn updates on again.
:param bool|None updates:
bool: whether to do updates
... | Get or set, whether automatic updates are performed. When updates are
off, the model might be in a non-working state. To make the model work
turn updates on again.
:param bool|None updates:
bool: whether to do updates
None: get the current update state | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/updateable.py#L42-L60 |
sods/paramz | paramz/core/updateable.py | Updateable.trigger_update | def trigger_update(self, trigger_parent=True):
"""
Update the model from the current state.
Make sure that updates are on, otherwise this
method will do nothing
:param bool trigger_parent: Whether to trigger the parent, after self has updated
"""
if not self.upda... | python | def trigger_update(self, trigger_parent=True):
"""
Update the model from the current state.
Make sure that updates are on, otherwise this
method will do nothing
:param bool trigger_parent: Whether to trigger the parent, after self has updated
"""
if not self.upda... | Update the model from the current state.
Make sure that updates are on, otherwise this
method will do nothing
:param bool trigger_parent: Whether to trigger the parent, after self has updated | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/updateable.py#L68-L79 |
sods/paramz | paramz/core/parameter_core.py | OptimizationHandlable.optimizer_array | def optimizer_array(self):
"""
Array for the optimizer to work on.
This array always lives in the space for the optimizer.
Thus, it is untransformed, going from Transformations.
Setting this array, will make sure the transformed parameters for this model
will be set acco... | python | def optimizer_array(self):
"""
Array for the optimizer to work on.
This array always lives in the space for the optimizer.
Thus, it is untransformed, going from Transformations.
Setting this array, will make sure the transformed parameters for this model
will be set acco... | Array for the optimizer to work on.
This array always lives in the space for the optimizer.
Thus, it is untransformed, going from Transformations.
Setting this array, will make sure the transformed parameters for this model
will be set accordingly. It has to be set with an array, retrie... | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/parameter_core.py#L67-L93 |
sods/paramz | paramz/core/parameter_core.py | OptimizationHandlable.optimizer_array | def optimizer_array(self, p):
"""
Make sure the optimizer copy does not get touched, thus, we only want to
set the values *inside* not the array itself.
Also we want to update param_array in here.
"""
f = None
if self.has_parent() and self.constraints[__fixed__].... | python | def optimizer_array(self, p):
"""
Make sure the optimizer copy does not get touched, thus, we only want to
set the values *inside* not the array itself.
Also we want to update param_array in here.
"""
f = None
if self.has_parent() and self.constraints[__fixed__].... | Make sure the optimizer copy does not get touched, thus, we only want to
set the values *inside* not the array itself.
Also we want to update param_array in here. | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/parameter_core.py#L96-L124 |
sods/paramz | paramz/core/parameter_core.py | OptimizationHandlable._trigger_params_changed | def _trigger_params_changed(self, trigger_parent=True):
"""
First tell all children to update,
then update yourself.
If trigger_parent is True, we will tell the parent, otherwise not.
"""
[p._trigger_params_changed(trigger_parent=False) for p in self.parameters if not p.... | python | def _trigger_params_changed(self, trigger_parent=True):
"""
First tell all children to update,
then update yourself.
If trigger_parent is True, we will tell the parent, otherwise not.
"""
[p._trigger_params_changed(trigger_parent=False) for p in self.parameters if not p.... | First tell all children to update,
then update yourself.
If trigger_parent is True, we will tell the parent, otherwise not. | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/parameter_core.py#L126-L134 |
sods/paramz | paramz/core/parameter_core.py | OptimizationHandlable._transform_gradients | def _transform_gradients(self, g):
"""
Transform the gradients by multiplying the gradient factor for each
constraint to it.
"""
#py3 fix
#[np.put(g, i, c.gradfactor(self.param_array[i], g[i])) for c, i in self.constraints.iteritems() if c != __fixed__]
[np.put(g,... | python | def _transform_gradients(self, g):
"""
Transform the gradients by multiplying the gradient factor for each
constraint to it.
"""
#py3 fix
#[np.put(g, i, c.gradfactor(self.param_array[i], g[i])) for c, i in self.constraints.iteritems() if c != __fixed__]
[np.put(g,... | Transform the gradients by multiplying the gradient factor for each
constraint to it. | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/parameter_core.py#L143-L152 |
sods/paramz | paramz/core/parameter_core.py | OptimizationHandlable.parameter_names | def parameter_names(self, add_self=False, adjust_for_printing=False, recursive=True, intermediate=False):
"""
Get the names of all parameters of this model or parameter. It starts
from the parameterized object you are calling this method on.
Note: This does not unravel multidimensional ... | python | def parameter_names(self, add_self=False, adjust_for_printing=False, recursive=True, intermediate=False):
"""
Get the names of all parameters of this model or parameter. It starts
from the parameterized object you are calling this method on.
Note: This does not unravel multidimensional ... | Get the names of all parameters of this model or parameter. It starts
from the parameterized object you are calling this method on.
Note: This does not unravel multidimensional parameters,
use parameter_names_flat to unravel parameters!
:param bool add_self: whether to add the ow... | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/parameter_core.py#L174-L199 |
sods/paramz | paramz/core/parameter_core.py | OptimizationHandlable.parameter_names_flat | def parameter_names_flat(self, include_fixed=False):
"""
Return the flattened parameter names for all subsequent parameters
of this parameter. We do not include the name for self here!
If you want the names for fixed parameters as well in this list,
set include_fixed to True.
... | python | def parameter_names_flat(self, include_fixed=False):
"""
Return the flattened parameter names for all subsequent parameters
of this parameter. We do not include the name for self here!
If you want the names for fixed parameters as well in this list,
set include_fixed to True.
... | Return the flattened parameter names for all subsequent parameters
of this parameter. We do not include the name for self here!
If you want the names for fixed parameters as well in this list,
set include_fixed to True.
if not hasattr(obj, 'cache'):
obj.cache = Funct... | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/parameter_core.py#L201-L223 |
sods/paramz | paramz/core/parameter_core.py | OptimizationHandlable.randomize | def randomize(self, rand_gen=None, *args, **kwargs):
"""
Randomize the model.
Make this draw from the rand_gen if one exists, else draw random normal(0,1)
:param rand_gen: np random number generator which takes args and kwargs
:param flaot loc: loc parameter for random number ge... | python | def randomize(self, rand_gen=None, *args, **kwargs):
"""
Randomize the model.
Make this draw from the rand_gen if one exists, else draw random normal(0,1)
:param rand_gen: np random number generator which takes args and kwargs
:param flaot loc: loc parameter for random number ge... | Randomize the model.
Make this draw from the rand_gen if one exists, else draw random normal(0,1)
:param rand_gen: np random number generator which takes args and kwargs
:param flaot loc: loc parameter for random number generator
:param float scale: scale parameter for random number gen... | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/parameter_core.py#L228-L250 |
sods/paramz | paramz/core/parameter_core.py | OptimizationHandlable._propagate_param_grad | def _propagate_param_grad(self, parray, garray):
"""
For propagating the param_array and gradient_array.
This ensures the in memory view of each subsequent array.
1.) connect param_array of children to self.param_array
2.) tell all children to propagate further
"""
... | python | def _propagate_param_grad(self, parray, garray):
"""
For propagating the param_array and gradient_array.
This ensures the in memory view of each subsequent array.
1.) connect param_array of children to self.param_array
2.) tell all children to propagate further
"""
... | For propagating the param_array and gradient_array.
This ensures the in memory view of each subsequent array.
1.) connect param_array of children to self.param_array
2.) tell all children to propagate further | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/parameter_core.py#L270-L296 |
sods/paramz | paramz/core/parameter_core.py | Parameterizable.initialize_parameter | def initialize_parameter(self):
"""
Call this function to initialize the model, if you built it without initialization.
This HAS to be called manually before optmizing or it will be causing
unexpected behaviour, if not errors!
"""
#logger.debug("connecting parameters")
... | python | def initialize_parameter(self):
"""
Call this function to initialize the model, if you built it without initialization.
This HAS to be called manually before optmizing or it will be causing
unexpected behaviour, if not errors!
"""
#logger.debug("connecting parameters")
... | Call this function to initialize the model, if you built it without initialization.
This HAS to be called manually before optmizing or it will be causing
unexpected behaviour, if not errors! | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/parameter_core.py#L326-L337 |
sods/paramz | paramz/core/parameter_core.py | Parameterizable.param_array | def param_array(self):
"""
Array representing the parameters of this class.
There is only one copy of all parameters in memory, two during optimization.
!WARNING!: setting the parameter array MUST always be done in memory:
m.param_array[:] = m_copy.param_array
"""
... | python | def param_array(self):
"""
Array representing the parameters of this class.
There is only one copy of all parameters in memory, two during optimization.
!WARNING!: setting the parameter array MUST always be done in memory:
m.param_array[:] = m_copy.param_array
"""
... | Array representing the parameters of this class.
There is only one copy of all parameters in memory, two during optimization.
!WARNING!: setting the parameter array MUST always be done in memory:
m.param_array[:] = m_copy.param_array | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/parameter_core.py#L340-L350 |
sods/paramz | paramz/core/parameter_core.py | Parameterizable.unfixed_param_array | def unfixed_param_array(self):
"""
Array representing the parameters of this class.
There is only one copy of all parameters in memory, two during optimization.
!WARNING!: setting the parameter array MUST always be done in memory:
m.param_array[:] = m_copy.param_array
""... | python | def unfixed_param_array(self):
"""
Array representing the parameters of this class.
There is only one copy of all parameters in memory, two during optimization.
!WARNING!: setting the parameter array MUST always be done in memory:
m.param_array[:] = m_copy.param_array
""... | Array representing the parameters of this class.
There is only one copy of all parameters in memory, two during optimization.
!WARNING!: setting the parameter array MUST always be done in memory:
m.param_array[:] = m_copy.param_array | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/parameter_core.py#L353-L366 |
sods/paramz | paramz/core/parameter_core.py | Parameterizable.traverse | def traverse(self, visit, *args, **kwargs):
"""
Traverse the hierarchy performing `visit(self, *args, **kwargs)`
at every node passed by downwards. This function includes self!
See *visitor pattern* in literature. This is implemented in pre-order fashion.
Example::
... | python | def traverse(self, visit, *args, **kwargs):
"""
Traverse the hierarchy performing `visit(self, *args, **kwargs)`
at every node passed by downwards. This function includes self!
See *visitor pattern* in literature. This is implemented in pre-order fashion.
Example::
... | Traverse the hierarchy performing `visit(self, *args, **kwargs)`
at every node passed by downwards. This function includes self!
See *visitor pattern* in literature. This is implemented in pre-order fashion.
Example::
#Collect all children:
children = []
s... | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/parameter_core.py#L368-L388 |
sods/paramz | paramz/core/parameter_core.py | Parameterizable.traverse_parents | def traverse_parents(self, visit, *args, **kwargs):
"""
Traverse the hierarchy upwards, visiting all parents and their children except self.
See "visitor pattern" in literature. This is implemented in pre-order fashion.
Example:
parents = []
self.traverse_parents(parent... | python | def traverse_parents(self, visit, *args, **kwargs):
"""
Traverse the hierarchy upwards, visiting all parents and their children except self.
See "visitor pattern" in literature. This is implemented in pre-order fashion.
Example:
parents = []
self.traverse_parents(parent... | Traverse the hierarchy upwards, visiting all parents and their children except self.
See "visitor pattern" in literature. This is implemented in pre-order fashion.
Example:
parents = []
self.traverse_parents(parents.append)
print parents | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/parameter_core.py#L395-L410 |
sods/paramz | paramz/core/parameter_core.py | Parameterizable.save | def save(self, filename, ftype='HDF5'): # pragma: no coverage
"""
Save all the model parameters into a file (HDF5 by default).
This is not supported yet. We are working on having a consistent,
human readable way of saving and loading GPy models. This only
saves the parameter arr... | python | def save(self, filename, ftype='HDF5'): # pragma: no coverage
"""
Save all the model parameters into a file (HDF5 by default).
This is not supported yet. We are working on having a consistent,
human readable way of saving and loading GPy models. This only
saves the parameter arr... | Save all the model parameters into a file (HDF5 by default).
This is not supported yet. We are working on having a consistent,
human readable way of saving and loading GPy models. This only
saves the parameter array to a hdf5 file. In order
to load the model again, use the same script f... | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/parameter_core.py#L540-L577 |
sods/paramz | paramz/examples/ridge_regression.py | RidgeRegression.phi | def phi(self, Xpred, degrees=None):
"""
Compute the design matrix for this model
using the degrees given by the index array
in degrees
:param array-like Xpred: inputs to compute the design matrix for
:param array-like degrees: array of degrees to use [default=range(self.... | python | def phi(self, Xpred, degrees=None):
"""
Compute the design matrix for this model
using the degrees given by the index array
in degrees
:param array-like Xpred: inputs to compute the design matrix for
:param array-like degrees: array of degrees to use [default=range(self.... | Compute the design matrix for this model
using the degrees given by the index array
in degrees
:param array-like Xpred: inputs to compute the design matrix for
:param array-like degrees: array of degrees to use [default=range(self.degree+1)]
:returns array-like phi: The design m... | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/examples/ridge_regression.py#L57-L75 |
sods/paramz | paramz/core/pickleable.py | Pickleable.pickle | def pickle(self, f, protocol=-1):
"""
:param f: either filename or open file object to write to.
if it is an open buffer, you have to make sure to close
it properly.
:param protocol: pickling protocol to use, python-pickle for details.
"""
try:... | python | def pickle(self, f, protocol=-1):
"""
:param f: either filename or open file object to write to.
if it is an open buffer, you have to make sure to close
it properly.
:param protocol: pickling protocol to use, python-pickle for details.
"""
try:... | :param f: either filename or open file object to write to.
if it is an open buffer, you have to make sure to close
it properly.
:param protocol: pickling protocol to use, python-pickle for details. | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/pickleable.py#L45-L65 |
sods/paramz | paramz/core/pickleable.py | Pickleable.copy | def copy(self, memo=None, which=None):
"""
Returns a (deep) copy of the current parameter handle.
All connections to parents of the copy will be cut.
:param dict memo: memo for deepcopy
:param Parameterized which: parameterized object which started the copy process [default: se... | python | def copy(self, memo=None, which=None):
"""
Returns a (deep) copy of the current parameter handle.
All connections to parents of the copy will be cut.
:param dict memo: memo for deepcopy
:param Parameterized which: parameterized object which started the copy process [default: se... | Returns a (deep) copy of the current parameter handle.
All connections to parents of the copy will be cut.
:param dict memo: memo for deepcopy
:param Parameterized which: parameterized object which started the copy process [default: self] | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/pickleable.py#L70-L95 |
PyAr/fades | fades/main.py | consolidate_dependencies | def consolidate_dependencies(needs_ipython, child_program,
requirement_files, manual_dependencies):
"""Parse files, get deps and merge them. Deps read later overwrite those read earlier."""
# We get the logger here because it's not defined at module level
logger = logging.getLog... | python | def consolidate_dependencies(needs_ipython, child_program,
requirement_files, manual_dependencies):
"""Parse files, get deps and merge them. Deps read later overwrite those read earlier."""
# We get the logger here because it's not defined at module level
logger = logging.getLog... | Parse files, get deps and merge them. Deps read later overwrite those read earlier. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/main.py#L56-L95 |
PyAr/fades | fades/main.py | decide_child_program | def decide_child_program(args_executable, args_child_program):
"""Decide which the child program really is (if any)."""
# We get the logger here because it's not defined at module level
logger = logging.getLogger('fades')
if args_executable:
# if --exec given, check that it's just the executabl... | python | def decide_child_program(args_executable, args_child_program):
"""Decide which the child program really is (if any)."""
# We get the logger here because it's not defined at module level
logger = logging.getLogger('fades')
if args_executable:
# if --exec given, check that it's just the executabl... | Decide which the child program really is (if any). | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/main.py#L98-L134 |
PyAr/fades | fades/main.py | detect_inside_virtualenv | def detect_inside_virtualenv(prefix, real_prefix, base_prefix):
"""Tell if fades is running inside a virtualenv.
The params 'real_prefix' and 'base_prefix' may be None.
This is copied from pip code (slightly modified), see
https://github.com/pypa/pip/blob/281eb61b09d87765d7c2b92f6982b3fe76ccb0af/... | python | def detect_inside_virtualenv(prefix, real_prefix, base_prefix):
"""Tell if fades is running inside a virtualenv.
The params 'real_prefix' and 'base_prefix' may be None.
This is copied from pip code (slightly modified), see
https://github.com/pypa/pip/blob/281eb61b09d87765d7c2b92f6982b3fe76ccb0af/... | Tell if fades is running inside a virtualenv.
The params 'real_prefix' and 'base_prefix' may be None.
This is copied from pip code (slightly modified), see
https://github.com/pypa/pip/blob/281eb61b09d87765d7c2b92f6982b3fe76ccb0af/
pip/locations.py#L39 | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/main.py#L137-L154 |
PyAr/fades | fades/main.py | _get_normalized_args | def _get_normalized_args(parser):
"""Return the parsed command line arguments.
Support the case when executed from a shebang, where all the
parameters come in sys.argv[1] in a single string separated
by spaces (in this case, the third parameter is what is being
executed)
"""
env = os.enviro... | python | def _get_normalized_args(parser):
"""Return the parsed command line arguments.
Support the case when executed from a shebang, where all the
parameters come in sys.argv[1] in a single string separated
by spaces (in this case, the third parameter is what is being
executed)
"""
env = os.enviro... | Return the parsed command line arguments.
Support the case when executed from a shebang, where all the
parameters come in sys.argv[1] in a single string separated
by spaces (in this case, the third parameter is what is being
executed) | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/main.py#L157-L169 |
PyAr/fades | fades/main.py | go | def go():
"""Make the magic happen."""
parser = argparse.ArgumentParser(prog='PROG', epilog=help_epilog,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('-V', '--version', action='store_true',
help="show version and info ... | python | def go():
"""Make the magic happen."""
parser = argparse.ArgumentParser(prog='PROG', epilog=help_epilog,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('-V', '--version', action='store_true',
help="show version and info ... | Make the magic happen. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/main.py#L172-L404 |
PyAr/fades | fades/logger.py | set_up | def set_up(verbose, quiet):
"""Set up the logging."""
logger = logging.getLogger('fades')
logger.setLevel(logging.DEBUG)
# select logging level according to user desire; also use a simpler
# formatting for non-verbose logging
if verbose:
log_level = logging.DEBUG
log_format = FM... | python | def set_up(verbose, quiet):
"""Set up the logging."""
logger = logging.getLogger('fades')
logger.setLevel(logging.DEBUG)
# select logging level according to user desire; also use a simpler
# formatting for non-verbose logging
if verbose:
log_level = logging.DEBUG
log_format = FM... | Set up the logging. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/logger.py#L53-L93 |
PyAr/fades | fades/logger.py | SalutingStreamHandler.emit | def emit(self, record):
"""Call father's emit, but salute first (just once)."""
if not self._already_saluted:
self._already_saluted = True
self._logger.info(SALUTATION)
super().emit(record) | python | def emit(self, record):
"""Call father's emit, but salute first (just once)."""
if not self._already_saluted:
self._already_saluted = True
self._logger.info(SALUTATION)
super().emit(record) | Call father's emit, but salute first (just once). | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/logger.py#L45-L50 |
PyAr/fades | fades/parsing.py | parse_fade_requirement | def parse_fade_requirement(text):
"""Return a requirement and repo from the given text, already parsed and converted."""
text = text.strip()
if "::" in text:
repo_raw, requirement = text.split("::", 1)
try:
repo = {'pypi': REPO_PYPI, 'vcs': REPO_VCS}[repo_raw]
except Key... | python | def parse_fade_requirement(text):
"""Return a requirement and repo from the given text, already parsed and converted."""
text = text.strip()
if "::" in text:
repo_raw, requirement = text.split("::", 1)
try:
repo = {'pypi': REPO_PYPI, 'vcs': REPO_VCS}[repo_raw]
except Key... | Return a requirement and repo from the given text, already parsed and converted. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/parsing.py#L67-L89 |
PyAr/fades | fades/parsing.py | _parse_content | def _parse_content(fh):
"""Parse the content of a script to find marked dependencies."""
content = iter(fh)
deps = {}
for line in content:
# quickly discard most of the lines
if 'fades' not in line:
continue
# discard other string with 'fades' that isn't a comment
... | python | def _parse_content(fh):
"""Parse the content of a script to find marked dependencies."""
content = iter(fh)
deps = {}
for line in content:
# quickly discard most of the lines
if 'fades' not in line:
continue
# discard other string with 'fades' that isn't a comment
... | Parse the content of a script to find marked dependencies. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/parsing.py#L92-L169 |
PyAr/fades | fades/parsing.py | _parse_docstring | def _parse_docstring(fh):
"""Parse the docstrings of a script to find marked dependencies."""
find_fades = re.compile(r'\b(fades)\b:').search
for line in fh:
if line.startswith("'"):
quote = "'"
break
if line.startswith('"'):
quote = '"'
break... | python | def _parse_docstring(fh):
"""Parse the docstrings of a script to find marked dependencies."""
find_fades = re.compile(r'\b(fades)\b:').search
for line in fh:
if line.startswith("'"):
quote = "'"
break
if line.startswith('"'):
quote = '"'
break... | Parse the docstrings of a script to find marked dependencies. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/parsing.py#L172-L209 |
PyAr/fades | fades/parsing.py | _parse_requirement | def _parse_requirement(iterable):
"""Actually parse the requirements, from file or manually specified."""
deps = {}
for line in iterable:
line = line.strip()
if not line or line[0] == '#':
continue
parsed_req = parse_fade_requirement(line)
if parsed_req is None:
... | python | def _parse_requirement(iterable):
"""Actually parse the requirements, from file or manually specified."""
deps = {}
for line in iterable:
line = line.strip()
if not line or line[0] == '#':
continue
parsed_req = parse_fade_requirement(line)
if parsed_req is None:
... | Actually parse the requirements, from file or manually specified. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/parsing.py#L212-L226 |
PyAr/fades | fades/parsing.py | _read_lines | def _read_lines(filepath):
"""Read a req file to a list to support nested requirement files."""
with open(filepath, 'rt', encoding='utf8') as fh:
for line in fh:
line = line.strip()
if line.startswith("-r"):
logger.debug("Reading deps from nested requirement file:... | python | def _read_lines(filepath):
"""Read a req file to a list to support nested requirement files."""
with open(filepath, 'rt', encoding='utf8') as fh:
for line in fh:
line = line.strip()
if line.startswith("-r"):
logger.debug("Reading deps from nested requirement file:... | Read a req file to a list to support nested requirement files. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/parsing.py#L236-L253 |
PyAr/fades | fades/envbuilder.py | create_venv | def create_venv(requested_deps, interpreter, is_current, options, pip_options):
"""Create a new virtualvenv with the requirements of this script."""
# create virtualenv
env = _FadesEnvBuilder()
env_path, env_bin_path, pip_installed = env.create_env(interpreter, is_current, options)
venv_data = {}
... | python | def create_venv(requested_deps, interpreter, is_current, options, pip_options):
"""Create a new virtualvenv with the requirements of this script."""
# create virtualenv
env = _FadesEnvBuilder()
env_path, env_bin_path, pip_installed = env.create_env(interpreter, is_current, options)
venv_data = {}
... | Create a new virtualvenv with the requirements of this script. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/envbuilder.py#L124-L168 |
PyAr/fades | fades/envbuilder.py | destroy_venv | def destroy_venv(env_path, venvscache=None):
"""Destroy a venv."""
# remove the venv itself in disk
logger.debug("Destroying virtualenv at: %s", env_path)
shutil.rmtree(env_path, ignore_errors=True)
# remove venv from cache
if venvscache is not None:
venvscache.remove(env_path) | python | def destroy_venv(env_path, venvscache=None):
"""Destroy a venv."""
# remove the venv itself in disk
logger.debug("Destroying virtualenv at: %s", env_path)
shutil.rmtree(env_path, ignore_errors=True)
# remove venv from cache
if venvscache is not None:
venvscache.remove(env_path) | Destroy a venv. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/envbuilder.py#L171-L179 |
PyAr/fades | fades/envbuilder.py | _FadesEnvBuilder.create_with_virtualenv | def create_with_virtualenv(self, interpreter, virtualenv_options):
"""Create a virtualenv using the virtualenv lib."""
args = ['virtualenv', '--python', interpreter, self.env_path]
args.extend(virtualenv_options)
if not self.pip_installed:
args.insert(3, '--no-pip')
t... | python | def create_with_virtualenv(self, interpreter, virtualenv_options):
"""Create a virtualenv using the virtualenv lib."""
args = ['virtualenv', '--python', interpreter, self.env_path]
args.extend(virtualenv_options)
if not self.pip_installed:
args.insert(3, '--no-pip')
t... | Create a virtualenv using the virtualenv lib. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/envbuilder.py#L75-L93 |
PyAr/fades | fades/envbuilder.py | _FadesEnvBuilder.create_env | def create_env(self, interpreter, is_current, options):
"""Create the virtualenv and return its info."""
if is_current:
# apply pyvenv options
pyvenv_options = options['pyvenv_options']
if "--system-site-packages" in pyvenv_options:
self.system_site_pa... | python | def create_env(self, interpreter, is_current, options):
"""Create the virtualenv and return its info."""
if is_current:
# apply pyvenv options
pyvenv_options = options['pyvenv_options']
if "--system-site-packages" in pyvenv_options:
self.system_site_pa... | Create the virtualenv and return its info. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/envbuilder.py#L95-L117 |
PyAr/fades | fades/envbuilder.py | UsageManager.store_usage_stat | def store_usage_stat(self, venv_data, cache):
"""Log an usage record for venv_data."""
with open(self.stat_file_path, 'at') as f:
self._write_venv_usage(f, venv_data) | python | def store_usage_stat(self, venv_data, cache):
"""Log an usage record for venv_data."""
with open(self.stat_file_path, 'at') as f:
self._write_venv_usage(f, venv_data) | Log an usage record for venv_data. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/envbuilder.py#L192-L195 |
PyAr/fades | fades/envbuilder.py | UsageManager.clean_unused_venvs | def clean_unused_venvs(self, max_days_to_keep):
"""Compact usage stats and remove venvs.
This method loads the complete file usage in memory, for every venv compact all records in
one (the lastest), updates this info for every env deleted and, finally, write the entire
file to disk.
... | python | def clean_unused_venvs(self, max_days_to_keep):
"""Compact usage stats and remove venvs.
This method loads the complete file usage in memory, for every venv compact all records in
one (the lastest), updates this info for every env deleted and, finally, write the entire
file to disk.
... | Compact usage stats and remove venvs.
This method loads the complete file usage in memory, for every venv compact all records in
one (the lastest), updates this info for every env deleted and, finally, write the entire
file to disk.
If something failed during this steps, usage file rem... | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/envbuilder.py#L214-L242 |
PyAr/fades | fades/helpers.py | logged_exec | def logged_exec(cmd):
"""Execute a command, redirecting the output to the log."""
logger = logging.getLogger('fades.exec')
logger.debug("Executing external command: %r", cmd)
p = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
stdout = []
... | python | def logged_exec(cmd):
"""Execute a command, redirecting the output to the log."""
logger = logging.getLogger('fades.exec')
logger.debug("Executing external command: %r", cmd)
p = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
stdout = []
... | Execute a command, redirecting the output to the log. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/helpers.py#L72-L86 |
PyAr/fades | fades/helpers.py | _get_specific_dir | def _get_specific_dir(dir_type):
"""Get a specific directory, using some XDG base, with sensible default."""
if SNAP_BASEDIR_NAME in os.environ:
logger.debug("Getting base dir information from SNAP_BASEDIR_NAME env var.")
direct = os.path.join(os.environ[SNAP_BASEDIR_NAME], dir_type)
else:
... | python | def _get_specific_dir(dir_type):
"""Get a specific directory, using some XDG base, with sensible default."""
if SNAP_BASEDIR_NAME in os.environ:
logger.debug("Getting base dir information from SNAP_BASEDIR_NAME env var.")
direct = os.path.join(os.environ[SNAP_BASEDIR_NAME], dir_type)
else:
... | Get a specific directory, using some XDG base, with sensible default. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/helpers.py#L94-L113 |
PyAr/fades | fades/helpers.py | _get_interpreter_info | def _get_interpreter_info(interpreter=None):
"""Return the interpreter's full path using pythonX.Y format."""
if interpreter is None:
# If interpreter is None by default returns the current interpreter data.
major, minor = sys.version_info[:2]
executable = sys.executable
else:
... | python | def _get_interpreter_info(interpreter=None):
"""Return the interpreter's full path using pythonX.Y format."""
if interpreter is None:
# If interpreter is None by default returns the current interpreter data.
major, minor = sys.version_info[:2]
executable = sys.executable
else:
... | Return the interpreter's full path using pythonX.Y format. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/helpers.py#L126-L146 |
PyAr/fades | fades/helpers.py | get_interpreter_version | def get_interpreter_version(requested_interpreter):
"""Return a 'sanitized' interpreter and indicates if it is the current one."""
logger.debug('Getting interpreter version for: %s', requested_interpreter)
current_interpreter = _get_interpreter_info()
logger.debug('Current interpreter is %s', current_in... | python | def get_interpreter_version(requested_interpreter):
"""Return a 'sanitized' interpreter and indicates if it is the current one."""
logger.debug('Getting interpreter version for: %s', requested_interpreter)
current_interpreter = _get_interpreter_info()
logger.debug('Current interpreter is %s', current_in... | Return a 'sanitized' interpreter and indicates if it is the current one. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/helpers.py#L149-L161 |
PyAr/fades | fades/helpers.py | check_pypi_updates | def check_pypi_updates(dependencies):
"""Return a list of dependencies to upgrade."""
dependencies_up_to_date = []
for dependency in dependencies.get('pypi', []):
# get latest version from PyPI api
try:
latest_version = get_latest_version_number(dependency.project_name)
e... | python | def check_pypi_updates(dependencies):
"""Return a list of dependencies to upgrade."""
dependencies_up_to_date = []
for dependency in dependencies.get('pypi', []):
# get latest version from PyPI api
try:
latest_version = get_latest_version_number(dependency.project_name)
e... | Return a list of dependencies to upgrade. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/helpers.py#L180-L214 |
PyAr/fades | fades/helpers.py | _pypi_head_package | def _pypi_head_package(dependency):
"""Hit pypi with a http HEAD to check if pkg_name exists."""
if dependency.specs:
_, version = dependency.specs[0]
url = BASE_PYPI_URL_WITH_VERSION.format(name=dependency.project_name, version=version)
else:
url = BASE_PYPI_URL.format(name=dependen... | python | def _pypi_head_package(dependency):
"""Hit pypi with a http HEAD to check if pkg_name exists."""
if dependency.specs:
_, version = dependency.specs[0]
url = BASE_PYPI_URL_WITH_VERSION.format(name=dependency.project_name, version=version)
else:
url = BASE_PYPI_URL.format(name=dependen... | Hit pypi with a http HEAD to check if pkg_name exists. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/helpers.py#L217-L242 |
PyAr/fades | fades/helpers.py | check_pypi_exists | def check_pypi_exists(dependencies):
"""Check if the indicated dependencies actually exists in pypi."""
for dependency in dependencies.get('pypi', []):
logger.debug("Checking if %r exists in PyPI", dependency)
try:
exists = _pypi_head_package(dependency)
except Exception as e... | python | def check_pypi_exists(dependencies):
"""Check if the indicated dependencies actually exists in pypi."""
for dependency in dependencies.get('pypi', []):
logger.debug("Checking if %r exists in PyPI", dependency)
try:
exists = _pypi_head_package(dependency)
except Exception as e... | Check if the indicated dependencies actually exists in pypi. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/helpers.py#L245-L258 |
PyAr/fades | fades/helpers.py | download_remote_script | def download_remote_script(url):
"""Download the content of a remote script to a local temp file."""
temp_fh = tempfile.NamedTemporaryFile('wt', encoding='utf8', suffix=".py", delete=False)
downloader = _ScriptDownloader(url)
logger.info(
"Downloading remote script from %r using (%r downloader) ... | python | def download_remote_script(url):
"""Download the content of a remote script to a local temp file."""
temp_fh = tempfile.NamedTemporaryFile('wt', encoding='utf8', suffix=".py", delete=False)
downloader = _ScriptDownloader(url)
logger.info(
"Downloading remote script from %r using (%r downloader) ... | Download the content of a remote script to a local temp file. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/helpers.py#L334-L345 |
PyAr/fades | fades/helpers.py | ExecutionError.dump_to_log | def dump_to_log(self, logger):
"""Send the cmd info and collected stdout to logger."""
logger.error("Execution ended in %s for cmd %s", self._retcode, self._cmd)
for line in self._collected_stdout:
logger.error(STDOUT_LOG_PREFIX + line) | python | def dump_to_log(self, logger):
"""Send the cmd info and collected stdout to logger."""
logger.error("Execution ended in %s for cmd %s", self._retcode, self._cmd)
for line in self._collected_stdout:
logger.error(STDOUT_LOG_PREFIX + line) | Send the cmd info and collected stdout to logger. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/helpers.py#L65-L69 |
PyAr/fades | fades/helpers.py | _ScriptDownloader._decide | def _decide(self):
"""Find out which method should be applied to download that URL."""
netloc = parse.urlparse(self.url).netloc
name = self.NETLOCS.get(netloc, 'raw')
return name | python | def _decide(self):
"""Find out which method should be applied to download that URL."""
netloc = parse.urlparse(self.url).netloc
name = self.NETLOCS.get(netloc, 'raw')
return name | Find out which method should be applied to download that URL. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/helpers.py#L287-L291 |
PyAr/fades | fades/helpers.py | _ScriptDownloader.get | def get(self):
"""Get the script content from the URL using the decided downloader."""
method_name = "_download_" + self.name
method = getattr(self, method_name)
return method() | python | def get(self):
"""Get the script content from the URL using the decided downloader."""
method_name = "_download_" + self.name
method = getattr(self, method_name)
return method() | Get the script content from the URL using the decided downloader. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/helpers.py#L293-L297 |
PyAr/fades | fades/helpers.py | _ScriptDownloader._download_raw | def _download_raw(self, url=None):
"""Download content from URL directly."""
if url is None:
url = self.url
req = request.Request(url, headers=self.HEADERS_PLAIN)
return request.urlopen(req).read().decode("utf8") | python | def _download_raw(self, url=None):
"""Download content from URL directly."""
if url is None:
url = self.url
req = request.Request(url, headers=self.HEADERS_PLAIN)
return request.urlopen(req).read().decode("utf8") | Download content from URL directly. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/helpers.py#L299-L304 |
PyAr/fades | fades/helpers.py | _ScriptDownloader._download_linkode | def _download_linkode(self):
"""Download content from Linkode pastebin."""
# build the API url
linkode_id = self.url.split("/")[-1]
if linkode_id.startswith("#"):
linkode_id = linkode_id[1:]
url = "https://linkode.org/api/1/linkodes/" + linkode_id
req = reque... | python | def _download_linkode(self):
"""Download content from Linkode pastebin."""
# build the API url
linkode_id = self.url.split("/")[-1]
if linkode_id.startswith("#"):
linkode_id = linkode_id[1:]
url = "https://linkode.org/api/1/linkodes/" + linkode_id
req = reque... | Download content from Linkode pastebin. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/helpers.py#L306-L319 |
PyAr/fades | fades/helpers.py | _ScriptDownloader._download_pastebin | def _download_pastebin(self):
"""Download content from Pastebin itself."""
paste_id = self.url.split("/")[-1]
url = "https://pastebin.com/raw/" + paste_id
return self._download_raw(url) | python | def _download_pastebin(self):
"""Download content from Pastebin itself."""
paste_id = self.url.split("/")[-1]
url = "https://pastebin.com/raw/" + paste_id
return self._download_raw(url) | Download content from Pastebin itself. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/helpers.py#L321-L325 |
PyAr/fades | fades/helpers.py | _ScriptDownloader._download_gist | def _download_gist(self):
"""Download content from github's pastebin."""
parts = parse.urlparse(self.url)
url = "https://gist.github.com" + parts.path + "/raw"
return self._download_raw(url) | python | def _download_gist(self):
"""Download content from github's pastebin."""
parts = parse.urlparse(self.url)
url = "https://gist.github.com" + parts.path + "/raw"
return self._download_raw(url) | Download content from github's pastebin. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/helpers.py#L327-L331 |
PyAr/fades | setup.py | get_version | def get_version():
"""Retrieves package version from the file."""
with open('fades/_version.py') as fh:
m = re.search("\(([^']*)\)", fh.read())
if m is None:
raise ValueError("Unrecognized version in 'fades/_version.py'")
return m.groups()[0].replace(', ', '.') | python | def get_version():
"""Retrieves package version from the file."""
with open('fades/_version.py') as fh:
m = re.search("\(([^']*)\)", fh.read())
if m is None:
raise ValueError("Unrecognized version in 'fades/_version.py'")
return m.groups()[0].replace(', ', '.') | Retrieves package version from the file. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/setup.py#L53-L59 |
PyAr/fades | setup.py | CustomInstall.initialize_options | def initialize_options(self):
"""Run parent initialization and then fix the scripts var."""
install.initialize_options(self)
# leave the proper script according to the platform
script = SCRIPT_WIN if sys.platform == "win32" else SCRIPT_REST
self.distribution.scripts = [script] | python | def initialize_options(self):
"""Run parent initialization and then fix the scripts var."""
install.initialize_options(self)
# leave the proper script according to the platform
script = SCRIPT_WIN if sys.platform == "win32" else SCRIPT_REST
self.distribution.scripts = [script] | Run parent initialization and then fix the scripts var. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/setup.py#L70-L76 |
PyAr/fades | setup.py | CustomInstall.run | def run(self):
"""Run parent install, and then save the man file."""
install.run(self)
# man directory
if self._custom_man_dir is not None:
if not os.path.exists(self._custom_man_dir):
os.makedirs(self._custom_man_dir)
shutil.copy("man/fades.1", s... | python | def run(self):
"""Run parent install, and then save the man file."""
install.run(self)
# man directory
if self._custom_man_dir is not None:
if not os.path.exists(self._custom_man_dir):
os.makedirs(self._custom_man_dir)
shutil.copy("man/fades.1", s... | Run parent install, and then save the man file. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/setup.py#L78-L86 |
PyAr/fades | setup.py | CustomInstall.finalize_options | def finalize_options(self):
"""Alter the installation path."""
install.finalize_options(self)
if self.prefix is None:
# no place for man page (like in a 'snap')
man_dir = None
else:
man_dir = os.path.join(self.prefix, "share", "man", "man1")
... | python | def finalize_options(self):
"""Alter the installation path."""
install.finalize_options(self)
if self.prefix is None:
# no place for man page (like in a 'snap')
man_dir = None
else:
man_dir = os.path.join(self.prefix, "share", "man", "man1")
... | Alter the installation path. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/setup.py#L88-L101 |
PyAr/fades | fades/file_options.py | options_from_file | def options_from_file(args):
"""Get a argparse.Namespace and return it updated with options from config files.
Config files will be parsed with priority equal to his order in CONFIG_FILES.
"""
logger.debug("updating options from config files")
updated_from_file = []
for config_file in CONFIG_FI... | python | def options_from_file(args):
"""Get a argparse.Namespace and return it updated with options from config files.
Config files will be parsed with priority equal to his order in CONFIG_FILES.
"""
logger.debug("updating options from config files")
updated_from_file = []
for config_file in CONFIG_FI... | Get a argparse.Namespace and return it updated with options from config files.
Config files will be parsed with priority equal to his order in CONFIG_FILES. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/file_options.py#L33-L66 |
PyAr/fades | fades/cache.py | VEnvsCache._venv_match | def _venv_match(self, installed, requirements):
"""Return True if what is installed satisfies the requirements.
This method has multiple exit-points, but only for False (because
if *anything* is not satisified, the venv is no good). Only after
all was checked, and it didn't exit, the ve... | python | def _venv_match(self, installed, requirements):
"""Return True if what is installed satisfies the requirements.
This method has multiple exit-points, but only for False (because
if *anything* is not satisified, the venv is no good). Only after
all was checked, and it didn't exit, the ve... | Return True if what is installed satisfies the requirements.
This method has multiple exit-points, but only for False (because
if *anything* is not satisified, the venv is no good). Only after
all was checked, and it didn't exit, the venv is ok so return True. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/cache.py#L44-L84 |
PyAr/fades | fades/cache.py | VEnvsCache._match_by_uuid | def _match_by_uuid(self, current_venvs, uuid):
"""Select a venv matching exactly by uuid."""
for venv_str in current_venvs:
venv = json.loads(venv_str)
env_path = venv.get('metadata', {}).get('env_path')
_, env_uuid = os.path.split(env_path)
if env_uuid ==... | python | def _match_by_uuid(self, current_venvs, uuid):
"""Select a venv matching exactly by uuid."""
for venv_str in current_venvs:
venv = json.loads(venv_str)
env_path = venv.get('metadata', {}).get('env_path')
_, env_uuid = os.path.split(env_path)
if env_uuid ==... | Select a venv matching exactly by uuid. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/cache.py#L86-L93 |
PyAr/fades | fades/cache.py | VEnvsCache._select_better_fit | def _select_better_fit(self, matching_venvs):
"""Receive a list of matching venvs, and decide which one is the best fit."""
# keep the venvs in a separate array, to pick up the winner, and the (sorted, to compare
# each dependency with its equivalent) in other structure to later compare
... | python | def _select_better_fit(self, matching_venvs):
"""Receive a list of matching venvs, and decide which one is the best fit."""
# keep the venvs in a separate array, to pick up the winner, and the (sorted, to compare
# each dependency with its equivalent) in other structure to later compare
... | Receive a list of matching venvs, and decide which one is the best fit. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/cache.py#L95-L123 |
PyAr/fades | fades/cache.py | VEnvsCache._match_by_requirements | def _match_by_requirements(self, current_venvs, requirements, interpreter, options):
"""Select a venv matching interpreter and options, complying with requirements.
Several venvs can be found in this case, will return the better fit.
"""
matching_venvs = []
for venv_str in curre... | python | def _match_by_requirements(self, current_venvs, requirements, interpreter, options):
"""Select a venv matching interpreter and options, complying with requirements.
Several venvs can be found in this case, will return the better fit.
"""
matching_venvs = []
for venv_str in curre... | Select a venv matching interpreter and options, complying with requirements.
Several venvs can be found in this case, will return the better fit. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/cache.py#L125-L146 |
PyAr/fades | fades/cache.py | VEnvsCache._select | def _select(self, current_venvs, requirements=None, interpreter='', uuid='', options=None):
"""Select which venv satisfy the received requirements."""
if uuid:
logger.debug("Searching a venv by uuid: %s", uuid)
venv = self._match_by_uuid(current_venvs, uuid)
else:
... | python | def _select(self, current_venvs, requirements=None, interpreter='', uuid='', options=None):
"""Select which venv satisfy the received requirements."""
if uuid:
logger.debug("Searching a venv by uuid: %s", uuid)
venv = self._match_by_uuid(current_venvs, uuid)
else:
... | Select which venv satisfy the received requirements. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/cache.py#L148-L163 |
PyAr/fades | fades/cache.py | VEnvsCache.get_venv | def get_venv(self, requirements=None, interpreter='', uuid='', options=None):
"""Find a venv that serves these requirements, if any."""
lines = self._read_cache()
return self._select(lines, requirements, interpreter, uuid=uuid, options=options) | python | def get_venv(self, requirements=None, interpreter='', uuid='', options=None):
"""Find a venv that serves these requirements, if any."""
lines = self._read_cache()
return self._select(lines, requirements, interpreter, uuid=uuid, options=options) | Find a venv that serves these requirements, if any. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/cache.py#L165-L168 |
PyAr/fades | fades/cache.py | VEnvsCache.store | def store(self, installed_stuff, metadata, interpreter, options):
"""Store the virtualenv metadata for the indicated installed_stuff."""
new_content = {
'timestamp': int(time.mktime(time.localtime())),
'installed': installed_stuff,
'metadata': metadata,
'i... | python | def store(self, installed_stuff, metadata, interpreter, options):
"""Store the virtualenv metadata for the indicated installed_stuff."""
new_content = {
'timestamp': int(time.mktime(time.localtime())),
'installed': installed_stuff,
'metadata': metadata,
'i... | Store the virtualenv metadata for the indicated installed_stuff. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/cache.py#L175-L187 |
PyAr/fades | fades/cache.py | VEnvsCache.remove | def remove(self, env_path):
"""Remove metadata for a given virtualenv from cache."""
with filelock(self.lockpath):
cache = self._read_cache()
logger.debug("Removing virtualenv from cache: %s" % env_path)
lines = [
line for line in cache
... | python | def remove(self, env_path):
"""Remove metadata for a given virtualenv from cache."""
with filelock(self.lockpath):
cache = self._read_cache()
logger.debug("Removing virtualenv from cache: %s" % env_path)
lines = [
line for line in cache
... | Remove metadata for a given virtualenv from cache. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/cache.py#L189-L198 |
PyAr/fades | fades/cache.py | VEnvsCache._read_cache | def _read_cache(self):
"""Read virtualenv metadata from cache."""
if os.path.exists(self.filepath):
with open(self.filepath, 'rt', encoding='utf8') as fh:
lines = [x.strip() for x in fh]
else:
logger.debug("Index not found, starting empty")
lin... | python | def _read_cache(self):
"""Read virtualenv metadata from cache."""
if os.path.exists(self.filepath):
with open(self.filepath, 'rt', encoding='utf8') as fh:
lines = [x.strip() for x in fh]
else:
logger.debug("Index not found, starting empty")
lin... | Read virtualenv metadata from cache. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/cache.py#L200-L208 |
PyAr/fades | fades/cache.py | VEnvsCache._write_cache | def _write_cache(self, lines, append=False):
"""Write virtualenv metadata to cache."""
mode = 'at' if append else 'wt'
with open(self.filepath, mode, encoding='utf8') as fh:
fh.writelines(line + '\n' for line in lines) | python | def _write_cache(self, lines, append=False):
"""Write virtualenv metadata to cache."""
mode = 'at' if append else 'wt'
with open(self.filepath, mode, encoding='utf8') as fh:
fh.writelines(line + '\n' for line in lines) | Write virtualenv metadata to cache. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/cache.py#L210-L214 |
PyAr/fades | fades/pipmanager.py | PipManager.install | def install(self, dependency):
"""Install a new dependency."""
if not self.pip_installed:
logger.info("Need to install a dependency with pip, but no builtin, "
"doing it manually (just wait a little, all should go well)")
self._brute_force_install_pip()
... | python | def install(self, dependency):
"""Install a new dependency."""
if not self.pip_installed:
logger.info("Need to install a dependency with pip, but no builtin, "
"doing it manually (just wait a little, all should go well)")
self._brute_force_install_pip()
... | Install a new dependency. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/pipmanager.py#L50-L75 |
PyAr/fades | fades/pipmanager.py | PipManager.get_version | def get_version(self, dependency):
"""Return the installed version parsing the output of 'pip show'."""
logger.debug("getting installed version for %s", dependency)
stdout = helpers.logged_exec([self.pip_exe, "show", str(dependency)])
version = [line for line in stdout if line.startswith... | python | def get_version(self, dependency):
"""Return the installed version parsing the output of 'pip show'."""
logger.debug("getting installed version for %s", dependency)
stdout = helpers.logged_exec([self.pip_exe, "show", str(dependency)])
version = [line for line in stdout if line.startswith... | Return the installed version parsing the output of 'pip show'. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/pipmanager.py#L77-L89 |
PyAr/fades | fades/pipmanager.py | PipManager._brute_force_install_pip | def _brute_force_install_pip(self):
"""A brute force install of pip itself."""
if os.path.exists(self.pip_installer_fname):
logger.debug("Using pip installer from %r", self.pip_installer_fname)
else:
logger.debug(
"Installer for pip not found in %r, downlo... | python | def _brute_force_install_pip(self):
"""A brute force install of pip itself."""
if os.path.exists(self.pip_installer_fname):
logger.debug("Using pip installer from %r", self.pip_installer_fname)
else:
logger.debug(
"Installer for pip not found in %r, downlo... | A brute force install of pip itself. | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/pipmanager.py#L98-L110 |
albertyw/csv-ical | csv_ical/convert.py | Convert._generate_configs_from_default | def _generate_configs_from_default(self, overrides=None):
# type: (Dict[str, int]) -> Dict[str, int]
""" Generate configs by inheriting from defaults """
config = DEFAULT_CONFIG.copy()
if not overrides:
overrides = {}
for k, v in overrides.items():
config[... | python | def _generate_configs_from_default(self, overrides=None):
# type: (Dict[str, int]) -> Dict[str, int]
""" Generate configs by inheriting from defaults """
config = DEFAULT_CONFIG.copy()
if not overrides:
overrides = {}
for k, v in overrides.items():
config[... | Generate configs by inheriting from defaults | https://github.com/albertyw/csv-ical/blob/cdb55a226cd0cb6cc214d896a6cea41a5b92c9ed/csv_ical/convert.py#L29-L37 |
albertyw/csv-ical | csv_ical/convert.py | Convert.read_ical | def read_ical(self, ical_file_location): # type: (str) -> Calendar
""" Read the ical file """
with open(ical_file_location, 'r') as ical_file:
data = ical_file.read()
self.cal = Calendar.from_ical(data)
return self.cal | python | def read_ical(self, ical_file_location): # type: (str) -> Calendar
""" Read the ical file """
with open(ical_file_location, 'r') as ical_file:
data = ical_file.read()
self.cal = Calendar.from_ical(data)
return self.cal | Read the ical file | https://github.com/albertyw/csv-ical/blob/cdb55a226cd0cb6cc214d896a6cea41a5b92c9ed/csv_ical/convert.py#L39-L44 |
albertyw/csv-ical | csv_ical/convert.py | Convert.read_csv | def read_csv(self, csv_location, csv_configs=None):
# type: (str, Dict[str, int]) -> List[List[str]]
""" Read the csv file """
csv_configs = self._generate_configs_from_default(csv_configs)
with open(csv_location, 'r') as csv_file:
csv_reader = csv.reader(csv_file)
... | python | def read_csv(self, csv_location, csv_configs=None):
# type: (str, Dict[str, int]) -> List[List[str]]
""" Read the csv file """
csv_configs = self._generate_configs_from_default(csv_configs)
with open(csv_location, 'r') as csv_file:
csv_reader = csv.reader(csv_file)
... | Read the csv file | https://github.com/albertyw/csv-ical/blob/cdb55a226cd0cb6cc214d896a6cea41a5b92c9ed/csv_ical/convert.py#L46-L54 |
albertyw/csv-ical | csv_ical/convert.py | Convert.make_ical | def make_ical(self, csv_configs=None):
# type: (Dict[str, int]) -> Calendar
""" Make iCal entries """
csv_configs = self._generate_configs_from_default(csv_configs)
self.cal = Calendar()
for row in self.csv_data:
event = Event()
event.add('summary', row[cs... | python | def make_ical(self, csv_configs=None):
# type: (Dict[str, int]) -> Calendar
""" Make iCal entries """
csv_configs = self._generate_configs_from_default(csv_configs)
self.cal = Calendar()
for row in self.csv_data:
event = Event()
event.add('summary', row[cs... | Make iCal entries | https://github.com/albertyw/csv-ical/blob/cdb55a226cd0cb6cc214d896a6cea41a5b92c9ed/csv_ical/convert.py#L56-L69 |
albertyw/csv-ical | csv_ical/convert.py | Convert.make_csv | def make_csv(self): # type: () -> None
""" Make CSV """
for event in self.cal.subcomponents:
if event.name != 'VEVENT':
continue
row = [
event.get('SUMMARY'),
event.get('DTSTART').dt,
event.get('DTEND').dt,
... | python | def make_csv(self): # type: () -> None
""" Make CSV """
for event in self.cal.subcomponents:
if event.name != 'VEVENT':
continue
row = [
event.get('SUMMARY'),
event.get('DTSTART').dt,
event.get('DTEND').dt,
... | Make CSV | https://github.com/albertyw/csv-ical/blob/cdb55a226cd0cb6cc214d896a6cea41a5b92c9ed/csv_ical/convert.py#L71-L84 |
albertyw/csv-ical | csv_ical/convert.py | Convert.save_ical | def save_ical(self, ical_location): # type: (str) -> None
""" Save the calendar instance to a file """
data = self.cal.to_ical()
with open(ical_location, 'w') as ical_file:
ical_file.write(data.decode('utf-8')) | python | def save_ical(self, ical_location): # type: (str) -> None
""" Save the calendar instance to a file """
data = self.cal.to_ical()
with open(ical_location, 'w') as ical_file:
ical_file.write(data.decode('utf-8')) | Save the calendar instance to a file | https://github.com/albertyw/csv-ical/blob/cdb55a226cd0cb6cc214d896a6cea41a5b92c9ed/csv_ical/convert.py#L86-L90 |
albertyw/csv-ical | csv_ical/convert.py | Convert.save_csv | def save_csv(self, csv_location): # type: (str) -> None
""" Save the csv to a file """
with open(csv_location, 'w') as csv_handle:
writer = csv.writer(csv_handle)
for row in self.csv_data:
writer.writerow(row) | python | def save_csv(self, csv_location): # type: (str) -> None
""" Save the csv to a file """
with open(csv_location, 'w') as csv_handle:
writer = csv.writer(csv_handle)
for row in self.csv_data:
writer.writerow(row) | Save the csv to a file | https://github.com/albertyw/csv-ical/blob/cdb55a226cd0cb6cc214d896a6cea41a5b92c9ed/csv_ical/convert.py#L92-L97 |
planetarypy/planetaryimage | planetaryimage/image.py | PlanetaryImage.open | def open(cls, filename):
""" Read an image file from disk
Parameters
----------
filename : string
Name of file to read as an image file. This file may be gzip
(``.gz``) or bzip2 (``.bz2``) compressed.
"""
if filename.endswith('.gz'):
... | python | def open(cls, filename):
""" Read an image file from disk
Parameters
----------
filename : string
Name of file to read as an image file. This file may be gzip
(``.gz``) or bzip2 (``.bz2``) compressed.
"""
if filename.endswith('.gz'):
... | Read an image file from disk
Parameters
----------
filename : string
Name of file to read as an image file. This file may be gzip
(``.gz``) or bzip2 (``.bz2``) compressed. | https://github.com/planetarypy/planetaryimage/blob/ee9aef4746ff7a003b1457565acb13f5f1db0375/planetaryimage/image.py#L69-L92 |
planetarypy/planetaryimage | planetaryimage/image.py | PlanetaryImage.image | def image(self):
"""An Image like array of ``self.data`` convenient for image processing tasks
* 2D array for single band, grayscale image data
* 3D array for three band, RGB image data
Enables working with ``self.data`` as if it were a PIL image.
See https://planetaryimage.re... | python | def image(self):
"""An Image like array of ``self.data`` convenient for image processing tasks
* 2D array for single band, grayscale image data
* 3D array for three band, RGB image data
Enables working with ``self.data`` as if it were a PIL image.
See https://planetaryimage.re... | An Image like array of ``self.data`` convenient for image processing tasks
* 2D array for single band, grayscale image data
* 3D array for three band, RGB image data
Enables working with ``self.data`` as if it were a PIL image.
See https://planetaryimage.readthedocs.io/en/latest/usage... | https://github.com/planetarypy/planetaryimage/blob/ee9aef4746ff7a003b1457565acb13f5f1db0375/planetaryimage/image.py#L131-L146 |
planetarypy/planetaryimage | planetaryimage/cubefile.py | CubeFile.apply_numpy_specials | def apply_numpy_specials(self, copy=True):
"""Convert isis special pixel values to numpy special pixel values.
======= =======
Isis Numpy
======= =======
Null nan
Lrs -inf
Lis -inf
His inf
... | python | def apply_numpy_specials(self, copy=True):
"""Convert isis special pixel values to numpy special pixel values.
======= =======
Isis Numpy
======= =======
Null nan
Lrs -inf
Lis -inf
His inf
... | Convert isis special pixel values to numpy special pixel values.
======= =======
Isis Numpy
======= =======
Null nan
Lrs -inf
Lis -inf
His inf
Hrs inf
======= =======
Par... | https://github.com/planetarypy/planetaryimage/blob/ee9aef4746ff7a003b1457565acb13f5f1db0375/planetaryimage/cubefile.py#L161-L199 |
planetarypy/planetaryimage | planetaryimage/pds3image.py | Pointer.parse | def parse(cls, value, record_bytes):
"""Parses the pointer label.
Parameters
----------
pointer_data
Supported values for `pointer_data` are::
^PTR = nnn
^PTR = nnn <BYTES>
^PTR = "filename"
^PTR = ("filename")... | python | def parse(cls, value, record_bytes):
"""Parses the pointer label.
Parameters
----------
pointer_data
Supported values for `pointer_data` are::
^PTR = nnn
^PTR = nnn <BYTES>
^PTR = "filename"
^PTR = ("filename")... | Parses the pointer label.
Parameters
----------
pointer_data
Supported values for `pointer_data` are::
^PTR = nnn
^PTR = nnn <BYTES>
^PTR = "filename"
^PTR = ("filename")
^PTR = ("filename", nnn)
... | https://github.com/planetarypy/planetaryimage/blob/ee9aef4746ff7a003b1457565acb13f5f1db0375/planetaryimage/pds3image.py#L24-L58 |
planetarypy/planetaryimage | planetaryimage/pds3image.py | PDS3Image._save | def _save(self, file_to_write, overwrite):
"""Save PDS3Image object as PDS3 file.
Parameters
----------
filename: Set filename for the pds image to be saved.
Overwrite: Use this keyword to save image with same filename.
Usage: image.save('temp.IMG', overwrite=True)
... | python | def _save(self, file_to_write, overwrite):
"""Save PDS3Image object as PDS3 file.
Parameters
----------
filename: Set filename for the pds image to be saved.
Overwrite: Use this keyword to save image with same filename.
Usage: image.save('temp.IMG', overwrite=True)
... | Save PDS3Image object as PDS3 file.
Parameters
----------
filename: Set filename for the pds image to be saved.
Overwrite: Use this keyword to save image with same filename.
Usage: image.save('temp.IMG', overwrite=True) | https://github.com/planetarypy/planetaryimage/blob/ee9aef4746ff7a003b1457565acb13f5f1db0375/planetaryimage/pds3image.py#L129-L181 |
planetarypy/planetaryimage | planetaryimage/pds3image.py | PDS3Image._create_label | def _create_label(self, array):
"""Create sample PDS3 label for NumPy Array.
It is called by 'image.py' to create PDS3Image object
from Numpy Array.
Returns
-------
PVLModule label for the given NumPy array.
Usage: self.label = _create_label(array)
"""
... | python | def _create_label(self, array):
"""Create sample PDS3 label for NumPy Array.
It is called by 'image.py' to create PDS3Image object
from Numpy Array.
Returns
-------
PVLModule label for the given NumPy array.
Usage: self.label = _create_label(array)
"""
... | Create sample PDS3 label for NumPy Array.
It is called by 'image.py' to create PDS3Image object
from Numpy Array.
Returns
-------
PVLModule label for the given NumPy array.
Usage: self.label = _create_label(array) | https://github.com/planetarypy/planetaryimage/blob/ee9aef4746ff7a003b1457565acb13f5f1db0375/planetaryimage/pds3image.py#L183-L222 |
planetarypy/planetaryimage | planetaryimage/pds3image.py | PDS3Image._update_label | def _update_label(self, label, array):
"""Update PDS3 label for NumPy Array.
It is called by '_create_label' to update label values
such as,
- ^IMAGE, RECORD_BYTES
- STANDARD_DEVIATION
- MAXIMUM, MINIMUM
- MEDIAN, MEAN
Returns
-------
Upda... | python | def _update_label(self, label, array):
"""Update PDS3 label for NumPy Array.
It is called by '_create_label' to update label values
such as,
- ^IMAGE, RECORD_BYTES
- STANDARD_DEVIATION
- MAXIMUM, MINIMUM
- MEDIAN, MEAN
Returns
-------
Upda... | Update PDS3 label for NumPy Array.
It is called by '_create_label' to update label values
such as,
- ^IMAGE, RECORD_BYTES
- STANDARD_DEVIATION
- MAXIMUM, MINIMUM
- MEDIAN, MEAN
Returns
-------
Update label module for the NumPy array.
Usag... | https://github.com/planetarypy/planetaryimage/blob/ee9aef4746ff7a003b1457565acb13f5f1db0375/planetaryimage/pds3image.py#L224-L259 |
planetarypy/planetaryimage | planetaryimage/pds3image.py | PDS3Image.dtype | def dtype(self):
"""Pixel data type."""
try:
return self.data.dtype
except AttributeError:
return numpy.dtype('%s%d' % (self._sample_type, self._sample_bytes)) | python | def dtype(self):
"""Pixel data type."""
try:
return self.data.dtype
except AttributeError:
return numpy.dtype('%s%d' % (self._sample_type, self._sample_bytes)) | Pixel data type. | https://github.com/planetarypy/planetaryimage/blob/ee9aef4746ff7a003b1457565acb13f5f1db0375/planetaryimage/pds3image.py#L336-L341 |
web-push-libs/encrypted-content-encoding | python/http_ece/__init__.py | derive_key | def derive_key(mode, version, salt, key,
private_key, dh, auth_secret,
keyid, keylabel="P-256"):
"""Derive the encryption key
:param mode: operational mode (encrypt or decrypt)
:type mode: enumerate('encrypt', 'decrypt)
:param salt: encryption salt value
:type salt: st... | python | def derive_key(mode, version, salt, key,
private_key, dh, auth_secret,
keyid, keylabel="P-256"):
"""Derive the encryption key
:param mode: operational mode (encrypt or decrypt)
:type mode: enumerate('encrypt', 'decrypt)
:param salt: encryption salt value
:type salt: st... | Derive the encryption key
:param mode: operational mode (encrypt or decrypt)
:type mode: enumerate('encrypt', 'decrypt)
:param salt: encryption salt value
:type salt: str
:param key: raw key
:type key: str
:param private_key: DH private key
:type key: object
:param dh: Diffie Helman... | https://github.com/web-push-libs/encrypted-content-encoding/blob/849aebea751752e17fc84a64ce1bbf65dc994e6c/python/http_ece/__init__.py#L37-L161 |
web-push-libs/encrypted-content-encoding | python/http_ece/__init__.py | iv | def iv(base, counter):
"""Generate an initialization vector.
"""
if (counter >> 64) != 0:
raise ECEException(u"Counter too big")
(mask,) = struct.unpack("!Q", base[4:])
return base[:4] + struct.pack("!Q", counter ^ mask) | python | def iv(base, counter):
"""Generate an initialization vector.
"""
if (counter >> 64) != 0:
raise ECEException(u"Counter too big")
(mask,) = struct.unpack("!Q", base[4:])
return base[:4] + struct.pack("!Q", counter ^ mask) | Generate an initialization vector. | https://github.com/web-push-libs/encrypted-content-encoding/blob/849aebea751752e17fc84a64ce1bbf65dc994e6c/python/http_ece/__init__.py#L164-L171 |
web-push-libs/encrypted-content-encoding | python/http_ece/__init__.py | decrypt | def decrypt(content, salt=None, key=None,
private_key=None, dh=None, auth_secret=None,
keyid=None, keylabel="P-256",
rs=4096, version="aes128gcm"):
"""
Decrypt a data block
:param content: Data to be decrypted
:type content: str
:param salt: Encryption salt
:... | python | def decrypt(content, salt=None, key=None,
private_key=None, dh=None, auth_secret=None,
keyid=None, keylabel="P-256",
rs=4096, version="aes128gcm"):
"""
Decrypt a data block
:param content: Data to be decrypted
:type content: str
:param salt: Encryption salt
:... | Decrypt a data block
:param content: Data to be decrypted
:type content: str
:param salt: Encryption salt
:type salt: str
:param key: local public key
:type key: str
:param private_key: DH private key
:type key: object
:param keyid: Internal key identifier for private key info
:... | https://github.com/web-push-libs/encrypted-content-encoding/blob/849aebea751752e17fc84a64ce1bbf65dc994e6c/python/http_ece/__init__.py#L174-L294 |
web-push-libs/encrypted-content-encoding | python/http_ece/__init__.py | encrypt | def encrypt(content, salt=None, key=None,
private_key=None, dh=None, auth_secret=None,
keyid=None, keylabel="P-256",
rs=4096, version="aes128gcm"):
"""
Encrypt a data block
:param content: block of data to encrypt
:type content: str
:param salt: Encryption salt
... | python | def encrypt(content, salt=None, key=None,
private_key=None, dh=None, auth_secret=None,
keyid=None, keylabel="P-256",
rs=4096, version="aes128gcm"):
"""
Encrypt a data block
:param content: block of data to encrypt
:type content: str
:param salt: Encryption salt
... | Encrypt a data block
:param content: block of data to encrypt
:type content: str
:param salt: Encryption salt
:type salt: str
:param key: Encryption key data
:type key: str
:param private_key: DH private key
:type key: object
:param keyid: Internal key identifier for private key inf... | https://github.com/web-push-libs/encrypted-content-encoding/blob/849aebea751752e17fc84a64ce1bbf65dc994e6c/python/http_ece/__init__.py#L297-L405 |
varlink/python | varlink/error.py | VarlinkError.parameters | def parameters(self, namespaced=False):
"""returns the exception varlink error parameters"""
if namespaced:
return json.loads(json.dumps(self.args[0]['parameters']), object_hook=lambda d: SimpleNamespace(**d))
else:
return self.args[0].get('parameters') | python | def parameters(self, namespaced=False):
"""returns the exception varlink error parameters"""
if namespaced:
return json.loads(json.dumps(self.args[0]['parameters']), object_hook=lambda d: SimpleNamespace(**d))
else:
return self.args[0].get('parameters') | returns the exception varlink error parameters | https://github.com/varlink/python/blob/b021a29dd9def06b03416d20e8b37be39c3edd33/varlink/error.py#L66-L71 |
varlink/python | varlink/server.py | Service.GetInfo | def GetInfo(self):
"""The standardized org.varlink.service.GetInfo() varlink method."""
return {
'vendor': self.vendor,
'product': self.product,
'version': self.version,
'url': self.url,
'interfaces': list(self.interfaces.keys())
} | python | def GetInfo(self):
"""The standardized org.varlink.service.GetInfo() varlink method."""
return {
'vendor': self.vendor,
'product': self.product,
'version': self.version,
'url': self.url,
'interfaces': list(self.interfaces.keys())
} | The standardized org.varlink.service.GetInfo() varlink method. | https://github.com/varlink/python/blob/b021a29dd9def06b03416d20e8b37be39c3edd33/varlink/server.py#L94-L102 |
varlink/python | varlink/server.py | Service.GetInterfaceDescription | def GetInterfaceDescription(self, interface):
"""The standardized org.varlink.service.GetInterfaceDescription() varlink method."""
try:
i = self.interfaces[interface]
except KeyError:
raise InterfaceNotFound(interface)
return {'description': i.description} | python | def GetInterfaceDescription(self, interface):
"""The standardized org.varlink.service.GetInterfaceDescription() varlink method."""
try:
i = self.interfaces[interface]
except KeyError:
raise InterfaceNotFound(interface)
return {'description': i.description} | The standardized org.varlink.service.GetInterfaceDescription() varlink method. | https://github.com/varlink/python/blob/b021a29dd9def06b03416d20e8b37be39c3edd33/varlink/server.py#L104-L111 |
varlink/python | varlink/server.py | Service.handle | def handle(self, message, _server=None, _request=None):
"""This generator function handles any incoming message.
Write any returned bytes to the output stream.
>>> for outgoing_message in service.handle(incoming_message):
>>> connection.write(outgoing_message)
"""
... | python | def handle(self, message, _server=None, _request=None):
"""This generator function handles any incoming message.
Write any returned bytes to the output stream.
>>> for outgoing_message in service.handle(incoming_message):
>>> connection.write(outgoing_message)
"""
... | This generator function handles any incoming message.
Write any returned bytes to the output stream.
>>> for outgoing_message in service.handle(incoming_message):
>>> connection.write(outgoing_message) | https://github.com/varlink/python/blob/b021a29dd9def06b03416d20e8b37be39c3edd33/varlink/server.py#L227-L252 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.