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 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
237,400 | 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):
"""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', []):
... | [
"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 |
237,401 | 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):
"""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:
... | [
"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 |
237,402 | 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):
"""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... | [
"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 |
237,403 | 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):
"""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... | [
"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 |
237,404 | 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):
"""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_... | [
"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 |
237,405 | 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):
"""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:
... | [
"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 |
237,406 | 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):
"""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()] | [
"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 |
237,407 | 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):
"""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:
... | [
"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 |
237,408 | 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):
"""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 | [
"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 |
237,409 | 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):
"""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 | [
"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 |
237,410 | 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):
"""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... | [
"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 |
237,411 | 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):
"""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... | [
"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 |
237,412 | 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):
"""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
... | [
"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 |
237,413 | 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):
"""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
-------
... | [
"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 |
237,414 | 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):
"""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... | [
"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 |
237,415 | 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):
"""Perform MIB variable ID and associated value conversion.
Parameters
----------
mibViewController : :py:class:`~pysnmp.smi.view.MibViewController`
class instance representing MIB browsing functionality.
Returns
... | [
"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 |
237,416 | 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):
"""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
-------
... | [
"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 |
237,417 | 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):
"""Perform MIB variable ID conversion and notification objects expansion.
Parameters
----------
mibViewController : :py:class:`~pysnmp.smi.view.MibViewController`
class instance representing MIB browsing functionality.
Re... | [
"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 |
237,418 | 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):
"""Creates a subclass with discreet values constraint.
"""
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 |
237,419 | 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):
"""Creates a subclass with value range constraint.
"""
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 |
237,420 | 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):
"""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... | [
"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 |
237,421 | 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):
"""Creates a subclass with value size constraint.
"""
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 |
237,422 | 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):
"""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... | [
"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 |
237,423 | 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):
"""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 ... | [
"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 |
237,424 | 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):
"""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... | [
"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 |
237,425 | 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):
"""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... | [
"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 |
237,426 | 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):
"""Unregister application with dispatcher"""
# 4.3.4
if contextEngineId is None:
# Default to local snmpEngineId
contextEngineId, = self.mibInstrumController.mibBuilder.importSymbols(
'__SNMP... | [
"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 |
237,427 | 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):
"""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 ... | [
"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 |
237,428 | 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):
"""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... | [
"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 |
237,429 | 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):
"""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... | [
"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 |
237,430 | 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):
"""Return tree node found by name"""
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 |
237,431 | 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):
"""Return tree node next to name"""
try:
nextNode = self.getBranch(name, **context)
except (error.NoSuchInstanceError, error.NoSuchObjectError):
return self.getNextBranch(name, **context)
else:
try:
... | [
"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 |
237,432 | 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):
"""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
... | [
"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 |
237,433 | 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):
"""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 ... | [
"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 |
237,434 | 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):
"""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... | [
"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 |
237,435 | 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):
"""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... | [
"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 |
237,436 | 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):
"""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... | [
"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 |
237,437 | 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):
"""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 ... | [
"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 |
237,438 | 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):
"""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 ... | [
"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 |
237,439 | 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):
"""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... | [
"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 |
237,440 | 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):
"""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... | [
"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 |
237,441 | 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):
"""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... | [
"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 |
237,442 | 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):
"""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... | [
"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 |
237,443 | 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):
"""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... | [
"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 |
237,444 | 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):
"""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
... | [
"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 |
237,445 | 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):
"""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... | [
"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 |
237,446 | 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):
"""Return column instance identification from indices"""
try:
return self._idxToIdCache[indices]
except TypeError:
cacheable = False
except KeyError:
cacheable = True
idx = 0
instId = ()
... | [
"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 |
237,447 | 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):
"""Build column instance name from components"""
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 |
237,448 | 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):
"""Build column instance names from 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 |
237,449 | 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):
"""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... | [
"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 |
237,450 | 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):
"""Copy received message metadata while it lasts"""
execCtx = snmpEngine.observer.getExecutionContext('rfc3412.receiveMessage:request')
return {
'securityModel': execCtx['securityModel'],
'securityName': execCtx['securityName'],
... | [
"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 |
237,451 | 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):
"""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... | [
"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 |
237,452 | 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):
"""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`
... | [
"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 |
237,453 | 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):
"""Raise exception on any error if user callback is missing"""
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 |
237,454 | 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):
"""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... | [
"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 |
237,455 | 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):
"""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
---------... | [
"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 |
237,456 | 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):
"""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... | [
"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 |
237,457 | 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):
"""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 ... | [
"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 |
237,458 | 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):
"""
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... | [
"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 |
237,459 | 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):
"""
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() | [
"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 |
237,460 | 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(_):
"""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-... | [
"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 |
237,461 | 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):
"""
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'... | [
"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 |
237,462 | 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):
"""
MobID representation as dict
"""
material = {'Data1': self.Data1,
'Data2': self.Data2,
'Data3': self.Data3,
'Data4': list(self.Data4)
}
return {'material':material,
... | [
"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 |
237,463 | 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):
"""
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":... | [
"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 |
237,464 | 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):
"""
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
... | [
"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 |
237,465 | 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):
"""
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... | [
"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 |
237,466 | 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):
"""
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)
... | [
"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 |
237,467 | 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):
"""
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... | [
"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 |
237,468 | 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):
"""
Create a storage DirEntry name path
"""
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 |
237,469 | 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):
"""
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... | [
"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 |
237,470 | 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):
"""
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):
... | [
"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 |
237,471 | 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'):
"""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... | [
"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 |
237,472 | 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):
"""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... | [
"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 |
237,473 | 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 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
} | [
"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 |
237,474 | 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):
""" 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... | [
"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 |
237,475 | 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):
""" 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 =... | [
"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 |
237,476 | 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):
""" Calculate how much variance in returns do the values explain """
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 |
237,477 | 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):
""" 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')... | [
"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 |
237,478 | 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):
""" Initialize weights to reasonable defaults """
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 |
237,479 | 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):
""" Concatenate accumulated tensors """
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 |
237,480 | 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):
""" 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... | [
"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 |
237,481 | 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):
""" Resolve function arguments and call them, possibily filling from the environment """
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 |
237,482 | 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):
""" 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)
... | [
"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 |
237,483 | 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):
""" 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 ... | [
"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 |
237,484 | MillionIntegrals/vel | vel/rl/api/evaluator.py | Evaluator.is_provided | def is_provided(self, name):
""" Capability check if evaluator provides given value """
if name in self._storage:
return True
elif name in self._providers:
return True
elif name.startswith('rollout:'):
rollout_name = name[8:]
else:
... | python | def is_provided(self, name):
""" Capability check if evaluator provides given value """
if name in self._storage:
return True
elif name in self._providers:
return True
elif name.startswith('rollout:'):
rollout_name = name[8:]
else:
... | [
"def",
"is_provided",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"_storage",
":",
"return",
"True",
"elif",
"name",
"in",
"self",
".",
"_providers",
":",
"return",
"True",
"elif",
"name",
".",
"startswith",
"(",
"'rollout:'",
... | Capability check if evaluator provides given value | [
"Capability",
"check",
"if",
"evaluator",
"provides",
"given",
"value"
] | e0726e1f63742b728966ccae0c8b825ea0ba491a | https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/api/evaluator.py#L103-L112 |
237,485 | MillionIntegrals/vel | vel/rl/api/evaluator.py | Evaluator.get | def get(self, name):
"""
Return a value from this evaluator.
Because tensor calculated is cached, it may lead to suble bugs if the same value is used multiple times
with and without no_grad() context.
It is advised in such cases to not use no_grad and stick to .detach()
... | python | def get(self, name):
"""
Return a value from this evaluator.
Because tensor calculated is cached, it may lead to suble bugs if the same value is used multiple times
with and without no_grad() context.
It is advised in such cases to not use no_grad and stick to .detach()
... | [
"def",
"get",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"_storage",
":",
"return",
"self",
".",
"_storage",
"[",
"name",
"]",
"elif",
"name",
"in",
"self",
".",
"_providers",
":",
"value",
"=",
"self",
".",
"_storage",
"[... | Return a value from this evaluator.
Because tensor calculated is cached, it may lead to suble bugs if the same value is used multiple times
with and without no_grad() context.
It is advised in such cases to not use no_grad and stick to .detach() | [
"Return",
"a",
"value",
"from",
"this",
"evaluator",
"."
] | e0726e1f63742b728966ccae0c8b825ea0ba491a | https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/api/evaluator.py#L114-L133 |
237,486 | MillionIntegrals/vel | vel/sources/vision/mnist.py | create | def create(model_config, batch_size, normalize=True, num_workers=0, augmentations=None):
""" Create a MNIST dataset, normalized """
path = model_config.data_dir('mnist')
train_dataset = datasets.MNIST(path, train=True, download=True)
test_dataset = datasets.MNIST(path, train=False, download=True)
... | python | def create(model_config, batch_size, normalize=True, num_workers=0, augmentations=None):
""" Create a MNIST dataset, normalized """
path = model_config.data_dir('mnist')
train_dataset = datasets.MNIST(path, train=True, download=True)
test_dataset = datasets.MNIST(path, train=False, download=True)
... | [
"def",
"create",
"(",
"model_config",
",",
"batch_size",
",",
"normalize",
"=",
"True",
",",
"num_workers",
"=",
"0",
",",
"augmentations",
"=",
"None",
")",
":",
"path",
"=",
"model_config",
".",
"data_dir",
"(",
"'mnist'",
")",
"train_dataset",
"=",
"dat... | Create a MNIST dataset, normalized | [
"Create",
"a",
"MNIST",
"dataset",
"normalized"
] | e0726e1f63742b728966ccae0c8b825ea0ba491a | https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/sources/vision/mnist.py#L11-L35 |
237,487 | MillionIntegrals/vel | vel/storage/classic.py | ClassicStorage.reset | def reset(self, configuration: dict) -> None:
"""
Whenever there was anything stored in the database or not, purge previous state and start
new training process from scratch.
"""
self.clean(0)
self.backend.store_config(configuration) | python | def reset(self, configuration: dict) -> None:
"""
Whenever there was anything stored in the database or not, purge previous state and start
new training process from scratch.
"""
self.clean(0)
self.backend.store_config(configuration) | [
"def",
"reset",
"(",
"self",
",",
"configuration",
":",
"dict",
")",
"->",
"None",
":",
"self",
".",
"clean",
"(",
"0",
")",
"self",
".",
"backend",
".",
"store_config",
"(",
"configuration",
")"
] | Whenever there was anything stored in the database or not, purge previous state and start
new training process from scratch. | [
"Whenever",
"there",
"was",
"anything",
"stored",
"in",
"the",
"database",
"or",
"not",
"purge",
"previous",
"state",
"and",
"start",
"new",
"training",
"process",
"from",
"scratch",
"."
] | e0726e1f63742b728966ccae0c8b825ea0ba491a | https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/storage/classic.py#L26-L32 |
237,488 | MillionIntegrals/vel | vel/storage/classic.py | ClassicStorage.load | def load(self, train_info: TrainingInfo) -> (dict, dict):
"""
Resume learning process and return loaded hidden state dictionary
"""
last_epoch = train_info.start_epoch_idx
model_state = torch.load(self.checkpoint_filename(last_epoch))
hidden_state = torch.load(self.check... | python | def load(self, train_info: TrainingInfo) -> (dict, dict):
"""
Resume learning process and return loaded hidden state dictionary
"""
last_epoch = train_info.start_epoch_idx
model_state = torch.load(self.checkpoint_filename(last_epoch))
hidden_state = torch.load(self.check... | [
"def",
"load",
"(",
"self",
",",
"train_info",
":",
"TrainingInfo",
")",
"->",
"(",
"dict",
",",
"dict",
")",
":",
"last_epoch",
"=",
"train_info",
".",
"start_epoch_idx",
"model_state",
"=",
"torch",
".",
"load",
"(",
"self",
".",
"checkpoint_filename",
"... | Resume learning process and return loaded hidden state dictionary | [
"Resume",
"learning",
"process",
"and",
"return",
"loaded",
"hidden",
"state",
"dictionary"
] | e0726e1f63742b728966ccae0c8b825ea0ba491a | https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/storage/classic.py#L34-L46 |
237,489 | MillionIntegrals/vel | vel/storage/classic.py | ClassicStorage.clean | def clean(self, global_epoch_idx):
""" Clean old checkpoints """
if self.cleaned:
return
self.cleaned = True
self.backend.clean(global_epoch_idx)
self._make_sure_dir_exists()
for x in os.listdir(self.model_config.checkpoint_dir()):
match = re.ma... | python | def clean(self, global_epoch_idx):
""" Clean old checkpoints """
if self.cleaned:
return
self.cleaned = True
self.backend.clean(global_epoch_idx)
self._make_sure_dir_exists()
for x in os.listdir(self.model_config.checkpoint_dir()):
match = re.ma... | [
"def",
"clean",
"(",
"self",
",",
"global_epoch_idx",
")",
":",
"if",
"self",
".",
"cleaned",
":",
"return",
"self",
".",
"cleaned",
"=",
"True",
"self",
".",
"backend",
".",
"clean",
"(",
"global_epoch_idx",
")",
"self",
".",
"_make_sure_dir_exists",
"(",... | Clean old checkpoints | [
"Clean",
"old",
"checkpoints"
] | e0726e1f63742b728966ccae0c8b825ea0ba491a | https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/storage/classic.py#L52-L85 |
237,490 | MillionIntegrals/vel | vel/storage/classic.py | ClassicStorage.checkpoint | def checkpoint(self, epoch_info: EpochInfo, model: Model):
""" When epoch is done, we persist the training state """
self.clean(epoch_info.global_epoch_idx - 1)
self._make_sure_dir_exists()
# Checkpoint latest
torch.save(model.state_dict(), self.checkpoint_filename(epoch_info.g... | python | def checkpoint(self, epoch_info: EpochInfo, model: Model):
""" When epoch is done, we persist the training state """
self.clean(epoch_info.global_epoch_idx - 1)
self._make_sure_dir_exists()
# Checkpoint latest
torch.save(model.state_dict(), self.checkpoint_filename(epoch_info.g... | [
"def",
"checkpoint",
"(",
"self",
",",
"epoch_info",
":",
"EpochInfo",
",",
"model",
":",
"Model",
")",
":",
"self",
".",
"clean",
"(",
"epoch_info",
".",
"global_epoch_idx",
"-",
"1",
")",
"self",
".",
"_make_sure_dir_exists",
"(",
")",
"# Checkpoint latest... | When epoch is done, we persist the training state | [
"When",
"epoch",
"is",
"done",
"we",
"persist",
"the",
"training",
"state"
] | e0726e1f63742b728966ccae0c8b825ea0ba491a | https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/storage/classic.py#L87-L118 |
237,491 | MillionIntegrals/vel | vel/storage/classic.py | ClassicStorage._persisted_last_epoch | def _persisted_last_epoch(self) -> int:
""" Return number of last epoch already calculated """
epoch_number = 0
self._make_sure_dir_exists()
for x in os.listdir(self.model_config.checkpoint_dir()):
match = re.match('checkpoint_(\\d+)\\.data', x)
if match:
... | python | def _persisted_last_epoch(self) -> int:
""" Return number of last epoch already calculated """
epoch_number = 0
self._make_sure_dir_exists()
for x in os.listdir(self.model_config.checkpoint_dir()):
match = re.match('checkpoint_(\\d+)\\.data', x)
if match:
... | [
"def",
"_persisted_last_epoch",
"(",
"self",
")",
"->",
"int",
":",
"epoch_number",
"=",
"0",
"self",
".",
"_make_sure_dir_exists",
"(",
")",
"for",
"x",
"in",
"os",
".",
"listdir",
"(",
"self",
".",
"model_config",
".",
"checkpoint_dir",
"(",
")",
")",
... | Return number of last epoch already calculated | [
"Return",
"number",
"of",
"last",
"epoch",
"already",
"calculated"
] | e0726e1f63742b728966ccae0c8b825ea0ba491a | https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/storage/classic.py#L140-L153 |
237,492 | MillionIntegrals/vel | vel/storage/classic.py | ClassicStorage._make_sure_dir_exists | def _make_sure_dir_exists(self):
""" Make sure directory exists """
filename = self.model_config.checkpoint_dir()
pathlib.Path(filename).mkdir(parents=True, exist_ok=True) | python | def _make_sure_dir_exists(self):
""" Make sure directory exists """
filename = self.model_config.checkpoint_dir()
pathlib.Path(filename).mkdir(parents=True, exist_ok=True) | [
"def",
"_make_sure_dir_exists",
"(",
"self",
")",
":",
"filename",
"=",
"self",
".",
"model_config",
".",
"checkpoint_dir",
"(",
")",
"pathlib",
".",
"Path",
"(",
"filename",
")",
".",
"mkdir",
"(",
"parents",
"=",
"True",
",",
"exist_ok",
"=",
"True",
"... | Make sure directory exists | [
"Make",
"sure",
"directory",
"exists"
] | e0726e1f63742b728966ccae0c8b825ea0ba491a | https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/storage/classic.py#L155-L158 |
237,493 | MillionIntegrals/vel | vel/rl/api/algo_base.py | clip_gradients | def clip_gradients(batch_result, model, max_grad_norm):
""" Clip gradients to a given maximum length """
if max_grad_norm is not None:
grad_norm = torch.nn.utils.clip_grad_norm_(
filter(lambda p: p.requires_grad, model.parameters()),
max_norm=max_grad_norm
)
else:
... | python | def clip_gradients(batch_result, model, max_grad_norm):
""" Clip gradients to a given maximum length """
if max_grad_norm is not None:
grad_norm = torch.nn.utils.clip_grad_norm_(
filter(lambda p: p.requires_grad, model.parameters()),
max_norm=max_grad_norm
)
else:
... | [
"def",
"clip_gradients",
"(",
"batch_result",
",",
"model",
",",
"max_grad_norm",
")",
":",
"if",
"max_grad_norm",
"is",
"not",
"None",
":",
"grad_norm",
"=",
"torch",
".",
"nn",
".",
"utils",
".",
"clip_grad_norm_",
"(",
"filter",
"(",
"lambda",
"p",
":",... | Clip gradients to a given maximum length | [
"Clip",
"gradients",
"to",
"a",
"given",
"maximum",
"length"
] | e0726e1f63742b728966ccae0c8b825ea0ba491a | https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/api/algo_base.py#L4-L14 |
237,494 | MillionIntegrals/vel | vel/rl/buffers/circular_replay_buffer.py | CircularReplayBuffer.sample_trajectories | def sample_trajectories(self, rollout_length, batch_info) -> Trajectories:
""" Sample batch of trajectories and return them """
indexes = self.backend.sample_batch_trajectories(rollout_length)
transition_tensors = self.backend.get_trajectories(indexes, rollout_length)
return Trajectorie... | python | def sample_trajectories(self, rollout_length, batch_info) -> Trajectories:
""" Sample batch of trajectories and return them """
indexes = self.backend.sample_batch_trajectories(rollout_length)
transition_tensors = self.backend.get_trajectories(indexes, rollout_length)
return Trajectorie... | [
"def",
"sample_trajectories",
"(",
"self",
",",
"rollout_length",
",",
"batch_info",
")",
"->",
"Trajectories",
":",
"indexes",
"=",
"self",
".",
"backend",
".",
"sample_batch_trajectories",
"(",
"rollout_length",
")",
"transition_tensors",
"=",
"self",
".",
"back... | Sample batch of trajectories and return them | [
"Sample",
"batch",
"of",
"trajectories",
"and",
"return",
"them"
] | e0726e1f63742b728966ccae0c8b825ea0ba491a | https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/buffers/circular_replay_buffer.py#L52-L63 |
237,495 | MillionIntegrals/vel | vel/rl/algo/policy_gradient/trpo.py | conjugate_gradient_method | def conjugate_gradient_method(matrix_vector_operator, loss_gradient, nsteps, rdotr_tol=1e-10):
""" Conjugate gradient algorithm """
x = torch.zeros_like(loss_gradient)
r = loss_gradient.clone()
p = loss_gradient.clone()
rdotr = torch.dot(r, r)
for i in range(nsteps):
Avp = matrix_vect... | python | def conjugate_gradient_method(matrix_vector_operator, loss_gradient, nsteps, rdotr_tol=1e-10):
""" Conjugate gradient algorithm """
x = torch.zeros_like(loss_gradient)
r = loss_gradient.clone()
p = loss_gradient.clone()
rdotr = torch.dot(r, r)
for i in range(nsteps):
Avp = matrix_vect... | [
"def",
"conjugate_gradient_method",
"(",
"matrix_vector_operator",
",",
"loss_gradient",
",",
"nsteps",
",",
"rdotr_tol",
"=",
"1e-10",
")",
":",
"x",
"=",
"torch",
".",
"zeros_like",
"(",
"loss_gradient",
")",
"r",
"=",
"loss_gradient",
".",
"clone",
"(",
")"... | Conjugate gradient algorithm | [
"Conjugate",
"gradient",
"algorithm"
] | e0726e1f63742b728966ccae0c8b825ea0ba491a | https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/algo/policy_gradient/trpo.py#L23-L47 |
237,496 | MillionIntegrals/vel | vel/rl/algo/policy_gradient/trpo.py | TrpoPolicyGradient.line_search | def line_search(self, model, rollout, original_policy_loss, original_policy_params, original_parameter_vec,
full_step, expected_improvement_full):
""" Find the right stepsize to make sure policy improves """
current_parameter_vec = original_parameter_vec.clone()
for idx in r... | python | def line_search(self, model, rollout, original_policy_loss, original_policy_params, original_parameter_vec,
full_step, expected_improvement_full):
""" Find the right stepsize to make sure policy improves """
current_parameter_vec = original_parameter_vec.clone()
for idx in r... | [
"def",
"line_search",
"(",
"self",
",",
"model",
",",
"rollout",
",",
"original_policy_loss",
",",
"original_policy_params",
",",
"original_parameter_vec",
",",
"full_step",
",",
"expected_improvement_full",
")",
":",
"current_parameter_vec",
"=",
"original_parameter_vec"... | Find the right stepsize to make sure policy improves | [
"Find",
"the",
"right",
"stepsize",
"to",
"make",
"sure",
"policy",
"improves"
] | e0726e1f63742b728966ccae0c8b825ea0ba491a | https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/algo/policy_gradient/trpo.py#L167-L205 |
237,497 | MillionIntegrals/vel | vel/rl/algo/policy_gradient/trpo.py | TrpoPolicyGradient.fisher_vector_product | def fisher_vector_product(self, vector, kl_divergence_gradient, model):
""" Calculate product Hessian @ vector """
assert not vector.requires_grad, "Vector must not propagate gradient"
dot_product = vector @ kl_divergence_gradient
# at least one dimension spans across two contiguous sub... | python | def fisher_vector_product(self, vector, kl_divergence_gradient, model):
""" Calculate product Hessian @ vector """
assert not vector.requires_grad, "Vector must not propagate gradient"
dot_product = vector @ kl_divergence_gradient
# at least one dimension spans across two contiguous sub... | [
"def",
"fisher_vector_product",
"(",
"self",
",",
"vector",
",",
"kl_divergence_gradient",
",",
"model",
")",
":",
"assert",
"not",
"vector",
".",
"requires_grad",
",",
"\"Vector must not propagate gradient\"",
"dot_product",
"=",
"vector",
"@",
"kl_divergence_gradient"... | Calculate product Hessian @ vector | [
"Calculate",
"product",
"Hessian"
] | e0726e1f63742b728966ccae0c8b825ea0ba491a | https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/algo/policy_gradient/trpo.py#L207-L216 |
237,498 | MillionIntegrals/vel | vel/rl/algo/policy_gradient/trpo.py | TrpoPolicyGradient.value_loss | def value_loss(self, model, observations, discounted_rewards):
""" Loss of value estimator """
value_outputs = model.value(observations)
value_loss = 0.5 * F.mse_loss(value_outputs, discounted_rewards)
return value_loss | python | def value_loss(self, model, observations, discounted_rewards):
""" Loss of value estimator """
value_outputs = model.value(observations)
value_loss = 0.5 * F.mse_loss(value_outputs, discounted_rewards)
return value_loss | [
"def",
"value_loss",
"(",
"self",
",",
"model",
",",
"observations",
",",
"discounted_rewards",
")",
":",
"value_outputs",
"=",
"model",
".",
"value",
"(",
"observations",
")",
"value_loss",
"=",
"0.5",
"*",
"F",
".",
"mse_loss",
"(",
"value_outputs",
",",
... | Loss of value estimator | [
"Loss",
"of",
"value",
"estimator"
] | e0726e1f63742b728966ccae0c8b825ea0ba491a | https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/algo/policy_gradient/trpo.py#L218-L222 |
237,499 | MillionIntegrals/vel | vel/rl/algo/policy_gradient/trpo.py | TrpoPolicyGradient.calc_policy_loss | def calc_policy_loss(self, model, policy_params, policy_entropy, rollout):
"""
Policy gradient loss - calculate from probability distribution
Calculate surrogate loss - advantage * policy_probability / fixed_initial_policy_probability
Because we operate with logarithm of -probability (... | python | def calc_policy_loss(self, model, policy_params, policy_entropy, rollout):
"""
Policy gradient loss - calculate from probability distribution
Calculate surrogate loss - advantage * policy_probability / fixed_initial_policy_probability
Because we operate with logarithm of -probability (... | [
"def",
"calc_policy_loss",
"(",
"self",
",",
"model",
",",
"policy_params",
",",
"policy_entropy",
",",
"rollout",
")",
":",
"actions",
"=",
"rollout",
".",
"batch_tensor",
"(",
"'actions'",
")",
"advantages",
"=",
"rollout",
".",
"batch_tensor",
"(",
"'advant... | Policy gradient loss - calculate from probability distribution
Calculate surrogate loss - advantage * policy_probability / fixed_initial_policy_probability
Because we operate with logarithm of -probability (neglogp) we do
- advantage * exp(fixed_neglogps - model_neglogps) | [
"Policy",
"gradient",
"loss",
"-",
"calculate",
"from",
"probability",
"distribution"
] | e0726e1f63742b728966ccae0c8b825ea0ba491a | https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/algo/policy_gradient/trpo.py#L224-L245 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.