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_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
ahwillia/tensortools
tensortools/visualization.py
_broadcast_arg
def _broadcast_arg(U, arg, argtype, name): """Broadcasts plotting option `arg` to all factors. Args: U : KTensor arg : argument provided by the user argtype : expected type for arg name : name of the variable, used for error handling Returns: iterable version of arg...
python
def _broadcast_arg(U, arg, argtype, name): """Broadcasts plotting option `arg` to all factors. Args: U : KTensor arg : argument provided by the user argtype : expected type for arg name : name of the variable, used for error handling Returns: iterable version of arg...
[ "def", "_broadcast_arg", "(", "U", ",", "arg", ",", "argtype", ",", "name", ")", ":", "# if input is not iterable, broadcast it all dimensions of the tensor", "if", "arg", "is", "None", "or", "isinstance", "(", "arg", ",", "argtype", ")", ":", "return", "[", "ar...
Broadcasts plotting option `arg` to all factors. Args: U : KTensor arg : argument provided by the user argtype : expected type for arg name : name of the variable, used for error handling Returns: iterable version of arg of length U.ndim
[ "Broadcasts", "plotting", "option", "arg", "to", "all", "factors", "." ]
train
https://github.com/ahwillia/tensortools/blob/f375633ec621caa96665a56205dcf932590d4a6e/tensortools/visualization.py#L248-L282
ahwillia/tensortools
tensortools/optimize/optim_utils.py
_check_cpd_inputs
def _check_cpd_inputs(X, rank): """Checks that inputs to optimization function are appropriate. Parameters ---------- X : ndarray Tensor used for fitting CP decomposition. rank : int Rank of low rank decomposition. Raises ------ ValueError: If inputs are not suited for ...
python
def _check_cpd_inputs(X, rank): """Checks that inputs to optimization function are appropriate. Parameters ---------- X : ndarray Tensor used for fitting CP decomposition. rank : int Rank of low rank decomposition. Raises ------ ValueError: If inputs are not suited for ...
[ "def", "_check_cpd_inputs", "(", "X", ",", "rank", ")", ":", "if", "X", ".", "ndim", "<", "3", ":", "raise", "ValueError", "(", "\"Array with X.ndim > 2 expected.\"", ")", "if", "rank", "<=", "0", "or", "not", "isinstance", "(", "rank", ",", "int", ")", ...
Checks that inputs to optimization function are appropriate. Parameters ---------- X : ndarray Tensor used for fitting CP decomposition. rank : int Rank of low rank decomposition. Raises ------ ValueError: If inputs are not suited for CP decomposition.
[ "Checks", "that", "inputs", "to", "optimization", "function", "are", "appropriate", "." ]
train
https://github.com/ahwillia/tensortools/blob/f375633ec621caa96665a56205dcf932590d4a6e/tensortools/optimize/optim_utils.py#L11-L28
ahwillia/tensortools
tensortools/optimize/optim_utils.py
_get_initial_ktensor
def _get_initial_ktensor(init, X, rank, random_state, scale_norm=True): """ Parameters ---------- init : str Specifies type of initializations ('randn', 'rand') X : ndarray Tensor that the decomposition is fit to. rank : int Rank of decomposition random_state : Random...
python
def _get_initial_ktensor(init, X, rank, random_state, scale_norm=True): """ Parameters ---------- init : str Specifies type of initializations ('randn', 'rand') X : ndarray Tensor that the decomposition is fit to. rank : int Rank of decomposition random_state : Random...
[ "def", "_get_initial_ktensor", "(", "init", ",", "X", ",", "rank", ",", "random_state", ",", "scale_norm", "=", "True", ")", ":", "normX", "=", "linalg", ".", "norm", "(", "X", ")", "if", "scale_norm", "else", "None", "if", "init", "==", "'randn'", ":"...
Parameters ---------- init : str Specifies type of initializations ('randn', 'rand') X : ndarray Tensor that the decomposition is fit to. rank : int Rank of decomposition random_state : RandomState or int Specifies seed for random number generator scale_norm : boo...
[ "Parameters", "----------", "init", ":", "str", "Specifies", "type", "of", "initializations", "(", "randn", "rand", ")", "X", ":", "ndarray", "Tensor", "that", "the", "decomposition", "is", "fit", "to", ".", "rank", ":", "int", "Rank", "of", "decomposition",...
train
https://github.com/ahwillia/tensortools/blob/f375633ec621caa96665a56205dcf932590d4a6e/tensortools/optimize/optim_utils.py#L31-L71
ahwillia/tensortools
tensortools/optimize/optim_utils.py
FitResult.still_optimizing
def still_optimizing(self): """True unless converged or maximum iterations/time exceeded.""" # Check if we need to give up on optimizing. if (self.iterations > self.max_iter) or (self.time_elapsed() > self.max_time): return False # Always optimize for at least 'min_iter' it...
python
def still_optimizing(self): """True unless converged or maximum iterations/time exceeded.""" # Check if we need to give up on optimizing. if (self.iterations > self.max_iter) or (self.time_elapsed() > self.max_time): return False # Always optimize for at least 'min_iter' it...
[ "def", "still_optimizing", "(", "self", ")", ":", "# Check if we need to give up on optimizing.", "if", "(", "self", ".", "iterations", ">", "self", ".", "max_iter", ")", "or", "(", "self", ".", "time_elapsed", "(", ")", ">", "self", ".", "max_time", ")", ":...
True unless converged or maximum iterations/time exceeded.
[ "True", "unless", "converged", "or", "maximum", "iterations", "/", "time", "exceeded", "." ]
train
https://github.com/ahwillia/tensortools/blob/f375633ec621caa96665a56205dcf932590d4a6e/tensortools/optimize/optim_utils.py#L126-L140
ahwillia/tensortools
tensortools/data/random_tensor.py
_check_random_state
def _check_random_state(random_state): """Checks and processes user input for seeding random numbers. Parameters ---------- random_state : int, RandomState instance or None If int, a RandomState instance is created with this integer seed. If RandomState instance, random_state is returne...
python
def _check_random_state(random_state): """Checks and processes user input for seeding random numbers. Parameters ---------- random_state : int, RandomState instance or None If int, a RandomState instance is created with this integer seed. If RandomState instance, random_state is returne...
[ "def", "_check_random_state", "(", "random_state", ")", ":", "if", "random_state", "is", "None", "or", "isinstance", "(", "random_state", ",", "int", ")", ":", "return", "sci", ".", "random", ".", "RandomState", "(", "random_state", ")", "elif", "isinstance", ...
Checks and processes user input for seeding random numbers. Parameters ---------- random_state : int, RandomState instance or None If int, a RandomState instance is created with this integer seed. If RandomState instance, random_state is returned; If None, a RandomState instance is ...
[ "Checks", "and", "processes", "user", "input", "for", "seeding", "random", "numbers", "." ]
train
https://github.com/ahwillia/tensortools/blob/f375633ec621caa96665a56205dcf932590d4a6e/tensortools/data/random_tensor.py#L10-L34
ahwillia/tensortools
tensortools/data/random_tensor.py
randn_ktensor
def randn_ktensor(shape, rank, norm=None, random_state=None): """ Generates a random N-way tensor with rank R, where the entries are drawn from the standard normal distribution. Parameters ---------- shape : tuple shape of the tensor rank : integer rank of the tensor n...
python
def randn_ktensor(shape, rank, norm=None, random_state=None): """ Generates a random N-way tensor with rank R, where the entries are drawn from the standard normal distribution. Parameters ---------- shape : tuple shape of the tensor rank : integer rank of the tensor n...
[ "def", "randn_ktensor", "(", "shape", ",", "rank", ",", "norm", "=", "None", ",", "random_state", "=", "None", ")", ":", "# Check input.", "rns", "=", "_check_random_state", "(", "random_state", ")", "# Draw low-rank factor matrices with i.i.d. Gaussian elements.", "f...
Generates a random N-way tensor with rank R, where the entries are drawn from the standard normal distribution. Parameters ---------- shape : tuple shape of the tensor rank : integer rank of the tensor norm : float or None, optional (defaults: None) If not None, the fa...
[ "Generates", "a", "random", "N", "-", "way", "tensor", "with", "rank", "R", "where", "the", "entries", "are", "drawn", "from", "the", "standard", "normal", "distribution", "." ]
train
https://github.com/ahwillia/tensortools/blob/f375633ec621caa96665a56205dcf932590d4a6e/tensortools/data/random_tensor.py#L47-L88
ahwillia/tensortools
tensortools/data/random_tensor.py
rand_ktensor
def rand_ktensor(shape, rank, norm=None, random_state=None): """ Generates a random N-way tensor with rank R, where the entries are drawn from the standard uniform distribution in the interval [0.0,1]. Parameters ---------- shape : tuple shape of the tensor rank : integer r...
python
def rand_ktensor(shape, rank, norm=None, random_state=None): """ Generates a random N-way tensor with rank R, where the entries are drawn from the standard uniform distribution in the interval [0.0,1]. Parameters ---------- shape : tuple shape of the tensor rank : integer r...
[ "def", "rand_ktensor", "(", "shape", ",", "rank", ",", "norm", "=", "None", ",", "random_state", "=", "None", ")", ":", "# Check input.", "rns", "=", "_check_random_state", "(", "random_state", ")", "# Randomize low-rank factor matrices i.i.d. uniform random elements.",...
Generates a random N-way tensor with rank R, where the entries are drawn from the standard uniform distribution in the interval [0.0,1]. Parameters ---------- shape : tuple shape of the tensor rank : integer rank of the tensor norm : float or None, optional (defaults: None) ...
[ "Generates", "a", "random", "N", "-", "way", "tensor", "with", "rank", "R", "where", "the", "entries", "are", "drawn", "from", "the", "standard", "uniform", "distribution", "in", "the", "interval", "[", "0", ".", "0", "1", "]", "." ]
train
https://github.com/ahwillia/tensortools/blob/f375633ec621caa96665a56205dcf932590d4a6e/tensortools/data/random_tensor.py#L91-L136
ahwillia/tensortools
tensortools/optimize/mcp_als.py
mcp_als
def mcp_als(X, rank, mask, random_state=None, init='randn', **options): """Fits CP Decomposition with missing data using Alternating Least Squares (ALS). Parameters ---------- X : (I_1, ..., I_N) array_like A tensor with ``X.ndim >= 3``. rank : integer The `rank` sets the number of...
python
def mcp_als(X, rank, mask, random_state=None, init='randn', **options): """Fits CP Decomposition with missing data using Alternating Least Squares (ALS). Parameters ---------- X : (I_1, ..., I_N) array_like A tensor with ``X.ndim >= 3``. rank : integer The `rank` sets the number of...
[ "def", "mcp_als", "(", "X", ",", "rank", ",", "mask", ",", "random_state", "=", "None", ",", "init", "=", "'randn'", ",", "*", "*", "options", ")", ":", "# Check inputs.", "optim_utils", ".", "_check_cpd_inputs", "(", "X", ",", "rank", ")", "# Initialize...
Fits CP Decomposition with missing data using Alternating Least Squares (ALS). Parameters ---------- X : (I_1, ..., I_N) array_like A tensor with ``X.ndim >= 3``. rank : integer The `rank` sets the number of components to be computed. mask : (I_1, ..., I_N) array_like A bi...
[ "Fits", "CP", "Decomposition", "with", "missing", "data", "using", "Alternating", "Least", "Squares", "(", "ALS", ")", "." ]
train
https://github.com/ahwillia/tensortools/blob/f375633ec621caa96665a56205dcf932590d4a6e/tensortools/optimize/mcp_als.py#L16-L127
ahwillia/tensortools
tensortools/optimize/ncp_bcd.py
ncp_bcd
def ncp_bcd(X, rank, random_state=None, init='rand', **options): """ Fits nonnegative CP Decomposition using the Block Coordinate Descent (BCD) Method. Parameters ---------- X : (I_1, ..., I_N) array_like A real array with nonnegative entries and ``X.ndim >= 3``. rank : integer ...
python
def ncp_bcd(X, rank, random_state=None, init='rand', **options): """ Fits nonnegative CP Decomposition using the Block Coordinate Descent (BCD) Method. Parameters ---------- X : (I_1, ..., I_N) array_like A real array with nonnegative entries and ``X.ndim >= 3``. rank : integer ...
[ "def", "ncp_bcd", "(", "X", ",", "rank", ",", "random_state", "=", "None", ",", "init", "=", "'rand'", ",", "*", "*", "options", ")", ":", "# Check inputs.", "optim_utils", ".", "_check_cpd_inputs", "(", "X", ",", "rank", ")", "# Store norm of X for computin...
Fits nonnegative CP Decomposition using the Block Coordinate Descent (BCD) Method. Parameters ---------- X : (I_1, ..., I_N) array_like A real array with nonnegative entries and ``X.ndim >= 3``. rank : integer The `rank` sets the number of components to be computed. random_sta...
[ "Fits", "nonnegative", "CP", "Decomposition", "using", "the", "Block", "Coordinate", "Descent", "(", "BCD", ")", "Method", "." ]
train
https://github.com/ahwillia/tensortools/blob/f375633ec621caa96665a56205dcf932590d4a6e/tensortools/optimize/ncp_bcd.py#L16-L155
ahwillia/tensortools
tensortools/optimize/ncp_hals.py
ncp_hals
def ncp_hals(X, rank, random_state=None, init='rand', **options): """ Fits nonnegtaive CP Decomposition using the Hierarcial Alternating Least Squares (HALS) Method. Parameters ---------- X : (I_1, ..., I_N) array_like A real array with nonnegative entries and ``X.ndim >= 3``. rank...
python
def ncp_hals(X, rank, random_state=None, init='rand', **options): """ Fits nonnegtaive CP Decomposition using the Hierarcial Alternating Least Squares (HALS) Method. Parameters ---------- X : (I_1, ..., I_N) array_like A real array with nonnegative entries and ``X.ndim >= 3``. rank...
[ "def", "ncp_hals", "(", "X", ",", "rank", ",", "random_state", "=", "None", ",", "init", "=", "'rand'", ",", "*", "*", "options", ")", ":", "# Check inputs.", "optim_utils", ".", "_check_cpd_inputs", "(", "X", ",", "rank", ")", "# Initialize problem.", "U"...
Fits nonnegtaive CP Decomposition using the Hierarcial Alternating Least Squares (HALS) Method. Parameters ---------- X : (I_1, ..., I_N) array_like A real array with nonnegative entries and ``X.ndim >= 3``. rank : integer The `rank` sets the number of components to be computed. ...
[ "Fits", "nonnegtaive", "CP", "Decomposition", "using", "the", "Hierarcial", "Alternating", "Least", "Squares", "(", "HALS", ")", "Method", "." ]
train
https://github.com/ahwillia/tensortools/blob/f375633ec621caa96665a56205dcf932590d4a6e/tensortools/optimize/ncp_hals.py#L18-L130
ahwillia/tensortools
tensortools/optimize/cp_als.py
cp_als
def cp_als(X, rank, random_state=None, init='randn', **options): """Fits CP Decomposition using Alternating Least Squares (ALS). Parameters ---------- X : (I_1, ..., I_N) array_like A tensor with ``X.ndim >= 3``. rank : integer The `rank` sets the number of components to be compute...
python
def cp_als(X, rank, random_state=None, init='randn', **options): """Fits CP Decomposition using Alternating Least Squares (ALS). Parameters ---------- X : (I_1, ..., I_N) array_like A tensor with ``X.ndim >= 3``. rank : integer The `rank` sets the number of components to be compute...
[ "def", "cp_als", "(", "X", ",", "rank", ",", "random_state", "=", "None", ",", "init", "=", "'randn'", ",", "*", "*", "options", ")", ":", "# Check inputs.", "optim_utils", ".", "_check_cpd_inputs", "(", "X", ",", "rank", ")", "# Initialize problem.", "U",...
Fits CP Decomposition using Alternating Least Squares (ALS). Parameters ---------- X : (I_1, ..., I_N) array_like A tensor with ``X.ndim >= 3``. rank : integer The `rank` sets the number of components to be computed. random_state : integer, ``RandomState``, or ``None``, optional (...
[ "Fits", "CP", "Decomposition", "using", "Alternating", "Least", "Squares", "(", "ALS", ")", "." ]
train
https://github.com/ahwillia/tensortools/blob/f375633ec621caa96665a56205dcf932590d4a6e/tensortools/optimize/cp_als.py#L16-L134
ahwillia/tensortools
tensortools/ensemble.py
Ensemble.fit
def fit(self, X, ranks, replicates=1, verbose=True): """ Fits CP tensor decompositions for different choices of rank. Parameters ---------- X : array_like Real tensor ranks : int, or iterable iterable specifying number of components in each model ...
python
def fit(self, X, ranks, replicates=1, verbose=True): """ Fits CP tensor decompositions for different choices of rank. Parameters ---------- X : array_like Real tensor ranks : int, or iterable iterable specifying number of components in each model ...
[ "def", "fit", "(", "self", ",", "X", ",", "ranks", ",", "replicates", "=", "1", ",", "verbose", "=", "True", ")", ":", "# Make ranks iterable if necessary.", "if", "not", "isinstance", "(", "ranks", ",", "collections", ".", "Iterable", ")", ":", "ranks", ...
Fits CP tensor decompositions for different choices of rank. Parameters ---------- X : array_like Real tensor ranks : int, or iterable iterable specifying number of components in each model replicates: int number of models to fit at each rank ...
[ "Fits", "CP", "tensor", "decompositions", "for", "different", "choices", "of", "rank", "." ]
train
https://github.com/ahwillia/tensortools/blob/f375633ec621caa96665a56205dcf932590d4a6e/tensortools/ensemble.py#L57-L128
ahwillia/tensortools
tensortools/ensemble.py
Ensemble.objectives
def objectives(self, rank): """Returns objective values of models with specified rank. """ self._check_rank(rank) return [result.obj for result in self.results[rank]]
python
def objectives(self, rank): """Returns objective values of models with specified rank. """ self._check_rank(rank) return [result.obj for result in self.results[rank]]
[ "def", "objectives", "(", "self", ",", "rank", ")", ":", "self", ".", "_check_rank", "(", "rank", ")", "return", "[", "result", ".", "obj", "for", "result", "in", "self", ".", "results", "[", "rank", "]", "]" ]
Returns objective values of models with specified rank.
[ "Returns", "objective", "values", "of", "models", "with", "specified", "rank", "." ]
train
https://github.com/ahwillia/tensortools/blob/f375633ec621caa96665a56205dcf932590d4a6e/tensortools/ensemble.py#L130-L134
ahwillia/tensortools
tensortools/ensemble.py
Ensemble.similarities
def similarities(self, rank): """Returns similarity scores for models with specified rank. """ self._check_rank(rank) return [result.similarity for result in self.results[rank]]
python
def similarities(self, rank): """Returns similarity scores for models with specified rank. """ self._check_rank(rank) return [result.similarity for result in self.results[rank]]
[ "def", "similarities", "(", "self", ",", "rank", ")", ":", "self", ".", "_check_rank", "(", "rank", ")", "return", "[", "result", ".", "similarity", "for", "result", "in", "self", ".", "results", "[", "rank", "]", "]" ]
Returns similarity scores for models with specified rank.
[ "Returns", "similarity", "scores", "for", "models", "with", "specified", "rank", "." ]
train
https://github.com/ahwillia/tensortools/blob/f375633ec621caa96665a56205dcf932590d4a6e/tensortools/ensemble.py#L136-L140
ahwillia/tensortools
tensortools/ensemble.py
Ensemble.factors
def factors(self, rank): """Returns KTensor factors for models with specified rank. """ self._check_rank(rank) return [result.factors for result in self.results[rank]]
python
def factors(self, rank): """Returns KTensor factors for models with specified rank. """ self._check_rank(rank) return [result.factors for result in self.results[rank]]
[ "def", "factors", "(", "self", ",", "rank", ")", ":", "self", ".", "_check_rank", "(", "rank", ")", "return", "[", "result", ".", "factors", "for", "result", "in", "self", ".", "results", "[", "rank", "]", "]" ]
Returns KTensor factors for models with specified rank.
[ "Returns", "KTensor", "factors", "for", "models", "with", "specified", "rank", "." ]
train
https://github.com/ahwillia/tensortools/blob/f375633ec621caa96665a56205dcf932590d4a6e/tensortools/ensemble.py#L142-L146
OCA/odoorpc
odoorpc/env.py
Environment.commit
def commit(self): """Commit dirty records to the server. This method is automatically called when the `auto_commit` option is set to `True` (default). It can be useful to set the former option to `False` to get better performance by reducing the number of RPC requests generated. ...
python
def commit(self): """Commit dirty records to the server. This method is automatically called when the `auto_commit` option is set to `True` (default). It can be useful to set the former option to `False` to get better performance by reducing the number of RPC requests generated. ...
[ "def", "commit", "(", "self", ")", ":", "# Iterate on a new set, as we remove record during iteration from the", "# original one", "for", "record", "in", "set", "(", "self", ".", "dirty", ")", ":", "values", "=", "{", "}", "for", "field", "in", "record", ".", "_...
Commit dirty records to the server. This method is automatically called when the `auto_commit` option is set to `True` (default). It can be useful to set the former option to `False` to get better performance by reducing the number of RPC requests generated. With `auto_commit` set to `T...
[ "Commit", "dirty", "records", "to", "the", "server", ".", "This", "method", "is", "automatically", "called", "when", "the", "auto_commit", "option", "is", "set", "to", "True", "(", "default", ")", ".", "It", "can", "be", "useful", "to", "set", "the", "fo...
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/env.py#L116-L163
OCA/odoorpc
odoorpc/env.py
Environment.ref
def ref(self, xml_id): """Return the record corresponding to the given `xml_id` (also called external ID). Raise an :class:`RPCError <odoorpc.error.RPCError>` if no record is found. .. doctest:: >>> odoo.env.ref('base.lang_en') Recordset('res.lang', [1])...
python
def ref(self, xml_id): """Return the record corresponding to the given `xml_id` (also called external ID). Raise an :class:`RPCError <odoorpc.error.RPCError>` if no record is found. .. doctest:: >>> odoo.env.ref('base.lang_en') Recordset('res.lang', [1])...
[ "def", "ref", "(", "self", ",", "xml_id", ")", ":", "model", ",", "id_", "=", "self", ".", "_odoo", ".", "execute", "(", "'ir.model.data'", ",", "'xmlid_to_res_model_res_id'", ",", "xml_id", ",", "True", ")", "return", "self", "[", "model", "]", ".", "...
Return the record corresponding to the given `xml_id` (also called external ID). Raise an :class:`RPCError <odoorpc.error.RPCError>` if no record is found. .. doctest:: >>> odoo.env.ref('base.lang_en') Recordset('res.lang', [1]) :return: a :class:`odoor...
[ "Return", "the", "record", "corresponding", "to", "the", "given", "xml_id", "(", "also", "called", "external", "ID", ")", ".", "Raise", "an", ":", "class", ":", "RPCError", "<odoorpc", ".", "error", ".", "RPCError", ">", "if", "no", "record", "is", "foun...
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/env.py#L180-L196
OCA/odoorpc
odoorpc/env.py
Environment._create_model_class
def _create_model_class(self, model): """Generate the model proxy class. :return: a :class:`odoorpc.models.Model` class """ cls_name = model.replace('.', '_') # Hack for Python 2 (no need to do this for Python 3) if sys.version_info[0] < 3: if isinstance(cls_...
python
def _create_model_class(self, model): """Generate the model proxy class. :return: a :class:`odoorpc.models.Model` class """ cls_name = model.replace('.', '_') # Hack for Python 2 (no need to do this for Python 3) if sys.version_info[0] < 3: if isinstance(cls_...
[ "def", "_create_model_class", "(", "self", ",", "model", ")", ":", "cls_name", "=", "model", ".", "replace", "(", "'.'", ",", "'_'", ")", "# Hack for Python 2 (no need to do this for Python 3)", "if", "sys", ".", "version_info", "[", "0", "]", "<", "3", ":", ...
Generate the model proxy class. :return: a :class:`odoorpc.models.Model` class
[ "Generate", "the", "model", "proxy", "class", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/env.py#L313-L343
OCA/odoorpc
odoorpc/session.py
get_all
def get_all(rc_file='~/.odoorpcrc'): """Return all session configurations from the `rc_file` file. >>> import odoorpc >>> from pprint import pprint as pp >>> pp(odoorpc.session.get_all()) # doctest: +SKIP {'foo': {'database': 'db_name', 'host': 'localhost', 'passwd': '...
python
def get_all(rc_file='~/.odoorpcrc'): """Return all session configurations from the `rc_file` file. >>> import odoorpc >>> from pprint import pprint as pp >>> pp(odoorpc.session.get_all()) # doctest: +SKIP {'foo': {'database': 'db_name', 'host': 'localhost', 'passwd': '...
[ "def", "get_all", "(", "rc_file", "=", "'~/.odoorpcrc'", ")", ":", "conf", "=", "ConfigParser", "(", ")", "conf", ".", "read", "(", "[", "os", ".", "path", ".", "expanduser", "(", "rc_file", ")", "]", ")", "sessions", "=", "{", "}", "for", "name", ...
Return all session configurations from the `rc_file` file. >>> import odoorpc >>> from pprint import pprint as pp >>> pp(odoorpc.session.get_all()) # doctest: +SKIP {'foo': {'database': 'db_name', 'host': 'localhost', 'passwd': 'password', 'port': 8069, ...
[ "Return", "all", "session", "configurations", "from", "the", "rc_file", "file", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/session.py#L35-L87
OCA/odoorpc
odoorpc/session.py
get
def get(name, rc_file='~/.odoorpcrc'): """Return the session configuration identified by `name` from the `rc_file` file. >>> import odoorpc >>> from pprint import pprint as pp >>> pp(odoorpc.session.get('foo')) # doctest: +SKIP {'database': 'db_name', 'host': 'localhost', 'passwd':...
python
def get(name, rc_file='~/.odoorpcrc'): """Return the session configuration identified by `name` from the `rc_file` file. >>> import odoorpc >>> from pprint import pprint as pp >>> pp(odoorpc.session.get('foo')) # doctest: +SKIP {'database': 'db_name', 'host': 'localhost', 'passwd':...
[ "def", "get", "(", "name", ",", "rc_file", "=", "'~/.odoorpcrc'", ")", ":", "conf", "=", "ConfigParser", "(", ")", "conf", ".", "read", "(", "[", "os", ".", "path", ".", "expanduser", "(", "rc_file", ")", "]", ")", "if", "not", "conf", ".", "has_se...
Return the session configuration identified by `name` from the `rc_file` file. >>> import odoorpc >>> from pprint import pprint as pp >>> pp(odoorpc.session.get('foo')) # doctest: +SKIP {'database': 'db_name', 'host': 'localhost', 'passwd': 'password', 'port': 8069, 'protocol...
[ "Return", "the", "session", "configuration", "identified", "by", "name", "from", "the", "rc_file", "file", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/session.py#L90-L144
OCA/odoorpc
odoorpc/session.py
save
def save(name, data, rc_file='~/.odoorpcrc'): """Save the `data` session configuration under the name `name` in the `rc_file` file. >>> import odoorpc >>> odoorpc.session.save( ... 'foo', ... {'type': 'ODOO', 'host': 'localhost', 'protocol': 'jsonrpc', ... 'port': 8069, 'timeou...
python
def save(name, data, rc_file='~/.odoorpcrc'): """Save the `data` session configuration under the name `name` in the `rc_file` file. >>> import odoorpc >>> odoorpc.session.save( ... 'foo', ... {'type': 'ODOO', 'host': 'localhost', 'protocol': 'jsonrpc', ... 'port': 8069, 'timeou...
[ "def", "save", "(", "name", ",", "data", ",", "rc_file", "=", "'~/.odoorpcrc'", ")", ":", "conf", "=", "ConfigParser", "(", ")", "conf", ".", "read", "(", "[", "os", ".", "path", ".", "expanduser", "(", "rc_file", ")", "]", ")", "if", "not", "conf"...
Save the `data` session configuration under the name `name` in the `rc_file` file. >>> import odoorpc >>> odoorpc.session.save( ... 'foo', ... {'type': 'ODOO', 'host': 'localhost', 'protocol': 'jsonrpc', ... 'port': 8069, 'timeout': 120, 'database': 'db_name' ... 'user': '...
[ "Save", "the", "data", "session", "configuration", "under", "the", "name", "name", "in", "the", "rc_file", "file", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/session.py#L147-L178
OCA/odoorpc
odoorpc/session.py
remove
def remove(name, rc_file='~/.odoorpcrc'): """Remove the session configuration identified by `name` from the `rc_file` file. >>> import odoorpc >>> odoorpc.session.remove('foo') # doctest: +SKIP .. doctest:: :hide: >>> import odoorpc >>> session = '%s_session' % DB ...
python
def remove(name, rc_file='~/.odoorpcrc'): """Remove the session configuration identified by `name` from the `rc_file` file. >>> import odoorpc >>> odoorpc.session.remove('foo') # doctest: +SKIP .. doctest:: :hide: >>> import odoorpc >>> session = '%s_session' % DB ...
[ "def", "remove", "(", "name", ",", "rc_file", "=", "'~/.odoorpcrc'", ")", ":", "conf", "=", "ConfigParser", "(", ")", "conf", ".", "read", "(", "[", "os", ".", "path", ".", "expanduser", "(", "rc_file", ")", "]", ")", "if", "not", "conf", ".", "has...
Remove the session configuration identified by `name` from the `rc_file` file. >>> import odoorpc >>> odoorpc.session.remove('foo') # doctest: +SKIP .. doctest:: :hide: >>> import odoorpc >>> session = '%s_session' % DB >>> odoorpc.session.remove(session) :rai...
[ "Remove", "the", "session", "configuration", "identified", "by", "name", "from", "the", "rc_file", "file", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/session.py#L181-L204
OCA/odoorpc
odoorpc/tools.py
get_encodings
def get_encodings(hint_encoding='utf-8'): """Used to try different encoding. Function copied from Odoo 11.0 (odoo.loglevels.get_encodings). This piece of code is licensed under the LGPL-v3 and so it is compatible with the LGPL-v3 license of OdooRPC:: - https://github.com/odoo/odoo/blob/11.0/LIC...
python
def get_encodings(hint_encoding='utf-8'): """Used to try different encoding. Function copied from Odoo 11.0 (odoo.loglevels.get_encodings). This piece of code is licensed under the LGPL-v3 and so it is compatible with the LGPL-v3 license of OdooRPC:: - https://github.com/odoo/odoo/blob/11.0/LIC...
[ "def", "get_encodings", "(", "hint_encoding", "=", "'utf-8'", ")", ":", "fallbacks", "=", "{", "'latin1'", ":", "'latin9'", ",", "'iso-8859-1'", ":", "'iso8859-15'", ",", "'cp1252'", ":", "'1252'", ",", "}", "if", "hint_encoding", ":", "yield", "hint_encoding"...
Used to try different encoding. Function copied from Odoo 11.0 (odoo.loglevels.get_encodings). This piece of code is licensed under the LGPL-v3 and so it is compatible with the LGPL-v3 license of OdooRPC:: - https://github.com/odoo/odoo/blob/11.0/LICENSE - https://github.com/odoo/odoo/blob/...
[ "Used", "to", "try", "different", "encoding", ".", "Function", "copied", "from", "Odoo", "11", ".", "0", "(", "odoo", ".", "loglevels", ".", "get_encodings", ")", ".", "This", "piece", "of", "code", "is", "licensed", "under", "the", "LGPL", "-", "v3", ...
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/tools.py#L104-L134
OCA/odoorpc
odoorpc/rpc/jsonrpclib.py
get_json_log_data
def get_json_log_data(data): """Returns a new `data` dictionary with hidden params for log purpose. """ log_data = data for param in LOG_HIDDEN_JSON_PARAMS: if param in data['params']: if log_data is data: log_data = copy.deepcopy(data) log_data['param...
python
def get_json_log_data(data): """Returns a new `data` dictionary with hidden params for log purpose. """ log_data = data for param in LOG_HIDDEN_JSON_PARAMS: if param in data['params']: if log_data is data: log_data = copy.deepcopy(data) log_data['param...
[ "def", "get_json_log_data", "(", "data", ")", ":", "log_data", "=", "data", "for", "param", "in", "LOG_HIDDEN_JSON_PARAMS", ":", "if", "param", "in", "data", "[", "'params'", "]", ":", "if", "log_data", "is", "data", ":", "log_data", "=", "copy", ".", "d...
Returns a new `data` dictionary with hidden params for log purpose.
[ "Returns", "a", "new", "data", "dictionary", "with", "hidden", "params", "for", "log", "purpose", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/rpc/jsonrpclib.py#L61-L71
OCA/odoorpc
odoorpc/odoo.py
ODOO.json
def json(self, url, params): """Low level method to execute JSON queries. It basically performs a request and raises an :class:`odoorpc.error.RPCError` exception if the response contains an error. You have to know the names of each parameter required by the function call...
python
def json(self, url, params): """Low level method to execute JSON queries. It basically performs a request and raises an :class:`odoorpc.error.RPCError` exception if the response contains an error. You have to know the names of each parameter required by the function call...
[ "def", "json", "(", "self", ",", "url", ",", "params", ")", ":", "data", "=", "self", ".", "_connector", ".", "proxy_json", "(", "url", ",", "params", ")", "if", "data", ".", "get", "(", "'error'", ")", ":", "raise", "error", ".", "RPCError", "(", ...
Low level method to execute JSON queries. It basically performs a request and raises an :class:`odoorpc.error.RPCError` exception if the response contains an error. You have to know the names of each parameter required by the function called, and set them in the `params` diction...
[ "Low", "level", "method", "to", "execute", "JSON", "queries", ".", "It", "basically", "performs", "a", "request", "and", "raises", "an", ":", "class", ":", "odoorpc", ".", "error", ".", "RPCError", "exception", "if", "the", "response", "contains", "an", "e...
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/odoo.py#L210-L286
OCA/odoorpc
odoorpc/odoo.py
ODOO.http
def http(self, url, data=None, headers=None): """Low level method to execute raw HTTP queries. .. note:: For low level JSON-RPC queries, see the more convenient :func:`odoorpc.ODOO.json` method instead. You have to know the names of each POST parameter required by the ...
python
def http(self, url, data=None, headers=None): """Low level method to execute raw HTTP queries. .. note:: For low level JSON-RPC queries, see the more convenient :func:`odoorpc.ODOO.json` method instead. You have to know the names of each POST parameter required by the ...
[ "def", "http", "(", "self", ",", "url", ",", "data", "=", "None", ",", "headers", "=", "None", ")", ":", "return", "self", ".", "_connector", ".", "proxy_http", "(", "url", ",", "data", ",", "headers", ")" ]
Low level method to execute raw HTTP queries. .. note:: For low level JSON-RPC queries, see the more convenient :func:`odoorpc.ODOO.json` method instead. You have to know the names of each POST parameter required by the URL, and set them in the `data` string/buffer. ...
[ "Low", "level", "method", "to", "execute", "raw", "HTTP", "queries", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/odoo.py#L288-L321
OCA/odoorpc
odoorpc/odoo.py
ODOO._check_logged_user
def _check_logged_user(self): """Check if a user is logged. Otherwise, an error is raised.""" if not self._env or not self._password or not self._login: raise error.InternalError("Login required")
python
def _check_logged_user(self): """Check if a user is logged. Otherwise, an error is raised.""" if not self._env or not self._password or not self._login: raise error.InternalError("Login required")
[ "def", "_check_logged_user", "(", "self", ")", ":", "if", "not", "self", ".", "_env", "or", "not", "self", ".", "_password", "or", "not", "self", ".", "_login", ":", "raise", "error", ".", "InternalError", "(", "\"Login required\"", ")" ]
Check if a user is logged. Otherwise, an error is raised.
[ "Check", "if", "a", "user", "is", "logged", ".", "Otherwise", "an", "error", "is", "raised", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/odoo.py#L326-L329
OCA/odoorpc
odoorpc/odoo.py
ODOO.login
def login(self, db, login='admin', password='admin'): """Log in as the given `user` with the password `passwd` on the database `db`. .. doctest:: :options: +SKIP >>> odoo.login('db_name', 'admin', 'admin') >>> odoo.env.user.name 'Administrator' ...
python
def login(self, db, login='admin', password='admin'): """Log in as the given `user` with the password `passwd` on the database `db`. .. doctest:: :options: +SKIP >>> odoo.login('db_name', 'admin', 'admin') >>> odoo.env.user.name 'Administrator' ...
[ "def", "login", "(", "self", ",", "db", ",", "login", "=", "'admin'", ",", "password", "=", "'admin'", ")", ":", "# Get the user's ID and generate the corresponding user record", "data", "=", "self", ".", "json", "(", "'/web/session/authenticate'", ",", "{", "'db'...
Log in as the given `user` with the password `passwd` on the database `db`. .. doctest:: :options: +SKIP >>> odoo.login('db_name', 'admin', 'admin') >>> odoo.env.user.name 'Administrator' *Python 2:* :raise: :class:`odoorpc.error.RPCErr...
[ "Log", "in", "as", "the", "given", "user", "with", "the", "password", "passwd", "on", "the", "database", "db", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/odoo.py#L331-L363
OCA/odoorpc
odoorpc/odoo.py
ODOO.logout
def logout(self): """Log out the user. >>> odoo.logout() True *Python 2:* :return: `True` if the operation succeed, `False` if no user was logged :raise: :class:`odoorpc.error.RPCError` :raise: `urllib2.URLError` (connection error) *Python 3:* ...
python
def logout(self): """Log out the user. >>> odoo.logout() True *Python 2:* :return: `True` if the operation succeed, `False` if no user was logged :raise: :class:`odoorpc.error.RPCError` :raise: `urllib2.URLError` (connection error) *Python 3:* ...
[ "def", "logout", "(", "self", ")", ":", "if", "not", "self", ".", "_env", ":", "return", "False", "self", ".", "json", "(", "'/web/session/destroy'", ",", "{", "}", ")", "self", ".", "_env", "=", "None", "self", ".", "_login", "=", "None", "self", ...
Log out the user. >>> odoo.logout() True *Python 2:* :return: `True` if the operation succeed, `False` if no user was logged :raise: :class:`odoorpc.error.RPCError` :raise: `urllib2.URLError` (connection error) *Python 3:* :return: `True` if the opera...
[ "Log", "out", "the", "user", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/odoo.py#L365-L389
OCA/odoorpc
odoorpc/odoo.py
ODOO.execute
def execute(self, model, method, *args): """Execute the `method` of `model`. `*args` parameters varies according to the `method` used. .. doctest:: :options: +SKIP >>> odoo.execute('res.partner', 'read', [1], ['name']) [{'id': 1, 'name': 'YourCompany'}] ...
python
def execute(self, model, method, *args): """Execute the `method` of `model`. `*args` parameters varies according to the `method` used. .. doctest:: :options: +SKIP >>> odoo.execute('res.partner', 'read', [1], ['name']) [{'id': 1, 'name': 'YourCompany'}] ...
[ "def", "execute", "(", "self", ",", "model", ",", "method", ",", "*", "args", ")", ":", "self", ".", "_check_logged_user", "(", ")", "# Execute the query", "args_to_send", "=", "[", "self", ".", "env", ".", "db", ",", "self", ".", "env", ".", "uid", ...
Execute the `method` of `model`. `*args` parameters varies according to the `method` used. .. doctest:: :options: +SKIP >>> odoo.execute('res.partner', 'read', [1], ['name']) [{'id': 1, 'name': 'YourCompany'}] .. doctest:: :hide: >>...
[ "Execute", "the", "method", "of", "model", ".", "*", "args", "parameters", "varies", "according", "to", "the", "method", "used", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/odoo.py#L395-L438
OCA/odoorpc
odoorpc/odoo.py
ODOO.exec_workflow
def exec_workflow(self, model, record_id, signal): """Execute the workflow `signal` on the instance having the ID `record_id` of `model`. *Python 2:* :raise: :class:`odoorpc.error.RPCError` :raise: :class:`odoorpc.error.InternalError` (if not logged) :raise: `urllib2.UR...
python
def exec_workflow(self, model, record_id, signal): """Execute the workflow `signal` on the instance having the ID `record_id` of `model`. *Python 2:* :raise: :class:`odoorpc.error.RPCError` :raise: :class:`odoorpc.error.InternalError` (if not logged) :raise: `urllib2.UR...
[ "def", "exec_workflow", "(", "self", ",", "model", ",", "record_id", ",", "signal", ")", ":", "if", "tools", ".", "v", "(", "self", ".", "version", ")", "[", "0", "]", ">=", "11", ":", "raise", "DeprecationWarning", "(", "u\"Workflows have been removed in ...
Execute the workflow `signal` on the instance having the ID `record_id` of `model`. *Python 2:* :raise: :class:`odoorpc.error.RPCError` :raise: :class:`odoorpc.error.InternalError` (if not logged) :raise: `urllib2.URLError` (connection error) *Python 3:* :rais...
[ "Execute", "the", "workflow", "signal", "on", "the", "instance", "having", "the", "ID", "record_id", "of", "model", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/odoo.py#L489-L517
OCA/odoorpc
odoorpc/odoo.py
ODOO.save
def save(self, name, rc_file='~/.odoorpcrc'): """Save the current :class:`ODOO <odoorpc.ODOO>` instance (a `session`) inside `rc_file` (``~/.odoorpcrc`` by default). This session will be identified by `name`:: >>> import odoorpc >>> odoo = odoorpc.ODOO('localhost', port=...
python
def save(self, name, rc_file='~/.odoorpcrc'): """Save the current :class:`ODOO <odoorpc.ODOO>` instance (a `session`) inside `rc_file` (``~/.odoorpcrc`` by default). This session will be identified by `name`:: >>> import odoorpc >>> odoo = odoorpc.ODOO('localhost', port=...
[ "def", "save", "(", "self", ",", "name", ",", "rc_file", "=", "'~/.odoorpcrc'", ")", ":", "self", ".", "_check_logged_user", "(", ")", "data", "=", "{", "'type'", ":", "self", ".", "__class__", ".", "__name__", ",", "'host'", ":", "self", ".", "host", ...
Save the current :class:`ODOO <odoorpc.ODOO>` instance (a `session`) inside `rc_file` (``~/.odoorpcrc`` by default). This session will be identified by `name`:: >>> import odoorpc >>> odoo = odoorpc.ODOO('localhost', port=8069) >>> odoo.login('db_name', 'admin', 'adm...
[ "Save", "the", "current", ":", "class", ":", "ODOO", "<odoorpc", ".", "ODOO", ">", "instance", "(", "a", "session", ")", "inside", "rc_file", "(", "~", "/", ".", "odoorpcrc", "by", "default", ")", ".", "This", "session", "will", "be", "identified", "by...
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/odoo.py#L523-L559
OCA/odoorpc
odoorpc/odoo.py
ODOO.load
def load(cls, name, rc_file='~/.odoorpcrc'): """Return a connected :class:`ODOO` session identified by `name`: .. doctest:: :options: +SKIP >>> import odoorpc >>> odoo = odoorpc.ODOO.load('foo') Such sessions are stored with the :func:`save <odoorpc...
python
def load(cls, name, rc_file='~/.odoorpcrc'): """Return a connected :class:`ODOO` session identified by `name`: .. doctest:: :options: +SKIP >>> import odoorpc >>> odoo = odoorpc.ODOO.load('foo') Such sessions are stored with the :func:`save <odoorpc...
[ "def", "load", "(", "cls", ",", "name", ",", "rc_file", "=", "'~/.odoorpcrc'", ")", ":", "data", "=", "session", ".", "get", "(", "name", ",", "rc_file", ")", "if", "data", ".", "get", "(", "'type'", ")", "!=", "cls", ".", "__name__", ":", "raise",...
Return a connected :class:`ODOO` session identified by `name`: .. doctest:: :options: +SKIP >>> import odoorpc >>> odoo = odoorpc.ODOO.load('foo') Such sessions are stored with the :func:`save <odoorpc.ODOO.save>` method. *Python 2:* :rais...
[ "Return", "a", "connected", ":", "class", ":", "ODOO", "session", "identified", "by", "name", ":" ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/odoo.py#L562-L597
OCA/odoorpc
odoorpc/odoo.py
ODOO.list
def list(cls, rc_file='~/.odoorpcrc'): """Return a list of all stored sessions available in the `rc_file` file: .. doctest:: :options: +SKIP >>> import odoorpc >>> odoorpc.ODOO.list() ['foo', 'bar'] Use the :func:`save <odoorpc.ODOO.save...
python
def list(cls, rc_file='~/.odoorpcrc'): """Return a list of all stored sessions available in the `rc_file` file: .. doctest:: :options: +SKIP >>> import odoorpc >>> odoorpc.ODOO.list() ['foo', 'bar'] Use the :func:`save <odoorpc.ODOO.save...
[ "def", "list", "(", "cls", ",", "rc_file", "=", "'~/.odoorpcrc'", ")", ":", "sessions", "=", "session", ".", "get_all", "(", "rc_file", ")", "return", "[", "name", "for", "name", "in", "sessions", "if", "sessions", "[", "name", "]", ".", "get", "(", ...
Return a list of all stored sessions available in the `rc_file` file: .. doctest:: :options: +SKIP >>> import odoorpc >>> odoorpc.ODOO.list() ['foo', 'bar'] Use the :func:`save <odoorpc.ODOO.save>` and :func:`load <odoorpc.ODOO.load>` me...
[ "Return", "a", "list", "of", "all", "stored", "sessions", "available", "in", "the", "rc_file", "file", ":" ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/odoo.py#L600-L625
OCA/odoorpc
odoorpc/odoo.py
ODOO.remove
def remove(cls, name, rc_file='~/.odoorpcrc'): """Remove the session identified by `name` from the `rc_file` file: .. doctest:: :options: +SKIP >>> import odoorpc >>> odoorpc.ODOO.remove('foo') True *Python 2:* :raise: `ValueError` (if ...
python
def remove(cls, name, rc_file='~/.odoorpcrc'): """Remove the session identified by `name` from the `rc_file` file: .. doctest:: :options: +SKIP >>> import odoorpc >>> odoorpc.ODOO.remove('foo') True *Python 2:* :raise: `ValueError` (if ...
[ "def", "remove", "(", "cls", ",", "name", ",", "rc_file", "=", "'~/.odoorpcrc'", ")", ":", "data", "=", "session", ".", "get", "(", "name", ",", "rc_file", ")", "if", "data", ".", "get", "(", "'type'", ")", "!=", "cls", ".", "__name__", ":", "raise...
Remove the session identified by `name` from the `rc_file` file: .. doctest:: :options: +SKIP >>> import odoorpc >>> odoorpc.ODOO.remove('foo') True *Python 2:* :raise: `ValueError` (if the session does not exist) :raise: `IOError` ...
[ "Remove", "the", "session", "identified", "by", "name", "from", "the", "rc_file", "file", ":" ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/odoo.py#L629-L655
OCA/odoorpc
odoorpc/db.py
DB.dump
def dump(self, password, db, format_='zip'): """Backup the `db` database. Returns the dump as a binary ZIP file containing the SQL dump file alongside the filestore directory (if any). >>> dump = odoo.db.dump('super_admin_passwd', 'prod') # doctest: +SKIP .. doctest:: :hide...
python
def dump(self, password, db, format_='zip'): """Backup the `db` database. Returns the dump as a binary ZIP file containing the SQL dump file alongside the filestore directory (if any). >>> dump = odoo.db.dump('super_admin_passwd', 'prod') # doctest: +SKIP .. doctest:: :hide...
[ "def", "dump", "(", "self", ",", "password", ",", "db", ",", "format_", "=", "'zip'", ")", ":", "args", "=", "[", "password", ",", "db", "]", "if", "v", "(", "self", ".", "_odoo", ".", "version", ")", "[", "0", "]", ">=", "9", ":", "args", "....
Backup the `db` database. Returns the dump as a binary ZIP file containing the SQL dump file alongside the filestore directory (if any). >>> dump = odoo.db.dump('super_admin_passwd', 'prod') # doctest: +SKIP .. doctest:: :hide: >>> dump = odoo.db.dump(SUPER_PWD, DB) ...
[ "Backup", "the", "db", "database", ".", "Returns", "the", "dump", "as", "a", "binary", "ZIP", "file", "containing", "the", "SQL", "dump", "file", "alongside", "the", "filestore", "directory", "(", "if", "any", ")", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/db.py#L56-L136
OCA/odoorpc
odoorpc/db.py
DB.create
def create(self, password, db, demo=False, lang='en_US', admin_password='admin'): """Request the server to create a new database named `db` which will have `admin_password` as administrator password and localized with the `lang` parameter. You have to set the flag `demo` to `True` in ord...
python
def create(self, password, db, demo=False, lang='en_US', admin_password='admin'): """Request the server to create a new database named `db` which will have `admin_password` as administrator password and localized with the `lang` parameter. You have to set the flag `demo` to `True` in ord...
[ "def", "create", "(", "self", ",", "password", ",", "db", ",", "demo", "=", "False", ",", "lang", "=", "'en_US'", ",", "admin_password", "=", "'admin'", ")", ":", "self", ".", "_odoo", ".", "json", "(", "'/jsonrpc'", ",", "{", "'service'", ":", "'db'...
Request the server to create a new database named `db` which will have `admin_password` as administrator password and localized with the `lang` parameter. You have to set the flag `demo` to `True` in order to insert demonstration data. >>> odoo.db.create('super_admin_passwd', 'p...
[ "Request", "the", "server", "to", "create", "a", "new", "database", "named", "db", "which", "will", "have", "admin_password", "as", "administrator", "password", "and", "localized", "with", "the", "lang", "parameter", ".", "You", "have", "to", "set", "the", "...
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/db.py#L167-L200
OCA/odoorpc
odoorpc/db.py
DB.drop
def drop(self, password, db): """Drop the `db` database. Returns `True` if the database was removed, `False` otherwise (database did not exist): >>> odoo.db.drop('super_admin_passwd', 'test') # doctest: +SKIP True The super administrator password is required to perform this met...
python
def drop(self, password, db): """Drop the `db` database. Returns `True` if the database was removed, `False` otherwise (database did not exist): >>> odoo.db.drop('super_admin_passwd', 'test') # doctest: +SKIP True The super administrator password is required to perform this met...
[ "def", "drop", "(", "self", ",", "password", ",", "db", ")", ":", "if", "self", ".", "_odoo", ".", "_env", "and", "self", ".", "_odoo", ".", "_env", ".", "db", "==", "db", ":", "# Remove the existing session to avoid HTTP session error", "self", ".", "_odo...
Drop the `db` database. Returns `True` if the database was removed, `False` otherwise (database did not exist): >>> odoo.db.drop('super_admin_passwd', 'test') # doctest: +SKIP True The super administrator password is required to perform this method. *Python 2:* :retur...
[ "Drop", "the", "db", "database", ".", "Returns", "True", "if", "the", "database", "was", "removed", "False", "otherwise", "(", "database", "did", "not", "exist", ")", ":" ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/db.py#L202-L231
OCA/odoorpc
odoorpc/db.py
DB.duplicate
def duplicate(self, password, db, new_db): """Duplicate `db' as `new_db`. >>> odoo.db.duplicate('super_admin_passwd', 'prod', 'test') # doctest: +SKIP The super administrator password is required to perform this method. *Python 2:* :raise: :class:`odoorpc.error.RPCError` (acc...
python
def duplicate(self, password, db, new_db): """Duplicate `db' as `new_db`. >>> odoo.db.duplicate('super_admin_passwd', 'prod', 'test') # doctest: +SKIP The super administrator password is required to perform this method. *Python 2:* :raise: :class:`odoorpc.error.RPCError` (acc...
[ "def", "duplicate", "(", "self", ",", "password", ",", "db", ",", "new_db", ")", ":", "self", ".", "_odoo", ".", "json", "(", "'/jsonrpc'", ",", "{", "'service'", ":", "'db'", ",", "'method'", ":", "'duplicate_database'", ",", "'args'", ":", "[", "pass...
Duplicate `db' as `new_db`. >>> odoo.db.duplicate('super_admin_passwd', 'prod', 'test') # doctest: +SKIP The super administrator password is required to perform this method. *Python 2:* :raise: :class:`odoorpc.error.RPCError` (access denied / wrong database) :raise: `urllib2....
[ "Duplicate", "db", "as", "new_db", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/db.py#L233-L254
OCA/odoorpc
odoorpc/db.py
DB.restore
def restore(self, password, db, dump, copy=False): """Restore the `dump` database into the new `db` database. The `dump` file object can be obtained with the :func:`dump <DB.dump>` method. If `copy` is set to `True`, the restored database will have a new UUID. >>> odoo.db.restor...
python
def restore(self, password, db, dump, copy=False): """Restore the `dump` database into the new `db` database. The `dump` file object can be obtained with the :func:`dump <DB.dump>` method. If `copy` is set to `True`, the restored database will have a new UUID. >>> odoo.db.restor...
[ "def", "restore", "(", "self", ",", "password", ",", "db", ",", "dump", ",", "copy", "=", "False", ")", ":", "if", "dump", ".", "closed", ":", "raise", "error", ".", "InternalError", "(", "\"Dump file closed\"", ")", "b64_data", "=", "base64", ".", "st...
Restore the `dump` database into the new `db` database. The `dump` file object can be obtained with the :func:`dump <DB.dump>` method. If `copy` is set to `True`, the restored database will have a new UUID. >>> odoo.db.restore('super_admin_passwd', 'test', dump_file) # doctest: +SKIP ...
[ "Restore", "the", "dump", "database", "into", "the", "new", "db", "database", ".", "The", "dump", "file", "object", "can", "be", "obtained", "with", "the", ":", "func", ":", "dump", "<DB", ".", "dump", ">", "method", ".", "If", "copy", "is", "set", "...
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/db.py#L279-L318
OCA/odoorpc
odoorpc/rpc/__init__.py
ConnectorJSONRPC._get_proxies
def _get_proxies(self): """Returns the :class:`ProxyJSON <odoorpc.rpc.jsonrpclib.ProxyJSON>` and :class:`ProxyHTTP <odoorpc.rpc.jsonrpclib.ProxyHTTP>` instances corresponding to the server version used. """ proxy_json = jsonrpclib.ProxyJSON( self.host, self.port, self...
python
def _get_proxies(self): """Returns the :class:`ProxyJSON <odoorpc.rpc.jsonrpclib.ProxyJSON>` and :class:`ProxyHTTP <odoorpc.rpc.jsonrpclib.ProxyHTTP>` instances corresponding to the server version used. """ proxy_json = jsonrpclib.ProxyJSON( self.host, self.port, self...
[ "def", "_get_proxies", "(", "self", ")", ":", "proxy_json", "=", "jsonrpclib", ".", "ProxyJSON", "(", "self", ".", "host", ",", "self", ".", "port", ",", "self", ".", "_timeout", ",", "ssl", "=", "self", ".", "ssl", ",", "deserialize", "=", "self", "...
Returns the :class:`ProxyJSON <odoorpc.rpc.jsonrpclib.ProxyJSON>` and :class:`ProxyHTTP <odoorpc.rpc.jsonrpclib.ProxyHTTP>` instances corresponding to the server version used.
[ "Returns", "the", ":", "class", ":", "ProxyJSON", "<odoorpc", ".", "rpc", ".", "jsonrpclib", ".", "ProxyJSON", ">", "and", ":", "class", ":", "ProxyHTTP", "<odoorpc", ".", "rpc", ".", "jsonrpclib", ".", "ProxyHTTP", ">", "instances", "corresponding", "to", ...
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/rpc/__init__.py#L211-L227
OCA/odoorpc
odoorpc/rpc/__init__.py
ConnectorJSONRPC.timeout
def timeout(self, timeout): """Set the timeout.""" self._proxy_json._timeout = timeout self._proxy_http._timeout = timeout
python
def timeout(self, timeout): """Set the timeout.""" self._proxy_json._timeout = timeout self._proxy_http._timeout = timeout
[ "def", "timeout", "(", "self", ",", "timeout", ")", ":", "self", ".", "_proxy_json", ".", "_timeout", "=", "timeout", "self", ".", "_proxy_http", ".", "_timeout", "=", "timeout" ]
Set the timeout.
[ "Set", "the", "timeout", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/rpc/__init__.py#L245-L248
OCA/odoorpc
odoorpc/fields.py
is_int
def is_int(value): """Return `True` if ``value`` is an integer.""" if isinstance(value, bool): return False try: int(value) return True except (ValueError, TypeError): return False
python
def is_int(value): """Return `True` if ``value`` is an integer.""" if isinstance(value, bool): return False try: int(value) return True except (ValueError, TypeError): return False
[ "def", "is_int", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "bool", ")", ":", "return", "False", "try", ":", "int", "(", "value", ")", "return", "True", "except", "(", "ValueError", ",", "TypeError", ")", ":", "return", "False" ]
Return `True` if ``value`` is an integer.
[ "Return", "True", "if", "value", "is", "an", "integer", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/fields.py#L32-L40
OCA/odoorpc
odoorpc/fields.py
odoo_tuple_in
def odoo_tuple_in(iterable): """Return `True` if `iterable` contains an expected tuple like ``(6, 0, IDS)`` (and so on). >>> odoo_tuple_in([0, 1, 2]) # Simple list False >>> odoo_tuple_in([(6, 0, [42])]) # List of tuples True >>> odoo_tuple_in([[1, 42]]) ...
python
def odoo_tuple_in(iterable): """Return `True` if `iterable` contains an expected tuple like ``(6, 0, IDS)`` (and so on). >>> odoo_tuple_in([0, 1, 2]) # Simple list False >>> odoo_tuple_in([(6, 0, [42])]) # List of tuples True >>> odoo_tuple_in([[1, 42]]) ...
[ "def", "odoo_tuple_in", "(", "iterable", ")", ":", "if", "not", "iterable", ":", "return", "False", "def", "is_odoo_tuple", "(", "elt", ")", ":", "\"\"\"Return `True` if `elt` is a Odoo special tuple.\"\"\"", "try", ":", "return", "elt", "[", ":", "1", "]", "[",...
Return `True` if `iterable` contains an expected tuple like ``(6, 0, IDS)`` (and so on). >>> odoo_tuple_in([0, 1, 2]) # Simple list False >>> odoo_tuple_in([(6, 0, [42])]) # List of tuples True >>> odoo_tuple_in([[1, 42]]) # List of lists True
[ "Return", "True", "if", "iterable", "contains", "an", "expected", "tuple", "like", "(", "6", "0", "IDS", ")", "(", "and", "so", "on", ")", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/fields.py#L55-L75
OCA/odoorpc
odoorpc/fields.py
tuples2ids
def tuples2ids(tuples, ids): """Update `ids` according to `tuples`, e.g. (3, 0, X), (4, 0, X)...""" for value in tuples: if value[0] == 6 and value[2]: ids = value[2] elif value[0] == 5: ids[:] = [] elif value[0] == 4 and value[1] and value[1] not in ids: ...
python
def tuples2ids(tuples, ids): """Update `ids` according to `tuples`, e.g. (3, 0, X), (4, 0, X)...""" for value in tuples: if value[0] == 6 and value[2]: ids = value[2] elif value[0] == 5: ids[:] = [] elif value[0] == 4 and value[1] and value[1] not in ids: ...
[ "def", "tuples2ids", "(", "tuples", ",", "ids", ")", ":", "for", "value", "in", "tuples", ":", "if", "value", "[", "0", "]", "==", "6", "and", "value", "[", "2", "]", ":", "ids", "=", "value", "[", "2", "]", "elif", "value", "[", "0", "]", "=...
Update `ids` according to `tuples`, e.g. (3, 0, X), (4, 0, X)...
[ "Update", "ids", "according", "to", "tuples", "e", ".", "g", ".", "(", "3", "0", "X", ")", "(", "4", "0", "X", ")", "..." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/fields.py#L78-L89
OCA/odoorpc
odoorpc/fields.py
records2ids
def records2ids(iterable): """Replace records contained in `iterable` with their corresponding IDs: >>> groups = list(odoo.env.user.groups_id) >>> records2ids(groups) [1, 2, 3, 14, 17, 18, 19, 7, 8, 9, 5, 20, 21, 22, 23] """ def record2id(elt): """If `elt` is a record, retur...
python
def records2ids(iterable): """Replace records contained in `iterable` with their corresponding IDs: >>> groups = list(odoo.env.user.groups_id) >>> records2ids(groups) [1, 2, 3, 14, 17, 18, 19, 7, 8, 9, 5, 20, 21, 22, 23] """ def record2id(elt): """If `elt` is a record, retur...
[ "def", "records2ids", "(", "iterable", ")", ":", "def", "record2id", "(", "elt", ")", ":", "\"\"\"If `elt` is a record, return its ID.\"\"\"", "if", "isinstance", "(", "elt", ",", "Model", ")", ":", "return", "elt", ".", "id", "return", "elt", "return", "[", ...
Replace records contained in `iterable` with their corresponding IDs: >>> groups = list(odoo.env.user.groups_id) >>> records2ids(groups) [1, 2, 3, 14, 17, 18, 19, 7, 8, 9, 5, 20, 21, 22, 23]
[ "Replace", "records", "contained", "in", "iterable", "with", "their", "corresponding", "IDs", ":" ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/fields.py#L92-L104
OCA/odoorpc
odoorpc/fields.py
generate_field
def generate_field(name, data): """Generate a well-typed field according to the data dictionary supplied (obtained via the `fields_get' method of any models). """ assert 'type' in data field = TYPES_TO_FIELDS.get(data['type'], Unknown)(name, data) return field
python
def generate_field(name, data): """Generate a well-typed field according to the data dictionary supplied (obtained via the `fields_get' method of any models). """ assert 'type' in data field = TYPES_TO_FIELDS.get(data['type'], Unknown)(name, data) return field
[ "def", "generate_field", "(", "name", ",", "data", ")", ":", "assert", "'type'", "in", "data", "field", "=", "TYPES_TO_FIELDS", ".", "get", "(", "data", "[", "'type'", "]", ",", "Unknown", ")", "(", "name", ",", "data", ")", "return", "field" ]
Generate a well-typed field according to the data dictionary supplied (obtained via the `fields_get' method of any models).
[ "Generate", "a", "well", "-", "typed", "field", "according", "to", "the", "data", "dictionary", "supplied", "(", "obtained", "via", "the", "fields_get", "method", "of", "any", "models", ")", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/fields.py#L712-L718
OCA/odoorpc
odoorpc/fields.py
BaseField.check_value
def check_value(self, value): """Check the validity of a value for the field.""" #if self.readonly: # raise error.Error( # "'{field_name}' field is readonly".format( # field_name=self.name)) if value and self.size: if not is_string(value):...
python
def check_value(self, value): """Check the validity of a value for the field.""" #if self.readonly: # raise error.Error( # "'{field_name}' field is readonly".format( # field_name=self.name)) if value and self.size: if not is_string(value):...
[ "def", "check_value", "(", "self", ",", "value", ")", ":", "#if self.readonly:", "# raise error.Error(", "# \"'{field_name}' field is readonly\".format(", "# field_name=self.name))", "if", "value", "and", "self", ".", "size", ":", "if", "not", "is_strin...
Check the validity of a value for the field.
[ "Check", "the", "validity", "of", "a", "value", "for", "the", "field", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/fields.py#L147-L162
OCA/odoorpc
odoorpc/fields.py
BaseField.store
def store(self, record, value): """Store the value in the record.""" record._values[self.name][record.id] = value
python
def store(self, record, value): """Store the value in the record.""" record._values[self.name][record.id] = value
[ "def", "store", "(", "self", ",", "record", ",", "value", ")", ":", "record", ".", "_values", "[", "self", ".", "name", "]", "[", "record", ".", "id", "]", "=", "value" ]
Store the value in the record.
[ "Store", "the", "value", "in", "the", "record", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/fields.py#L164-L166
OCA/odoorpc
odoorpc/fields.py
Many2many.store
def store(self, record, value): """Store the value in the record.""" if record._values[self.name].get(record.id): tuples2ids(value, record._values[self.name][record.id]) else: record._values[self.name][record.id] = tuples2ids(value, [])
python
def store(self, record, value): """Store the value in the record.""" if record._values[self.name].get(record.id): tuples2ids(value, record._values[self.name][record.id]) else: record._values[self.name][record.id] = tuples2ids(value, [])
[ "def", "store", "(", "self", ",", "record", ",", "value", ")", ":", "if", "record", ".", "_values", "[", "self", ".", "name", "]", ".", "get", "(", "record", ".", "id", ")", ":", "tuples2ids", "(", "value", ",", "record", ".", "_values", "[", "se...
Store the value in the record.
[ "Store", "the", "value", "in", "the", "record", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/fields.py#L439-L444
OCA/odoorpc
odoorpc/fields.py
Reference._check_relation
def _check_relation(self, relation): """Raise a `ValueError` if `relation` is not allowed among the possible values. """ selection = [val[0] for val in self.selection] if relation not in selection: raise ValueError( ("The value '{value}' supplied doesn...
python
def _check_relation(self, relation): """Raise a `ValueError` if `relation` is not allowed among the possible values. """ selection = [val[0] for val in self.selection] if relation not in selection: raise ValueError( ("The value '{value}' supplied doesn...
[ "def", "_check_relation", "(", "self", ",", "relation", ")", ":", "selection", "=", "[", "val", "[", "0", "]", "for", "val", "in", "self", ".", "selection", "]", "if", "relation", "not", "in", "selection", ":", "raise", "ValueError", "(", "(", "\"The v...
Raise a `ValueError` if `relation` is not allowed among the possible values.
[ "Raise", "a", "ValueError", "if", "relation", "is", "not", "allowed", "among", "the", "possible", "values", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/fields.py#L612-L625
OCA/odoorpc
odoorpc/report.py
Report.download
def download(self, name, ids, datas=None, context=None): """Download a report from the server and return it as a remote file. For instance, to download the "Quotation / Order" report of sale orders identified by the IDs ``[2, 3]``: .. doctest:: :options: +SKIP >...
python
def download(self, name, ids, datas=None, context=None): """Download a report from the server and return it as a remote file. For instance, to download the "Quotation / Order" report of sale orders identified by the IDs ``[2, 3]``: .. doctest:: :options: +SKIP >...
[ "def", "download", "(", "self", ",", "name", ",", "ids", ",", "datas", "=", "None", ",", "context", "=", "None", ")", ":", "if", "context", "is", "None", ":", "context", "=", "self", ".", "_odoo", ".", "env", ".", "context", "def", "check_report", ...
Download a report from the server and return it as a remote file. For instance, to download the "Quotation / Order" report of sale orders identified by the IDs ``[2, 3]``: .. doctest:: :options: +SKIP >>> report = odoo.report.download('sale.report_saleorder', [2, 3]) ...
[ "Download", "a", "report", "from", "the", "server", "and", "return", "it", "as", "a", "remote", "file", ".", "For", "instance", "to", "download", "the", "Quotation", "/", "Order", "report", "of", "sale", "orders", "identified", "by", "the", "IDs", "[", "...
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/report.py#L68-L156
OCA/odoorpc
odoorpc/report.py
Report.list
def list(self): """List available reports from the server by returning a dictionary with reports classified by data model: .. doctest:: :options: +SKIP >>> odoo.report.list()['account.invoice'] [{'name': u'Duplicates', 'report_name': u'account....
python
def list(self): """List available reports from the server by returning a dictionary with reports classified by data model: .. doctest:: :options: +SKIP >>> odoo.report.list()['account.invoice'] [{'name': u'Duplicates', 'report_name': u'account....
[ "def", "list", "(", "self", ")", ":", "report_model", "=", "'ir.actions.report'", "if", "v", "(", "self", ".", "_odoo", ".", "version", ")", "[", "0", "]", "<", "11", ":", "report_model", "=", "'ir.actions.report.xml'", "IrReport", "=", "self", ".", "_od...
List available reports from the server by returning a dictionary with reports classified by data model: .. doctest:: :options: +SKIP >>> odoo.report.list()['account.invoice'] [{'name': u'Duplicates', 'report_name': u'account.account_invoice_report_dupl...
[ "List", "available", "reports", "from", "the", "server", "by", "returning", "a", "dictionary", "with", "reports", "classified", "by", "data", "model", ":" ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/report.py#L158-L205
OCA/odoorpc
odoorpc/models.py
Model._browse
def _browse(cls, env, ids, from_record=None, iterated=None): """Create an instance (a recordset) corresponding to `ids` and attached to `env`. `from_record` parameter is used when the recordset is related to a parent record, and as such can take the value of a tuple (record, fie...
python
def _browse(cls, env, ids, from_record=None, iterated=None): """Create an instance (a recordset) corresponding to `ids` and attached to `env`. `from_record` parameter is used when the recordset is related to a parent record, and as such can take the value of a tuple (record, fie...
[ "def", "_browse", "(", "cls", ",", "env", ",", "ids", ",", "from_record", "=", "None", ",", "iterated", "=", "None", ")", ":", "records", "=", "cls", "(", ")", "records", ".", "_env_local", "=", "env", "records", ".", "_ids", "=", "_normalize_ids", "...
Create an instance (a recordset) corresponding to `ids` and attached to `env`. `from_record` parameter is used when the recordset is related to a parent record, and as such can take the value of a tuple (record, field). This is useful to update the parent record when the current...
[ "Create", "an", "instance", "(", "a", "recordset", ")", "corresponding", "to", "ids", "and", "attached", "to", "env", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/models.py#L220-L247
OCA/odoorpc
odoorpc/models.py
Model.with_context
def with_context(cls, *args, **kwargs): """Return a model (or recordset) equivalent to the current model (or recordset) attached to an environment with another context. The context is taken from the current environment or from the positional arguments `args` if given, and modified by `kw...
python
def with_context(cls, *args, **kwargs): """Return a model (or recordset) equivalent to the current model (or recordset) attached to an environment with another context. The context is taken from the current environment or from the positional arguments `args` if given, and modified by `kw...
[ "def", "with_context", "(", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "context", "=", "dict", "(", "args", "[", "0", "]", "if", "args", "else", "cls", ".", "env", ".", "context", ",", "*", "*", "kwargs", ")", "return", "cls", ...
Return a model (or recordset) equivalent to the current model (or recordset) attached to an environment with another context. The context is taken from the current environment or from the positional arguments `args` if given, and modified by `kwargs`. Thus, the following two examples ar...
[ "Return", "a", "model", "(", "or", "recordset", ")", "equivalent", "to", "the", "current", "model", "(", "or", "recordset", ")", "attached", "to", "an", "environment", "with", "another", "context", ".", "The", "context", "is", "taken", "from", "the", "curr...
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/models.py#L283-L324
OCA/odoorpc
odoorpc/models.py
Model._with_context
def _with_context(self, *args, **kwargs): """As the `with_context` class method but for recordset.""" context = dict(args[0] if args else self.env.context, **kwargs) return self.with_env(self.env(context=context))
python
def _with_context(self, *args, **kwargs): """As the `with_context` class method but for recordset.""" context = dict(args[0] if args else self.env.context, **kwargs) return self.with_env(self.env(context=context))
[ "def", "_with_context", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "context", "=", "dict", "(", "args", "[", "0", "]", "if", "args", "else", "self", ".", "env", ".", "context", ",", "*", "*", "kwargs", ")", "return", "self"...
As the `with_context` class method but for recordset.
[ "As", "the", "with_context", "class", "method", "but", "for", "recordset", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/models.py#L326-L329
OCA/odoorpc
odoorpc/models.py
Model.with_env
def with_env(cls, env): """Return a model (or recordset) equivalent to the current model (or recordset) attached to `env`. """ new_cls = type(cls.__name__, cls.__bases__, dict(cls.__dict__)) new_cls._env = env return new_cls
python
def with_env(cls, env): """Return a model (or recordset) equivalent to the current model (or recordset) attached to `env`. """ new_cls = type(cls.__name__, cls.__bases__, dict(cls.__dict__)) new_cls._env = env return new_cls
[ "def", "with_env", "(", "cls", ",", "env", ")", ":", "new_cls", "=", "type", "(", "cls", ".", "__name__", ",", "cls", ".", "__bases__", ",", "dict", "(", "cls", ".", "__dict__", ")", ")", "new_cls", ".", "_env", "=", "env", "return", "new_cls" ]
Return a model (or recordset) equivalent to the current model (or recordset) attached to `env`.
[ "Return", "a", "model", "(", "or", "recordset", ")", "equivalent", "to", "the", "current", "model", "(", "or", "recordset", ")", "attached", "to", "env", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/models.py#L332-L338
OCA/odoorpc
odoorpc/models.py
Model._with_env
def _with_env(self, env): """As the `with_env` class method but for recordset.""" res = self._browse(env, self._ids) return res
python
def _with_env(self, env): """As the `with_env` class method but for recordset.""" res = self._browse(env, self._ids) return res
[ "def", "_with_env", "(", "self", ",", "env", ")", ":", "res", "=", "self", ".", "_browse", "(", "env", ",", "self", ".", "_ids", ")", "return", "res" ]
As the `with_env` class method but for recordset.
[ "As", "the", "with_env", "class", "method", "but", "for", "recordset", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/models.py#L340-L343
OCA/odoorpc
odoorpc/models.py
Model._init_values
def _init_values(self, context=None): """Retrieve field values from the server. May be used to restore the original values in the purpose to cancel all changes made. """ if context is None: context = self.env.context # Get basic fields (no relational ones) ...
python
def _init_values(self, context=None): """Retrieve field values from the server. May be used to restore the original values in the purpose to cancel all changes made. """ if context is None: context = self.env.context # Get basic fields (no relational ones) ...
[ "def", "_init_values", "(", "self", ",", "context", "=", "None", ")", ":", "if", "context", "is", "None", ":", "context", "=", "self", ".", "env", ".", "context", "# Get basic fields (no relational ones)", "basic_fields", "=", "[", "]", "for", "field_name", ...
Retrieve field values from the server. May be used to restore the original values in the purpose to cancel all changes made.
[ "Retrieve", "field", "values", "from", "the", "server", ".", "May", "be", "used", "to", "restore", "the", "original", "values", "in", "the", "purpose", "to", "cancel", "all", "changes", "made", "." ]
train
https://github.com/OCA/odoorpc/blob/d90aa0b2bc4fafbab8bd8f50d50e3fb0b9ba91f0/odoorpc/models.py#L345-L380
ethereum/eth-utils
eth_utils/currency.py
from_wei
def from_wei(number: int, unit: str) -> Union[int, decimal.Decimal]: """ Takes a number of wei and converts it to any other ether unit. """ if unit.lower() not in units: raise ValueError( "Unknown unit. Must be one of {0}".format("/".join(units.keys())) ) if number == 0...
python
def from_wei(number: int, unit: str) -> Union[int, decimal.Decimal]: """ Takes a number of wei and converts it to any other ether unit. """ if unit.lower() not in units: raise ValueError( "Unknown unit. Must be one of {0}".format("/".join(units.keys())) ) if number == 0...
[ "def", "from_wei", "(", "number", ":", "int", ",", "unit", ":", "str", ")", "->", "Union", "[", "int", ",", "decimal", ".", "Decimal", "]", ":", "if", "unit", ".", "lower", "(", ")", "not", "in", "units", ":", "raise", "ValueError", "(", "\"Unknown...
Takes a number of wei and converts it to any other ether unit.
[ "Takes", "a", "number", "of", "wei", "and", "converts", "it", "to", "any", "other", "ether", "unit", "." ]
train
https://github.com/ethereum/eth-utils/blob/d9889753a8e016d2fcd64ade0e2db3844486551d/eth_utils/currency.py#L40-L62
ethereum/eth-utils
eth_utils/currency.py
to_wei
def to_wei(number: int, unit: str) -> int: """ Takes a number of a unit and converts it to wei. """ if unit.lower() not in units: raise ValueError( "Unknown unit. Must be one of {0}".format("/".join(units.keys())) ) if is_integer(number) or is_string(number): d_...
python
def to_wei(number: int, unit: str) -> int: """ Takes a number of a unit and converts it to wei. """ if unit.lower() not in units: raise ValueError( "Unknown unit. Must be one of {0}".format("/".join(units.keys())) ) if is_integer(number) or is_string(number): d_...
[ "def", "to_wei", "(", "number", ":", "int", ",", "unit", ":", "str", ")", "->", "int", ":", "if", "unit", ".", "lower", "(", ")", "not", "in", "units", ":", "raise", "ValueError", "(", "\"Unknown unit. Must be one of {0}\"", ".", "format", "(", "\"/\"",...
Takes a number of a unit and converts it to wei.
[ "Takes", "a", "number", "of", "a", "unit", "and", "converts", "it", "to", "wei", "." ]
train
https://github.com/ethereum/eth-utils/blob/d9889753a8e016d2fcd64ade0e2db3844486551d/eth_utils/currency.py#L65-L103
ethereum/eth-utils
eth_utils/conversions.py
to_hex
def to_hex( primitive: Primitives = None, hexstr: HexStr = None, text: str = None ) -> HexStr: """ Auto converts any supported value into its hex representation. Trims leading zeros, as defined in: https://github.com/ethereum/wiki/wiki/JSON-RPC#hex-value-encoding """ if hexstr is not None: ...
python
def to_hex( primitive: Primitives = None, hexstr: HexStr = None, text: str = None ) -> HexStr: """ Auto converts any supported value into its hex representation. Trims leading zeros, as defined in: https://github.com/ethereum/wiki/wiki/JSON-RPC#hex-value-encoding """ if hexstr is not None: ...
[ "def", "to_hex", "(", "primitive", ":", "Primitives", "=", "None", ",", "hexstr", ":", "HexStr", "=", "None", ",", "text", ":", "str", "=", "None", ")", "->", "HexStr", ":", "if", "hexstr", "is", "not", "None", ":", "return", "HexStr", "(", "add_0x_p...
Auto converts any supported value into its hex representation. Trims leading zeros, as defined in: https://github.com/ethereum/wiki/wiki/JSON-RPC#hex-value-encoding
[ "Auto", "converts", "any", "supported", "value", "into", "its", "hex", "representation", ".", "Trims", "leading", "zeros", "as", "defined", "in", ":", "https", ":", "//", "github", ".", "com", "/", "ethereum", "/", "wiki", "/", "wiki", "/", "JSON", "-", ...
train
https://github.com/ethereum/eth-utils/blob/d9889753a8e016d2fcd64ade0e2db3844486551d/eth_utils/conversions.py#L11-L42
ethereum/eth-utils
eth_utils/conversions.py
to_int
def to_int( primitive: Primitives = None, hexstr: HexStr = None, text: str = None ) -> int: """ Converts value to its integer representation. Values are converted this way: * primitive: * bytes, bytearrays: big-endian integer * bool: True => 1, False => 0 * hexstr: interpret he...
python
def to_int( primitive: Primitives = None, hexstr: HexStr = None, text: str = None ) -> int: """ Converts value to its integer representation. Values are converted this way: * primitive: * bytes, bytearrays: big-endian integer * bool: True => 1, False => 0 * hexstr: interpret he...
[ "def", "to_int", "(", "primitive", ":", "Primitives", "=", "None", ",", "hexstr", ":", "HexStr", "=", "None", ",", "text", ":", "str", "=", "None", ")", "->", "int", ":", "if", "hexstr", "is", "not", "None", ":", "return", "int", "(", "hexstr", ","...
Converts value to its integer representation. Values are converted this way: * primitive: * bytes, bytearrays: big-endian integer * bool: True => 1, False => 0 * hexstr: interpret hex as integer * text: interpret as string of digits, like '12' => 12
[ "Converts", "value", "to", "its", "integer", "representation", ".", "Values", "are", "converted", "this", "way", ":" ]
train
https://github.com/ethereum/eth-utils/blob/d9889753a8e016d2fcd64ade0e2db3844486551d/eth_utils/conversions.py#L46-L74
ethereum/eth-utils
eth_utils/conversions.py
text_if_str
def text_if_str( to_type: Callable[..., T], text_or_primitive: Union[bytes, int, str] ) -> T: """ Convert to a type, assuming that strings can be only unicode text (not a hexstr) :param to_type function: takes the arguments (primitive, hexstr=hexstr, text=text), eg~ to_bytes, to_text, to_hex, t...
python
def text_if_str( to_type: Callable[..., T], text_or_primitive: Union[bytes, int, str] ) -> T: """ Convert to a type, assuming that strings can be only unicode text (not a hexstr) :param to_type function: takes the arguments (primitive, hexstr=hexstr, text=text), eg~ to_bytes, to_text, to_hex, t...
[ "def", "text_if_str", "(", "to_type", ":", "Callable", "[", "...", ",", "T", "]", ",", "text_or_primitive", ":", "Union", "[", "bytes", ",", "int", ",", "str", "]", ")", "->", "T", ":", "if", "isinstance", "(", "text_or_primitive", ",", "str", ")", "...
Convert to a type, assuming that strings can be only unicode text (not a hexstr) :param to_type function: takes the arguments (primitive, hexstr=hexstr, text=text), eg~ to_bytes, to_text, to_hex, to_int, etc :param text_or_primitive bytes, str, int: value to convert
[ "Convert", "to", "a", "type", "assuming", "that", "strings", "can", "be", "only", "unicode", "text", "(", "not", "a", "hexstr", ")" ]
train
https://github.com/ethereum/eth-utils/blob/d9889753a8e016d2fcd64ade0e2db3844486551d/eth_utils/conversions.py#L119-L132
ethereum/eth-utils
eth_utils/conversions.py
hexstr_if_str
def hexstr_if_str( to_type: Callable[..., T], hexstr_or_primitive: Union[bytes, int, str] ) -> T: """ Convert to a type, assuming that strings can be only hexstr (not unicode text) :param to_type function: takes the arguments (primitive, hexstr=hexstr, text=text), eg~ to_bytes, to_text, to_hex,...
python
def hexstr_if_str( to_type: Callable[..., T], hexstr_or_primitive: Union[bytes, int, str] ) -> T: """ Convert to a type, assuming that strings can be only hexstr (not unicode text) :param to_type function: takes the arguments (primitive, hexstr=hexstr, text=text), eg~ to_bytes, to_text, to_hex,...
[ "def", "hexstr_if_str", "(", "to_type", ":", "Callable", "[", "...", ",", "T", "]", ",", "hexstr_or_primitive", ":", "Union", "[", "bytes", ",", "int", ",", "str", "]", ")", "->", "T", ":", "if", "isinstance", "(", "hexstr_or_primitive", ",", "str", ")...
Convert to a type, assuming that strings can be only hexstr (not unicode text) :param to_type function: takes the arguments (primitive, hexstr=hexstr, text=text), eg~ to_bytes, to_text, to_hex, to_int, etc :param hexstr_or_primitive bytes, str, int: value to convert
[ "Convert", "to", "a", "type", "assuming", "that", "strings", "can", "be", "only", "hexstr", "(", "not", "unicode", "text", ")" ]
train
https://github.com/ethereum/eth-utils/blob/d9889753a8e016d2fcd64ade0e2db3844486551d/eth_utils/conversions.py#L135-L154
ethereum/eth-utils
eth_utils/decorators.py
validate_conversion_arguments
def validate_conversion_arguments(to_wrap): """ Validates arguments for conversion functions. - Only a single argument is present - Kwarg must be 'primitive' 'hexstr' or 'text' - If it is 'hexstr' or 'text' that it is a text type """ @functools.wraps(to_wrap) def wrapper(*args, **kwargs...
python
def validate_conversion_arguments(to_wrap): """ Validates arguments for conversion functions. - Only a single argument is present - Kwarg must be 'primitive' 'hexstr' or 'text' - If it is 'hexstr' or 'text' that it is a text type """ @functools.wraps(to_wrap) def wrapper(*args, **kwargs...
[ "def", "validate_conversion_arguments", "(", "to_wrap", ")", ":", "@", "functools", ".", "wraps", "(", "to_wrap", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "_assert_one_val", "(", "*", "args", ",", "*", "*", "kwargs", ...
Validates arguments for conversion functions. - Only a single argument is present - Kwarg must be 'primitive' 'hexstr' or 'text' - If it is 'hexstr' or 'text' that it is a text type
[ "Validates", "arguments", "for", "conversion", "functions", ".", "-", "Only", "a", "single", "argument", "is", "present", "-", "Kwarg", "must", "be", "primitive", "hexstr", "or", "text", "-", "If", "it", "is", "hexstr", "or", "text", "that", "it", "is", ...
train
https://github.com/ethereum/eth-utils/blob/d9889753a8e016d2fcd64ade0e2db3844486551d/eth_utils/decorators.py#L59-L77
ethereum/eth-utils
eth_utils/decorators.py
return_arg_type
def return_arg_type(at_position): """ Wrap the return value with the result of `type(args[at_position])` """ def decorator(to_wrap): @functools.wraps(to_wrap) def wrapper(*args, **kwargs): result = to_wrap(*args, **kwargs) ReturnType = type(args[at_position]) ...
python
def return_arg_type(at_position): """ Wrap the return value with the result of `type(args[at_position])` """ def decorator(to_wrap): @functools.wraps(to_wrap) def wrapper(*args, **kwargs): result = to_wrap(*args, **kwargs) ReturnType = type(args[at_position]) ...
[ "def", "return_arg_type", "(", "at_position", ")", ":", "def", "decorator", "(", "to_wrap", ")", ":", "@", "functools", ".", "wraps", "(", "to_wrap", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "result", "=", "to_wrap", ...
Wrap the return value with the result of `type(args[at_position])`
[ "Wrap", "the", "return", "value", "with", "the", "result", "of", "type", "(", "args", "[", "at_position", "]", ")" ]
train
https://github.com/ethereum/eth-utils/blob/d9889753a8e016d2fcd64ade0e2db3844486551d/eth_utils/decorators.py#L80-L94
ethereum/eth-utils
eth_utils/decorators.py
replace_exceptions
def replace_exceptions( old_to_new_exceptions: Dict[Type[BaseException], Type[BaseException]] ) -> Callable[..., Any]: """ Replaces old exceptions with new exceptions to be raised in their place. """ old_exceptions = tuple(old_to_new_exceptions.keys()) def decorator(to_wrap: Callable[..., Any])...
python
def replace_exceptions( old_to_new_exceptions: Dict[Type[BaseException], Type[BaseException]] ) -> Callable[..., Any]: """ Replaces old exceptions with new exceptions to be raised in their place. """ old_exceptions = tuple(old_to_new_exceptions.keys()) def decorator(to_wrap: Callable[..., Any])...
[ "def", "replace_exceptions", "(", "old_to_new_exceptions", ":", "Dict", "[", "Type", "[", "BaseException", "]", ",", "Type", "[", "BaseException", "]", "]", ")", "->", "Callable", "[", "...", ",", "Any", "]", ":", "old_exceptions", "=", "tuple", "(", "old_...
Replaces old exceptions with new exceptions to be raised in their place.
[ "Replaces", "old", "exceptions", "with", "new", "exceptions", "to", "be", "raised", "in", "their", "place", "." ]
train
https://github.com/ethereum/eth-utils/blob/d9889753a8e016d2fcd64ade0e2db3844486551d/eth_utils/decorators.py#L97-L124
ethereum/eth-utils
eth_utils/abi.py
collapse_if_tuple
def collapse_if_tuple(abi): """Converts a tuple from a dict to a parenthesized list of its types. >>> from eth_utils.abi import collapse_if_tuple >>> collapse_if_tuple( ... { ... 'components': [ ... {'name': 'anAddress', 'type': 'address'}, ... {'name': '...
python
def collapse_if_tuple(abi): """Converts a tuple from a dict to a parenthesized list of its types. >>> from eth_utils.abi import collapse_if_tuple >>> collapse_if_tuple( ... { ... 'components': [ ... {'name': 'anAddress', 'type': 'address'}, ... {'name': '...
[ "def", "collapse_if_tuple", "(", "abi", ")", ":", "typ", "=", "abi", "[", "\"type\"", "]", "if", "not", "typ", ".", "startswith", "(", "\"tuple\"", ")", ":", "return", "typ", "delimited", "=", "\",\"", ".", "join", "(", "collapse_if_tuple", "(", "c", "...
Converts a tuple from a dict to a parenthesized list of its types. >>> from eth_utils.abi import collapse_if_tuple >>> collapse_if_tuple( ... { ... 'components': [ ... {'name': 'anAddress', 'type': 'address'}, ... {'name': 'anInt', 'type': 'uint256'}, ......
[ "Converts", "a", "tuple", "from", "a", "dict", "to", "a", "parenthesized", "list", "of", "its", "types", "." ]
train
https://github.com/ethereum/eth-utils/blob/d9889753a8e016d2fcd64ade0e2db3844486551d/eth_utils/abi.py#L6-L32
ethereum/eth-utils
eth_utils/address.py
is_hex_address
def is_hex_address(value: Any) -> bool: """ Checks if the given string of text type is an address in hexadecimal encoded form. """ if not is_text(value): return False elif not is_hex(value): return False else: unprefixed = remove_0x_prefix(value) return len(unpref...
python
def is_hex_address(value: Any) -> bool: """ Checks if the given string of text type is an address in hexadecimal encoded form. """ if not is_text(value): return False elif not is_hex(value): return False else: unprefixed = remove_0x_prefix(value) return len(unpref...
[ "def", "is_hex_address", "(", "value", ":", "Any", ")", "->", "bool", ":", "if", "not", "is_text", "(", "value", ")", ":", "return", "False", "elif", "not", "is_hex", "(", "value", ")", ":", "return", "False", "else", ":", "unprefixed", "=", "remove_0x...
Checks if the given string of text type is an address in hexadecimal encoded form.
[ "Checks", "if", "the", "given", "string", "of", "text", "type", "is", "an", "address", "in", "hexadecimal", "encoded", "form", "." ]
train
https://github.com/ethereum/eth-utils/blob/d9889753a8e016d2fcd64ade0e2db3844486551d/eth_utils/address.py#L10-L20
ethereum/eth-utils
eth_utils/address.py
is_binary_address
def is_binary_address(value: Any) -> bool: """ Checks if the given string is an address in raw bytes form. """ if not is_bytes(value): return False elif len(value) != 20: return False else: return True
python
def is_binary_address(value: Any) -> bool: """ Checks if the given string is an address in raw bytes form. """ if not is_bytes(value): return False elif len(value) != 20: return False else: return True
[ "def", "is_binary_address", "(", "value", ":", "Any", ")", "->", "bool", ":", "if", "not", "is_bytes", "(", "value", ")", ":", "return", "False", "elif", "len", "(", "value", ")", "!=", "20", ":", "return", "False", "else", ":", "return", "True" ]
Checks if the given string is an address in raw bytes form.
[ "Checks", "if", "the", "given", "string", "is", "an", "address", "in", "raw", "bytes", "form", "." ]
train
https://github.com/ethereum/eth-utils/blob/d9889753a8e016d2fcd64ade0e2db3844486551d/eth_utils/address.py#L23-L32
ethereum/eth-utils
eth_utils/address.py
is_address
def is_address(value: Any) -> bool: """ Checks if the given string in a supported value is an address in any of the known formats. """ if is_checksum_formatted_address(value): return is_checksum_address(value) elif is_hex_address(value): return True elif is_binary_address(val...
python
def is_address(value: Any) -> bool: """ Checks if the given string in a supported value is an address in any of the known formats. """ if is_checksum_formatted_address(value): return is_checksum_address(value) elif is_hex_address(value): return True elif is_binary_address(val...
[ "def", "is_address", "(", "value", ":", "Any", ")", "->", "bool", ":", "if", "is_checksum_formatted_address", "(", "value", ")", ":", "return", "is_checksum_address", "(", "value", ")", "elif", "is_hex_address", "(", "value", ")", ":", "return", "True", "eli...
Checks if the given string in a supported value is an address in any of the known formats.
[ "Checks", "if", "the", "given", "string", "in", "a", "supported", "value", "is", "an", "address", "in", "any", "of", "the", "known", "formats", "." ]
train
https://github.com/ethereum/eth-utils/blob/d9889753a8e016d2fcd64ade0e2db3844486551d/eth_utils/address.py#L35-L47
ethereum/eth-utils
eth_utils/address.py
to_normalized_address
def to_normalized_address(value: AnyStr) -> HexAddress: """ Converts an address to its normalized hexadecimal representation. """ try: hex_address = hexstr_if_str(to_hex, value).lower() except AttributeError: raise TypeError( "Value must be any string, instead got type {}...
python
def to_normalized_address(value: AnyStr) -> HexAddress: """ Converts an address to its normalized hexadecimal representation. """ try: hex_address = hexstr_if_str(to_hex, value).lower() except AttributeError: raise TypeError( "Value must be any string, instead got type {}...
[ "def", "to_normalized_address", "(", "value", ":", "AnyStr", ")", "->", "HexAddress", ":", "try", ":", "hex_address", "=", "hexstr_if_str", "(", "to_hex", ",", "value", ")", ".", "lower", "(", ")", "except", "AttributeError", ":", "raise", "TypeError", "(", ...
Converts an address to its normalized hexadecimal representation.
[ "Converts", "an", "address", "to", "its", "normalized", "hexadecimal", "representation", "." ]
train
https://github.com/ethereum/eth-utils/blob/d9889753a8e016d2fcd64ade0e2db3844486551d/eth_utils/address.py#L50-L65
ethereum/eth-utils
eth_utils/address.py
is_normalized_address
def is_normalized_address(value: Any) -> bool: """ Returns whether the provided value is an address in its normalized form. """ if not is_address(value): return False else: return value == to_normalized_address(value)
python
def is_normalized_address(value: Any) -> bool: """ Returns whether the provided value is an address in its normalized form. """ if not is_address(value): return False else: return value == to_normalized_address(value)
[ "def", "is_normalized_address", "(", "value", ":", "Any", ")", "->", "bool", ":", "if", "not", "is_address", "(", "value", ")", ":", "return", "False", "else", ":", "return", "value", "==", "to_normalized_address", "(", "value", ")" ]
Returns whether the provided value is an address in its normalized form.
[ "Returns", "whether", "the", "provided", "value", "is", "an", "address", "in", "its", "normalized", "form", "." ]
train
https://github.com/ethereum/eth-utils/blob/d9889753a8e016d2fcd64ade0e2db3844486551d/eth_utils/address.py#L68-L75
ethereum/eth-utils
eth_utils/address.py
is_canonical_address
def is_canonical_address(address: Any) -> bool: """ Returns `True` if the `value` is an address in its canonical form. """ if not is_bytes(address) or len(address) != 20: return False return address == to_canonical_address(address)
python
def is_canonical_address(address: Any) -> bool: """ Returns `True` if the `value` is an address in its canonical form. """ if not is_bytes(address) or len(address) != 20: return False return address == to_canonical_address(address)
[ "def", "is_canonical_address", "(", "address", ":", "Any", ")", "->", "bool", ":", "if", "not", "is_bytes", "(", "address", ")", "or", "len", "(", "address", ")", "!=", "20", ":", "return", "False", "return", "address", "==", "to_canonical_address", "(", ...
Returns `True` if the `value` is an address in its canonical form.
[ "Returns", "True", "if", "the", "value", "is", "an", "address", "in", "its", "canonical", "form", "." ]
train
https://github.com/ethereum/eth-utils/blob/d9889753a8e016d2fcd64ade0e2db3844486551d/eth_utils/address.py#L86-L92
ethereum/eth-utils
eth_utils/address.py
is_same_address
def is_same_address(left: AnyAddress, right: AnyAddress) -> bool: """ Checks if both addresses are same or not. """ if not is_address(left) or not is_address(right): raise ValueError("Both values must be valid addresses") else: return to_normalized_address(left) == to_normalized_addr...
python
def is_same_address(left: AnyAddress, right: AnyAddress) -> bool: """ Checks if both addresses are same or not. """ if not is_address(left) or not is_address(right): raise ValueError("Both values must be valid addresses") else: return to_normalized_address(left) == to_normalized_addr...
[ "def", "is_same_address", "(", "left", ":", "AnyAddress", ",", "right", ":", "AnyAddress", ")", "->", "bool", ":", "if", "not", "is_address", "(", "left", ")", "or", "not", "is_address", "(", "right", ")", ":", "raise", "ValueError", "(", "\"Both values mu...
Checks if both addresses are same or not.
[ "Checks", "if", "both", "addresses", "are", "same", "or", "not", "." ]
train
https://github.com/ethereum/eth-utils/blob/d9889753a8e016d2fcd64ade0e2db3844486551d/eth_utils/address.py#L95-L102
ethereum/eth-utils
eth_utils/address.py
to_checksum_address
def to_checksum_address(value: AnyStr) -> ChecksumAddress: """ Makes a checksum address given a supported format. """ norm_address = to_normalized_address(value) address_hash = encode_hex(keccak(text=remove_0x_prefix(norm_address))) checksum_address = add_0x_prefix( "".join( ...
python
def to_checksum_address(value: AnyStr) -> ChecksumAddress: """ Makes a checksum address given a supported format. """ norm_address = to_normalized_address(value) address_hash = encode_hex(keccak(text=remove_0x_prefix(norm_address))) checksum_address = add_0x_prefix( "".join( ...
[ "def", "to_checksum_address", "(", "value", ":", "AnyStr", ")", "->", "ChecksumAddress", ":", "norm_address", "=", "to_normalized_address", "(", "value", ")", "address_hash", "=", "encode_hex", "(", "keccak", "(", "text", "=", "remove_0x_prefix", "(", "norm_addres...
Makes a checksum address given a supported format.
[ "Makes", "a", "checksum", "address", "given", "a", "supported", "format", "." ]
train
https://github.com/ethereum/eth-utils/blob/d9889753a8e016d2fcd64ade0e2db3844486551d/eth_utils/address.py#L105-L122
Azure/msrestazure-for-python
msrestazure/azure_active_directory.py
get_msi_token
def get_msi_token(resource, port=50342, msi_conf=None): """Get MSI token if MSI_ENDPOINT is set. IF MSI_ENDPOINT is not set, will try legacy access through 'http://localhost:{}/oauth2/token'.format(port). If msi_conf is used, must be a dict of one key in ["client_id", "object_id", "msi_res_id"] :para...
python
def get_msi_token(resource, port=50342, msi_conf=None): """Get MSI token if MSI_ENDPOINT is set. IF MSI_ENDPOINT is not set, will try legacy access through 'http://localhost:{}/oauth2/token'.format(port). If msi_conf is used, must be a dict of one key in ["client_id", "object_id", "msi_res_id"] :para...
[ "def", "get_msi_token", "(", "resource", ",", "port", "=", "50342", ",", "msi_conf", "=", "None", ")", ":", "request_uri", "=", "os", ".", "environ", ".", "get", "(", "\"MSI_ENDPOINT\"", ",", "'http://localhost:{}/oauth2/token'", ".", "format", "(", "port", ...
Get MSI token if MSI_ENDPOINT is set. IF MSI_ENDPOINT is not set, will try legacy access through 'http://localhost:{}/oauth2/token'.format(port). If msi_conf is used, must be a dict of one key in ["client_id", "object_id", "msi_res_id"] :param str resource: The resource where the token would be use. ...
[ "Get", "MSI", "token", "if", "MSI_ENDPOINT", "is", "set", "." ]
train
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/azure_active_directory.py#L462-L492
Azure/msrestazure-for-python
msrestazure/azure_active_directory.py
get_msi_token_webapp
def get_msi_token_webapp(resource): """Get a MSI token from inside a webapp or functions. Env variable will look like: - MSI_ENDPOINT = http://127.0.0.1:41741/MSI/token/ - MSI_SECRET = 69418689F1E342DD946CB82994CDA3CB """ try: msi_endpoint = os.environ['MSI_ENDPOINT'] msi_secre...
python
def get_msi_token_webapp(resource): """Get a MSI token from inside a webapp or functions. Env variable will look like: - MSI_ENDPOINT = http://127.0.0.1:41741/MSI/token/ - MSI_SECRET = 69418689F1E342DD946CB82994CDA3CB """ try: msi_endpoint = os.environ['MSI_ENDPOINT'] msi_secre...
[ "def", "get_msi_token_webapp", "(", "resource", ")", ":", "try", ":", "msi_endpoint", "=", "os", ".", "environ", "[", "'MSI_ENDPOINT'", "]", "msi_secret", "=", "os", ".", "environ", "[", "'MSI_SECRET'", "]", "except", "KeyError", "as", "err", ":", "err_msg",...
Get a MSI token from inside a webapp or functions. Env variable will look like: - MSI_ENDPOINT = http://127.0.0.1:41741/MSI/token/ - MSI_SECRET = 69418689F1E342DD946CB82994CDA3CB
[ "Get", "a", "MSI", "token", "from", "inside", "a", "webapp", "or", "functions", "." ]
train
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/azure_active_directory.py#L494-L534
Azure/msrestazure-for-python
msrestazure/azure_active_directory.py
AADMixin._configure
def _configure(self, **kwargs): """Configure authentication endpoint. Optional kwargs may include: - cloud_environment (msrestazure.azure_cloud.Cloud): A targeted cloud environment - china (bool): Configure auth for China-based service, default is 'False'. ...
python
def _configure(self, **kwargs): """Configure authentication endpoint. Optional kwargs may include: - cloud_environment (msrestazure.azure_cloud.Cloud): A targeted cloud environment - china (bool): Configure auth for China-based service, default is 'False'. ...
[ "def", "_configure", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ".", "get", "(", "'china'", ")", ":", "err_msg", "=", "(", "\"china parameter is deprecated, \"", "\"please use \"", "\"cloud_environment=msrestazure.azure_cloud.AZURE_CHINA_CLOUD\"", ...
Configure authentication endpoint. Optional kwargs may include: - cloud_environment (msrestazure.azure_cloud.Cloud): A targeted cloud environment - china (bool): Configure auth for China-based service, default is 'False'. - tenant (str): Alternative tenant, de...
[ "Configure", "authentication", "endpoint", "." ]
train
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/azure_active_directory.py#L60-L100
Azure/msrestazure-for-python
msrestazure/azure_active_directory.py
AADMixin._convert_token
def _convert_token(self, token): """Convert token fields from camel case. :param dict token: An authentication token. :rtype: dict """ # Beware that ADAL returns a pointer to its own dict, do # NOT change it in place token = token.copy() # If it's from A...
python
def _convert_token(self, token): """Convert token fields from camel case. :param dict token: An authentication token. :rtype: dict """ # Beware that ADAL returns a pointer to its own dict, do # NOT change it in place token = token.copy() # If it's from A...
[ "def", "_convert_token", "(", "self", ",", "token", ")", ":", "# Beware that ADAL returns a pointer to its own dict, do", "# NOT change it in place", "token", "=", "token", ".", "copy", "(", ")", "# If it's from ADAL, expiresOn will be in ISO form.", "# Bring it back to float, us...
Convert token fields from camel case. :param dict token: An authentication token. :rtype: dict
[ "Convert", "token", "fields", "from", "camel", "case", "." ]
train
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/azure_active_directory.py#L159-L174
Azure/msrestazure-for-python
msrestazure/azure_active_directory.py
AADMixin.signed_session
def signed_session(self, session=None): """Create token-friendly Requests session, using auto-refresh. Used internally when a request is made. If a session object is provided, configure it directly. Otherwise, create a new session and return it. :param session: The session to c...
python
def signed_session(self, session=None): """Create token-friendly Requests session, using auto-refresh. Used internally when a request is made. If a session object is provided, configure it directly. Otherwise, create a new session and return it. :param session: The session to c...
[ "def", "signed_session", "(", "self", ",", "session", "=", "None", ")", ":", "self", ".", "set_token", "(", ")", "# Adal does the caching.", "self", ".", "_parse_token", "(", ")", "return", "super", "(", "AADMixin", ",", "self", ")", ".", "signed_session", ...
Create token-friendly Requests session, using auto-refresh. Used internally when a request is made. If a session object is provided, configure it directly. Otherwise, create a new session and return it. :param session: The session to configure for authentication :type session: ...
[ "Create", "token", "-", "friendly", "Requests", "session", "using", "auto", "-", "refresh", ".", "Used", "internally", "when", "a", "request", "is", "made", "." ]
train
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/azure_active_directory.py#L189-L201
Azure/msrestazure-for-python
msrestazure/azure_active_directory.py
AADMixin.refresh_session
def refresh_session(self, session=None): """Return updated session if token has expired, attempts to refresh using newly acquired token. If a session object is provided, configure it directly. Otherwise, create a new session and return it. :param session: The session to configu...
python
def refresh_session(self, session=None): """Return updated session if token has expired, attempts to refresh using newly acquired token. If a session object is provided, configure it directly. Otherwise, create a new session and return it. :param session: The session to configu...
[ "def", "refresh_session", "(", "self", ",", "session", "=", "None", ")", ":", "if", "'refresh_token'", "in", "self", ".", "token", ":", "try", ":", "token", "=", "self", ".", "_context", ".", "acquire_token_with_refresh_token", "(", "self", ".", "token", "...
Return updated session if token has expired, attempts to refresh using newly acquired token. If a session object is provided, configure it directly. Otherwise, create a new session and return it. :param session: The session to configure for authentication :type session: request...
[ "Return", "updated", "session", "if", "token", "has", "expired", "attempts", "to", "refresh", "using", "newly", "acquired", "token", "." ]
train
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/azure_active_directory.py#L203-L225
Azure/msrestazure-for-python
msrestazure/azure_active_directory.py
UserPassCredentials.set_token
def set_token(self): """Get token using Username/Password credentials. :raises: AuthenticationError if credentials invalid, or call fails. """ super(UserPassCredentials, self).set_token() try: token = self._context.acquire_token_with_username_password( ...
python
def set_token(self): """Get token using Username/Password credentials. :raises: AuthenticationError if credentials invalid, or call fails. """ super(UserPassCredentials, self).set_token() try: token = self._context.acquire_token_with_username_password( ...
[ "def", "set_token", "(", "self", ")", ":", "super", "(", "UserPassCredentials", ",", "self", ")", ".", "set_token", "(", ")", "try", ":", "token", "=", "self", ".", "_context", ".", "acquire_token_with_username_password", "(", "self", ".", "resource", ",", ...
Get token using Username/Password credentials. :raises: AuthenticationError if credentials invalid, or call fails.
[ "Get", "token", "using", "Username", "/", "Password", "credentials", "." ]
train
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/azure_active_directory.py#L310-L325
Azure/msrestazure-for-python
msrestazure/azure_active_directory.py
ServicePrincipalCredentials.set_token
def set_token(self): """Get token using Client ID/Secret credentials. :raises: AuthenticationError if credentials invalid, or call fails. """ super(ServicePrincipalCredentials, self).set_token() try: token = self._context.acquire_token_with_client_credentials( ...
python
def set_token(self): """Get token using Client ID/Secret credentials. :raises: AuthenticationError if credentials invalid, or call fails. """ super(ServicePrincipalCredentials, self).set_token() try: token = self._context.acquire_token_with_client_credentials( ...
[ "def", "set_token", "(", "self", ")", ":", "super", "(", "ServicePrincipalCredentials", ",", "self", ")", ".", "set_token", "(", ")", "try", ":", "token", "=", "self", ".", "_context", ".", "acquire_token_with_client_credentials", "(", "self", ".", "resource",...
Get token using Client ID/Secret credentials. :raises: AuthenticationError if credentials invalid, or call fails.
[ "Get", "token", "using", "Client", "ID", "/", "Secret", "credentials", "." ]
train
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/azure_active_directory.py#L356-L370
Azure/msrestazure-for-python
msrestazure/azure_active_directory.py
AdalAuthentication.signed_session
def signed_session(self, session=None): """Create requests session with any required auth headers applied. If a session object is provided, configure it directly. Otherwise, create a new session and return it. :param session: The session to configure for authentication :type se...
python
def signed_session(self, session=None): """Create requests session with any required auth headers applied. If a session object is provided, configure it directly. Otherwise, create a new session and return it. :param session: The session to configure for authentication :type se...
[ "def", "signed_session", "(", "self", ",", "session", "=", "None", ")", ":", "session", "=", "super", "(", "AdalAuthentication", ",", "self", ")", ".", "signed_session", "(", "session", ")", "try", ":", "raw_token", "=", "self", ".", "_adal_method", "(", ...
Create requests session with any required auth headers applied. If a session object is provided, configure it directly. Otherwise, create a new session and return it. :param session: The session to configure for authentication :type session: requests.Session :rtype: requests.Se...
[ "Create", "requests", "session", "with", "any", "required", "auth", "headers", "applied", "." ]
train
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/azure_active_directory.py#L434-L460
Azure/msrestazure-for-python
msrestazure/azure_active_directory.py
MSIAuthentication.signed_session
def signed_session(self, session=None): """Create requests session with any required auth headers applied. If a session object is provided, configure it directly. Otherwise, create a new session and return it. :param session: The session to configure for authentication :type se...
python
def signed_session(self, session=None): """Create requests session with any required auth headers applied. If a session object is provided, configure it directly. Otherwise, create a new session and return it. :param session: The session to configure for authentication :type se...
[ "def", "signed_session", "(", "self", ",", "session", "=", "None", ")", ":", "# Token cache is handled by the VM extension, call each time to avoid expiration", "self", ".", "set_token", "(", ")", "return", "super", "(", "MSIAuthentication", ",", "self", ")", ".", "si...
Create requests session with any required auth headers applied. If a session object is provided, configure it directly. Otherwise, create a new session and return it. :param session: The session to configure for authentication :type session: requests.Session :rtype: requests.Se...
[ "Create", "requests", "session", "with", "any", "required", "auth", "headers", "applied", "." ]
train
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/azure_active_directory.py#L587-L599
Azure/msrestazure-for-python
msrestazure/azure_operation.py
_validate
def _validate(url): """Validate a url. :param str url: Polling URL extracted from response header. :raises: ValueError if URL has no scheme or host. """ if url is None: return parsed = urlparse(url) if not parsed.scheme or not parsed.netloc: raise ValueError("Invalid URL hea...
python
def _validate(url): """Validate a url. :param str url: Polling URL extracted from response header. :raises: ValueError if URL has no scheme or host. """ if url is None: return parsed = urlparse(url) if not parsed.scheme or not parsed.netloc: raise ValueError("Invalid URL hea...
[ "def", "_validate", "(", "url", ")", ":", "if", "url", "is", "None", ":", "return", "parsed", "=", "urlparse", "(", "url", ")", "if", "not", "parsed", ".", "scheme", "or", "not", "parsed", ".", "netloc", ":", "raise", "ValueError", "(", "\"Invalid URL ...
Validate a url. :param str url: Polling URL extracted from response header. :raises: ValueError if URL has no scheme or host.
[ "Validate", "a", "url", "." ]
train
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/azure_operation.py#L63-L73
Azure/msrestazure-for-python
msrestazure/azure_operation.py
_get_header_url
def _get_header_url(response, header_name): """Get a URL from a header requests. :param requests.Response response: REST call response. :param str header_name: Header name. :returns: URL if not None AND valid, None otherwise """ url = response.headers.get(header_name) try: _validate...
python
def _get_header_url(response, header_name): """Get a URL from a header requests. :param requests.Response response: REST call response. :param str header_name: Header name. :returns: URL if not None AND valid, None otherwise """ url = response.headers.get(header_name) try: _validate...
[ "def", "_get_header_url", "(", "response", ",", "header_name", ")", ":", "url", "=", "response", ".", "headers", ".", "get", "(", "header_name", ")", "try", ":", "_validate", "(", "url", ")", "except", "ValueError", ":", "return", "None", "else", ":", "r...
Get a URL from a header requests. :param requests.Response response: REST call response. :param str header_name: Header name. :returns: URL if not None AND valid, None otherwise
[ "Get", "a", "URL", "from", "a", "header", "requests", "." ]
train
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/azure_operation.py#L75-L88
Azure/msrestazure-for-python
msrestazure/azure_operation.py
LongRunningOperation._raise_if_bad_http_status_and_method
def _raise_if_bad_http_status_and_method(self, response): """Check response status code is valid for a Put or Patch request. Must be 200, 201, 202, or 204. :raises: BadStatus if invalid status. """ code = response.status_code if code in {200, 202} or \ (code =...
python
def _raise_if_bad_http_status_and_method(self, response): """Check response status code is valid for a Put or Patch request. Must be 200, 201, 202, or 204. :raises: BadStatus if invalid status. """ code = response.status_code if code in {200, 202} or \ (code =...
[ "def", "_raise_if_bad_http_status_and_method", "(", "self", ",", "response", ")", ":", "code", "=", "response", ".", "status_code", "if", "code", "in", "{", "200", ",", "202", "}", "or", "(", "code", "==", "201", "and", "self", ".", "method", "in", "{", ...
Check response status code is valid for a Put or Patch request. Must be 200, 201, 202, or 204. :raises: BadStatus if invalid status.
[ "Check", "response", "status", "code", "is", "valid", "for", "a", "Put", "or", "Patch", "request", ".", "Must", "be", "200", "201", "202", "or", "204", "." ]
train
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/azure_operation.py#L136-L148
Azure/msrestazure-for-python
msrestazure/azure_operation.py
LongRunningOperation._is_empty
def _is_empty(self, response): """Check if response body contains meaningful content. :rtype: bool :raises: DeserializationError if response body contains invalid json data. """ if not response.content: return True try: body = response.js...
python
def _is_empty(self, response): """Check if response body contains meaningful content. :rtype: bool :raises: DeserializationError if response body contains invalid json data. """ if not response.content: return True try: body = response.js...
[ "def", "_is_empty", "(", "self", ",", "response", ")", ":", "if", "not", "response", ".", "content", ":", "return", "True", "try", ":", "body", "=", "response", ".", "json", "(", ")", "return", "not", "body", "except", "ValueError", ":", "raise", "Dese...
Check if response body contains meaningful content. :rtype: bool :raises: DeserializationError if response body contains invalid json data.
[ "Check", "if", "response", "body", "contains", "meaningful", "content", "." ]
train
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/azure_operation.py#L150-L164
Azure/msrestazure-for-python
msrestazure/azure_operation.py
LongRunningOperation._deserialize
def _deserialize(self, response): """Attempt to deserialize resource from response. :param requests.Response response: latest REST call response. """ # Hacking response with initial status_code previous_status = response.status_code response.status_code = self.initial_st...
python
def _deserialize(self, response): """Attempt to deserialize resource from response. :param requests.Response response: latest REST call response. """ # Hacking response with initial status_code previous_status = response.status_code response.status_code = self.initial_st...
[ "def", "_deserialize", "(", "self", ",", "response", ")", ":", "# Hacking response with initial status_code", "previous_status", "=", "response", ".", "status_code", "response", ".", "status_code", "=", "self", ".", "initial_status_code", "resource", "=", "self", ".",...
Attempt to deserialize resource from response. :param requests.Response response: latest REST call response.
[ "Attempt", "to", "deserialize", "resource", "from", "response", "." ]
train
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/azure_operation.py#L166-L190
Azure/msrestazure-for-python
msrestazure/azure_operation.py
LongRunningOperation._get_async_status
def _get_async_status(self, response): """Attempt to find status info in response body. :param requests.Response response: latest REST call response. :rtype: str :returns: Status if found, else 'None'. """ if self._is_empty(response): return None body...
python
def _get_async_status(self, response): """Attempt to find status info in response body. :param requests.Response response: latest REST call response. :rtype: str :returns: Status if found, else 'None'. """ if self._is_empty(response): return None body...
[ "def", "_get_async_status", "(", "self", ",", "response", ")", ":", "if", "self", ".", "_is_empty", "(", "response", ")", ":", "return", "None", "body", "=", "response", ".", "json", "(", ")", "return", "body", ".", "get", "(", "'status'", ")" ]
Attempt to find status info in response body. :param requests.Response response: latest REST call response. :rtype: str :returns: Status if found, else 'None'.
[ "Attempt", "to", "find", "status", "info", "in", "response", "body", "." ]
train
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/azure_operation.py#L192-L202
Azure/msrestazure-for-python
msrestazure/azure_operation.py
LongRunningOperation._get_provisioning_state
def _get_provisioning_state(self, response): """ Attempt to get provisioning state from resource. :param requests.Response response: latest REST call response. :returns: Status if found, else 'None'. """ if self._is_empty(response): return None body = ...
python
def _get_provisioning_state(self, response): """ Attempt to get provisioning state from resource. :param requests.Response response: latest REST call response. :returns: Status if found, else 'None'. """ if self._is_empty(response): return None body = ...
[ "def", "_get_provisioning_state", "(", "self", ",", "response", ")", ":", "if", "self", ".", "_is_empty", "(", "response", ")", ":", "return", "None", "body", "=", "response", ".", "json", "(", ")", "return", "body", ".", "get", "(", "\"properties\"", ",...
Attempt to get provisioning state from resource. :param requests.Response response: latest REST call response. :returns: Status if found, else 'None'.
[ "Attempt", "to", "get", "provisioning", "state", "from", "resource", ".", ":", "param", "requests", ".", "Response", "response", ":", "latest", "REST", "call", "response", ".", ":", "returns", ":", "Status", "if", "found", "else", "None", "." ]
train
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/azure_operation.py#L204-L213
Azure/msrestazure-for-python
msrestazure/azure_operation.py
LongRunningOperation.get_status_from_location
def get_status_from_location(self, response): """Process the latest status update retrieved from a 'location' header. :param requests.Response response: latest REST call response. :raises: BadResponse if response has no body and not status 202. """ self._raise_if_bad_htt...
python
def get_status_from_location(self, response): """Process the latest status update retrieved from a 'location' header. :param requests.Response response: latest REST call response. :raises: BadResponse if response has no body and not status 202. """ self._raise_if_bad_htt...
[ "def", "get_status_from_location", "(", "self", ",", "response", ")", ":", "self", ".", "_raise_if_bad_http_status_and_method", "(", "response", ")", "code", "=", "response", ".", "status_code", "if", "code", "==", "202", ":", "self", ".", "status", "=", "\"In...
Process the latest status update retrieved from a 'location' header. :param requests.Response response: latest REST call response. :raises: BadResponse if response has no body and not status 202.
[ "Process", "the", "latest", "status", "update", "retrieved", "from", "a", "location", "header", "." ]
train
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/azure_operation.py#L260-L276
Azure/msrestazure-for-python
msrestazure/azure_operation.py
LongRunningOperation.get_status_from_resource
def get_status_from_resource(self, response): """Process the latest status update retrieved from the same URL as the previous request. :param requests.Response response: latest REST call response. :raises: BadResponse if status not 200 or 204. """ self._raise_if_bad_http...
python
def get_status_from_resource(self, response): """Process the latest status update retrieved from the same URL as the previous request. :param requests.Response response: latest REST call response. :raises: BadResponse if status not 200 or 204. """ self._raise_if_bad_http...
[ "def", "get_status_from_resource", "(", "self", ",", "response", ")", ":", "self", ".", "_raise_if_bad_http_status_and_method", "(", "response", ")", "if", "self", ".", "_is_empty", "(", "response", ")", ":", "raise", "BadResponse", "(", "'The response from long run...
Process the latest status update retrieved from the same URL as the previous request. :param requests.Response response: latest REST call response. :raises: BadResponse if status not 200 or 204.
[ "Process", "the", "latest", "status", "update", "retrieved", "from", "the", "same", "URL", "as", "the", "previous", "request", "." ]
train
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/azure_operation.py#L278-L293
Azure/msrestazure-for-python
msrestazure/azure_operation.py
AzureOperationPoller._start
def _start(self, update_cmd): """Start the long running operation. On completion, runs any callbacks. :param callable update_cmd: The API reuqest to check the status of the operation. """ try: self._poll(update_cmd) except BadStatus: sel...
python
def _start(self, update_cmd): """Start the long running operation. On completion, runs any callbacks. :param callable update_cmd: The API reuqest to check the status of the operation. """ try: self._poll(update_cmd) except BadStatus: sel...
[ "def", "_start", "(", "self", ",", "update_cmd", ")", ":", "try", ":", "self", ".", "_poll", "(", "update_cmd", ")", "except", "BadStatus", ":", "self", ".", "_operation", ".", "status", "=", "'Failed'", "self", ".", "_exception", "=", "CloudError", "(",...
Start the long running operation. On completion, runs any callbacks. :param callable update_cmd: The API reuqest to check the status of the operation.
[ "Start", "the", "long", "running", "operation", ".", "On", "completion", "runs", "any", "callbacks", "." ]
train
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/azure_operation.py#L376-L407
Azure/msrestazure-for-python
msrestazure/azure_operation.py
AzureOperationPoller._polling_cookie
def _polling_cookie(self): """Collect retry cookie - we only want to do this for the test server at this point, unless we implement a proper cookie policy. :returns: Dictionary containing a cookie header if required, otherwise an empty dictionary. """ parsed_url = urlpa...
python
def _polling_cookie(self): """Collect retry cookie - we only want to do this for the test server at this point, unless we implement a proper cookie policy. :returns: Dictionary containing a cookie header if required, otherwise an empty dictionary. """ parsed_url = urlpa...
[ "def", "_polling_cookie", "(", "self", ")", ":", "parsed_url", "=", "urlparse", "(", "self", ".", "_response", ".", "request", ".", "url", ")", "host", "=", "parsed_url", ".", "hostname", ".", "strip", "(", "'.'", ")", "if", "host", "==", "'localhost'", ...
Collect retry cookie - we only want to do this for the test server at this point, unless we implement a proper cookie policy. :returns: Dictionary containing a cookie header if required, otherwise an empty dictionary.
[ "Collect", "retry", "cookie", "-", "we", "only", "want", "to", "do", "this", "for", "the", "test", "server", "at", "this", "point", "unless", "we", "implement", "a", "proper", "cookie", "policy", "." ]
train
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/azure_operation.py#L420-L431
Azure/msrestazure-for-python
msrestazure/azure_operation.py
AzureOperationPoller._poll
def _poll(self, update_cmd): """Poll status of operation so long as operation is incomplete and we have an endpoint to query. :param callable update_cmd: The function to call to retrieve the latest status of the long running operation. :raises: OperationFailed if operation stat...
python
def _poll(self, update_cmd): """Poll status of operation so long as operation is incomplete and we have an endpoint to query. :param callable update_cmd: The function to call to retrieve the latest status of the long running operation. :raises: OperationFailed if operation stat...
[ "def", "_poll", "(", "self", ",", "update_cmd", ")", ":", "initial_url", "=", "self", ".", "_response", ".", "request", ".", "url", "while", "not", "finished", "(", "self", ".", "status", "(", ")", ")", ":", "self", ".", "_delay", "(", ")", "headers"...
Poll status of operation so long as operation is incomplete and we have an endpoint to query. :param callable update_cmd: The function to call to retrieve the latest status of the long running operation. :raises: OperationFailed if operation status 'Failed' or 'Cancelled'. :rai...
[ "Poll", "status", "of", "operation", "so", "long", "as", "operation", "is", "incomplete", "and", "we", "have", "an", "endpoint", "to", "query", "." ]
train
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/azure_operation.py#L433-L475
Azure/msrestazure-for-python
msrestazure/azure_operation.py
AzureOperationPoller.add_done_callback
def add_done_callback(self, func): """Add callback function to be run once the long running operation has completed - regardless of the status of the operation. :param callable func: Callback function that takes at least one argument, a completed LongRunningOperation. :raises: ...
python
def add_done_callback(self, func): """Add callback function to be run once the long running operation has completed - regardless of the status of the operation. :param callable func: Callback function that takes at least one argument, a completed LongRunningOperation. :raises: ...
[ "def", "add_done_callback", "(", "self", ",", "func", ")", ":", "if", "self", ".", "_done", "is", "None", "or", "self", ".", "_done", ".", "is_set", "(", ")", ":", "raise", "ValueError", "(", "\"Process is complete.\"", ")", "self", ".", "_callbacks", "....
Add callback function to be run once the long running operation has completed - regardless of the status of the operation. :param callable func: Callback function that takes at least one argument, a completed LongRunningOperation. :raises: ValueError if the long running operation has a...
[ "Add", "callback", "function", "to", "be", "run", "once", "the", "long", "running", "operation", "has", "completed", "-", "regardless", "of", "the", "status", "of", "the", "operation", "." ]
train
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/azure_operation.py#L519-L530