repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
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...
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
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 ...
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.
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...
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...
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...
True unless converged or maximum iterations/time exceeded.
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...
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 ...
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...
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...
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...
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) ...
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...
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...
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 ...
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...
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...
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. ...
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...
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 (...
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 ...
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 ...
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]]
Returns objective values of models with specified rank.
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]]
Returns similarity scores for models with specified rank.
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]]
Returns KTensor factors for models with specified rank.
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. ...
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...
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])...
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...
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_...
Generate the model proxy class. :return: a :class:`odoorpc.models.Model` class
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': '...
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, ...
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':...
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...
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...
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': '...
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 ...
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...
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...
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/...
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...
Returns a new `data` dictionary with hidden params for log purpose.
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...
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...
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 ...
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. ...
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")
Check if a user is logged. Otherwise, an error is raised.
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' ...
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...
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:* ...
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...
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'}] ...
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: >>...
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...
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...
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=...
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...
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...
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...
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...
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...
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 ...
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` ...
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...
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) ...
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...
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...
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...
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...
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...
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....
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...
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 ...
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...
Returns the :class:`ProxyJSON <odoorpc.rpc.jsonrpclib.ProxyJSON>` and :class:`ProxyHTTP <odoorpc.rpc.jsonrpclib.ProxyHTTP>` instances corresponding to the server version used.
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
Set the timeout.
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
Return `True` if ``value`` is an integer.
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]]) ...
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
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: ...
Update `ids` according to `tuples`, e.g. (3, 0, X), (4, 0, X)...
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...
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]
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
Generate a well-typed field according to the data dictionary supplied (obtained via the `fields_get' method of any models).
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):...
Check the validity of a value for the field.
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
Store the value in the record.
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, [])
Store the value in the record.
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...
Raise a `ValueError` if `relation` is not allowed among the possible values.
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 >...
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]) ...
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....
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...
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...
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...
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...
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...
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))
As the `with_context` class method but for recordset.
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
Return a model (or recordset) equivalent to the current model (or recordset) attached to `env`.
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
As the `with_env` class method but for recordset.
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) ...
Retrieve field values from the server. May be used to restore the original values in the purpose to cancel all changes made.
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...
Takes a number of wei and converts it to any other ether unit.
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_...
Takes a number of a unit and converts it to wei.
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: ...
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
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...
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
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...
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
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,...
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
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...
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
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]) ...
Wrap the return value with the result of `type(args[at_position])`
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])...
Replaces old exceptions with new exceptions to be raised in their place.
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': '...
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'}, ......
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...
Checks if the given string of text type is an address in hexadecimal encoded form.
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
Checks if the given string is an address in raw bytes form.
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...
Checks if the given string in a supported value is an address in any of the known formats.
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 {}...
Converts an address to its normalized hexadecimal representation.
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)
Returns whether the provided value is an address in its normalized form.
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)
Returns `True` if the `value` is an address in its canonical form.
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...
Checks if both addresses are same or not.
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( ...
Makes a checksum address given a supported format.
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...
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. ...
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...
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
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'. ...
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...
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...
Convert token fields from camel case. :param dict token: An authentication token. :rtype: dict
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...
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: ...
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...
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...
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( ...
Get token using Username/Password credentials. :raises: AuthenticationError if credentials invalid, or call fails.
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( ...
Get token using Client ID/Secret credentials. :raises: AuthenticationError if credentials invalid, or call fails.
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...
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...
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...
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...
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...
Validate a url. :param str url: Polling URL extracted from response header. :raises: ValueError if URL has no scheme or host.
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...
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
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 =...
Check response status code is valid for a Put or Patch request. Must be 200, 201, 202, or 204. :raises: BadStatus if invalid status.
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...
Check if response body contains meaningful content. :rtype: bool :raises: DeserializationError if response body contains invalid json data.
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...
Attempt to deserialize resource from response. :param requests.Response response: latest REST call response.
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...
Attempt to find status info in response body. :param requests.Response response: latest REST call response. :rtype: str :returns: Status if found, else 'None'.
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 = ...
Attempt to get provisioning state from resource. :param requests.Response response: latest REST call response. :returns: Status if found, else 'None'.
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...
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.
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...
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.
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...
Start the long running operation. On completion, runs any callbacks. :param callable update_cmd: The API reuqest to check the status of the operation.
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...
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.
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...
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...
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: ...
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...
https://github.com/Azure/msrestazure-for-python/blob/5f99262305692525d03ca87d2c5356b05c5aa874/msrestazure/azure_operation.py#L519-L530