id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
51
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
251,200
F5Networks/f5-common-python
f5/bigip/tm/asm/policies/__init__.py
Policy.delete
def delete(self, **kwargs): """Custom deletion logic to handle edge cases This shouldn't be needed, but ASM has a tendency to raise various errors that are painful to handle from a customer point-of-view The error itself are described in their exception handler To address thes...
python
def delete(self, **kwargs): for x in range(0, 30): try: return self._delete(**kwargs) except iControlUnexpectedHTTPError as ex: if self._check_exception(ex): continue else: raise
[ "def", "delete", "(", "self", ",", "*", "*", "kwargs", ")", ":", "for", "x", "in", "range", "(", "0", ",", "30", ")", ":", "try", ":", "return", "self", ".", "_delete", "(", "*", "*", "kwargs", ")", "except", "iControlUnexpectedHTTPError", "as", "e...
Custom deletion logic to handle edge cases This shouldn't be needed, but ASM has a tendency to raise various errors that are painful to handle from a customer point-of-view The error itself are described in their exception handler To address these failure, we try a number of exception...
[ "Custom", "deletion", "logic", "to", "handle", "edge", "cases" ]
7e67d5acd757a60e3d5f8c88c534bd72208f5494
https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/tm/asm/policies/__init__.py#L174-L195
251,201
laurencium/Causalinference
causalinference/causal.py
CausalModel.reset
def reset(self): """ Reinitializes data to original inputs, and drops any estimated results. """ Y, D, X = self.old_data['Y'], self.old_data['D'], self.old_data['X'] self.raw_data = Data(Y, D, X) self.summary_stats = Summary(self.raw_data) self.propensity = None self.cutoff = None self.blocks = No...
python
def reset(self): Y, D, X = self.old_data['Y'], self.old_data['D'], self.old_data['X'] self.raw_data = Data(Y, D, X) self.summary_stats = Summary(self.raw_data) self.propensity = None self.cutoff = None self.blocks = None self.strata = None self.estimates = Estimators()
[ "def", "reset", "(", "self", ")", ":", "Y", ",", "D", ",", "X", "=", "self", ".", "old_data", "[", "'Y'", "]", ",", "self", ".", "old_data", "[", "'D'", "]", ",", "self", ".", "old_data", "[", "'X'", "]", "self", ".", "raw_data", "=", "Data", ...
Reinitializes data to original inputs, and drops any estimated results.
[ "Reinitializes", "data", "to", "original", "inputs", "and", "drops", "any", "estimated", "results", "." ]
3b20ae0560c711628fba47975180c8484d8aa3e7
https://github.com/laurencium/Causalinference/blob/3b20ae0560c711628fba47975180c8484d8aa3e7/causalinference/causal.py#L21-L35
251,202
laurencium/Causalinference
causalinference/causal.py
CausalModel.est_propensity
def est_propensity(self, lin='all', qua=None): """ Estimates the propensity scores given list of covariates to include linearly or quadratically. The propensity score is the conditional probability of receiving the treatment given the observed covariates. Estimation is done via a logistic regression. P...
python
def est_propensity(self, lin='all', qua=None): lin_terms = parse_lin_terms(self.raw_data['K'], lin) qua_terms = parse_qua_terms(self.raw_data['K'], qua) self.propensity = Propensity(self.raw_data, lin_terms, qua_terms) self.raw_data._dict['pscore'] = self.propensity['fitted'] self._post_pscore_init()
[ "def", "est_propensity", "(", "self", ",", "lin", "=", "'all'", ",", "qua", "=", "None", ")", ":", "lin_terms", "=", "parse_lin_terms", "(", "self", ".", "raw_data", "[", "'K'", "]", ",", "lin", ")", "qua_terms", "=", "parse_qua_terms", "(", "self", "....
Estimates the propensity scores given list of covariates to include linearly or quadratically. The propensity score is the conditional probability of receiving the treatment given the observed covariates. Estimation is done via a logistic regression. Parameters ---------- lin: string or list, optional ...
[ "Estimates", "the", "propensity", "scores", "given", "list", "of", "covariates", "to", "include", "linearly", "or", "quadratically", "." ]
3b20ae0560c711628fba47975180c8484d8aa3e7
https://github.com/laurencium/Causalinference/blob/3b20ae0560c711628fba47975180c8484d8aa3e7/causalinference/causal.py#L38-L69
251,203
laurencium/Causalinference
causalinference/causal.py
CausalModel.trim
def trim(self): """ Trims data based on propensity score to create a subsample with better covariate balance. The default cutoff value is set to 0.1. To set a custom cutoff value, modify the object attribute named cutoff directly. This method should only be executed after the propensity score has bee...
python
def trim(self): if 0 < self.cutoff <= 0.5: pscore = self.raw_data['pscore'] keep = (pscore >= self.cutoff) & (pscore <= 1-self.cutoff) Y_trimmed = self.raw_data['Y'][keep] D_trimmed = self.raw_data['D'][keep] X_trimmed = self.raw_data['X'][keep] self.raw_data = Data(Y_trimmed, D_trimmed, X_trimmed)...
[ "def", "trim", "(", "self", ")", ":", "if", "0", "<", "self", ".", "cutoff", "<=", "0.5", ":", "pscore", "=", "self", ".", "raw_data", "[", "'pscore'", "]", "keep", "=", "(", "pscore", ">=", "self", ".", "cutoff", ")", "&", "(", "pscore", "<=", ...
Trims data based on propensity score to create a subsample with better covariate balance. The default cutoff value is set to 0.1. To set a custom cutoff value, modify the object attribute named cutoff directly. This method should only be executed after the propensity score has been estimated.
[ "Trims", "data", "based", "on", "propensity", "score", "to", "create", "a", "subsample", "with", "better", "covariate", "balance", ".", "The", "default", "cutoff", "value", "is", "set", "to", "0", ".", "1", ".", "To", "set", "a", "custom", "cutoff", "val...
3b20ae0560c711628fba47975180c8484d8aa3e7
https://github.com/laurencium/Causalinference/blob/3b20ae0560c711628fba47975180c8484d8aa3e7/causalinference/causal.py#L118-L145
251,204
laurencium/Causalinference
causalinference/causal.py
CausalModel.stratify
def stratify(self): """ Stratifies the sample based on propensity score. By default the sample is divided into five equal-sized bins. The number of bins can be set by modifying the object attribute named blocks. Alternatively, custom-sized bins can be created by setting blocks equal to a sorted list of ...
python
def stratify(self): Y, D, X = self.raw_data['Y'], self.raw_data['D'], self.raw_data['X'] pscore = self.raw_data['pscore'] if isinstance(self.blocks, int): blocks = split_equal_bins(pscore, self.blocks) else: blocks = self.blocks[:] # make a copy; should be sorted blocks[0] = 0 # avoids always dropp...
[ "def", "stratify", "(", "self", ")", ":", "Y", ",", "D", ",", "X", "=", "self", ".", "raw_data", "[", "'Y'", "]", ",", "self", ".", "raw_data", "[", "'D'", "]", ",", "self", ".", "raw_data", "[", "'X'", "]", "pscore", "=", "self", ".", "raw_dat...
Stratifies the sample based on propensity score. By default the sample is divided into five equal-sized bins. The number of bins can be set by modifying the object attribute named blocks. Alternatively, custom-sized bins can be created by setting blocks equal to a sorted list of numbers between 0 and 1 ind...
[ "Stratifies", "the", "sample", "based", "on", "propensity", "score", ".", "By", "default", "the", "sample", "is", "divided", "into", "five", "equal", "-", "sized", "bins", ".", "The", "number", "of", "bins", "can", "be", "set", "by", "modifying", "the", ...
3b20ae0560c711628fba47975180c8484d8aa3e7
https://github.com/laurencium/Causalinference/blob/3b20ae0560c711628fba47975180c8484d8aa3e7/causalinference/causal.py#L171-L199
251,205
laurencium/Causalinference
causalinference/causal.py
CausalModel.est_via_matching
def est_via_matching(self, weights='inv', matches=1, bias_adj=False): """ Estimates average treatment effects using nearest- neighborhood matching. Matching is done with replacement. Method supports multiple matching. Correcting bias that arise due to imperfect matches is also supported. For details on me...
python
def est_via_matching(self, weights='inv', matches=1, bias_adj=False): X, K = self.raw_data['X'], self.raw_data['K'] X_c, X_t = self.raw_data['X_c'], self.raw_data['X_t'] if weights == 'inv': W = 1/X.var(0) elif weights == 'maha': V_c = np.cov(X_c, rowvar=False, ddof=0) V_t = np.cov(X_t, rowvar=False,...
[ "def", "est_via_matching", "(", "self", ",", "weights", "=", "'inv'", ",", "matches", "=", "1", ",", "bias_adj", "=", "False", ")", ":", "X", ",", "K", "=", "self", ".", "raw_data", "[", "'X'", "]", ",", "self", ".", "raw_data", "[", "'K'", "]", ...
Estimates average treatment effects using nearest- neighborhood matching. Matching is done with replacement. Method supports multiple matching. Correcting bias that arise due to imperfect matches is also supported. For details on methodology, see [1]_. Parameters ---------- weights: str or positive defi...
[ "Estimates", "average", "treatment", "effects", "using", "nearest", "-", "neighborhood", "matching", "." ]
3b20ae0560c711628fba47975180c8484d8aa3e7
https://github.com/laurencium/Causalinference/blob/3b20ae0560c711628fba47975180c8484d8aa3e7/causalinference/causal.py#L285-L332
251,206
laurencium/Causalinference
causalinference/utils/tools.py
random_data
def random_data(N=5000, K=3, unobservables=False, **kwargs): """ Function that generates data according to one of two simple models that satisfies the unconfoundedness assumption. The covariates and error terms are generated according to X ~ N(mu, Sigma), epsilon ~ N(0, Gamma). The counterfactual outcomes are...
python
def random_data(N=5000, K=3, unobservables=False, **kwargs): mu = kwargs.get('mu', np.zeros(K)) beta = kwargs.get('beta', np.ones(K)) theta = kwargs.get('theta', np.ones(K)) delta = kwargs.get('delta', 3) Sigma = kwargs.get('Sigma', np.identity(K)) Gamma = kwargs.get('Gamma', np.identity(2)) X = np.random.mult...
[ "def", "random_data", "(", "N", "=", "5000", ",", "K", "=", "3", ",", "unobservables", "=", "False", ",", "*", "*", "kwargs", ")", ":", "mu", "=", "kwargs", ".", "get", "(", "'mu'", ",", "np", ".", "zeros", "(", "K", ")", ")", "beta", "=", "k...
Function that generates data according to one of two simple models that satisfies the unconfoundedness assumption. The covariates and error terms are generated according to X ~ N(mu, Sigma), epsilon ~ N(0, Gamma). The counterfactual outcomes are generated by Y0 = X*beta + epsilon_0, Y1 = delta + X*(beta+thet...
[ "Function", "that", "generates", "data", "according", "to", "one", "of", "two", "simple", "models", "that", "satisfies", "the", "unconfoundedness", "assumption", "." ]
3b20ae0560c711628fba47975180c8484d8aa3e7
https://github.com/laurencium/Causalinference/blob/3b20ae0560c711628fba47975180c8484d8aa3e7/causalinference/utils/tools.py#L54-L113
251,207
laurencium/Causalinference
causalinference/core/summary.py
Summary._summarize_pscore
def _summarize_pscore(self, pscore_c, pscore_t): """ Called by Strata class during initialization. """ self._dict['p_min'] = min(pscore_c.min(), pscore_t.min()) self._dict['p_max'] = max(pscore_c.max(), pscore_t.max()) self._dict['p_c_mean'] = pscore_c.mean() self._dict['p_t_mean'] = pscore_t.mean()
python
def _summarize_pscore(self, pscore_c, pscore_t): self._dict['p_min'] = min(pscore_c.min(), pscore_t.min()) self._dict['p_max'] = max(pscore_c.max(), pscore_t.max()) self._dict['p_c_mean'] = pscore_c.mean() self._dict['p_t_mean'] = pscore_t.mean()
[ "def", "_summarize_pscore", "(", "self", ",", "pscore_c", ",", "pscore_t", ")", ":", "self", ".", "_dict", "[", "'p_min'", "]", "=", "min", "(", "pscore_c", ".", "min", "(", ")", ",", "pscore_t", ".", "min", "(", ")", ")", "self", ".", "_dict", "["...
Called by Strata class during initialization.
[ "Called", "by", "Strata", "class", "during", "initialization", "." ]
3b20ae0560c711628fba47975180c8484d8aa3e7
https://github.com/laurencium/Causalinference/blob/3b20ae0560c711628fba47975180c8484d8aa3e7/causalinference/core/summary.py#L40-L49
251,208
yoavaviram/python-amazon-simple-product-api
amazon/api.py
AmazonAPI.lookup_bulk
def lookup_bulk(self, ResponseGroup="Large", **kwargs): """Lookup Amazon Products in bulk. Returns all products matching requested ASINs, ignoring invalid entries. :return: A list of :class:`~.AmazonProduct` instances. """ response = self.api.ItemLookup(Res...
python
def lookup_bulk(self, ResponseGroup="Large", **kwargs): response = self.api.ItemLookup(ResponseGroup=ResponseGroup, **kwargs) root = objectify.fromstring(response) if not hasattr(root.Items, 'Item'): return [] return list( AmazonProduct( item, ...
[ "def", "lookup_bulk", "(", "self", ",", "ResponseGroup", "=", "\"Large\"", ",", "*", "*", "kwargs", ")", ":", "response", "=", "self", ".", "api", ".", "ItemLookup", "(", "ResponseGroup", "=", "ResponseGroup", ",", "*", "*", "kwargs", ")", "root", "=", ...
Lookup Amazon Products in bulk. Returns all products matching requested ASINs, ignoring invalid entries. :return: A list of :class:`~.AmazonProduct` instances.
[ "Lookup", "Amazon", "Products", "in", "bulk", "." ]
f1cb0e209145fcfac9444e4c733dd19deb59d31a
https://github.com/yoavaviram/python-amazon-simple-product-api/blob/f1cb0e209145fcfac9444e4c733dd19deb59d31a/amazon/api.py#L200-L219
251,209
yoavaviram/python-amazon-simple-product-api
amazon/api.py
AmazonAPI.similarity_lookup
def similarity_lookup(self, ResponseGroup="Large", **kwargs): """Similarty Lookup. Returns up to ten products that are similar to all items specified in the request. Example: >>> api.similarity_lookup(ItemId='B002L3XLBO,B000LQTBKI') """ response = self.api.S...
python
def similarity_lookup(self, ResponseGroup="Large", **kwargs): response = self.api.SimilarityLookup( ResponseGroup=ResponseGroup, **kwargs) root = objectify.fromstring(response) if root.Items.Request.IsValid == 'False': code = root.Items.Request.Errors.Error.Code ...
[ "def", "similarity_lookup", "(", "self", ",", "ResponseGroup", "=", "\"Large\"", ",", "*", "*", "kwargs", ")", ":", "response", "=", "self", ".", "api", ".", "SimilarityLookup", "(", "ResponseGroup", "=", "ResponseGroup", ",", "*", "*", "kwargs", ")", "roo...
Similarty Lookup. Returns up to ten products that are similar to all items specified in the request. Example: >>> api.similarity_lookup(ItemId='B002L3XLBO,B000LQTBKI')
[ "Similarty", "Lookup", "." ]
f1cb0e209145fcfac9444e4c733dd19deb59d31a
https://github.com/yoavaviram/python-amazon-simple-product-api/blob/f1cb0e209145fcfac9444e4c733dd19deb59d31a/amazon/api.py#L221-L247
251,210
yoavaviram/python-amazon-simple-product-api
amazon/api.py
AmazonAPI.browse_node_lookup
def browse_node_lookup(self, ResponseGroup="BrowseNodeInfo", **kwargs): """Browse Node Lookup. Returns the specified browse node's name, children, and ancestors. Example: >>> api.browse_node_lookup(BrowseNodeId='163357') """ response = self.api.BrowseNodeLookup( ...
python
def browse_node_lookup(self, ResponseGroup="BrowseNodeInfo", **kwargs): response = self.api.BrowseNodeLookup( ResponseGroup=ResponseGroup, **kwargs) root = objectify.fromstring(response) if root.BrowseNodes.Request.IsValid == 'False': code = root.BrowseNodes.Request.Error...
[ "def", "browse_node_lookup", "(", "self", ",", "ResponseGroup", "=", "\"BrowseNodeInfo\"", ",", "*", "*", "kwargs", ")", ":", "response", "=", "self", ".", "api", ".", "BrowseNodeLookup", "(", "ResponseGroup", "=", "ResponseGroup", ",", "*", "*", "kwargs", "...
Browse Node Lookup. Returns the specified browse node's name, children, and ancestors. Example: >>> api.browse_node_lookup(BrowseNodeId='163357')
[ "Browse", "Node", "Lookup", "." ]
f1cb0e209145fcfac9444e4c733dd19deb59d31a
https://github.com/yoavaviram/python-amazon-simple-product-api/blob/f1cb0e209145fcfac9444e4c733dd19deb59d31a/amazon/api.py#L249-L265
251,211
yoavaviram/python-amazon-simple-product-api
amazon/api.py
AmazonAPI.search_n
def search_n(self, n, **kwargs): """Search and return first N results.. :param n: An integer specifying the number of results to return. :return: A list of :class:`~.AmazonProduct`. """ region = kwargs.get('region', self.region) kwargs.update({'re...
python
def search_n(self, n, **kwargs): region = kwargs.get('region', self.region) kwargs.update({'region': region}) items = AmazonSearch(self.api, self.aws_associate_tag, **kwargs) return list(islice(items, n))
[ "def", "search_n", "(", "self", ",", "n", ",", "*", "*", "kwargs", ")", ":", "region", "=", "kwargs", ".", "get", "(", "'region'", ",", "self", ".", "region", ")", "kwargs", ".", "update", "(", "{", "'region'", ":", "region", "}", ")", "items", "...
Search and return first N results.. :param n: An integer specifying the number of results to return. :return: A list of :class:`~.AmazonProduct`.
[ "Search", "and", "return", "first", "N", "results", ".." ]
f1cb0e209145fcfac9444e4c733dd19deb59d31a
https://github.com/yoavaviram/python-amazon-simple-product-api/blob/f1cb0e209145fcfac9444e4c733dd19deb59d31a/amazon/api.py#L277-L288
251,212
yoavaviram/python-amazon-simple-product-api
amazon/api.py
LXMLWrapper._safe_get_element_date
def _safe_get_element_date(self, path, root=None): """Safe get elemnent date. Get element as datetime.date or None, :param root: Lxml element. :param path: String path (i.e. 'Items.Item.Offers.Offer'). :return: datetime.date or None. "...
python
def _safe_get_element_date(self, path, root=None): value = self._safe_get_element_text(path=path, root=root) if value is not None: try: value = dateutil.parser.parse(value) if value: value = value.date() except ValueError: ...
[ "def", "_safe_get_element_date", "(", "self", ",", "path", ",", "root", "=", "None", ")", ":", "value", "=", "self", ".", "_safe_get_element_text", "(", "path", "=", "path", ",", "root", "=", "root", ")", "if", "value", "is", "not", "None", ":", "try",...
Safe get elemnent date. Get element as datetime.date or None, :param root: Lxml element. :param path: String path (i.e. 'Items.Item.Offers.Offer'). :return: datetime.date or None.
[ "Safe", "get", "elemnent", "date", "." ]
f1cb0e209145fcfac9444e4c733dd19deb59d31a
https://github.com/yoavaviram/python-amazon-simple-product-api/blob/f1cb0e209145fcfac9444e4c733dd19deb59d31a/amazon/api.py#L490-L510
251,213
yoavaviram/python-amazon-simple-product-api
amazon/api.py
AmazonSearch.iterate_pages
def iterate_pages(self): """Iterate Pages. A generator which iterates over all pages. Keep in mind that Amazon limits the number of pages it makes available. :return: Yields lxml root elements. """ try: while not self.is_last_page: ...
python
def iterate_pages(self): try: while not self.is_last_page: self.current_page += 1 yield self._query(ItemPage=self.current_page, **self.kwargs) except NoMorePages: pass
[ "def", "iterate_pages", "(", "self", ")", ":", "try", ":", "while", "not", "self", ".", "is_last_page", ":", "self", ".", "current_page", "+=", "1", "yield", "self", ".", "_query", "(", "ItemPage", "=", "self", ".", "current_page", ",", "*", "*", "self...
Iterate Pages. A generator which iterates over all pages. Keep in mind that Amazon limits the number of pages it makes available. :return: Yields lxml root elements.
[ "Iterate", "Pages", "." ]
f1cb0e209145fcfac9444e4c733dd19deb59d31a
https://github.com/yoavaviram/python-amazon-simple-product-api/blob/f1cb0e209145fcfac9444e4c733dd19deb59d31a/amazon/api.py#L549-L563
251,214
yoavaviram/python-amazon-simple-product-api
amazon/api.py
AmazonBrowseNode.ancestor
def ancestor(self): """This browse node's immediate ancestor in the browse node tree. :return: The ancestor as an :class:`~.AmazonBrowseNode`, or None. """ ancestors = getattr(self.parsed_response, 'Ancestors', None) if hasattr(ancestors, 'BrowseNode'): r...
python
def ancestor(self): ancestors = getattr(self.parsed_response, 'Ancestors', None) if hasattr(ancestors, 'BrowseNode'): return AmazonBrowseNode(ancestors['BrowseNode']) return None
[ "def", "ancestor", "(", "self", ")", ":", "ancestors", "=", "getattr", "(", "self", ".", "parsed_response", ",", "'Ancestors'", ",", "None", ")", "if", "hasattr", "(", "ancestors", ",", "'BrowseNode'", ")", ":", "return", "AmazonBrowseNode", "(", "ancestors"...
This browse node's immediate ancestor in the browse node tree. :return: The ancestor as an :class:`~.AmazonBrowseNode`, or None.
[ "This", "browse", "node", "s", "immediate", "ancestor", "in", "the", "browse", "node", "tree", "." ]
f1cb0e209145fcfac9444e4c733dd19deb59d31a
https://github.com/yoavaviram/python-amazon-simple-product-api/blob/f1cb0e209145fcfac9444e4c733dd19deb59d31a/amazon/api.py#L624-L633
251,215
yoavaviram/python-amazon-simple-product-api
amazon/api.py
AmazonBrowseNode.ancestors
def ancestors(self): """A list of this browse node's ancestors in the browse node tree. :return: List of :class:`~.AmazonBrowseNode` objects. """ ancestors = [] node = self.ancestor while node is not None: ancestors.append(node) node =...
python
def ancestors(self): ancestors = [] node = self.ancestor while node is not None: ancestors.append(node) node = node.ancestor return ancestors
[ "def", "ancestors", "(", "self", ")", ":", "ancestors", "=", "[", "]", "node", "=", "self", ".", "ancestor", "while", "node", "is", "not", "None", ":", "ancestors", ".", "append", "(", "node", ")", "node", "=", "node", ".", "ancestor", "return", "anc...
A list of this browse node's ancestors in the browse node tree. :return: List of :class:`~.AmazonBrowseNode` objects.
[ "A", "list", "of", "this", "browse", "node", "s", "ancestors", "in", "the", "browse", "node", "tree", "." ]
f1cb0e209145fcfac9444e4c733dd19deb59d31a
https://github.com/yoavaviram/python-amazon-simple-product-api/blob/f1cb0e209145fcfac9444e4c733dd19deb59d31a/amazon/api.py#L636-L647
251,216
yoavaviram/python-amazon-simple-product-api
amazon/api.py
AmazonBrowseNode.children
def children(self): """This browse node's children in the browse node tree. :return: A list of this browse node's children in the browse node tree. """ children = [] child_nodes = getattr(self.parsed_response, 'Children') for child in getattr(child_nodes, 'BrowseNode', []): ...
python
def children(self): children = [] child_nodes = getattr(self.parsed_response, 'Children') for child in getattr(child_nodes, 'BrowseNode', []): children.append(AmazonBrowseNode(child)) return children
[ "def", "children", "(", "self", ")", ":", "children", "=", "[", "]", "child_nodes", "=", "getattr", "(", "self", ".", "parsed_response", ",", "'Children'", ")", "for", "child", "in", "getattr", "(", "child_nodes", ",", "'BrowseNode'", ",", "[", "]", ")",...
This browse node's children in the browse node tree. :return: A list of this browse node's children in the browse node tree.
[ "This", "browse", "node", "s", "children", "in", "the", "browse", "node", "tree", "." ]
f1cb0e209145fcfac9444e4c733dd19deb59d31a
https://github.com/yoavaviram/python-amazon-simple-product-api/blob/f1cb0e209145fcfac9444e4c733dd19deb59d31a/amazon/api.py#L650-L660
251,217
yoavaviram/python-amazon-simple-product-api
amazon/api.py
AmazonProduct.price_and_currency
def price_and_currency(self): """Get Offer Price and Currency. Return price according to the following process: * If product has a sale return Sales Price, otherwise, * Return Price, otherwise, * Return lowest offer price, otherwise, * Return None. :return: ...
python
def price_and_currency(self): price = self._safe_get_element_text( 'Offers.Offer.OfferListing.SalePrice.Amount') if price: currency = self._safe_get_element_text( 'Offers.Offer.OfferListing.SalePrice.CurrencyCode') else: price = self._safe_get_...
[ "def", "price_and_currency", "(", "self", ")", ":", "price", "=", "self", ".", "_safe_get_element_text", "(", "'Offers.Offer.OfferListing.SalePrice.Amount'", ")", "if", "price", ":", "currency", "=", "self", ".", "_safe_get_element_text", "(", "'Offers.Offer.OfferListin...
Get Offer Price and Currency. Return price according to the following process: * If product has a sale return Sales Price, otherwise, * Return Price, otherwise, * Return lowest offer price, otherwise, * Return None. :return: A tuple containing: ...
[ "Get", "Offer", "Price", "and", "Currency", "." ]
f1cb0e209145fcfac9444e4c733dd19deb59d31a
https://github.com/yoavaviram/python-amazon-simple-product-api/blob/f1cb0e209145fcfac9444e4c733dd19deb59d31a/amazon/api.py#L687-L724
251,218
yoavaviram/python-amazon-simple-product-api
amazon/api.py
AmazonProduct.reviews
def reviews(self): """Customer Reviews. Get a iframe URL for customer reviews. :return: A tuple of: has_reviews (bool), reviews url (string) """ iframe = self._safe_get_element_text('CustomerReviews.IFrameURL') has_reviews = self._safe_get_element_text('Cust...
python
def reviews(self): iframe = self._safe_get_element_text('CustomerReviews.IFrameURL') has_reviews = self._safe_get_element_text('CustomerReviews.HasReviews') if has_reviews is not None and has_reviews == 'true': has_reviews = True else: has_reviews = False ...
[ "def", "reviews", "(", "self", ")", ":", "iframe", "=", "self", ".", "_safe_get_element_text", "(", "'CustomerReviews.IFrameURL'", ")", "has_reviews", "=", "self", ".", "_safe_get_element_text", "(", "'CustomerReviews.HasReviews'", ")", "if", "has_reviews", "is", "n...
Customer Reviews. Get a iframe URL for customer reviews. :return: A tuple of: has_reviews (bool), reviews url (string)
[ "Customer", "Reviews", "." ]
f1cb0e209145fcfac9444e4c733dd19deb59d31a
https://github.com/yoavaviram/python-amazon-simple-product-api/blob/f1cb0e209145fcfac9444e4c733dd19deb59d31a/amazon/api.py#L954-L968
251,219
yoavaviram/python-amazon-simple-product-api
amazon/api.py
AmazonProduct.editorial_reviews
def editorial_reviews(self): """Editorial Review. Returns a list of all editorial reviews. :return: A list containing: Editorial Review (string) """ result = [] reviews_node = self._safe_get_element('EditorialReviews') if reviews_no...
python
def editorial_reviews(self): result = [] reviews_node = self._safe_get_element('EditorialReviews') if reviews_node is not None: for review_node in reviews_node.iterchildren(): content_node = getattr(review_node, 'Content') if content_node is not None:...
[ "def", "editorial_reviews", "(", "self", ")", ":", "result", "=", "[", "]", "reviews_node", "=", "self", ".", "_safe_get_element", "(", "'EditorialReviews'", ")", "if", "reviews_node", "is", "not", "None", ":", "for", "review_node", "in", "reviews_node", ".", ...
Editorial Review. Returns a list of all editorial reviews. :return: A list containing: Editorial Review (string)
[ "Editorial", "Review", "." ]
f1cb0e209145fcfac9444e4c733dd19deb59d31a
https://github.com/yoavaviram/python-amazon-simple-product-api/blob/f1cb0e209145fcfac9444e4c733dd19deb59d31a/amazon/api.py#L1069-L1087
251,220
yoavaviram/python-amazon-simple-product-api
amazon/api.py
AmazonProduct.list_price
def list_price(self): """List Price. :return: A tuple containing: 1. Decimal representation of price. 2. ISO Currency code (string). """ price = self._safe_get_element_text('ItemAttributes.ListPrice.Amount') currency = self._safe_get_...
python
def list_price(self): price = self._safe_get_element_text('ItemAttributes.ListPrice.Amount') currency = self._safe_get_element_text( 'ItemAttributes.ListPrice.CurrencyCode') if price: dprice = Decimal( price) / 100 if 'JP' not in self.region else Decimal(p...
[ "def", "list_price", "(", "self", ")", ":", "price", "=", "self", ".", "_safe_get_element_text", "(", "'ItemAttributes.ListPrice.Amount'", ")", "currency", "=", "self", ".", "_safe_get_element_text", "(", "'ItemAttributes.ListPrice.CurrencyCode'", ")", "if", "price", ...
List Price. :return: A tuple containing: 1. Decimal representation of price. 2. ISO Currency code (string).
[ "List", "Price", "." ]
f1cb0e209145fcfac9444e4c733dd19deb59d31a
https://github.com/yoavaviram/python-amazon-simple-product-api/blob/f1cb0e209145fcfac9444e4c733dd19deb59d31a/amazon/api.py#L1124-L1141
251,221
yoavaviram/python-amazon-simple-product-api
amazon/api.py
AmazonProduct.get_parent
def get_parent(self): """Get Parent. Fetch parent product if it exists. Use `parent_asin` to check if a parent exist before fetching. :return: An instance of :class:`~.AmazonProduct` representing the parent product. """ if not self.parent: ...
python
def get_parent(self): if not self.parent: parent = self._safe_get_element('ParentASIN') if parent: self.parent = self.api.lookup(ItemId=parent) return self.parent
[ "def", "get_parent", "(", "self", ")", ":", "if", "not", "self", ".", "parent", ":", "parent", "=", "self", ".", "_safe_get_element", "(", "'ParentASIN'", ")", "if", "parent", ":", "self", ".", "parent", "=", "self", ".", "api", ".", "lookup", "(", "...
Get Parent. Fetch parent product if it exists. Use `parent_asin` to check if a parent exist before fetching. :return: An instance of :class:`~.AmazonProduct` representing the parent product.
[ "Get", "Parent", "." ]
f1cb0e209145fcfac9444e4c733dd19deb59d31a
https://github.com/yoavaviram/python-amazon-simple-product-api/blob/f1cb0e209145fcfac9444e4c733dd19deb59d31a/amazon/api.py#L1196-L1210
251,222
yoavaviram/python-amazon-simple-product-api
amazon/api.py
AmazonProduct.browse_nodes
def browse_nodes(self): """Browse Nodes. :return: A list of :class:`~.AmazonBrowseNode` objects. """ root = self._safe_get_element('BrowseNodes') if root is None: return [] return [AmazonBrowseNode(child) for child in root.iterchildren()]
python
def browse_nodes(self): root = self._safe_get_element('BrowseNodes') if root is None: return [] return [AmazonBrowseNode(child) for child in root.iterchildren()]
[ "def", "browse_nodes", "(", "self", ")", ":", "root", "=", "self", ".", "_safe_get_element", "(", "'BrowseNodes'", ")", "if", "root", "is", "None", ":", "return", "[", "]", "return", "[", "AmazonBrowseNode", "(", "child", ")", "for", "child", "in", "root...
Browse Nodes. :return: A list of :class:`~.AmazonBrowseNode` objects.
[ "Browse", "Nodes", "." ]
f1cb0e209145fcfac9444e4c733dd19deb59d31a
https://github.com/yoavaviram/python-amazon-simple-product-api/blob/f1cb0e209145fcfac9444e4c733dd19deb59d31a/amazon/api.py#L1213-L1223
251,223
yoavaviram/python-amazon-simple-product-api
amazon/api.py
AmazonProduct.images
def images(self): """List of images for a response. When using lookup with RespnoseGroup 'Images', you'll get a list of images. Parse them so they are returned in an easily used list format. :return: A list of `ObjectifiedElement` images """ try: ...
python
def images(self): try: images = [image for image in self._safe_get_element( 'ImageSets.ImageSet')] except TypeError: # No images in this ResponseGroup images = [] return images
[ "def", "images", "(", "self", ")", ":", "try", ":", "images", "=", "[", "image", "for", "image", "in", "self", ".", "_safe_get_element", "(", "'ImageSets.ImageSet'", ")", "]", "except", "TypeError", ":", "# No images in this ResponseGroup", "images", "=", "[",...
List of images for a response. When using lookup with RespnoseGroup 'Images', you'll get a list of images. Parse them so they are returned in an easily used list format. :return: A list of `ObjectifiedElement` images
[ "List", "of", "images", "for", "a", "response", ".", "When", "using", "lookup", "with", "RespnoseGroup", "Images", "you", "ll", "get", "a", "list", "of", "images", ".", "Parse", "them", "so", "they", "are", "returned", "in", "an", "easily", "used", "list...
f1cb0e209145fcfac9444e4c733dd19deb59d31a
https://github.com/yoavaviram/python-amazon-simple-product-api/blob/f1cb0e209145fcfac9444e4c733dd19deb59d31a/amazon/api.py#L1226-L1240
251,224
yoavaviram/python-amazon-simple-product-api
amazon/api.py
AmazonProduct.actors
def actors(self): """Movie Actors. :return: A list of actors names. """ result = [] actors = self._safe_get_element('ItemAttributes.Actor') or [] for actor in actors: result.append(actor.text) return result
python
def actors(self): result = [] actors = self._safe_get_element('ItemAttributes.Actor') or [] for actor in actors: result.append(actor.text) return result
[ "def", "actors", "(", "self", ")", ":", "result", "=", "[", "]", "actors", "=", "self", ".", "_safe_get_element", "(", "'ItemAttributes.Actor'", ")", "or", "[", "]", "for", "actor", "in", "actors", ":", "result", ".", "append", "(", "actor", ".", "text...
Movie Actors. :return: A list of actors names.
[ "Movie", "Actors", "." ]
f1cb0e209145fcfac9444e4c733dd19deb59d31a
https://github.com/yoavaviram/python-amazon-simple-product-api/blob/f1cb0e209145fcfac9444e4c733dd19deb59d31a/amazon/api.py#L1252-L1262
251,225
yoavaviram/python-amazon-simple-product-api
amazon/api.py
AmazonProduct.directors
def directors(self): """Movie Directors. :return: A list of directors for a movie. """ result = [] directors = self._safe_get_element('ItemAttributes.Director') or [] for director in directors: result.append(director.text) return result
python
def directors(self): result = [] directors = self._safe_get_element('ItemAttributes.Director') or [] for director in directors: result.append(director.text) return result
[ "def", "directors", "(", "self", ")", ":", "result", "=", "[", "]", "directors", "=", "self", ".", "_safe_get_element", "(", "'ItemAttributes.Director'", ")", "or", "[", "]", "for", "director", "in", "directors", ":", "result", ".", "append", "(", "directo...
Movie Directors. :return: A list of directors for a movie.
[ "Movie", "Directors", "." ]
f1cb0e209145fcfac9444e4c733dd19deb59d31a
https://github.com/yoavaviram/python-amazon-simple-product-api/blob/f1cb0e209145fcfac9444e4c733dd19deb59d31a/amazon/api.py#L1265-L1275
251,226
etingof/pysnmp
pysnmp/smi/rfc1902.py
ObjectIdentity.getMibSymbol
def getMibSymbol(self): """Returns MIB variable symbolic identification. Returns ------- str MIB module name str MIB variable symbolic name : :py:class:`~pysnmp.proto.rfc1902.ObjectName` class instance representing MIB variable inst...
python
def getMibSymbol(self): if self._state & self.ST_CLEAN: return self._modName, self._symName, self._indices else: raise SmiError( '%s object not fully initialized' % self.__class__.__name__)
[ "def", "getMibSymbol", "(", "self", ")", ":", "if", "self", ".", "_state", "&", "self", ".", "ST_CLEAN", ":", "return", "self", ".", "_modName", ",", "self", ".", "_symName", ",", "self", ".", "_indices", "else", ":", "raise", "SmiError", "(", "'%s obj...
Returns MIB variable symbolic identification. Returns ------- str MIB module name str MIB variable symbolic name : :py:class:`~pysnmp.proto.rfc1902.ObjectName` class instance representing MIB variable instance index. Raises ...
[ "Returns", "MIB", "variable", "symbolic", "identification", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/rfc1902.py#L98-L128
251,227
etingof/pysnmp
pysnmp/smi/rfc1902.py
ObjectIdentity.getOid
def getOid(self): """Returns OID identifying MIB variable. Returns ------- : :py:class:`~pysnmp.proto.rfc1902.ObjectName` full OID identifying MIB variable including possible index part. Raises ------ SmiError If MIB variable conversion ha...
python
def getOid(self): if self._state & self.ST_CLEAN: return self._oid else: raise SmiError( '%s object not fully initialized' % self.__class__.__name__)
[ "def", "getOid", "(", "self", ")", ":", "if", "self", ".", "_state", "&", "self", ".", "ST_CLEAN", ":", "return", "self", ".", "_oid", "else", ":", "raise", "SmiError", "(", "'%s object not fully initialized'", "%", "self", ".", "__class__", ".", "__name__...
Returns OID identifying MIB variable. Returns ------- : :py:class:`~pysnmp.proto.rfc1902.ObjectName` full OID identifying MIB variable including possible index part. Raises ------ SmiError If MIB variable conversion has not been performed. ...
[ "Returns", "OID", "identifying", "MIB", "variable", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/rfc1902.py#L130-L156
251,228
etingof/pysnmp
pysnmp/smi/rfc1902.py
ObjectIdentity.getLabel
def getLabel(self): """Returns symbolic path to this MIB variable. Meaning a sequence of symbolic identifications for each of parent MIB objects in MIB tree. Returns ------- tuple sequence of names of nodes in a MIB tree from the top of the tree ...
python
def getLabel(self): if self._state & self.ST_CLEAN: return self._label else: raise SmiError( '%s object not fully initialized' % self.__class__.__name__)
[ "def", "getLabel", "(", "self", ")", ":", "if", "self", ".", "_state", "&", "self", ".", "ST_CLEAN", ":", "return", "self", ".", "_label", "else", ":", "raise", "SmiError", "(", "'%s object not fully initialized'", "%", "self", ".", "__class__", ".", "__na...
Returns symbolic path to this MIB variable. Meaning a sequence of symbolic identifications for each of parent MIB objects in MIB tree. Returns ------- tuple sequence of names of nodes in a MIB tree from the top of the tree towards this MIB variable. ...
[ "Returns", "symbolic", "path", "to", "this", "MIB", "variable", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/rfc1902.py#L158-L193
251,229
etingof/pysnmp
pysnmp/smi/rfc1902.py
ObjectIdentity.addMibSource
def addMibSource(self, *mibSources): """Adds path to repository to search PySNMP MIB files. Parameters ---------- *mibSources : one or more paths to search or Python package names to import and search for PySNMP MIB modules. Returns ------- ...
python
def addMibSource(self, *mibSources): if self._mibSourcesToAdd is None: self._mibSourcesToAdd = mibSources else: self._mibSourcesToAdd += mibSources return self
[ "def", "addMibSource", "(", "self", ",", "*", "mibSources", ")", ":", "if", "self", ".", "_mibSourcesToAdd", "is", "None", ":", "self", ".", "_mibSourcesToAdd", "=", "mibSources", "else", ":", "self", ".", "_mibSourcesToAdd", "+=", "mibSources", "return", "s...
Adds path to repository to search PySNMP MIB files. Parameters ---------- *mibSources : one or more paths to search or Python package names to import and search for PySNMP MIB modules. Returns ------- : :py:class:`~pysnmp.smi.rfc1902.ObjectIdenti...
[ "Adds", "path", "to", "repository", "to", "search", "PySNMP", "MIB", "files", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/rfc1902.py#L253-L287
251,230
etingof/pysnmp
pysnmp/smi/rfc1902.py
ObjectIdentity.loadMibs
def loadMibs(self, *modNames): """Schedules search and load of given MIB modules. Parameters ---------- *modNames: one or more MIB module names to load up and use for MIB variables resolution purposes. Returns ------- : :py:class:`~pysnmp...
python
def loadMibs(self, *modNames): if self._modNamesToLoad is None: self._modNamesToLoad = modNames else: self._modNamesToLoad += modNames return self
[ "def", "loadMibs", "(", "self", ",", "*", "modNames", ")", ":", "if", "self", ".", "_modNamesToLoad", "is", "None", ":", "self", ".", "_modNamesToLoad", "=", "modNames", "else", ":", "self", ".", "_modNamesToLoad", "+=", "modNames", "return", "self" ]
Schedules search and load of given MIB modules. Parameters ---------- *modNames: one or more MIB module names to load up and use for MIB variables resolution purposes. Returns ------- : :py:class:`~pysnmp.smi.rfc1902.ObjectIdentity` r...
[ "Schedules", "search", "and", "load", "of", "given", "MIB", "modules", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/rfc1902.py#L290-L316
251,231
etingof/pysnmp
pysnmp/smi/rfc1902.py
ObjectType.resolveWithMib
def resolveWithMib(self, mibViewController): """Perform MIB variable ID and associated value conversion. Parameters ---------- mibViewController : :py:class:`~pysnmp.smi.view.MibViewController` class instance representing MIB browsing functionality. Returns ...
python
def resolveWithMib(self, mibViewController): if self._state & self.ST_CLEAM: return self self._args[0].resolveWithMib(mibViewController) MibScalar, MibTableColumn = mibViewController.mibBuilder.importSymbols( 'SNMPv2-SMI', 'MibScalar', 'MibTableColumn') if not ...
[ "def", "resolveWithMib", "(", "self", ",", "mibViewController", ")", ":", "if", "self", ".", "_state", "&", "self", ".", "ST_CLEAM", ":", "return", "self", "self", ".", "_args", "[", "0", "]", ".", "resolveWithMib", "(", "mibViewController", ")", "MibScala...
Perform MIB variable ID and associated value conversion. Parameters ---------- mibViewController : :py:class:`~pysnmp.smi.view.MibViewController` class instance representing MIB browsing functionality. Returns ------- : :py:class:`~pysnmp.smi.rfc1902.ObjectT...
[ "Perform", "MIB", "variable", "ID", "and", "associated", "value", "conversion", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/rfc1902.py#L911-L993
251,232
etingof/pysnmp
pysnmp/smi/rfc1902.py
NotificationType.addVarBinds
def addVarBinds(self, *varBinds): """Appends variable-binding to notification. Parameters ---------- *varBinds : :py:class:`~pysnmp.smi.rfc1902.ObjectType` One or more :py:class:`~pysnmp.smi.rfc1902.ObjectType` class instances. Returns ------- ...
python
def addVarBinds(self, *varBinds): debug.logger & debug.FLAG_MIB and debug.logger( 'additional var-binds: %r' % (varBinds,)) if self._state & self.ST_CLEAN: raise SmiError( '%s object is already sealed' % self.__class__.__name__) else: self._a...
[ "def", "addVarBinds", "(", "self", ",", "*", "varBinds", ")", ":", "debug", ".", "logger", "&", "debug", ".", "FLAG_MIB", "and", "debug", ".", "logger", "(", "'additional var-binds: %r'", "%", "(", "varBinds", ",", ")", ")", "if", "self", ".", "_state", ...
Appends variable-binding to notification. Parameters ---------- *varBinds : :py:class:`~pysnmp.smi.rfc1902.ObjectType` One or more :py:class:`~pysnmp.smi.rfc1902.ObjectType` class instances. Returns ------- : :py:class:`~pysnmp.smi.rfc1902.Notifi...
[ "Appends", "variable", "-", "binding", "to", "notification", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/rfc1902.py#L1096-L1133
251,233
etingof/pysnmp
pysnmp/smi/rfc1902.py
NotificationType.resolveWithMib
def resolveWithMib(self, mibViewController): """Perform MIB variable ID conversion and notification objects expansion. Parameters ---------- mibViewController : :py:class:`~pysnmp.smi.view.MibViewController` class instance representing MIB browsing functionality. Re...
python
def resolveWithMib(self, mibViewController): if self._state & self.ST_CLEAN: return self self._objectIdentity.resolveWithMib(mibViewController) self._varBinds.append( ObjectType(ObjectIdentity(v2c.apiTrapPDU.snmpTrapOID), self._objectIdentity).res...
[ "def", "resolveWithMib", "(", "self", ",", "mibViewController", ")", ":", "if", "self", ".", "_state", "&", "self", ".", "ST_CLEAN", ":", "return", "self", "self", ".", "_objectIdentity", ".", "resolveWithMib", "(", "mibViewController", ")", "self", ".", "_v...
Perform MIB variable ID conversion and notification objects expansion. Parameters ---------- mibViewController : :py:class:`~pysnmp.smi.view.MibViewController` class instance representing MIB browsing functionality. Returns ------- : :py:class:`~pysnmp.smi.r...
[ "Perform", "MIB", "variable", "ID", "conversion", "and", "notification", "objects", "expansion", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/rfc1902.py#L1224-L1319
251,234
etingof/pysnmp
pysnmp/proto/rfc1902.py
Integer32.withValues
def withValues(cls, *values): """Creates a subclass with discreet values constraint. """ class X(cls): subtypeSpec = cls.subtypeSpec + constraint.SingleValueConstraint( *values) X.__name__ = cls.__name__ return X
python
def withValues(cls, *values): class X(cls): subtypeSpec = cls.subtypeSpec + constraint.SingleValueConstraint( *values) X.__name__ = cls.__name__ return X
[ "def", "withValues", "(", "cls", ",", "*", "values", ")", ":", "class", "X", "(", "cls", ")", ":", "subtypeSpec", "=", "cls", ".", "subtypeSpec", "+", "constraint", ".", "SingleValueConstraint", "(", "*", "values", ")", "X", ".", "__name__", "=", "cls"...
Creates a subclass with discreet values constraint.
[ "Creates", "a", "subclass", "with", "discreet", "values", "constraint", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/proto/rfc1902.py#L93-L102
251,235
etingof/pysnmp
pysnmp/proto/rfc1902.py
Integer32.withRange
def withRange(cls, minimum, maximum): """Creates a subclass with value range constraint. """ class X(cls): subtypeSpec = cls.subtypeSpec + constraint.ValueRangeConstraint( minimum, maximum) X.__name__ = cls.__name__ return X
python
def withRange(cls, minimum, maximum): class X(cls): subtypeSpec = cls.subtypeSpec + constraint.ValueRangeConstraint( minimum, maximum) X.__name__ = cls.__name__ return X
[ "def", "withRange", "(", "cls", ",", "minimum", ",", "maximum", ")", ":", "class", "X", "(", "cls", ")", ":", "subtypeSpec", "=", "cls", ".", "subtypeSpec", "+", "constraint", ".", "ValueRangeConstraint", "(", "minimum", ",", "maximum", ")", "X", ".", ...
Creates a subclass with value range constraint.
[ "Creates", "a", "subclass", "with", "value", "range", "constraint", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/proto/rfc1902.py#L105-L114
251,236
etingof/pysnmp
pysnmp/proto/rfc1902.py
Integer.withNamedValues
def withNamedValues(cls, **values): """Create a subclass with discreet named values constraint. Reduce fully duplicate enumerations along the way. """ enums = set(cls.namedValues.items()) enums.update(values.items()) class X(cls): namedValues = namedval.Name...
python
def withNamedValues(cls, **values): enums = set(cls.namedValues.items()) enums.update(values.items()) class X(cls): namedValues = namedval.NamedValues(*enums) subtypeSpec = cls.subtypeSpec + constraint.SingleValueConstraint( *values.values()) X._...
[ "def", "withNamedValues", "(", "cls", ",", "*", "*", "values", ")", ":", "enums", "=", "set", "(", "cls", ".", "namedValues", ".", "items", "(", ")", ")", "enums", ".", "update", "(", "values", ".", "items", "(", ")", ")", "class", "X", "(", "cls...
Create a subclass with discreet named values constraint. Reduce fully duplicate enumerations along the way.
[ "Create", "a", "subclass", "with", "discreet", "named", "values", "constraint", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/proto/rfc1902.py#L162-L177
251,237
etingof/pysnmp
pysnmp/proto/rfc1902.py
OctetString.withSize
def withSize(cls, minimum, maximum): """Creates a subclass with value size constraint. """ class X(cls): subtypeSpec = cls.subtypeSpec + constraint.ValueSizeConstraint( minimum, maximum) X.__name__ = cls.__name__ return X
python
def withSize(cls, minimum, maximum): class X(cls): subtypeSpec = cls.subtypeSpec + constraint.ValueSizeConstraint( minimum, maximum) X.__name__ = cls.__name__ return X
[ "def", "withSize", "(", "cls", ",", "minimum", ",", "maximum", ")", ":", "class", "X", "(", "cls", ")", ":", "subtypeSpec", "=", "cls", ".", "subtypeSpec", "+", "constraint", ".", "ValueSizeConstraint", "(", "minimum", ",", "maximum", ")", "X", ".", "_...
Creates a subclass with value size constraint.
[ "Creates", "a", "subclass", "with", "value", "size", "constraint", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/proto/rfc1902.py#L248-L257
251,238
etingof/pysnmp
pysnmp/proto/rfc1902.py
Bits.withNamedBits
def withNamedBits(cls, **values): """Creates a subclass with discreet named bits constraint. Reduce fully duplicate enumerations along the way. """ enums = set(cls.namedValues.items()) enums.update(values.items()) class X(cls): namedValues = namedval.NamedVa...
python
def withNamedBits(cls, **values): enums = set(cls.namedValues.items()) enums.update(values.items()) class X(cls): namedValues = namedval.NamedValues(*enums) X.__name__ = cls.__name__ return X
[ "def", "withNamedBits", "(", "cls", ",", "*", "*", "values", ")", ":", "enums", "=", "set", "(", "cls", ".", "namedValues", ".", "items", "(", ")", ")", "enums", ".", "update", "(", "values", ".", "items", "(", ")", ")", "class", "X", "(", "cls",...
Creates a subclass with discreet named bits constraint. Reduce fully duplicate enumerations along the way.
[ "Creates", "a", "subclass", "with", "discreet", "named", "bits", "constraint", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/proto/rfc1902.py#L698-L710
251,239
etingof/pysnmp
pysnmp/smi/builder.py
MibBuilder.loadModule
def loadModule(self, modName, **userCtx): """Load and execute MIB modules as Python code""" for mibSource in self._mibSources: debug.logger & debug.FLAG_BLD and debug.logger( 'loadModule: trying %s at %s' % (modName, mibSource)) try: codeObj, sfx ...
python
def loadModule(self, modName, **userCtx): for mibSource in self._mibSources: debug.logger & debug.FLAG_BLD and debug.logger( 'loadModule: trying %s at %s' % (modName, mibSource)) try: codeObj, sfx = mibSource.read(modName) except IOError as e...
[ "def", "loadModule", "(", "self", ",", "modName", ",", "*", "*", "userCtx", ")", ":", "for", "mibSource", "in", "self", ".", "_mibSources", ":", "debug", ".", "logger", "&", "debug", ".", "FLAG_BLD", "and", "debug", ".", "logger", "(", "'loadModule: tryi...
Load and execute MIB modules as Python code
[ "Load", "and", "execute", "MIB", "modules", "as", "Python", "code" ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/builder.py#L354-L407
251,240
etingof/pysnmp
pysnmp/hlapi/v1arch/asyncore/sync/cmdgen.py
nextCmd
def nextCmd(snmpDispatcher, authData, transportTarget, *varBinds, **options): """Create a generator to perform one or more SNMP GETNEXT queries. On each iteration, new SNMP GETNEXT request is send (:RFC:`1905#section-4.2.2`). The iterator blocks waiting for response to arrive or error to oc...
python
def nextCmd(snmpDispatcher, authData, transportTarget, *varBinds, **options): def cbFun(*args, **kwargs): response[:] = args + (kwargs.get('nextVarBinds', ()),) options['cbFun'] = cbFun lexicographicMode = options.pop('lexicographicMode', True) maxRows = options.pop('maxRows', 0) ...
[ "def", "nextCmd", "(", "snmpDispatcher", ",", "authData", ",", "transportTarget", ",", "*", "varBinds", ",", "*", "*", "options", ")", ":", "def", "cbFun", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "response", "[", ":", "]", "=", "args", ...
Create a generator to perform one or more SNMP GETNEXT queries. On each iteration, new SNMP GETNEXT request is send (:RFC:`1905#section-4.2.2`). The iterator blocks waiting for response to arrive or error to occur. Parameters ---------- snmpDispatcher : :py:class:`~pysnmp.hlapi.snmpDispatcher`...
[ "Create", "a", "generator", "to", "perform", "one", "or", "more", "SNMP", "GETNEXT", "queries", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/hlapi/v1arch/asyncore/sync/cmdgen.py#L201-L363
251,241
etingof/pysnmp
pysnmp/proto/rfc3412.py
MsgAndPduDispatcher.registerContextEngineId
def registerContextEngineId(self, contextEngineId, pduTypes, processPdu): """Register application with dispatcher""" # 4.3.2 -> no-op # 4.3.3 for pduType in pduTypes: k = contextEngineId, pduType if k in self._appsRegistration: raise error.Protoco...
python
def registerContextEngineId(self, contextEngineId, pduTypes, processPdu): # 4.3.2 -> no-op # 4.3.3 for pduType in pduTypes: k = contextEngineId, pduType if k in self._appsRegistration: raise error.ProtocolError( 'Duplicate registration...
[ "def", "registerContextEngineId", "(", "self", ",", "contextEngineId", ",", "pduTypes", ",", "processPdu", ")", ":", "# 4.3.2 -> no-op", "# 4.3.3", "for", "pduType", "in", "pduTypes", ":", "k", "=", "contextEngineId", ",", "pduType", "if", "k", "in", "self", "...
Register application with dispatcher
[ "Register", "application", "with", "dispatcher" ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/proto/rfc3412.py#L64-L80
251,242
etingof/pysnmp
pysnmp/proto/rfc3412.py
MsgAndPduDispatcher.unregisterContextEngineId
def unregisterContextEngineId(self, contextEngineId, pduTypes): """Unregister application with dispatcher""" # 4.3.4 if contextEngineId is None: # Default to local snmpEngineId contextEngineId, = self.mibInstrumController.mibBuilder.importSymbols( '__SNMP...
python
def unregisterContextEngineId(self, contextEngineId, pduTypes): # 4.3.4 if contextEngineId is None: # Default to local snmpEngineId contextEngineId, = self.mibInstrumController.mibBuilder.importSymbols( '__SNMP-FRAMEWORK-MIB', 'snmpEngineID') for pduType ...
[ "def", "unregisterContextEngineId", "(", "self", ",", "contextEngineId", ",", "pduTypes", ")", ":", "# 4.3.4", "if", "contextEngineId", "is", "None", ":", "# Default to local snmpEngineId", "contextEngineId", ",", "=", "self", ".", "mibInstrumController", ".", "mibBui...
Unregister application with dispatcher
[ "Unregister", "application", "with", "dispatcher" ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/proto/rfc3412.py#L83-L99
251,243
etingof/pysnmp
pysnmp/hlapi/v3arch/twisted/ntforg.py
sendNotification
def sendNotification(snmpEngine, authData, transportTarget, contextData, notifyType, *varBinds, **options): """Sends SNMP notification. Based on passed parameters, prepares SNMP TRAP or INFORM message (:RFC:`1905#section-4.2.6`) and schedules its transmission by :mod:`twisted` I/O ...
python
def sendNotification(snmpEngine, authData, transportTarget, contextData, notifyType, *varBinds, **options): def __cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): lookupMib, deferred = cbCtx if err...
[ "def", "sendNotification", "(", "snmpEngine", ",", "authData", ",", "transportTarget", ",", "contextData", ",", "notifyType", ",", "*", "varBinds", ",", "*", "*", "options", ")", ":", "def", "__cbFun", "(", "snmpEngine", ",", "sendRequestHandle", ",", "errorIn...
Sends SNMP notification. Based on passed parameters, prepares SNMP TRAP or INFORM message (:RFC:`1905#section-4.2.6`) and schedules its transmission by :mod:`twisted` I/O framework at a later point of time. Parameters ---------- snmpEngine: :py:class:`~pysnmp.hlapi.SnmpEngine` Class in...
[ "Sends", "SNMP", "notification", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/hlapi/v3arch/twisted/ntforg.py#L25-L189
251,244
etingof/pysnmp
pysnmp/hlapi/v3arch/twisted/cmdgen.py
nextCmd
def nextCmd(snmpEngine, authData, transportTarget, contextData, *varBinds, **options): """Performs SNMP GETNEXT query. Based on passed parameters, prepares SNMP GETNEXT packet (:RFC:`1905#section-4.2.2`) and schedules its transmission by :mod:`twisted` I/O framework at a later point of time...
python
def nextCmd(snmpEngine, authData, transportTarget, contextData, *varBinds, **options): def __cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): lookupMib, deferred = cbCtx if (options.get('ignoreNonIncrea...
[ "def", "nextCmd", "(", "snmpEngine", ",", "authData", ",", "transportTarget", ",", "contextData", ",", "*", "varBinds", ",", "*", "*", "options", ")", ":", "def", "__cbFun", "(", "snmpEngine", ",", "sendRequestHandle", ",", "errorIndication", ",", "errorStatus...
Performs SNMP GETNEXT query. Based on passed parameters, prepares SNMP GETNEXT packet (:RFC:`1905#section-4.2.2`) and schedules its transmission by :mod:`twisted` I/O framework at a later point of time. Parameters ---------- snmpEngine : :class:`~pysnmp.hlapi.SnmpEngine` Class instance...
[ "Performs", "SNMP", "GETNEXT", "query", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/hlapi/v3arch/twisted/cmdgen.py#L268-L401
251,245
etingof/pysnmp
pysnmp/smi/mibs/SNMPv2-SMI.py
ManagedMibObject.getBranch
def getBranch(self, name, **context): """Return a branch of this tree where the 'name' OID may reside""" for keyLen in self._vars.getKeysLens(): subName = name[:keyLen] if subName in self._vars: return self._vars[subName] raise error.NoSuchObjectError(nam...
python
def getBranch(self, name, **context): for keyLen in self._vars.getKeysLens(): subName = name[:keyLen] if subName in self._vars: return self._vars[subName] raise error.NoSuchObjectError(name=name, idx=context.get('idx'))
[ "def", "getBranch", "(", "self", ",", "name", ",", "*", "*", "context", ")", ":", "for", "keyLen", "in", "self", ".", "_vars", ".", "getKeysLens", "(", ")", ":", "subName", "=", "name", "[", ":", "keyLen", "]", "if", "subName", "in", "self", ".", ...
Return a branch of this tree where the 'name' OID may reside
[ "Return", "a", "branch", "of", "this", "tree", "where", "the", "name", "OID", "may", "reside" ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/mibs/SNMPv2-SMI.py#L455-L462
251,246
etingof/pysnmp
pysnmp/smi/mibs/SNMPv2-SMI.py
ManagedMibObject.getNode
def getNode(self, name, **context): """Return tree node found by name""" if name == self.name: return self else: return self.getBranch(name, **context).getNode(name, **context)
python
def getNode(self, name, **context): if name == self.name: return self else: return self.getBranch(name, **context).getNode(name, **context)
[ "def", "getNode", "(", "self", ",", "name", ",", "*", "*", "context", ")", ":", "if", "name", "==", "self", ".", "name", ":", "return", "self", "else", ":", "return", "self", ".", "getBranch", "(", "name", ",", "*", "*", "context", ")", ".", "get...
Return tree node found by name
[ "Return", "tree", "node", "found", "by", "name" ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/mibs/SNMPv2-SMI.py#L478-L483
251,247
etingof/pysnmp
pysnmp/smi/mibs/SNMPv2-SMI.py
ManagedMibObject.getNextNode
def getNextNode(self, name, **context): """Return tree node next to name""" try: nextNode = self.getBranch(name, **context) except (error.NoSuchInstanceError, error.NoSuchObjectError): return self.getNextBranch(name, **context) else: try: ...
python
def getNextNode(self, name, **context): try: nextNode = self.getBranch(name, **context) except (error.NoSuchInstanceError, error.NoSuchObjectError): return self.getNextBranch(name, **context) else: try: return nextNode.getNextNode(name, **conte...
[ "def", "getNextNode", "(", "self", ",", "name", ",", "*", "*", "context", ")", ":", "try", ":", "nextNode", "=", "self", ".", "getBranch", "(", "name", ",", "*", "*", "context", ")", "except", "(", "error", ".", "NoSuchInstanceError", ",", "error", "...
Return tree node next to name
[ "Return", "tree", "node", "next", "to", "name" ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/mibs/SNMPv2-SMI.py#L485-L498
251,248
etingof/pysnmp
pysnmp/smi/mibs/SNMPv2-SMI.py
ManagedMibObject.writeCommit
def writeCommit(self, varBind, **context): """Commit new value of the Managed Object Instance. Implements the second of the multi-step workflow of the SNMP SET command processing (:RFC:`1905#section-4.2.5`). The goal of the second phase is to actually modify the requested Managed ...
python
def writeCommit(self, varBind, **context): name, val = varBind (debug.logger & debug.FLAG_INS and debug.logger('%s: writeCommit(%s, %r)' % (self, name, val))) cbFun = context['cbFun'] instances = context['instances'].setdefault(self.name, {self.ST_CREATE: {}, self.ST_DESTROY:...
[ "def", "writeCommit", "(", "self", ",", "varBind", ",", "*", "*", "context", ")", ":", "name", ",", "val", "=", "varBind", "(", "debug", ".", "logger", "&", "debug", ".", "FLAG_INS", "and", "debug", ".", "logger", "(", "'%s: writeCommit(%s, %r)'", "%", ...
Commit new value of the Managed Object Instance. Implements the second of the multi-step workflow of the SNMP SET command processing (:RFC:`1905#section-4.2.5`). The goal of the second phase is to actually modify the requested Managed Object Instance. When multiple Managed Objects Inst...
[ "Commit", "new", "value", "of", "the", "Managed", "Object", "Instance", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/mibs/SNMPv2-SMI.py#L860-L925
251,249
etingof/pysnmp
pysnmp/smi/mibs/SNMPv2-SMI.py
MibScalar.readGet
def readGet(self, varBind, **context): """Read Managed Object Instance. Implements the second of the two phases of the SNMP GET command processing (:RFC:`1905#section-4.2.1`). The goal of the second phase is to actually read the requested Managed Object Instance. When multiple ...
python
def readGet(self, varBind, **context): name, val = varBind (debug.logger & debug.FLAG_INS and debug.logger('%s: readGet(%s, %r)' % (self, name, val))) cbFun = context['cbFun'] if name == self.name: cbFun((name, exval.noSuchInstance), **context) return ...
[ "def", "readGet", "(", "self", ",", "varBind", ",", "*", "*", "context", ")", ":", "name", ",", "val", "=", "varBind", "(", "debug", ".", "logger", "&", "debug", ".", "FLAG_INS", "and", "debug", ".", "logger", "(", "'%s: readGet(%s, %r)'", "%", "(", ...
Read Managed Object Instance. Implements the second of the two phases of the SNMP GET command processing (:RFC:`1905#section-4.2.1`). The goal of the second phase is to actually read the requested Managed Object Instance. When multiple Managed Objects Instances are read at once...
[ "Read", "Managed", "Object", "Instance", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/mibs/SNMPv2-SMI.py#L1139-L1203
251,250
etingof/pysnmp
pysnmp/smi/mibs/SNMPv2-SMI.py
MibScalar.readGetNext
def readGetNext(self, varBind, **context): """Read the next Managed Object Instance. Implements the second of the two phases of the SNMP GETNEXT command processing (:RFC:`1905#section-4.2.2`). The goal of the second phase is to actually read the Managed Object Instance which is...
python
def readGetNext(self, varBind, **context): name, val = varBind (debug.logger & debug.FLAG_INS and debug.logger('%s: readGetNext(%s, %r)' % (self, name, val))) acFun = context.get('acFun') if acFun: if (self.maxAccess not in ('readonly', 'readwrite', 'readcreate') o...
[ "def", "readGetNext", "(", "self", ",", "varBind", ",", "*", "*", "context", ")", ":", "name", ",", "val", "=", "varBind", "(", "debug", ".", "logger", "&", "debug", ".", "FLAG_INS", "and", "debug", ".", "logger", "(", "'%s: readGetNext(%s, %r)'", "%", ...
Read the next Managed Object Instance. Implements the second of the two phases of the SNMP GETNEXT command processing (:RFC:`1905#section-4.2.2`). The goal of the second phase is to actually read the Managed Object Instance which is next in the MIB tree to the one being requested. ...
[ "Read", "the", "next", "Managed", "Object", "Instance", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/mibs/SNMPv2-SMI.py#L1205-L1274
251,251
etingof/pysnmp
pysnmp/smi/mibs/SNMPv2-SMI.py
MibScalar.createCommit
def createCommit(self, varBind, **context): """Create Managed Object Instance. Implements the second of the multi-step workflow similar to the SNMP SET command processing (:RFC:`1905#section-4.2.5`). The goal of the second phase is to actually create requested Managed Object In...
python
def createCommit(self, varBind, **context): name, val = varBind (debug.logger & debug.FLAG_INS and debug.logger('%s: writeCommit(%s, %r)' % (self, name, val))) cbFun = context['cbFun'] instances = context['instances'].setdefault(self.name, {self.ST_CREATE: {}, self.ST_DESTROY...
[ "def", "createCommit", "(", "self", ",", "varBind", ",", "*", "*", "context", ")", ":", "name", ",", "val", "=", "varBind", "(", "debug", ".", "logger", "&", "debug", ".", "FLAG_INS", "and", "debug", ".", "logger", "(", "'%s: writeCommit(%s, %r)'", "%", ...
Create Managed Object Instance. Implements the second of the multi-step workflow similar to the SNMP SET command processing (:RFC:`1905#section-4.2.5`). The goal of the second phase is to actually create requested Managed Object Instance. When multiple Managed Objects Instances are cre...
[ "Create", "Managed", "Object", "Instance", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/mibs/SNMPv2-SMI.py#L1420-L1481
251,252
etingof/pysnmp
pysnmp/smi/mibs/SNMPv2-SMI.py
MibScalar.createCleanup
def createCleanup(self, varBind, **context): """Finalize Managed Object Instance creation. Implements the successful third step of the multi-step workflow similar to the SNMP SET command processing (:RFC:`1905#section-4.2.5`). The goal of the third (successful) phase is to seal the new...
python
def createCleanup(self, varBind, **context): name, val = varBind (debug.logger & debug.FLAG_INS and debug.logger('%s: createCleanup(%s, %r)' % (self, name, val))) instances = context['instances'].setdefault(self.name, {self.ST_CREATE: {}, self.ST_DESTROY: {}}) idx = context['i...
[ "def", "createCleanup", "(", "self", ",", "varBind", ",", "*", "*", "context", ")", ":", "name", ",", "val", "=", "varBind", "(", "debug", ".", "logger", "&", "debug", ".", "FLAG_INS", "and", "debug", ".", "logger", "(", "'%s: createCleanup(%s, %r)'", "%...
Finalize Managed Object Instance creation. Implements the successful third step of the multi-step workflow similar to the SNMP SET command processing (:RFC:`1905#section-4.2.5`). The goal of the third (successful) phase is to seal the new Managed Object Instance. Once the system transi...
[ "Finalize", "Managed", "Object", "Instance", "creation", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/mibs/SNMPv2-SMI.py#L1483-L1534
251,253
etingof/pysnmp
pysnmp/smi/mibs/SNMPv2-SMI.py
MibTableColumn.destroyCommit
def destroyCommit(self, varBind, **context): """Destroy Managed Object Instance. Implements the second of the multi-step workflow similar to the SNMP SET command processing (:RFC:`1905#section-4.2.5`). The goal of the second phase is to actually remove requested Managed Object ...
python
def destroyCommit(self, varBind, **context): name, val = varBind (debug.logger & debug.FLAG_INS and debug.logger('%s: destroyCommit(%s, %r)' % (self, name, val))) instances = context['instances'].setdefault(self.name, {self.ST_CREATE: {}, self.ST_DESTROY: {}}) idx = context['i...
[ "def", "destroyCommit", "(", "self", ",", "varBind", ",", "*", "*", "context", ")", ":", "name", ",", "val", "=", "varBind", "(", "debug", ".", "logger", "&", "debug", ".", "FLAG_INS", "and", "debug", ".", "logger", "(", "'%s: destroyCommit(%s, %r)'", "%...
Destroy Managed Object Instance. Implements the second of the multi-step workflow similar to the SNMP SET command processing (:RFC:`1905#section-4.2.5`). The goal of the second phase is to actually remove requested Managed Object Instance from the MIB tree. When multiple Managed Object...
[ "Destroy", "Managed", "Object", "Instance", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/mibs/SNMPv2-SMI.py#L2267-L2327
251,254
etingof/pysnmp
pysnmp/smi/mibs/SNMPv2-SMI.py
MibTableRow.oidToValue
def oidToValue(self, syntax, identifier, impliedFlag=False, parentIndices=None): """Turn SMI table instance identifier into a value object. SNMP SMI table objects are identified by OIDs composed of columnar object ID and instance index. The index part can be composed from the values of ...
python
def oidToValue(self, syntax, identifier, impliedFlag=False, parentIndices=None): if not identifier: raise error.SmiError('Short OID for index %r' % (syntax,)) if hasattr(syntax, 'cloneFromName'): return syntax.cloneFromName( identifier, impliedFlag, parentRow=sel...
[ "def", "oidToValue", "(", "self", ",", "syntax", ",", "identifier", ",", "impliedFlag", "=", "False", ",", "parentIndices", "=", "None", ")", ":", "if", "not", "identifier", ":", "raise", "error", ".", "SmiError", "(", "'Short OID for index %r'", "%", "(", ...
Turn SMI table instance identifier into a value object. SNMP SMI table objects are identified by OIDs composed of columnar object ID and instance index. The index part can be composed from the values of one or more tabular objects. This method takes sequence of integers, representing t...
[ "Turn", "SMI", "table", "instance", "identifier", "into", "a", "value", "object", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/mibs/SNMPv2-SMI.py#L2478-L2548
251,255
etingof/pysnmp
pysnmp/smi/mibs/SNMPv2-SMI.py
MibTableRow.valueToOid
def valueToOid(self, value, impliedFlag=False, parentIndices=None): """Turn value object into SMI table instance identifier. SNMP SMI table objects are identified by OIDs composed of columnar object ID and instance index. The index part can be composed from the values of one or more tab...
python
def valueToOid(self, value, impliedFlag=False, parentIndices=None): if hasattr(value, 'cloneAsName'): return value.cloneAsName(impliedFlag, parentRow=self, parentIndices=parentIndices) baseTag = value.getTagSet().getBaseTag() if baseTag == Integer.tagSet.getBaseTag(): re...
[ "def", "valueToOid", "(", "self", ",", "value", ",", "impliedFlag", "=", "False", ",", "parentIndices", "=", "None", ")", ":", "if", "hasattr", "(", "value", ",", "'cloneAsName'", ")", ":", "return", "value", ".", "cloneAsName", "(", "impliedFlag", ",", ...
Turn value object into SMI table instance identifier. SNMP SMI table objects are identified by OIDs composed of columnar object ID and instance index. The index part can be composed from the values of one or more tabular objects. This method takes an arbitrary value object and turns it...
[ "Turn", "value", "object", "into", "SMI", "table", "instance", "identifier", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/mibs/SNMPv2-SMI.py#L2552-L2608
251,256
etingof/pysnmp
pysnmp/smi/mibs/SNMPv2-SMI.py
MibTableRow.announceManagementEvent
def announceManagementEvent(self, action, varBind, **context): """Announce mass operation on parent table's row. SNMP SMI provides a way to extend already existing SMI table with another table. Whenever a mass operation on parent table's column is performed (e.g. row creation or destruc...
python
def announceManagementEvent(self, action, varBind, **context): name, val = varBind cbFun = context['cbFun'] if not self._augmentingRows: cbFun(varBind, **context) return # Convert OID suffix into index values instId = name[len(self.name) + 1:] b...
[ "def", "announceManagementEvent", "(", "self", ",", "action", ",", "varBind", ",", "*", "*", "context", ")", ":", "name", ",", "val", "=", "varBind", "cbFun", "=", "context", "[", "'cbFun'", "]", "if", "not", "self", ".", "_augmentingRows", ":", "cbFun",...
Announce mass operation on parent table's row. SNMP SMI provides a way to extend already existing SMI table with another table. Whenever a mass operation on parent table's column is performed (e.g. row creation or destruction), this operation has to be propagated over all the extending ...
[ "Announce", "mass", "operation", "on", "parent", "table", "s", "row", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/mibs/SNMPv2-SMI.py#L2612-L2693
251,257
etingof/pysnmp
pysnmp/smi/mibs/SNMPv2-SMI.py
MibTableRow.receiveManagementEvent
def receiveManagementEvent(self, action, varBind, **context): """Apply mass operation on extending table's row. SNMP SMI provides a way to extend already existing SMI table with another table. Whenever a mass operation on parent table's column is performed (e.g. row creation or destruct...
python
def receiveManagementEvent(self, action, varBind, **context): baseIndices, val = varBind # The default implementation supports one-to-one rows dependency instId = () # Resolve indices intersection for impliedFlag, modName, symName in self._indexNames: mibObj, = mibB...
[ "def", "receiveManagementEvent", "(", "self", ",", "action", ",", "varBind", ",", "*", "*", "context", ")", ":", "baseIndices", ",", "val", "=", "varBind", "# The default implementation supports one-to-one rows dependency", "instId", "=", "(", ")", "# Resolve indices ...
Apply mass operation on extending table's row. SNMP SMI provides a way to extend already existing SMI table with another table. Whenever a mass operation on parent table's column is performed (e.g. row creation or destruction), this operation has to be propagated over all the extending ...
[ "Apply", "mass", "operation", "on", "extending", "table", "s", "row", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/mibs/SNMPv2-SMI.py#L2695-L2751
251,258
etingof/pysnmp
pysnmp/smi/mibs/SNMPv2-SMI.py
MibTableRow.registerAugmentation
def registerAugmentation(self, *names): """Register table extension. SNMP SMI provides a way to extend already existing SMI table with another table. This method registers dependent (extending) table (or type :py:class:`MibTableRow`) to already existing table. Whenever a row of...
python
def registerAugmentation(self, *names): for name in names: if name in self._augmentingRows: raise error.SmiError( 'Row %s already augmented by %s::%s' % (self.name, name[0], name[1]) ) self._augmentingRows.add(name) return sel...
[ "def", "registerAugmentation", "(", "self", ",", "*", "names", ")", ":", "for", "name", "in", "names", ":", "if", "name", "in", "self", ".", "_augmentingRows", ":", "raise", "error", ".", "SmiError", "(", "'Row %s already augmented by %s::%s'", "%", "(", "se...
Register table extension. SNMP SMI provides a way to extend already existing SMI table with another table. This method registers dependent (extending) table (or type :py:class:`MibTableRow`) to already existing table. Whenever a row of the parent table is created or destroyed, the ...
[ "Register", "table", "extension", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/mibs/SNMPv2-SMI.py#L2753-L2779
251,259
etingof/pysnmp
pysnmp/smi/mibs/SNMPv2-SMI.py
MibTableRow._manageColumns
def _manageColumns(self, action, varBind, **context): """Apply a management action on all columns Parameters ---------- action: :py:class:`str` any of :py:class:`MibInstrumController`'s states to apply on all columns but the one passed in `varBind` varBind: :py:clas...
python
def _manageColumns(self, action, varBind, **context): name, val = varBind (debug.logger & debug.FLAG_INS and debug.logger('%s: _manageColumns(%s, %s, %r)' % (self, action, name, val))) cbFun = context['cbFun'] colLen = len(self.name) + 1 # Build a map of index names ...
[ "def", "_manageColumns", "(", "self", ",", "action", ",", "varBind", ",", "*", "*", "context", ")", ":", "name", ",", "val", "=", "varBind", "(", "debug", ".", "logger", "&", "debug", ".", "FLAG_INS", "and", "debug", ".", "logger", "(", "'%s: _manageCo...
Apply a management action on all columns Parameters ---------- action: :py:class:`str` any of :py:class:`MibInstrumController`'s states to apply on all columns but the one passed in `varBind` varBind: :py:class:`~pysnmp.smi.rfc1902.ObjectType` object representing ...
[ "Apply", "a", "management", "action", "on", "all", "columns" ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/mibs/SNMPv2-SMI.py#L2791-L2879
251,260
etingof/pysnmp
pysnmp/smi/mibs/SNMPv2-SMI.py
MibTableRow._checkColumns
def _checkColumns(self, varBind, **context): """Check the consistency of all columns. Parameters ---------- varBind: :py:class:`~pysnmp.smi.rfc1902.ObjectType` object representing new :py:class:`RowStatus` Managed Object Instance value being set on table row ...
python
def _checkColumns(self, varBind, **context): name, val = varBind (debug.logger & debug.FLAG_INS and debug.logger('%s: _checkColumns(%s, %r)' % (self, name, val))) cbFun = context['cbFun'] # RowStatus != active if val != 1: cbFun(varBind, **context) ...
[ "def", "_checkColumns", "(", "self", ",", "varBind", ",", "*", "*", "context", ")", ":", "name", ",", "val", "=", "varBind", "(", "debug", ".", "logger", "&", "debug", ".", "FLAG_INS", "and", "debug", ".", "logger", "(", "'%s: _checkColumns(%s, %r)'", "%...
Check the consistency of all columns. Parameters ---------- varBind: :py:class:`~pysnmp.smi.rfc1902.ObjectType` object representing new :py:class:`RowStatus` Managed Object Instance value being set on table row Other Parameters ---------------- ...
[ "Check", "the", "consistency", "of", "all", "columns", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/mibs/SNMPv2-SMI.py#L2881-L2949
251,261
etingof/pysnmp
pysnmp/smi/mibs/SNMPv2-SMI.py
MibTableRow.getIndicesFromInstId
def getIndicesFromInstId(self, instId): """Return index values for instance identification""" if instId in self._idToIdxCache: return self._idToIdxCache[instId] indices = [] for impliedFlag, modName, symName in self._indexNames: mibObj, = mibBuilder.importSymbols...
python
def getIndicesFromInstId(self, instId): if instId in self._idToIdxCache: return self._idToIdxCache[instId] indices = [] for impliedFlag, modName, symName in self._indexNames: mibObj, = mibBuilder.importSymbols(modName, symName) try: syntax, in...
[ "def", "getIndicesFromInstId", "(", "self", ",", "instId", ")", ":", "if", "instId", "in", "self", ".", "_idToIdxCache", ":", "return", "self", ".", "_idToIdxCache", "[", "instId", "]", "indices", "=", "[", "]", "for", "impliedFlag", ",", "modName", ",", ...
Return index values for instance identification
[ "Return", "index", "values", "for", "instance", "identification" ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/mibs/SNMPv2-SMI.py#L3278-L3306
251,262
etingof/pysnmp
pysnmp/smi/mibs/SNMPv2-SMI.py
MibTableRow.getInstIdFromIndices
def getInstIdFromIndices(self, *indices): """Return column instance identification from indices""" try: return self._idxToIdCache[indices] except TypeError: cacheable = False except KeyError: cacheable = True idx = 0 instId = () ...
python
def getInstIdFromIndices(self, *indices): try: return self._idxToIdCache[indices] except TypeError: cacheable = False except KeyError: cacheable = True idx = 0 instId = () parentIndices = [] for impliedFlag, modName, symName in ...
[ "def", "getInstIdFromIndices", "(", "self", ",", "*", "indices", ")", ":", "try", ":", "return", "self", ".", "_idxToIdCache", "[", "indices", "]", "except", "TypeError", ":", "cacheable", "=", "False", "except", "KeyError", ":", "cacheable", "=", "True", ...
Return column instance identification from indices
[ "Return", "column", "instance", "identification", "from", "indices" ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/mibs/SNMPv2-SMI.py#L3308-L3329
251,263
etingof/pysnmp
pysnmp/smi/mibs/SNMPv2-SMI.py
MibTableRow.getInstNameByIndex
def getInstNameByIndex(self, colId, *indices): """Build column instance name from components""" return self.name + (colId,) + self.getInstIdFromIndices(*indices)
python
def getInstNameByIndex(self, colId, *indices): return self.name + (colId,) + self.getInstIdFromIndices(*indices)
[ "def", "getInstNameByIndex", "(", "self", ",", "colId", ",", "*", "indices", ")", ":", "return", "self", ".", "name", "+", "(", "colId", ",", ")", "+", "self", ".", "getInstIdFromIndices", "(", "*", "indices", ")" ]
Build column instance name from components
[ "Build", "column", "instance", "name", "from", "components" ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/mibs/SNMPv2-SMI.py#L3333-L3335
251,264
etingof/pysnmp
pysnmp/smi/mibs/SNMPv2-SMI.py
MibTableRow.getInstNamesByIndex
def getInstNamesByIndex(self, *indices): """Build column instance names from indices""" instNames = [] for columnName in self._vars.keys(): instNames.append( self.getInstNameByIndex(*(columnName[-1],) + indices) ) return tuple(instNames)
python
def getInstNamesByIndex(self, *indices): instNames = [] for columnName in self._vars.keys(): instNames.append( self.getInstNameByIndex(*(columnName[-1],) + indices) ) return tuple(instNames)
[ "def", "getInstNamesByIndex", "(", "self", ",", "*", "indices", ")", ":", "instNames", "=", "[", "]", "for", "columnName", "in", "self", ".", "_vars", ".", "keys", "(", ")", ":", "instNames", ".", "append", "(", "self", ".", "getInstNameByIndex", "(", ...
Build column instance names from indices
[ "Build", "column", "instance", "names", "from", "indices" ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/mibs/SNMPv2-SMI.py#L3337-L3345
251,265
etingof/pysnmp
pysnmp/hlapi/v3arch/asyncore/sync/cmdgen.py
nextCmd
def nextCmd(snmpEngine, authData, transportTarget, contextData, *varBinds, **options): """Creates a generator to perform one or more SNMP GETNEXT queries. On each iteration, new SNMP GETNEXT request is send (:RFC:`1905#section-4.2.2`). The iterator blocks waiting for response to arrive or e...
python
def nextCmd(snmpEngine, authData, transportTarget, contextData, *varBinds, **options): # noinspection PyShadowingNames def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): cbCtx['errorIndication'] = errorIndicati...
[ "def", "nextCmd", "(", "snmpEngine", ",", "authData", ",", "transportTarget", ",", "contextData", ",", "*", "varBinds", ",", "*", "*", "options", ")", ":", "# noinspection PyShadowingNames", "def", "cbFun", "(", "snmpEngine", ",", "sendRequestHandle", ",", "erro...
Creates a generator to perform one or more SNMP GETNEXT queries. On each iteration, new SNMP GETNEXT request is send (:RFC:`1905#section-4.2.2`). The iterator blocks waiting for response to arrive or error to occur. Parameters ---------- snmpEngine : :py:class:`~pysnmp.hlapi.SnmpEngine` ...
[ "Creates", "a", "generator", "to", "perform", "one", "or", "more", "SNMP", "GETNEXT", "queries", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/hlapi/v3arch/asyncore/sync/cmdgen.py#L229-L413
251,266
etingof/pysnmp
pysnmp/entity/rfc3413/cmdrsp.py
CommandResponderBase._storeAccessContext
def _storeAccessContext(snmpEngine): """Copy received message metadata while it lasts""" execCtx = snmpEngine.observer.getExecutionContext('rfc3412.receiveMessage:request') return { 'securityModel': execCtx['securityModel'], 'securityName': execCtx['securityName'], ...
python
def _storeAccessContext(snmpEngine): execCtx = snmpEngine.observer.getExecutionContext('rfc3412.receiveMessage:request') return { 'securityModel': execCtx['securityModel'], 'securityName': execCtx['securityName'], 'securityLevel': execCtx['securityLevel'], ...
[ "def", "_storeAccessContext", "(", "snmpEngine", ")", ":", "execCtx", "=", "snmpEngine", ".", "observer", ".", "getExecutionContext", "(", "'rfc3412.receiveMessage:request'", ")", "return", "{", "'securityModel'", ":", "execCtx", "[", "'securityModel'", "]", ",", "'...
Copy received message metadata while it lasts
[ "Copy", "received", "message", "metadata", "while", "it", "lasts" ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/entity/rfc3413/cmdrsp.py#L174-L184
251,267
etingof/pysnmp
pysnmp/entity/rfc3413/cmdrsp.py
NextCommandResponder._getManagedObjectsInstances
def _getManagedObjectsInstances(self, varBinds, **context): """Iterate over Managed Objects fulfilling SNMP query. Returns ------- :py:class:`list` - List of Managed Objects Instances to respond with or `None` to indicate that not all objects have been gathered s...
python
def _getManagedObjectsInstances(self, varBinds, **context): rspVarBinds = context['rspVarBinds'] varBindsMap = context['varBindsMap'] rtrVarBinds = [] for idx, varBind in enumerate(varBinds): name, val = varBind if (exval.noSuchObject.isSameTypeWith(val) or ...
[ "def", "_getManagedObjectsInstances", "(", "self", ",", "varBinds", ",", "*", "*", "context", ")", ":", "rspVarBinds", "=", "context", "[", "'rspVarBinds'", "]", "varBindsMap", "=", "context", "[", "'varBindsMap'", "]", "rtrVarBinds", "=", "[", "]", "for", "...
Iterate over Managed Objects fulfilling SNMP query. Returns ------- :py:class:`list` - List of Managed Objects Instances to respond with or `None` to indicate that not all objects have been gathered so far.
[ "Iterate", "over", "Managed", "Objects", "fulfilling", "SNMP", "query", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/entity/rfc3413/cmdrsp.py#L339-L375
251,268
etingof/pysnmp
pysnmp/proto/rfc1155.py
NetworkAddress.clone
def clone(self, value=univ.noValue, **kwargs): """Clone this instance. If *value* is specified, use its tag as the component type selector, and itself as the component value. :param value: (Optional) the component value. :type value: :py:obj:`pyasn1.type.base.Asn1ItemBase` ...
python
def clone(self, value=univ.noValue, **kwargs): cloned = univ.Choice.clone(self, **kwargs) if value is not univ.noValue: if isinstance(value, NetworkAddress): value = value.getComponent() elif not isinstance(value, IpAddress): # IpAddress is the o...
[ "def", "clone", "(", "self", ",", "value", "=", "univ", ".", "noValue", ",", "*", "*", "kwargs", ")", ":", "cloned", "=", "univ", ".", "Choice", ".", "clone", "(", "self", ",", "*", "*", "kwargs", ")", "if", "value", "is", "not", "univ", ".", "...
Clone this instance. If *value* is specified, use its tag as the component type selector, and itself as the component value. :param value: (Optional) the component value. :type value: :py:obj:`pyasn1.type.base.Asn1ItemBase` :return: the cloned instance. :rtype: :py:obj:...
[ "Clone", "this", "instance", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/proto/rfc1155.py#L63-L95
251,269
etingof/pysnmp
pysnmp/smi/instrum.py
MibInstrumController._defaultErrorHandler
def _defaultErrorHandler(varBinds, **context): """Raise exception on any error if user callback is missing""" errors = context.get('errors') if errors: err = errors[-1] raise err['error']
python
def _defaultErrorHandler(varBinds, **context): errors = context.get('errors') if errors: err = errors[-1] raise err['error']
[ "def", "_defaultErrorHandler", "(", "varBinds", ",", "*", "*", "context", ")", ":", "errors", "=", "context", ".", "get", "(", "'errors'", ")", "if", "errors", ":", "err", "=", "errors", "[", "-", "1", "]", "raise", "err", "[", "'error'", "]" ]
Raise exception on any error if user callback is missing
[ "Raise", "exception", "on", "any", "error", "if", "user", "callback", "is", "missing" ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/instrum.py#L375-L381
251,270
etingof/pysnmp
pysnmp/smi/instrum.py
MibInstrumController.readMibObjects
def readMibObjects(self, *varBinds, **context): """Read Managed Objects Instances. Given one or more py:class:`~pysnmp.smi.rfc1902.ObjectType` objects, read all or none of the referenced Managed Objects Instances. Parameters ---------- varBinds: :py:class:`tuple` of :py...
python
def readMibObjects(self, *varBinds, **context): if 'cbFun' not in context: context['cbFun'] = self._defaultErrorHandler self.flipFlopFsm(self.FSM_READ_VAR, *varBinds, **context)
[ "def", "readMibObjects", "(", "self", ",", "*", "varBinds", ",", "*", "*", "context", ")", ":", "if", "'cbFun'", "not", "in", "context", ":", "context", "[", "'cbFun'", "]", "=", "self", ".", "_defaultErrorHandler", "self", ".", "flipFlopFsm", "(", "self...
Read Managed Objects Instances. Given one or more py:class:`~pysnmp.smi.rfc1902.ObjectType` objects, read all or none of the referenced Managed Objects Instances. Parameters ---------- varBinds: :py:class:`tuple` of :py:class:`~pysnmp.smi.rfc1902.ObjectType` objects ...
[ "Read", "Managed", "Objects", "Instances", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/instrum.py#L383-L435
251,271
etingof/pysnmp
pysnmp/smi/instrum.py
MibInstrumController.readNextMibObjects
def readNextMibObjects(self, *varBinds, **context): """Read Managed Objects Instances next to the given ones. Given one or more py:class:`~pysnmp.smi.rfc1902.ObjectType` objects, read all or none of the Managed Objects Instances next to the referenced ones. Parameters ---------...
python
def readNextMibObjects(self, *varBinds, **context): if 'cbFun' not in context: context['cbFun'] = self._defaultErrorHandler self.flipFlopFsm(self.FSM_READ_NEXT_VAR, *varBinds, **context)
[ "def", "readNextMibObjects", "(", "self", ",", "*", "varBinds", ",", "*", "*", "context", ")", ":", "if", "'cbFun'", "not", "in", "context", ":", "context", "[", "'cbFun'", "]", "=", "self", ".", "_defaultErrorHandler", "self", ".", "flipFlopFsm", "(", "...
Read Managed Objects Instances next to the given ones. Given one or more py:class:`~pysnmp.smi.rfc1902.ObjectType` objects, read all or none of the Managed Objects Instances next to the referenced ones. Parameters ---------- varBinds: :py:class:`tuple` of :py:class:`~pysnmp.smi...
[ "Read", "Managed", "Objects", "Instances", "next", "to", "the", "given", "ones", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/instrum.py#L437-L495
251,272
etingof/pysnmp
pysnmp/smi/instrum.py
MibInstrumController.writeMibObjects
def writeMibObjects(self, *varBinds, **context): """Create, destroy or modify Managed Objects Instances. Given one or more py:class:`~pysnmp.smi.rfc1902.ObjectType` objects, create, destroy or modify all or none of the referenced Managed Objects Instances. If a non-existing Managed Ob...
python
def writeMibObjects(self, *varBinds, **context): if 'cbFun' not in context: context['cbFun'] = self._defaultErrorHandler self.flipFlopFsm(self.FSM_WRITE_VAR, *varBinds, **context)
[ "def", "writeMibObjects", "(", "self", ",", "*", "varBinds", ",", "*", "*", "context", ")", ":", "if", "'cbFun'", "not", "in", "context", ":", "context", "[", "'cbFun'", "]", "=", "self", ".", "_defaultErrorHandler", "self", ".", "flipFlopFsm", "(", "sel...
Create, destroy or modify Managed Objects Instances. Given one or more py:class:`~pysnmp.smi.rfc1902.ObjectType` objects, create, destroy or modify all or none of the referenced Managed Objects Instances. If a non-existing Managed Object Instance is written, the new Managed Object Ins...
[ "Create", "destroy", "or", "modify", "Managed", "Objects", "Instances", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/instrum.py#L497-L564
251,273
etingof/pysnmp
pysnmp/hlapi/v1arch/asyncore/cmdgen.py
bulkCmd
def bulkCmd(snmpDispatcher, authData, transportTarget, nonRepeaters, maxRepetitions, *varBinds, **options): """Initiate SNMP GETBULK query over SNMPv2c. Based on passed parameters, prepares SNMP GETBULK packet (:RFC:`1905#section-4.2.3`) and schedules its transmission by I/O framework at a ...
python
def bulkCmd(snmpDispatcher, authData, transportTarget, nonRepeaters, maxRepetitions, *varBinds, **options): def _cbFun(snmpDispatcher, stateHandle, errorIndication, rspPdu, _cbCtx): if not cbFun: return if errorIndication: cbFun(errorIndication, pMod.Integer(0), ...
[ "def", "bulkCmd", "(", "snmpDispatcher", ",", "authData", ",", "transportTarget", ",", "nonRepeaters", ",", "maxRepetitions", ",", "*", "varBinds", ",", "*", "*", "options", ")", ":", "def", "_cbFun", "(", "snmpDispatcher", ",", "stateHandle", ",", "errorIndic...
Initiate SNMP GETBULK query over SNMPv2c. Based on passed parameters, prepares SNMP GETBULK packet (:RFC:`1905#section-4.2.3`) and schedules its transmission by I/O framework at a later point of time. Parameters ---------- snmpDispatcher: :py:class:`~pysnmp.hlapi.v1arch.asyncore.SnmpDispatcher...
[ "Initiate", "SNMP", "GETBULK", "query", "over", "SNMPv2c", "." ]
cde062dd42f67dfd2d7686286a322d40e9c3a4b7
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/hlapi/v1arch/asyncore/cmdgen.py#L451-L626
251,274
markreidvfx/pyaaf2
aaf2/file.py
AAFFile.save
def save(self): """ Writes current changes to disk and flushes modified objects in the AAFObjectManager """ if self.mode in ("wb+", 'rb+'): if not self.is_open: raise IOError("file closed") self.write_reference_properties() self...
python
def save(self): if self.mode in ("wb+", 'rb+'): if not self.is_open: raise IOError("file closed") self.write_reference_properties() self.manager.write_objects()
[ "def", "save", "(", "self", ")", ":", "if", "self", ".", "mode", "in", "(", "\"wb+\"", ",", "'rb+'", ")", ":", "if", "not", "self", ".", "is_open", ":", "raise", "IOError", "(", "\"file closed\"", ")", "self", ".", "write_reference_properties", "(", ")...
Writes current changes to disk and flushes modified objects in the AAFObjectManager
[ "Writes", "current", "changes", "to", "disk", "and", "flushes", "modified", "objects", "in", "the", "AAFObjectManager" ]
37de8c10d3c3495cc00c705eb6c5048bc4a7e51f
https://github.com/markreidvfx/pyaaf2/blob/37de8c10d3c3495cc00c705eb6c5048bc4a7e51f/aaf2/file.py#L339-L348
251,275
markreidvfx/pyaaf2
aaf2/file.py
AAFFile.close
def close(self): """ Close the file. A closed file cannot be read or written any more. """ self.save() self.manager.remove_temp() self.cfb.close() self.is_open = False self.f.close()
python
def close(self): self.save() self.manager.remove_temp() self.cfb.close() self.is_open = False self.f.close()
[ "def", "close", "(", "self", ")", ":", "self", ".", "save", "(", ")", "self", ".", "manager", ".", "remove_temp", "(", ")", "self", ".", "cfb", ".", "close", "(", ")", "self", ".", "is_open", "=", "False", "self", ".", "f", ".", "close", "(", "...
Close the file. A closed file cannot be read or written any more.
[ "Close", "the", "file", ".", "A", "closed", "file", "cannot", "be", "read", "or", "written", "any", "more", "." ]
37de8c10d3c3495cc00c705eb6c5048bc4a7e51f
https://github.com/markreidvfx/pyaaf2/blob/37de8c10d3c3495cc00c705eb6c5048bc4a7e51f/aaf2/file.py#L350-L358
251,276
markreidvfx/pyaaf2
docs/source/conf.py
run_apidoc
def run_apidoc(_): """This method is required by the setup method below.""" import os dirname = os.path.dirname(__file__) ignore_paths = [os.path.join(dirname, '../../aaf2/model'),] # https://github.com/sphinx-doc/sphinx/blob/master/sphinx/ext/apidoc.py argv = [ '--force', '--no-...
python
def run_apidoc(_): import os dirname = os.path.dirname(__file__) ignore_paths = [os.path.join(dirname, '../../aaf2/model'),] # https://github.com/sphinx-doc/sphinx/blob/master/sphinx/ext/apidoc.py argv = [ '--force', '--no-toc', '--separate', '--module-first', ...
[ "def", "run_apidoc", "(", "_", ")", ":", "import", "os", "dirname", "=", "os", ".", "path", ".", "dirname", "(", "__file__", ")", "ignore_paths", "=", "[", "os", ".", "path", ".", "join", "(", "dirname", ",", "'../../aaf2/model'", ")", ",", "]", "# h...
This method is required by the setup method below.
[ "This", "method", "is", "required", "by", "the", "setup", "method", "below", "." ]
37de8c10d3c3495cc00c705eb6c5048bc4a7e51f
https://github.com/markreidvfx/pyaaf2/blob/37de8c10d3c3495cc00c705eb6c5048bc4a7e51f/docs/source/conf.py#L182-L199
251,277
markreidvfx/pyaaf2
aaf2/mobid.py
MobID.from_dict
def from_dict(self, d): """ Set MobID from a dict """ self.length = d.get("length", 0) self.instanceHigh = d.get("instanceHigh", 0) self.instanceMid = d.get("instanceMid", 0) self.instanceLow = d.get("instanceLow", 0) material = d.get("material", {'Data1'...
python
def from_dict(self, d): self.length = d.get("length", 0) self.instanceHigh = d.get("instanceHigh", 0) self.instanceMid = d.get("instanceMid", 0) self.instanceLow = d.get("instanceLow", 0) material = d.get("material", {'Data1':0, 'Data2':0, 'Data3':0, 'Data4': [0 for i in range(8...
[ "def", "from_dict", "(", "self", ",", "d", ")", ":", "self", ".", "length", "=", "d", ".", "get", "(", "\"length\"", ",", "0", ")", "self", ".", "instanceHigh", "=", "d", ".", "get", "(", "\"instanceHigh\"", ",", "0", ")", "self", ".", "instanceMid...
Set MobID from a dict
[ "Set", "MobID", "from", "a", "dict" ]
37de8c10d3c3495cc00c705eb6c5048bc4a7e51f
https://github.com/markreidvfx/pyaaf2/blob/37de8c10d3c3495cc00c705eb6c5048bc4a7e51f/aaf2/mobid.py#L280-L296
251,278
markreidvfx/pyaaf2
aaf2/mobid.py
MobID.to_dict
def to_dict(self): """ MobID representation as dict """ material = {'Data1': self.Data1, 'Data2': self.Data2, 'Data3': self.Data3, 'Data4': list(self.Data4) } return {'material':material, ...
python
def to_dict(self): material = {'Data1': self.Data1, 'Data2': self.Data2, 'Data3': self.Data3, 'Data4': list(self.Data4) } return {'material':material, 'length': self.length, 'instanceHigh': s...
[ "def", "to_dict", "(", "self", ")", ":", "material", "=", "{", "'Data1'", ":", "self", ".", "Data1", ",", "'Data2'", ":", "self", ".", "Data2", ",", "'Data3'", ":", "self", ".", "Data3", ",", "'Data4'", ":", "list", "(", "self", ".", "Data4", ")", ...
MobID representation as dict
[ "MobID", "representation", "as", "dict" ]
37de8c10d3c3495cc00c705eb6c5048bc4a7e51f
https://github.com/markreidvfx/pyaaf2/blob/37de8c10d3c3495cc00c705eb6c5048bc4a7e51f/aaf2/mobid.py#L298-L315
251,279
markreidvfx/pyaaf2
aaf2/ama.py
wave_infochunk
def wave_infochunk(path): """ Returns a bytearray of the WAVE RIFF header and fmt chunk for a `WAVEDescriptor` `Summary` """ with open(path,'rb') as file: if file.read(4) != b"RIFF": return None data_size = file.read(4) # container size if file.read(4) != b"WAVE":...
python
def wave_infochunk(path): with open(path,'rb') as file: if file.read(4) != b"RIFF": return None data_size = file.read(4) # container size if file.read(4) != b"WAVE": return None while True: chunkid = file.read(4) sizebuf = file.read(4) ...
[ "def", "wave_infochunk", "(", "path", ")", ":", "with", "open", "(", "path", ",", "'rb'", ")", "as", "file", ":", "if", "file", ".", "read", "(", "4", ")", "!=", "b\"RIFF\"", ":", "return", "None", "data_size", "=", "file", ".", "read", "(", "4", ...
Returns a bytearray of the WAVE RIFF header and fmt chunk for a `WAVEDescriptor` `Summary`
[ "Returns", "a", "bytearray", "of", "the", "WAVE", "RIFF", "header", "and", "fmt", "chunk", "for", "a", "WAVEDescriptor", "Summary" ]
37de8c10d3c3495cc00c705eb6c5048bc4a7e51f
https://github.com/markreidvfx/pyaaf2/blob/37de8c10d3c3495cc00c705eb6c5048bc4a7e51f/aaf2/ama.py#L329-L353
251,280
markreidvfx/pyaaf2
aaf2/cfb.py
DirEntry.pop
def pop(self): """ remove self from binary search tree """ entry = self parent = self.parent root = parent.child() dir_per_sector = self.storage.sector_size // 128 max_dirs_entries = self.storage.dir_sector_count * dir_per_sector count = 0 ...
python
def pop(self): entry = self parent = self.parent root = parent.child() dir_per_sector = self.storage.sector_size // 128 max_dirs_entries = self.storage.dir_sector_count * dir_per_sector count = 0 if root.dir_id == entry.dir_id: parent.child_id = Non...
[ "def", "pop", "(", "self", ")", ":", "entry", "=", "self", "parent", "=", "self", ".", "parent", "root", "=", "parent", ".", "child", "(", ")", "dir_per_sector", "=", "self", ".", "storage", ".", "sector_size", "//", "128", "max_dirs_entries", "=", "se...
remove self from binary search tree
[ "remove", "self", "from", "binary", "search", "tree" ]
37de8c10d3c3495cc00c705eb6c5048bc4a7e51f
https://github.com/markreidvfx/pyaaf2/blob/37de8c10d3c3495cc00c705eb6c5048bc4a7e51f/aaf2/cfb.py#L609-L664
251,281
markreidvfx/pyaaf2
aaf2/cfb.py
CompoundFileBinary.remove
def remove(self, path): """ Removes both streams and storage DirEntry types from file. storage type entries need to be empty dirs. """ entry = self.find(path) if not entry: raise ValueError("%s does not exists" % path) if entry.type == 'root storage...
python
def remove(self, path): entry = self.find(path) if not entry: raise ValueError("%s does not exists" % path) if entry.type == 'root storage': raise ValueError("can no remove root entry") if entry.type == "storage" and not entry.child_id is None: rais...
[ "def", "remove", "(", "self", ",", "path", ")", ":", "entry", "=", "self", ".", "find", "(", "path", ")", "if", "not", "entry", ":", "raise", "ValueError", "(", "\"%s does not exists\"", "%", "path", ")", "if", "entry", ".", "type", "==", "'root storag...
Removes both streams and storage DirEntry types from file. storage type entries need to be empty dirs.
[ "Removes", "both", "streams", "and", "storage", "DirEntry", "types", "from", "file", ".", "storage", "type", "entries", "need", "to", "be", "empty", "dirs", "." ]
37de8c10d3c3495cc00c705eb6c5048bc4a7e51f
https://github.com/markreidvfx/pyaaf2/blob/37de8c10d3c3495cc00c705eb6c5048bc4a7e51f/aaf2/cfb.py#L1606-L1629
251,282
markreidvfx/pyaaf2
aaf2/cfb.py
CompoundFileBinary.rmtree
def rmtree(self, path): """ Removes directory structure, similar to shutil.rmtree. """ for root, storage, streams in self.walk(path, topdown=False): for item in streams: self.free_fat_chain(item.sector_id, item.byte_size < self.min_stream_max_size) ...
python
def rmtree(self, path): for root, storage, streams in self.walk(path, topdown=False): for item in streams: self.free_fat_chain(item.sector_id, item.byte_size < self.min_stream_max_size) self.free_dir_entry(item) for item in storage: self....
[ "def", "rmtree", "(", "self", ",", "path", ")", ":", "for", "root", ",", "storage", ",", "streams", "in", "self", ".", "walk", "(", "path", ",", "topdown", "=", "False", ")", ":", "for", "item", "in", "streams", ":", "self", ".", "free_fat_chain", ...
Removes directory structure, similar to shutil.rmtree.
[ "Removes", "directory", "structure", "similar", "to", "shutil", ".", "rmtree", "." ]
37de8c10d3c3495cc00c705eb6c5048bc4a7e51f
https://github.com/markreidvfx/pyaaf2/blob/37de8c10d3c3495cc00c705eb6c5048bc4a7e51f/aaf2/cfb.py#L1632-L1648
251,283
markreidvfx/pyaaf2
aaf2/cfb.py
CompoundFileBinary.listdir_dict
def listdir_dict(self, path = None): """ Return a dict containing the ``DirEntry`` objects in the directory given by path with name of the dir as key. """ if path is None: path = self.root root = self.find(path) if root is None: raise Val...
python
def listdir_dict(self, path = None): if path is None: path = self.root root = self.find(path) if root is None: raise ValueError("unable to find dir: %s" % str(path)) if not root.isdir(): raise ValueError("can only list storage types") childr...
[ "def", "listdir_dict", "(", "self", ",", "path", "=", "None", ")", ":", "if", "path", "is", "None", ":", "path", "=", "self", ".", "root", "root", "=", "self", ".", "find", "(", "path", ")", "if", "root", "is", "None", ":", "raise", "ValueError", ...
Return a dict containing the ``DirEntry`` objects in the directory given by path with name of the dir as key.
[ "Return", "a", "dict", "containing", "the", "DirEntry", "objects", "in", "the", "directory", "given", "by", "path", "with", "name", "of", "the", "dir", "as", "key", "." ]
37de8c10d3c3495cc00c705eb6c5048bc4a7e51f
https://github.com/markreidvfx/pyaaf2/blob/37de8c10d3c3495cc00c705eb6c5048bc4a7e51f/aaf2/cfb.py#L1660-L1709
251,284
markreidvfx/pyaaf2
aaf2/cfb.py
CompoundFileBinary.makedir
def makedir(self, path, class_id=None): """ Create a storage DirEntry name path """ return self.create_dir_entry(path, dir_type='storage', class_id=class_id)
python
def makedir(self, path, class_id=None): return self.create_dir_entry(path, dir_type='storage', class_id=class_id)
[ "def", "makedir", "(", "self", ",", "path", ",", "class_id", "=", "None", ")", ":", "return", "self", ".", "create_dir_entry", "(", "path", ",", "dir_type", "=", "'storage'", ",", "class_id", "=", "class_id", ")" ]
Create a storage DirEntry name path
[ "Create", "a", "storage", "DirEntry", "name", "path" ]
37de8c10d3c3495cc00c705eb6c5048bc4a7e51f
https://github.com/markreidvfx/pyaaf2/blob/37de8c10d3c3495cc00c705eb6c5048bc4a7e51f/aaf2/cfb.py#L1800-L1804
251,285
markreidvfx/pyaaf2
aaf2/cfb.py
CompoundFileBinary.makedirs
def makedirs(self, path): """ Recursive storage DirEntry creation function. """ root = "" assert path.startswith('/') p = path.strip('/') for item in p.split('/'): root += "/" + item if not self.exists(root): self.makedir(r...
python
def makedirs(self, path): root = "" assert path.startswith('/') p = path.strip('/') for item in p.split('/'): root += "/" + item if not self.exists(root): self.makedir(root) return self.find(path)
[ "def", "makedirs", "(", "self", ",", "path", ")", ":", "root", "=", "\"\"", "assert", "path", ".", "startswith", "(", "'/'", ")", "p", "=", "path", ".", "strip", "(", "'/'", ")", "for", "item", "in", "p", ".", "split", "(", "'/'", ")", ":", "ro...
Recursive storage DirEntry creation function.
[ "Recursive", "storage", "DirEntry", "creation", "function", "." ]
37de8c10d3c3495cc00c705eb6c5048bc4a7e51f
https://github.com/markreidvfx/pyaaf2/blob/37de8c10d3c3495cc00c705eb6c5048bc4a7e51f/aaf2/cfb.py#L1806-L1819
251,286
markreidvfx/pyaaf2
aaf2/cfb.py
CompoundFileBinary.move
def move(self, src, dst): """ Moves ``DirEntry`` from src to dst """ src_entry = self.find(src) if src_entry is None: raise ValueError("src path does not exist: %s" % src) if dst.endswith('/'): dst += src_entry.name if self.exists(dst): ...
python
def move(self, src, dst): src_entry = self.find(src) if src_entry is None: raise ValueError("src path does not exist: %s" % src) if dst.endswith('/'): dst += src_entry.name if self.exists(dst): raise ValueError("dst path already exist: %s" % dst) ...
[ "def", "move", "(", "self", ",", "src", ",", "dst", ")", ":", "src_entry", "=", "self", ".", "find", "(", "src", ")", "if", "src_entry", "is", "None", ":", "raise", "ValueError", "(", "\"src path does not exist: %s\"", "%", "src", ")", "if", "dst", "."...
Moves ``DirEntry`` from src to dst
[ "Moves", "DirEntry", "from", "src", "to", "dst" ]
37de8c10d3c3495cc00c705eb6c5048bc4a7e51f
https://github.com/markreidvfx/pyaaf2/blob/37de8c10d3c3495cc00c705eb6c5048bc4a7e51f/aaf2/cfb.py#L1821-L1862
251,287
markreidvfx/pyaaf2
aaf2/cfb.py
CompoundFileBinary.open
def open(self, path, mode='r'): """Open stream, returning ``Stream`` object""" entry = self.find(path) if entry is None: if mode == 'r': raise ValueError("stream does not exists: %s" % path) entry = self.create_dir_entry(path, 'stream', None) els...
python
def open(self, path, mode='r'): entry = self.find(path) if entry is None: if mode == 'r': raise ValueError("stream does not exists: %s" % path) entry = self.create_dir_entry(path, 'stream', None) else: if not entry.isfile(): ra...
[ "def", "open", "(", "self", ",", "path", ",", "mode", "=", "'r'", ")", ":", "entry", "=", "self", ".", "find", "(", "path", ")", "if", "entry", "is", "None", ":", "if", "mode", "==", "'r'", ":", "raise", "ValueError", "(", "\"stream does not exists: ...
Open stream, returning ``Stream`` object
[ "Open", "stream", "returning", "Stream", "object" ]
37de8c10d3c3495cc00c705eb6c5048bc4a7e51f
https://github.com/markreidvfx/pyaaf2/blob/37de8c10d3c3495cc00c705eb6c5048bc4a7e51f/aaf2/cfb.py#L1864-L1887
251,288
markreidvfx/pyaaf2
aaf2/properties.py
add2set
def add2set(self, pid, key, value): """low level add to StrongRefSetProperty""" prop = self.property_entries[pid] current = prop.objects.get(key, None) current_local_key = prop.references.get(key, None) if current and current is not value: current.detach() if current_local_key is None...
python
def add2set(self, pid, key, value): prop = self.property_entries[pid] current = prop.objects.get(key, None) current_local_key = prop.references.get(key, None) if current and current is not value: current.detach() if current_local_key is None: prop.references[key] = prop.next_free_...
[ "def", "add2set", "(", "self", ",", "pid", ",", "key", ",", "value", ")", ":", "prop", "=", "self", ".", "property_entries", "[", "pid", "]", "current", "=", "prop", ".", "objects", ".", "get", "(", "key", ",", "None", ")", "current_local_key", "=", ...
low level add to StrongRefSetProperty
[ "low", "level", "add", "to", "StrongRefSetProperty" ]
37de8c10d3c3495cc00c705eb6c5048bc4a7e51f
https://github.com/markreidvfx/pyaaf2/blob/37de8c10d3c3495cc00c705eb6c5048bc4a7e51f/aaf2/properties.py#L1313-L1336
251,289
MillionIntegrals/vel
vel/rl/modules/q_distributional_head.py
QDistributionalHead.histogram_info
def histogram_info(self) -> dict: """ Return extra information about histogram """ return { 'support_atoms': self.support_atoms, 'atom_delta': self.atom_delta, 'vmin': self.vmin, 'vmax': self.vmax, 'num_atoms': self.atoms }
python
def histogram_info(self) -> dict: return { 'support_atoms': self.support_atoms, 'atom_delta': self.atom_delta, 'vmin': self.vmin, 'vmax': self.vmax, 'num_atoms': self.atoms }
[ "def", "histogram_info", "(", "self", ")", "->", "dict", ":", "return", "{", "'support_atoms'", ":", "self", ".", "support_atoms", ",", "'atom_delta'", ":", "self", ".", "atom_delta", ",", "'vmin'", ":", "self", ".", "vmin", ",", "'vmax'", ":", "self", "...
Return extra information about histogram
[ "Return", "extra", "information", "about", "histogram" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/modules/q_distributional_head.py#L31-L39
251,290
MillionIntegrals/vel
vel/rl/modules/q_distributional_head.py
QDistributionalHead.sample
def sample(self, histogram_logits): """ Sample from a greedy strategy with given q-value histogram """ histogram_probs = histogram_logits.exp() # Batch size * actions * atoms atoms = self.support_atoms.view(1, 1, self.atoms) # Need to introduce two new dimensions return (histogram_prob...
python
def sample(self, histogram_logits): histogram_probs = histogram_logits.exp() # Batch size * actions * atoms atoms = self.support_atoms.view(1, 1, self.atoms) # Need to introduce two new dimensions return (histogram_probs * atoms).sum(dim=-1).argmax(dim=1)
[ "def", "sample", "(", "self", ",", "histogram_logits", ")", ":", "histogram_probs", "=", "histogram_logits", ".", "exp", "(", ")", "# Batch size * actions * atoms", "atoms", "=", "self", ".", "support_atoms", ".", "view", "(", "1", ",", "1", ",", "self", "."...
Sample from a greedy strategy with given q-value histogram
[ "Sample", "from", "a", "greedy", "strategy", "with", "given", "q", "-", "value", "histogram" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/modules/q_distributional_head.py#L52-L56
251,291
MillionIntegrals/vel
vel/sources/nlp/text_url.py
TextUrlSource.download
def download(self): """ Make sure data file is downloaded and stored properly """ if not os.path.exists(self.data_path): # Create if it doesn't exist pathlib.Path(self.data_path).mkdir(parents=True, exist_ok=True) if not os.path.exists(self.text_path): http =...
python
def download(self): if not os.path.exists(self.data_path): # Create if it doesn't exist pathlib.Path(self.data_path).mkdir(parents=True, exist_ok=True) if not os.path.exists(self.text_path): http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED', ca_certs=certifi.where...
[ "def", "download", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "data_path", ")", ":", "# Create if it doesn't exist", "pathlib", ".", "Path", "(", "self", ".", "data_path", ")", ".", "mkdir", "(", "parents", ...
Make sure data file is downloaded and stored properly
[ "Make", "sure", "data", "file", "is", "downloaded", "and", "stored", "properly" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/sources/nlp/text_url.py#L148-L186
251,292
MillionIntegrals/vel
vel/math/functions.py
explained_variance
def explained_variance(returns, values): """ Calculate how much variance in returns do the values explain """ exp_var = 1 - torch.var(returns - values) / torch.var(returns) return exp_var.item()
python
def explained_variance(returns, values): exp_var = 1 - torch.var(returns - values) / torch.var(returns) return exp_var.item()
[ "def", "explained_variance", "(", "returns", ",", "values", ")", ":", "exp_var", "=", "1", "-", "torch", ".", "var", "(", "returns", "-", "values", ")", "/", "torch", ".", "var", "(", "returns", ")", "return", "exp_var", ".", "item", "(", ")" ]
Calculate how much variance in returns do the values explain
[ "Calculate", "how", "much", "variance", "in", "returns", "do", "the", "values", "explain" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/math/functions.py#L4-L7
251,293
MillionIntegrals/vel
vel/sources/img_dir_source.py
create
def create(model_config, path, num_workers, batch_size, augmentations=None, tta=None): """ Create an ImageDirSource with supplied arguments """ if not os.path.isabs(path): path = model_config.project_top_dir(path) train_path = os.path.join(path, 'train') valid_path = os.path.join(path, 'valid')...
python
def create(model_config, path, num_workers, batch_size, augmentations=None, tta=None): if not os.path.isabs(path): path = model_config.project_top_dir(path) train_path = os.path.join(path, 'train') valid_path = os.path.join(path, 'valid') train_ds = ImageDirSource(train_path) val_ds = Imag...
[ "def", "create", "(", "model_config", ",", "path", ",", "num_workers", ",", "batch_size", ",", "augmentations", "=", "None", ",", "tta", "=", "None", ")", ":", "if", "not", "os", ".", "path", ".", "isabs", "(", "path", ")", ":", "path", "=", "model_c...
Create an ImageDirSource with supplied arguments
[ "Create", "an", "ImageDirSource", "with", "supplied", "arguments" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/sources/img_dir_source.py#L12-L30
251,294
MillionIntegrals/vel
vel/rl/models/q_model.py
QModel.reset_weights
def reset_weights(self): """ Initialize weights to reasonable defaults """ self.input_block.reset_weights() self.backbone.reset_weights() self.q_head.reset_weights()
python
def reset_weights(self): self.input_block.reset_weights() self.backbone.reset_weights() self.q_head.reset_weights()
[ "def", "reset_weights", "(", "self", ")", ":", "self", ".", "input_block", ".", "reset_weights", "(", ")", "self", ".", "backbone", ".", "reset_weights", "(", ")", "self", ".", "q_head", ".", "reset_weights", "(", ")" ]
Initialize weights to reasonable defaults
[ "Initialize", "weights", "to", "reasonable", "defaults" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/models/q_model.py#L50-L54
251,295
MillionIntegrals/vel
vel/util/tensor_accumulator.py
TensorAccumulator.result
def result(self): """ Concatenate accumulated tensors """ return {k: torch.stack(v) for k, v in self.accumulants.items()}
python
def result(self): return {k: torch.stack(v) for k, v in self.accumulants.items()}
[ "def", "result", "(", "self", ")", ":", "return", "{", "k", ":", "torch", ".", "stack", "(", "v", ")", "for", "k", ",", "v", "in", "self", ".", "accumulants", ".", "items", "(", ")", "}" ]
Concatenate accumulated tensors
[ "Concatenate", "accumulated", "tensors" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/util/tensor_accumulator.py#L14-L16
251,296
MillionIntegrals/vel
vel/internals/provider.py
Provider.resolve_parameters
def resolve_parameters(self, func, extra_env=None): """ Resolve parameter dictionary for the supplied function """ parameter_list = [ (k, v.default == inspect.Parameter.empty) for k, v in inspect.signature(func).parameters.items() ] extra_env = extra_env if extra_env is not N...
python
def resolve_parameters(self, func, extra_env=None): parameter_list = [ (k, v.default == inspect.Parameter.empty) for k, v in inspect.signature(func).parameters.items() ] extra_env = extra_env if extra_env is not None else {} kwargs = {} for parameter_name, is_require...
[ "def", "resolve_parameters", "(", "self", ",", "func", ",", "extra_env", "=", "None", ")", ":", "parameter_list", "=", "[", "(", "k", ",", "v", ".", "default", "==", "inspect", ".", "Parameter", ".", "empty", ")", "for", "k", ",", "v", "in", "inspect...
Resolve parameter dictionary for the supplied function
[ "Resolve", "parameter", "dictionary", "for", "the", "supplied", "function" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/internals/provider.py#L24-L52
251,297
MillionIntegrals/vel
vel/internals/provider.py
Provider.resolve_and_call
def resolve_and_call(self, func, extra_env=None): """ Resolve function arguments and call them, possibily filling from the environment """ kwargs = self.resolve_parameters(func, extra_env=extra_env) return func(**kwargs)
python
def resolve_and_call(self, func, extra_env=None): kwargs = self.resolve_parameters(func, extra_env=extra_env) return func(**kwargs)
[ "def", "resolve_and_call", "(", "self", ",", "func", ",", "extra_env", "=", "None", ")", ":", "kwargs", "=", "self", ".", "resolve_parameters", "(", "func", ",", "extra_env", "=", "extra_env", ")", "return", "func", "(", "*", "*", "kwargs", ")" ]
Resolve function arguments and call them, possibily filling from the environment
[ "Resolve", "function", "arguments", "and", "call", "them", "possibily", "filling", "from", "the", "environment" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/internals/provider.py#L54-L57
251,298
MillionIntegrals/vel
vel/internals/provider.py
Provider.instantiate_from_data
def instantiate_from_data(self, object_data): """ Instantiate object from the supplied data, additional args may come from the environment """ if isinstance(object_data, dict) and 'name' in object_data: name = object_data['name'] module = importlib.import_module(name) ...
python
def instantiate_from_data(self, object_data): if isinstance(object_data, dict) and 'name' in object_data: name = object_data['name'] module = importlib.import_module(name) return self.resolve_and_call(module.create, extra_env=object_data) if isinstance(object_data, di...
[ "def", "instantiate_from_data", "(", "self", ",", "object_data", ")", ":", "if", "isinstance", "(", "object_data", ",", "dict", ")", "and", "'name'", "in", "object_data", ":", "name", "=", "object_data", "[", "'name'", "]", "module", "=", "importlib", ".", ...
Instantiate object from the supplied data, additional args may come from the environment
[ "Instantiate", "object", "from", "the", "supplied", "data", "additional", "args", "may", "come", "from", "the", "environment" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/internals/provider.py#L59-L77
251,299
MillionIntegrals/vel
vel/internals/provider.py
Provider.render_configuration
def render_configuration(self, configuration=None): """ Render variables in configuration object but don't instantiate anything """ if configuration is None: configuration = self.environment if isinstance(configuration, dict): return {k: self.render_configuration(v) for ...
python
def render_configuration(self, configuration=None): if configuration is None: configuration = self.environment if isinstance(configuration, dict): return {k: self.render_configuration(v) for k, v in configuration.items()} elif isinstance(configuration, list): ...
[ "def", "render_configuration", "(", "self", ",", "configuration", "=", "None", ")", ":", "if", "configuration", "is", "None", ":", "configuration", "=", "self", ".", "environment", "if", "isinstance", "(", "configuration", ",", "dict", ")", ":", "return", "{...
Render variables in configuration object but don't instantiate anything
[ "Render", "variables", "in", "configuration", "object", "but", "don", "t", "instantiate", "anything" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/internals/provider.py#L79-L91