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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
ANTsX/ANTsPy | ants/core/ants_metric.py | ANTsImageToImageMetric.set_moving_image | def set_moving_image(self, image):
"""
Set Moving ANTsImage for metric
"""
if not isinstance(image, iio.ANTsImage):
raise ValueError('image must be ANTsImage type')
if image.dimension != self.dimension:
raise ValueError('image dim (%i) does not match metr... | python | def set_moving_image(self, image):
"""
Set Moving ANTsImage for metric
"""
if not isinstance(image, iio.ANTsImage):
raise ValueError('image must be ANTsImage type')
if image.dimension != self.dimension:
raise ValueError('image dim (%i) does not match metr... | [
"def",
"set_moving_image",
"(",
"self",
",",
"image",
")",
":",
"if",
"not",
"isinstance",
"(",
"image",
",",
"iio",
".",
"ANTsImage",
")",
":",
"raise",
"ValueError",
"(",
"'image must be ANTsImage type'",
")",
"if",
"image",
".",
"dimension",
"!=",
"self",... | Set Moving ANTsImage for metric | [
"Set",
"Moving",
"ANTsImage",
"for",
"metric"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_metric.py#L74-L85 | train |
ANTsX/ANTsPy | ants/utils/image_to_cluster_images.py | image_to_cluster_images | def image_to_cluster_images(image, min_cluster_size=50, min_thresh=1e-06, max_thresh=1):
"""
Converts an image to several independent images.
Produces a unique image for each connected
component 1 through N of size > min_cluster_size
ANTsR function: `image2ClusterImages`
Arguments
------... | python | def image_to_cluster_images(image, min_cluster_size=50, min_thresh=1e-06, max_thresh=1):
"""
Converts an image to several independent images.
Produces a unique image for each connected
component 1 through N of size > min_cluster_size
ANTsR function: `image2ClusterImages`
Arguments
------... | [
"def",
"image_to_cluster_images",
"(",
"image",
",",
"min_cluster_size",
"=",
"50",
",",
"min_thresh",
"=",
"1e-06",
",",
"max_thresh",
"=",
"1",
")",
":",
"if",
"not",
"isinstance",
"(",
"image",
",",
"iio",
".",
"ANTsImage",
")",
":",
"raise",
"ValueErro... | Converts an image to several independent images.
Produces a unique image for each connected
component 1 through N of size > min_cluster_size
ANTsR function: `image2ClusterImages`
Arguments
---------
image : ANTsImage
input image
min_cluster_size : integer
throw away clust... | [
"Converts",
"an",
"image",
"to",
"several",
"independent",
"images",
"."
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/image_to_cluster_images.py#L9-L51 | train |
ANTsX/ANTsPy | ants/utils/threshold_image.py | threshold_image | def threshold_image(image, low_thresh=None, high_thresh=None, inval=1, outval=0, binary=True):
"""
Converts a scalar image into a binary image by thresholding operations
ANTsR function: `thresholdImage`
Arguments
---------
image : ANTsImage
Input image to operate on
low_thresh... | python | def threshold_image(image, low_thresh=None, high_thresh=None, inval=1, outval=0, binary=True):
"""
Converts a scalar image into a binary image by thresholding operations
ANTsR function: `thresholdImage`
Arguments
---------
image : ANTsImage
Input image to operate on
low_thresh... | [
"def",
"threshold_image",
"(",
"image",
",",
"low_thresh",
"=",
"None",
",",
"high_thresh",
"=",
"None",
",",
"inval",
"=",
"1",
",",
"outval",
"=",
"0",
",",
"binary",
"=",
"True",
")",
":",
"if",
"high_thresh",
"is",
"None",
":",
"high_thresh",
"=",
... | Converts a scalar image into a binary image by thresholding operations
ANTsR function: `thresholdImage`
Arguments
---------
image : ANTsImage
Input image to operate on
low_thresh : scalar (optional)
Lower edge of threshold window
hight_thresh : scalar (optional)
... | [
"Converts",
"a",
"scalar",
"image",
"into",
"a",
"binary",
"image",
"by",
"thresholding",
"operations"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/threshold_image.py#L10-L60 | train |
ANTsX/ANTsPy | ants/registration/symmetrize_image.py | symmetrize_image | def symmetrize_image(image):
"""
Use registration and reflection to make an image symmetric
ANTsR function: N/A
Arguments
---------
image : ANTsImage
image to make symmetric
Returns
-------
ANTsImage
Example
-------
>>> import ants
>>> image = ants.image_r... | python | def symmetrize_image(image):
"""
Use registration and reflection to make an image symmetric
ANTsR function: N/A
Arguments
---------
image : ANTsImage
image to make symmetric
Returns
-------
ANTsImage
Example
-------
>>> import ants
>>> image = ants.image_r... | [
"def",
"symmetrize_image",
"(",
"image",
")",
":",
"imager",
"=",
"reflect_image",
"(",
"image",
",",
"axis",
"=",
"0",
")",
"imageavg",
"=",
"imager",
"*",
"0.5",
"+",
"image",
"for",
"i",
"in",
"range",
"(",
"5",
")",
":",
"w1",
"=",
"registration"... | Use registration and reflection to make an image symmetric
ANTsR function: N/A
Arguments
---------
image : ANTsImage
image to make symmetric
Returns
-------
ANTsImage
Example
-------
>>> import ants
>>> image = ants.image_read( ants.get_ants_data('r16') , 'float')... | [
"Use",
"registration",
"and",
"reflection",
"to",
"make",
"an",
"image",
"symmetric"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/registration/symmetrize_image.py#L13-L49 | train |
freakboy3742/pyxero | xero/basemanager.py | BaseManager._get_attachments | def _get_attachments(self, id):
"""Retrieve a list of attachments associated with this Xero object."""
uri = '/'.join([self.base_url, self.name, id, 'Attachments']) + '/'
return uri, {}, 'get', None, None, False | python | def _get_attachments(self, id):
"""Retrieve a list of attachments associated with this Xero object."""
uri = '/'.join([self.base_url, self.name, id, 'Attachments']) + '/'
return uri, {}, 'get', None, None, False | [
"def",
"_get_attachments",
"(",
"self",
",",
"id",
")",
":",
"uri",
"=",
"'/'",
".",
"join",
"(",
"[",
"self",
".",
"base_url",
",",
"self",
".",
"name",
",",
"id",
",",
"'Attachments'",
"]",
")",
"+",
"'/'",
"return",
"uri",
",",
"{",
"}",
",",
... | Retrieve a list of attachments associated with this Xero object. | [
"Retrieve",
"a",
"list",
"of",
"attachments",
"associated",
"with",
"this",
"Xero",
"object",
"."
] | 5566f17fa06ed1f2fb9426c112951a72276b0f9a | https://github.com/freakboy3742/pyxero/blob/5566f17fa06ed1f2fb9426c112951a72276b0f9a/xero/basemanager.py#L240-L243 | train |
freakboy3742/pyxero | xero/basemanager.py | BaseManager._put_attachment_data | def _put_attachment_data(self, id, filename, data, content_type, include_online=False):
"""Upload an attachment to the Xero object."""
uri = '/'.join([self.base_url, self.name, id, 'Attachments', filename])
params = {'IncludeOnline': 'true'} if include_online else {}
headers = {'Content-... | python | def _put_attachment_data(self, id, filename, data, content_type, include_online=False):
"""Upload an attachment to the Xero object."""
uri = '/'.join([self.base_url, self.name, id, 'Attachments', filename])
params = {'IncludeOnline': 'true'} if include_online else {}
headers = {'Content-... | [
"def",
"_put_attachment_data",
"(",
"self",
",",
"id",
",",
"filename",
",",
"data",
",",
"content_type",
",",
"include_online",
"=",
"False",
")",
":",
"uri",
"=",
"'/'",
".",
"join",
"(",
"[",
"self",
".",
"base_url",
",",
"self",
".",
"name",
",",
... | Upload an attachment to the Xero object. | [
"Upload",
"an",
"attachment",
"to",
"the",
"Xero",
"object",
"."
] | 5566f17fa06ed1f2fb9426c112951a72276b0f9a | https://github.com/freakboy3742/pyxero/blob/5566f17fa06ed1f2fb9426c112951a72276b0f9a/xero/basemanager.py#L280-L285 | train |
freakboy3742/pyxero | examples/partner_oauth_flow/runserver.py | PartnerCredentialsHandler.page_response | def page_response(self, title='', body=''):
"""
Helper to render an html page with dynamic content
"""
f = StringIO()
f.write('<!DOCTYPE html>\n')
f.write('<html>\n')
f.write('<head><title>{}</title><head>\n'.format(title))
f.write('<body>\n<h2>{}</h2>\n'.... | python | def page_response(self, title='', body=''):
"""
Helper to render an html page with dynamic content
"""
f = StringIO()
f.write('<!DOCTYPE html>\n')
f.write('<html>\n')
f.write('<head><title>{}</title><head>\n'.format(title))
f.write('<body>\n<h2>{}</h2>\n'.... | [
"def",
"page_response",
"(",
"self",
",",
"title",
"=",
"''",
",",
"body",
"=",
"''",
")",
":",
"f",
"=",
"StringIO",
"(",
")",
"f",
".",
"write",
"(",
"'<!DOCTYPE html>\\n'",
")",
"f",
".",
"write",
"(",
"'<html>\\n'",
")",
"f",
".",
"write",
"(",... | Helper to render an html page with dynamic content | [
"Helper",
"to",
"render",
"an",
"html",
"page",
"with",
"dynamic",
"content"
] | 5566f17fa06ed1f2fb9426c112951a72276b0f9a | https://github.com/freakboy3742/pyxero/blob/5566f17fa06ed1f2fb9426c112951a72276b0f9a/examples/partner_oauth_flow/runserver.py#L22-L41 | train |
freakboy3742/pyxero | examples/partner_oauth_flow/runserver.py | PartnerCredentialsHandler.redirect_response | def redirect_response(self, url, permanent=False):
"""
Generate redirect response
"""
if permanent:
self.send_response(301)
else:
self.send_response(302)
self.send_header("Location", url)
self.end_headers() | python | def redirect_response(self, url, permanent=False):
"""
Generate redirect response
"""
if permanent:
self.send_response(301)
else:
self.send_response(302)
self.send_header("Location", url)
self.end_headers() | [
"def",
"redirect_response",
"(",
"self",
",",
"url",
",",
"permanent",
"=",
"False",
")",
":",
"if",
"permanent",
":",
"self",
".",
"send_response",
"(",
"301",
")",
"else",
":",
"self",
".",
"send_response",
"(",
"302",
")",
"self",
".",
"send_header",
... | Generate redirect response | [
"Generate",
"redirect",
"response"
] | 5566f17fa06ed1f2fb9426c112951a72276b0f9a | https://github.com/freakboy3742/pyxero/blob/5566f17fa06ed1f2fb9426c112951a72276b0f9a/examples/partner_oauth_flow/runserver.py#L43-L52 | train |
freakboy3742/pyxero | xero/auth.py | PublicCredentials._init_credentials | def _init_credentials(self, oauth_token, oauth_token_secret):
"Depending on the state passed in, get self._oauth up and running"
if oauth_token and oauth_token_secret:
if self.verified:
# If provided, this is a fully verified set of
# credentials. Store the oa... | python | def _init_credentials(self, oauth_token, oauth_token_secret):
"Depending on the state passed in, get self._oauth up and running"
if oauth_token and oauth_token_secret:
if self.verified:
# If provided, this is a fully verified set of
# credentials. Store the oa... | [
"def",
"_init_credentials",
"(",
"self",
",",
"oauth_token",
",",
"oauth_token_secret",
")",
":",
"\"Depending on the state passed in, get self._oauth up and running\"",
"if",
"oauth_token",
"and",
"oauth_token_secret",
":",
"if",
"self",
".",
"verified",
":",
"self",
"."... | Depending on the state passed in, get self._oauth up and running | [
"Depending",
"on",
"the",
"state",
"passed",
"in",
"get",
"self",
".",
"_oauth",
"up",
"and",
"running"
] | 5566f17fa06ed1f2fb9426c112951a72276b0f9a | https://github.com/freakboy3742/pyxero/blob/5566f17fa06ed1f2fb9426c112951a72276b0f9a/xero/auth.py#L134-L163 | train |
freakboy3742/pyxero | xero/auth.py | PublicCredentials._init_oauth | def _init_oauth(self, oauth_token, oauth_token_secret):
"Store and initialize a verified set of OAuth credentials"
self.oauth_token = oauth_token
self.oauth_token_secret = oauth_token_secret
self._oauth = OAuth1(
self.consumer_key,
client_secret=self.consumer_sec... | python | def _init_oauth(self, oauth_token, oauth_token_secret):
"Store and initialize a verified set of OAuth credentials"
self.oauth_token = oauth_token
self.oauth_token_secret = oauth_token_secret
self._oauth = OAuth1(
self.consumer_key,
client_secret=self.consumer_sec... | [
"def",
"_init_oauth",
"(",
"self",
",",
"oauth_token",
",",
"oauth_token_secret",
")",
":",
"\"Store and initialize a verified set of OAuth credentials\"",
"self",
".",
"oauth_token",
"=",
"oauth_token",
"self",
".",
"oauth_token_secret",
"=",
"oauth_token_secret",
"self",
... | Store and initialize a verified set of OAuth credentials | [
"Store",
"and",
"initialize",
"a",
"verified",
"set",
"of",
"OAuth",
"credentials"
] | 5566f17fa06ed1f2fb9426c112951a72276b0f9a | https://github.com/freakboy3742/pyxero/blob/5566f17fa06ed1f2fb9426c112951a72276b0f9a/xero/auth.py#L165-L177 | train |
freakboy3742/pyxero | xero/auth.py | PublicCredentials._process_oauth_response | def _process_oauth_response(self, response):
"Extracts the fields from an oauth response"
if response.status_code == 200:
credentials = parse_qs(response.text)
# Initialize the oauth credentials
self._init_oauth(
credentials.get('oauth_token')[0],
... | python | def _process_oauth_response(self, response):
"Extracts the fields from an oauth response"
if response.status_code == 200:
credentials = parse_qs(response.text)
# Initialize the oauth credentials
self._init_oauth(
credentials.get('oauth_token')[0],
... | [
"def",
"_process_oauth_response",
"(",
"self",
",",
"response",
")",
":",
"\"Extracts the fields from an oauth response\"",
"if",
"response",
".",
"status_code",
"==",
"200",
":",
"credentials",
"=",
"parse_qs",
"(",
"response",
".",
"text",
")",
"self",
".",
"_in... | Extracts the fields from an oauth response | [
"Extracts",
"the",
"fields",
"from",
"an",
"oauth",
"response"
] | 5566f17fa06ed1f2fb9426c112951a72276b0f9a | https://github.com/freakboy3742/pyxero/blob/5566f17fa06ed1f2fb9426c112951a72276b0f9a/xero/auth.py#L179-L210 | train |
freakboy3742/pyxero | xero/auth.py | PublicCredentials.state | def state(self):
"""Obtain the useful state of this credentials object so that
we can reconstruct it independently.
"""
return dict(
(attr, getattr(self, attr))
for attr in (
'consumer_key', 'consumer_secret', 'callback_uri',
'verif... | python | def state(self):
"""Obtain the useful state of this credentials object so that
we can reconstruct it independently.
"""
return dict(
(attr, getattr(self, attr))
for attr in (
'consumer_key', 'consumer_secret', 'callback_uri',
'verif... | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"dict",
"(",
"(",
"attr",
",",
"getattr",
"(",
"self",
",",
"attr",
")",
")",
"for",
"attr",
"in",
"(",
"'consumer_key'",
",",
"'consumer_secret'",
",",
"'callback_uri'",
",",
"'verified'",
",",
"'oauth_to... | Obtain the useful state of this credentials object so that
we can reconstruct it independently. | [
"Obtain",
"the",
"useful",
"state",
"of",
"this",
"credentials",
"object",
"so",
"that",
"we",
"can",
"reconstruct",
"it",
"independently",
"."
] | 5566f17fa06ed1f2fb9426c112951a72276b0f9a | https://github.com/freakboy3742/pyxero/blob/5566f17fa06ed1f2fb9426c112951a72276b0f9a/xero/auth.py#L245-L258 | train |
freakboy3742/pyxero | xero/auth.py | PublicCredentials.verify | def verify(self, verifier):
"Verify an OAuth token"
# Construct the credentials for the verification request
oauth = OAuth1(
self.consumer_key,
client_secret=self.consumer_secret,
resource_owner_key=self.oauth_token,
resource_owner_secret=self.oau... | python | def verify(self, verifier):
"Verify an OAuth token"
# Construct the credentials for the verification request
oauth = OAuth1(
self.consumer_key,
client_secret=self.consumer_secret,
resource_owner_key=self.oauth_token,
resource_owner_secret=self.oau... | [
"def",
"verify",
"(",
"self",
",",
"verifier",
")",
":",
"\"Verify an OAuth token\"",
"oauth",
"=",
"OAuth1",
"(",
"self",
".",
"consumer_key",
",",
"client_secret",
"=",
"self",
".",
"consumer_secret",
",",
"resource_owner_key",
"=",
"self",
".",
"oauth_token",... | Verify an OAuth token | [
"Verify",
"an",
"OAuth",
"token"
] | 5566f17fa06ed1f2fb9426c112951a72276b0f9a | https://github.com/freakboy3742/pyxero/blob/5566f17fa06ed1f2fb9426c112951a72276b0f9a/xero/auth.py#L260-L279 | train |
freakboy3742/pyxero | xero/auth.py | PublicCredentials.url | def url(self):
"Returns the URL that can be visited to obtain a verifier code"
# The authorize url is always api.xero.com
query_string = {'oauth_token': self.oauth_token}
if self.scope:
query_string['scope'] = self.scope
url = XERO_BASE_URL + AUTHORIZE_URL + '?' + \... | python | def url(self):
"Returns the URL that can be visited to obtain a verifier code"
# The authorize url is always api.xero.com
query_string = {'oauth_token': self.oauth_token}
if self.scope:
query_string['scope'] = self.scope
url = XERO_BASE_URL + AUTHORIZE_URL + '?' + \... | [
"def",
"url",
"(",
"self",
")",
":",
"\"Returns the URL that can be visited to obtain a verifier code\"",
"query_string",
"=",
"{",
"'oauth_token'",
":",
"self",
".",
"oauth_token",
"}",
"if",
"self",
".",
"scope",
":",
"query_string",
"[",
"'scope'",
"]",
"=",
"s... | Returns the URL that can be visited to obtain a verifier code | [
"Returns",
"the",
"URL",
"that",
"can",
"be",
"visited",
"to",
"obtain",
"a",
"verifier",
"code"
] | 5566f17fa06ed1f2fb9426c112951a72276b0f9a | https://github.com/freakboy3742/pyxero/blob/5566f17fa06ed1f2fb9426c112951a72276b0f9a/xero/auth.py#L282-L292 | train |
freakboy3742/pyxero | xero/auth.py | PartnerCredentials.refresh | def refresh(self):
"Refresh an expired token"
# Construct the credentials for the verification request
oauth = OAuth1(
self.consumer_key,
client_secret=self.consumer_secret,
resource_owner_key=self.oauth_token,
resource_owner_secret=self.oauth_tok... | python | def refresh(self):
"Refresh an expired token"
# Construct the credentials for the verification request
oauth = OAuth1(
self.consumer_key,
client_secret=self.consumer_secret,
resource_owner_key=self.oauth_token,
resource_owner_secret=self.oauth_tok... | [
"def",
"refresh",
"(",
"self",
")",
":",
"\"Refresh an expired token\"",
"oauth",
"=",
"OAuth1",
"(",
"self",
".",
"consumer_key",
",",
"client_secret",
"=",
"self",
".",
"consumer_secret",
",",
"resource_owner_key",
"=",
"self",
".",
"oauth_token",
",",
"resour... | Refresh an expired token | [
"Refresh",
"an",
"expired",
"token"
] | 5566f17fa06ed1f2fb9426c112951a72276b0f9a | https://github.com/freakboy3742/pyxero/blob/5566f17fa06ed1f2fb9426c112951a72276b0f9a/xero/auth.py#L375-L393 | train |
freakboy3742/pyxero | xero/filesmanager.py | FilesManager._get_files | def _get_files(self, folderId):
"""Retrieve the list of files contained in a folder"""
uri = '/'.join([self.base_url, self.name, folderId, 'Files'])
return uri, {}, 'get', None, None, False, None | python | def _get_files(self, folderId):
"""Retrieve the list of files contained in a folder"""
uri = '/'.join([self.base_url, self.name, folderId, 'Files'])
return uri, {}, 'get', None, None, False, None | [
"def",
"_get_files",
"(",
"self",
",",
"folderId",
")",
":",
"uri",
"=",
"'/'",
".",
"join",
"(",
"[",
"self",
".",
"base_url",
",",
"self",
".",
"name",
",",
"folderId",
",",
"'Files'",
"]",
")",
"return",
"uri",
",",
"{",
"}",
",",
"'get'",
","... | Retrieve the list of files contained in a folder | [
"Retrieve",
"the",
"list",
"of",
"files",
"contained",
"in",
"a",
"folder"
] | 5566f17fa06ed1f2fb9426c112951a72276b0f9a | https://github.com/freakboy3742/pyxero/blob/5566f17fa06ed1f2fb9426c112951a72276b0f9a/xero/filesmanager.py#L118-L121 | train |
dmulcahey/zha-device-handlers | zhaquirks/hivehome/__init__.py | MotionCluster.handle_cluster_request | def handle_cluster_request(self, tsn, command_id, args):
"""Handle the cluster command."""
if command_id == 0:
if self._timer_handle:
self._timer_handle.cancel()
loop = asyncio.get_event_loop()
self._timer_handle = loop.call_later(30, self._turn_off) | python | def handle_cluster_request(self, tsn, command_id, args):
"""Handle the cluster command."""
if command_id == 0:
if self._timer_handle:
self._timer_handle.cancel()
loop = asyncio.get_event_loop()
self._timer_handle = loop.call_later(30, self._turn_off) | [
"def",
"handle_cluster_request",
"(",
"self",
",",
"tsn",
",",
"command_id",
",",
"args",
")",
":",
"if",
"command_id",
"==",
"0",
":",
"if",
"self",
".",
"_timer_handle",
":",
"self",
".",
"_timer_handle",
".",
"cancel",
"(",
")",
"loop",
"=",
"asyncio"... | Handle the cluster command. | [
"Handle",
"the",
"cluster",
"command",
"."
] | bab2a53724c6fb5caee2e796dd46ebcb45400f93 | https://github.com/dmulcahey/zha-device-handlers/blob/bab2a53724c6fb5caee2e796dd46ebcb45400f93/zhaquirks/hivehome/__init__.py#L21-L27 | train |
dmulcahey/zha-device-handlers | zhaquirks/xiaomi/__init__.py | BasicCluster._parse_attributes | def _parse_attributes(self, value):
"""Parse non standard atrributes."""
from zigpy.zcl import foundation as f
attributes = {}
attribute_names = {
1: BATTERY_VOLTAGE_MV,
3: TEMPERATURE,
4: XIAOMI_ATTR_4,
5: XIAOMI_ATTR_5,
6: XIA... | python | def _parse_attributes(self, value):
"""Parse non standard atrributes."""
from zigpy.zcl import foundation as f
attributes = {}
attribute_names = {
1: BATTERY_VOLTAGE_MV,
3: TEMPERATURE,
4: XIAOMI_ATTR_4,
5: XIAOMI_ATTR_5,
6: XIA... | [
"def",
"_parse_attributes",
"(",
"self",
",",
"value",
")",
":",
"from",
"zigpy",
".",
"zcl",
"import",
"foundation",
"as",
"f",
"attributes",
"=",
"{",
"}",
"attribute_names",
"=",
"{",
"1",
":",
"BATTERY_VOLTAGE_MV",
",",
"3",
":",
"TEMPERATURE",
",",
... | Parse non standard atrributes. | [
"Parse",
"non",
"standard",
"atrributes",
"."
] | bab2a53724c6fb5caee2e796dd46ebcb45400f93 | https://github.com/dmulcahey/zha-device-handlers/blob/bab2a53724c6fb5caee2e796dd46ebcb45400f93/zhaquirks/xiaomi/__init__.py#L64-L91 | train |
dmulcahey/zha-device-handlers | zhaquirks/xiaomi/__init__.py | BasicCluster._calculate_remaining_battery_percentage | def _calculate_remaining_battery_percentage(self, voltage):
"""Calculate percentage."""
min_voltage = 2500
max_voltage = 3000
percent = (voltage - min_voltage) / (max_voltage - min_voltage) * 200
return min(200, percent) | python | def _calculate_remaining_battery_percentage(self, voltage):
"""Calculate percentage."""
min_voltage = 2500
max_voltage = 3000
percent = (voltage - min_voltage) / (max_voltage - min_voltage) * 200
return min(200, percent) | [
"def",
"_calculate_remaining_battery_percentage",
"(",
"self",
",",
"voltage",
")",
":",
"min_voltage",
"=",
"2500",
"max_voltage",
"=",
"3000",
"percent",
"=",
"(",
"voltage",
"-",
"min_voltage",
")",
"/",
"(",
"max_voltage",
"-",
"min_voltage",
")",
"*",
"20... | Calculate percentage. | [
"Calculate",
"percentage",
"."
] | bab2a53724c6fb5caee2e796dd46ebcb45400f93 | https://github.com/dmulcahey/zha-device-handlers/blob/bab2a53724c6fb5caee2e796dd46ebcb45400f93/zhaquirks/xiaomi/__init__.py#L93-L98 | train |
dmulcahey/zha-device-handlers | zhaquirks/xiaomi/__init__.py | PowerConfigurationCluster.battery_reported | def battery_reported(self, voltage, rawVoltage):
"""Battery reported."""
self._update_attribute(BATTERY_PERCENTAGE_REMAINING, voltage)
self._update_attribute(self.BATTERY_VOLTAGE_ATTR,
int(rawVoltage / 100)) | python | def battery_reported(self, voltage, rawVoltage):
"""Battery reported."""
self._update_attribute(BATTERY_PERCENTAGE_REMAINING, voltage)
self._update_attribute(self.BATTERY_VOLTAGE_ATTR,
int(rawVoltage / 100)) | [
"def",
"battery_reported",
"(",
"self",
",",
"voltage",
",",
"rawVoltage",
")",
":",
"self",
".",
"_update_attribute",
"(",
"BATTERY_PERCENTAGE_REMAINING",
",",
"voltage",
")",
"self",
".",
"_update_attribute",
"(",
"self",
".",
"BATTERY_VOLTAGE_ATTR",
",",
"int",... | Battery reported. | [
"Battery",
"reported",
"."
] | bab2a53724c6fb5caee2e796dd46ebcb45400f93 | https://github.com/dmulcahey/zha-device-handlers/blob/bab2a53724c6fb5caee2e796dd46ebcb45400f93/zhaquirks/xiaomi/__init__.py#L122-L126 | train |
dmulcahey/zha-device-handlers | zhaquirks/smartthings/tag_v4.py | FastPollingPowerConfigurationCluster.configure_reporting | async def configure_reporting(self, attribute, min_interval,
max_interval, reportable_change):
"""Configure reporting."""
result = await super().configure_reporting(
PowerConfigurationCluster.BATTERY_VOLTAGE_ATTR,
self.FREQUENCY,
self... | python | async def configure_reporting(self, attribute, min_interval,
max_interval, reportable_change):
"""Configure reporting."""
result = await super().configure_reporting(
PowerConfigurationCluster.BATTERY_VOLTAGE_ATTR,
self.FREQUENCY,
self... | [
"async",
"def",
"configure_reporting",
"(",
"self",
",",
"attribute",
",",
"min_interval",
",",
"max_interval",
",",
"reportable_change",
")",
":",
"result",
"=",
"await",
"super",
"(",
")",
".",
"configure_reporting",
"(",
"PowerConfigurationCluster",
".",
"BATTE... | Configure reporting. | [
"Configure",
"reporting",
"."
] | bab2a53724c6fb5caee2e796dd46ebcb45400f93 | https://github.com/dmulcahey/zha-device-handlers/blob/bab2a53724c6fb5caee2e796dd46ebcb45400f93/zhaquirks/smartthings/tag_v4.py#L23-L32 | train |
F5Networks/f5-common-python | f5/bigip/tm/sys/folder.py | Folder.update | def update(self, **kwargs):
'''Update the object, removing device group if inherited
If inheritedDevicegroup is the string "true" we need to remove
deviceGroup from the args before we update or we get the
following error:
The floating traffic-group: /Common/traffic-group-1 can ... | python | def update(self, **kwargs):
'''Update the object, removing device group if inherited
If inheritedDevicegroup is the string "true" we need to remove
deviceGroup from the args before we update or we get the
following error:
The floating traffic-group: /Common/traffic-group-1 can ... | [
"def",
"update",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"inherit_device_group",
"=",
"self",
".",
"__dict__",
".",
"get",
"(",
"'inheritedDevicegroup'",
",",
"False",
")",
"if",
"inherit_device_group",
"==",
"'true'",
":",
"self",
".",
"__dict__",
".",
... | Update the object, removing device group if inherited
If inheritedDevicegroup is the string "true" we need to remove
deviceGroup from the args before we update or we get the
following error:
The floating traffic-group: /Common/traffic-group-1 can only be set on
/testfolder if i... | [
"Update",
"the",
"object",
"removing",
"device",
"group",
"if",
"inherited"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/tm/sys/folder.py#L90-L103 | train |
F5Networks/f5-common-python | f5/bigip/tm/cm/device_group.py | Device_Group.sync_to | def sync_to(self):
"""Wrapper method that synchronizes configuration to DG.
Executes the containing object's cm :meth:`~f5.bigip.cm.Cm.exec_cmd`
method to sync the configuration TO the device-group.
:note:: Both sync_to, and sync_from methods are convenience
methods wh... | python | def sync_to(self):
"""Wrapper method that synchronizes configuration to DG.
Executes the containing object's cm :meth:`~f5.bigip.cm.Cm.exec_cmd`
method to sync the configuration TO the device-group.
:note:: Both sync_to, and sync_from methods are convenience
methods wh... | [
"def",
"sync_to",
"(",
"self",
")",
":",
"device_group_collection",
"=",
"self",
".",
"_meta_data",
"[",
"'container'",
"]",
"cm",
"=",
"device_group_collection",
".",
"_meta_data",
"[",
"'container'",
"]",
"sync_cmd",
"=",
"'config-sync to-group %s'",
"%",
"self"... | Wrapper method that synchronizes configuration to DG.
Executes the containing object's cm :meth:`~f5.bigip.cm.Cm.exec_cmd`
method to sync the configuration TO the device-group.
:note:: Both sync_to, and sync_from methods are convenience
methods which usually are not what this ... | [
"Wrapper",
"method",
"that",
"synchronizes",
"configuration",
"to",
"DG",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/tm/cm/device_group.py#L62-L77 | train |
F5Networks/f5-common-python | f5/bigip/tm/sys/application.py | Service._create | def _create(self, **kwargs):
'''Create service on device and create accompanying Python object.
:params kwargs: keyword arguments passed in from create call
:raises: HTTPError
:returns: Python Service object
'''
try:
return super(Service, self)._create(**kwa... | python | def _create(self, **kwargs):
'''Create service on device and create accompanying Python object.
:params kwargs: keyword arguments passed in from create call
:raises: HTTPError
:returns: Python Service object
'''
try:
return super(Service, self)._create(**kwa... | [
"def",
"_create",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"try",
":",
"return",
"super",
"(",
"Service",
",",
"self",
")",
".",
"_create",
"(",
"**",
"kwargs",
")",
"except",
"HTTPError",
"as",
"ex",
":",
"if",
"\"The configuration was updated successf... | Create service on device and create accompanying Python object.
:params kwargs: keyword arguments passed in from create call
:raises: HTTPError
:returns: Python Service object | [
"Create",
"service",
"on",
"device",
"and",
"create",
"accompanying",
"Python",
"object",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/tm/sys/application.py#L105-L133 | train |
F5Networks/f5-common-python | f5/bigip/tm/sys/application.py | Service._build_service_uri | def _build_service_uri(self, base_uri, partition, name):
'''Build the proper uri for a service resource.
This follows the scheme:
<base_uri>/~<partition>~<<name>.app>~<name>
:param base_uri: str -- base uri for container
:param partition: str -- partition for this service
... | python | def _build_service_uri(self, base_uri, partition, name):
'''Build the proper uri for a service resource.
This follows the scheme:
<base_uri>/~<partition>~<<name>.app>~<name>
:param base_uri: str -- base uri for container
:param partition: str -- partition for this service
... | [
"def",
"_build_service_uri",
"(",
"self",
",",
"base_uri",
",",
"partition",
",",
"name",
")",
":",
"name",
"=",
"name",
".",
"replace",
"(",
"'/'",
",",
"'~'",
")",
"return",
"'%s~%s~%s.app~%s'",
"%",
"(",
"base_uri",
",",
"partition",
",",
"name",
",",... | Build the proper uri for a service resource.
This follows the scheme:
<base_uri>/~<partition>~<<name>.app>~<name>
:param base_uri: str -- base uri for container
:param partition: str -- partition for this service
:param name: str -- name of the service
:returns: str... | [
"Build",
"the",
"proper",
"uri",
"for",
"a",
"service",
"resource",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/tm/sys/application.py#L168-L180 | train |
F5Networks/f5-common-python | f5/bigiq/cm/device/licensing/pool/utility.py | Members.delete | def delete(self, **kwargs):
"""Deletes a member from a license pool
You need to be careful with this method. When you use it, and it
succeeds on the remote BIG-IP, the configuration of the BIG-IP
will be reloaded. During this process, you will not be able to
access the REST inte... | python | def delete(self, **kwargs):
"""Deletes a member from a license pool
You need to be careful with this method. When you use it, and it
succeeds on the remote BIG-IP, the configuration of the BIG-IP
will be reloaded. During this process, you will not be able to
access the REST inte... | [
"def",
"delete",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"if",
"'id'",
"not",
"in",
"kwargs",
":",
"delete_uri",
"=",
"self",
".",
"_meta_data",
"[",
"'uri'",
"]",
"if",
"delete_uri",
".",
"endswith",
"(",
"'/'",
")",
":",
"delete_uri",
"=",
"del... | Deletes a member from a license pool
You need to be careful with this method. When you use it, and it
succeeds on the remote BIG-IP, the configuration of the BIG-IP
will be reloaded. During this process, you will not be able to
access the REST interface.
This method overrides t... | [
"Deletes",
"a",
"member",
"from",
"a",
"license",
"pool"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigiq/cm/device/licensing/pool/utility.py#L137-L187 | train |
F5Networks/f5-common-python | f5/multi_device/trust_domain.py | TrustDomain._set_attributes | def _set_attributes(self, **kwargs):
'''Set attributes for instance in one place
:param kwargs: dict -- dictionary of keyword arguments
'''
self.devices = kwargs['devices'][:]
self.partition = kwargs['partition']
self.device_group_name = 'device_trust_group'
sel... | python | def _set_attributes(self, **kwargs):
'''Set attributes for instance in one place
:param kwargs: dict -- dictionary of keyword arguments
'''
self.devices = kwargs['devices'][:]
self.partition = kwargs['partition']
self.device_group_name = 'device_trust_group'
sel... | [
"def",
"_set_attributes",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"devices",
"=",
"kwargs",
"[",
"'devices'",
"]",
"[",
":",
"]",
"self",
".",
"partition",
"=",
"kwargs",
"[",
"'partition'",
"]",
"self",
".",
"device_group_name",
"=",
... | Set attributes for instance in one place
:param kwargs: dict -- dictionary of keyword arguments | [
"Set",
"attributes",
"for",
"instance",
"in",
"one",
"place"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/multi_device/trust_domain.py#L76-L85 | train |
F5Networks/f5-common-python | f5/multi_device/trust_domain.py | TrustDomain.validate | def validate(self):
'''Validate that devices are each trusted by one another
:param kwargs: dict -- keyword args for devices and partition
:raises: DeviceNotTrusted
'''
self._populate_domain()
missing = []
for domain_device in self.domain:
for truste... | python | def validate(self):
'''Validate that devices are each trusted by one another
:param kwargs: dict -- keyword args for devices and partition
:raises: DeviceNotTrusted
'''
self._populate_domain()
missing = []
for domain_device in self.domain:
for truste... | [
"def",
"validate",
"(",
"self",
")",
":",
"self",
".",
"_populate_domain",
"(",
")",
"missing",
"=",
"[",
"]",
"for",
"domain_device",
"in",
"self",
".",
"domain",
":",
"for",
"truster",
",",
"trustees",
"in",
"iteritems",
"(",
"self",
".",
"domain",
"... | Validate that devices are each trusted by one another
:param kwargs: dict -- keyword args for devices and partition
:raises: DeviceNotTrusted | [
"Validate",
"that",
"devices",
"are",
"each",
"trusted",
"by",
"one",
"another"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/multi_device/trust_domain.py#L87-L112 | train |
F5Networks/f5-common-python | f5/multi_device/trust_domain.py | TrustDomain._populate_domain | def _populate_domain(self):
'''Populate TrustDomain's domain attribute.
This entails an inspection of each device's certificate-authority
devices in its trust domain and recording them. After which, we
get a dictionary of who trusts who in the domain.
'''
self.domain = ... | python | def _populate_domain(self):
'''Populate TrustDomain's domain attribute.
This entails an inspection of each device's certificate-authority
devices in its trust domain and recording them. After which, we
get a dictionary of who trusts who in the domain.
'''
self.domain = ... | [
"def",
"_populate_domain",
"(",
"self",
")",
":",
"self",
".",
"domain",
"=",
"{",
"}",
"for",
"device",
"in",
"self",
".",
"devices",
":",
"device_name",
"=",
"get_device_info",
"(",
"device",
")",
".",
"name",
"ca_devices",
"=",
"device",
".",
"tm",
... | Populate TrustDomain's domain attribute.
This entails an inspection of each device's certificate-authority
devices in its trust domain and recording them. After which, we
get a dictionary of who trusts who in the domain. | [
"Populate",
"TrustDomain",
"s",
"domain",
"attribute",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/multi_device/trust_domain.py#L114-L131 | train |
F5Networks/f5-common-python | f5/multi_device/trust_domain.py | TrustDomain.create | def create(self, **kwargs):
'''Add trusted peers to the root bigip device.
When adding a trusted device to a device, the trust is reflexive. That
is, the truster trusts the trustee and the trustee trusts the truster.
So we only need to add the trusted devices to one device.
:pa... | python | def create(self, **kwargs):
'''Add trusted peers to the root bigip device.
When adding a trusted device to a device, the trust is reflexive. That
is, the truster trusts the trustee and the trustee trusts the truster.
So we only need to add the trusted devices to one device.
:pa... | [
"def",
"create",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"_set_attributes",
"(",
"**",
"kwargs",
")",
"for",
"device",
"in",
"self",
".",
"devices",
"[",
"1",
":",
"]",
":",
"self",
".",
"_add_trustee",
"(",
"device",
")",
"pollster"... | Add trusted peers to the root bigip device.
When adding a trusted device to a device, the trust is reflexive. That
is, the truster trusts the trustee and the trustee trusts the truster.
So we only need to add the trusted devices to one device.
:param kwargs: dict -- devices and partiti... | [
"Add",
"trusted",
"peers",
"to",
"the",
"root",
"bigip",
"device",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/multi_device/trust_domain.py#L133-L146 | train |
F5Networks/f5-common-python | f5/multi_device/trust_domain.py | TrustDomain.teardown | def teardown(self):
'''Teardown trust domain by removing trusted devices.'''
for device in self.devices:
self._remove_trustee(device)
self._populate_domain()
self.domain = {} | python | def teardown(self):
'''Teardown trust domain by removing trusted devices.'''
for device in self.devices:
self._remove_trustee(device)
self._populate_domain()
self.domain = {} | [
"def",
"teardown",
"(",
"self",
")",
":",
"for",
"device",
"in",
"self",
".",
"devices",
":",
"self",
".",
"_remove_trustee",
"(",
"device",
")",
"self",
".",
"_populate_domain",
"(",
")",
"self",
".",
"domain",
"=",
"{",
"}"
] | Teardown trust domain by removing trusted devices. | [
"Teardown",
"trust",
"domain",
"by",
"removing",
"trusted",
"devices",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/multi_device/trust_domain.py#L148-L154 | train |
F5Networks/f5-common-python | f5/multi_device/trust_domain.py | TrustDomain._add_trustee | def _add_trustee(self, device):
'''Add a single trusted device to the trust domain.
:param device: ManagementRoot object -- device to add to trust domain
'''
device_name = get_device_info(device).name
if device_name in self.domain:
msg = 'Device: %r is already in th... | python | def _add_trustee(self, device):
'''Add a single trusted device to the trust domain.
:param device: ManagementRoot object -- device to add to trust domain
'''
device_name = get_device_info(device).name
if device_name in self.domain:
msg = 'Device: %r is already in th... | [
"def",
"_add_trustee",
"(",
"self",
",",
"device",
")",
":",
"device_name",
"=",
"get_device_info",
"(",
"device",
")",
".",
"name",
"if",
"device_name",
"in",
"self",
".",
"domain",
":",
"msg",
"=",
"'Device: %r is already in this trust domain.'",
"%",
"device_... | Add a single trusted device to the trust domain.
:param device: ManagementRoot object -- device to add to trust domain | [
"Add",
"a",
"single",
"trusted",
"device",
"to",
"the",
"trust",
"domain",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/multi_device/trust_domain.py#L156-L166 | train |
F5Networks/f5-common-python | f5/multi_device/trust_domain.py | TrustDomain._remove_trustee | def _remove_trustee(self, device):
'''Remove a trustee from the trust domain.
:param device: MangementRoot object -- device to remove
'''
trustee_name = get_device_info(device).name
name_object_map = get_device_names_to_objects(self.devices)
delete_func = self._get_dele... | python | def _remove_trustee(self, device):
'''Remove a trustee from the trust domain.
:param device: MangementRoot object -- device to remove
'''
trustee_name = get_device_info(device).name
name_object_map = get_device_names_to_objects(self.devices)
delete_func = self._get_dele... | [
"def",
"_remove_trustee",
"(",
"self",
",",
"device",
")",
":",
"trustee_name",
"=",
"get_device_info",
"(",
"device",
")",
".",
"name",
"name_object_map",
"=",
"get_device_names_to_objects",
"(",
"self",
".",
"devices",
")",
"delete_func",
"=",
"self",
".",
"... | Remove a trustee from the trust domain.
:param device: MangementRoot object -- device to remove | [
"Remove",
"a",
"trustee",
"from",
"the",
"trust",
"domain",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/multi_device/trust_domain.py#L168-L189 | train |
F5Networks/f5-common-python | f5/multi_device/trust_domain.py | TrustDomain._modify_trust | def _modify_trust(self, truster, mod_peer_func, trustee):
'''Modify a trusted peer device by deploying an iapp.
:param truster: ManagementRoot object -- device on which to perform
commands
:param mod_peer_func: function -- function to call to modify peer
:param ... | python | def _modify_trust(self, truster, mod_peer_func, trustee):
'''Modify a trusted peer device by deploying an iapp.
:param truster: ManagementRoot object -- device on which to perform
commands
:param mod_peer_func: function -- function to call to modify peer
:param ... | [
"def",
"_modify_trust",
"(",
"self",
",",
"truster",
",",
"mod_peer_func",
",",
"trustee",
")",
":",
"iapp_name",
"=",
"'trusted_device'",
"mod_peer_cmd",
"=",
"mod_peer_func",
"(",
"trustee",
")",
"iapp_actions",
"=",
"self",
".",
"iapp_actions",
".",
"copy",
... | Modify a trusted peer device by deploying an iapp.
:param truster: ManagementRoot object -- device on which to perform
commands
:param mod_peer_func: function -- function to call to modify peer
:param trustee: ManagementRoot object or str -- device to modify | [
"Modify",
"a",
"trusted",
"peer",
"device",
"by",
"deploying",
"an",
"iapp",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/multi_device/trust_domain.py#L191-L206 | train |
F5Networks/f5-common-python | f5/multi_device/trust_domain.py | TrustDomain._delete_iapp | def _delete_iapp(self, iapp_name, deploying_device):
'''Delete an iapp service and template on the root device.
:param iapp_name: str -- name of iapp
:param deploying_device: ManagementRoot object -- device where the
iapp will be deleted
'''
iap... | python | def _delete_iapp(self, iapp_name, deploying_device):
'''Delete an iapp service and template on the root device.
:param iapp_name: str -- name of iapp
:param deploying_device: ManagementRoot object -- device where the
iapp will be deleted
'''
iap... | [
"def",
"_delete_iapp",
"(",
"self",
",",
"iapp_name",
",",
"deploying_device",
")",
":",
"iapp",
"=",
"deploying_device",
".",
"tm",
".",
"sys",
".",
"application",
"iapp_serv",
"=",
"iapp",
".",
"services",
".",
"service",
".",
"load",
"(",
"name",
"=",
... | Delete an iapp service and template on the root device.
:param iapp_name: str -- name of iapp
:param deploying_device: ManagementRoot object -- device where the
iapp will be deleted | [
"Delete",
"an",
"iapp",
"service",
"and",
"template",
"on",
"the",
"root",
"device",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/multi_device/trust_domain.py#L208-L224 | train |
F5Networks/f5-common-python | f5/multi_device/trust_domain.py | TrustDomain._deploy_iapp | def _deploy_iapp(self, iapp_name, actions, deploying_device):
'''Deploy iapp to add trusted device
:param iapp_name: str -- name of iapp
:param actions: dict -- actions definition of iapp sections
:param deploying_device: ManagementRoot object -- device where the
... | python | def _deploy_iapp(self, iapp_name, actions, deploying_device):
'''Deploy iapp to add trusted device
:param iapp_name: str -- name of iapp
:param actions: dict -- actions definition of iapp sections
:param deploying_device: ManagementRoot object -- device where the
... | [
"def",
"_deploy_iapp",
"(",
"self",
",",
"iapp_name",
",",
"actions",
",",
"deploying_device",
")",
":",
"tmpl",
"=",
"deploying_device",
".",
"tm",
".",
"sys",
".",
"application",
".",
"templates",
".",
"template",
"serv",
"=",
"deploying_device",
".",
"tm"... | Deploy iapp to add trusted device
:param iapp_name: str -- name of iapp
:param actions: dict -- actions definition of iapp sections
:param deploying_device: ManagementRoot object -- device where the
iapp will be created | [
"Deploy",
"iapp",
"to",
"add",
"trusted",
"device"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/multi_device/trust_domain.py#L226-L245 | train |
F5Networks/f5-common-python | f5/multi_device/trust_domain.py | TrustDomain._get_add_trustee_cmd | def _get_add_trustee_cmd(self, trustee):
'''Get tmsh command to add a trusted device.
:param trustee: ManagementRoot object -- device to add as trusted
:returns: str -- tmsh command to add trustee
'''
trustee_info = pollster(get_device_info)(trustee)
username = trustee.... | python | def _get_add_trustee_cmd(self, trustee):
'''Get tmsh command to add a trusted device.
:param trustee: ManagementRoot object -- device to add as trusted
:returns: str -- tmsh command to add trustee
'''
trustee_info = pollster(get_device_info)(trustee)
username = trustee.... | [
"def",
"_get_add_trustee_cmd",
"(",
"self",
",",
"trustee",
")",
":",
"trustee_info",
"=",
"pollster",
"(",
"get_device_info",
")",
"(",
"trustee",
")",
"username",
"=",
"trustee",
".",
"_meta_data",
"[",
"'username'",
"]",
"password",
"=",
"trustee",
".",
"... | Get tmsh command to add a trusted device.
:param trustee: ManagementRoot object -- device to add as trusted
:returns: str -- tmsh command to add trustee | [
"Get",
"tmsh",
"command",
"to",
"add",
"a",
"trusted",
"device",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/multi_device/trust_domain.py#L247-L259 | train |
F5Networks/f5-common-python | f5/bigip/tm/vcmp/virtual_disk.py | Virtual_Disk.load | def load(self, **kwargs):
"""Loads a given resource
Loads a given resource provided a 'name' and an optional 'slot'
parameter. The 'slot' parameter is not a required load parameter
because it is provided as an optional way of constructing the
correct 'name' of the vCMP resource.... | python | def load(self, **kwargs):
"""Loads a given resource
Loads a given resource provided a 'name' and an optional 'slot'
parameter. The 'slot' parameter is not a required load parameter
because it is provided as an optional way of constructing the
correct 'name' of the vCMP resource.... | [
"def",
"load",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"kwargs",
"[",
"'transform_name'",
"]",
"=",
"True",
"kwargs",
"=",
"self",
".",
"_mutate_name",
"(",
"kwargs",
")",
"return",
"self",
".",
"_load",
"(",
"**",
"kwargs",
")"
] | Loads a given resource
Loads a given resource provided a 'name' and an optional 'slot'
parameter. The 'slot' parameter is not a required load parameter
because it is provided as an optional way of constructing the
correct 'name' of the vCMP resource.
:param kwargs:
:ret... | [
"Loads",
"a",
"given",
"resource"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/tm/vcmp/virtual_disk.py#L53-L66 | train |
F5Networks/f5-common-python | f5/utils/iapp_parser.py | IappParser._get_section_end_index | def _get_section_end_index(self, section, section_start):
'''Get end of section's content.
In the loop to match braces, we must not count curly braces that are
within a doubly quoted string.
:param section: string name of section
:param section_start: integer index of section's... | python | def _get_section_end_index(self, section, section_start):
'''Get end of section's content.
In the loop to match braces, we must not count curly braces that are
within a doubly quoted string.
:param section: string name of section
:param section_start: integer index of section's... | [
"def",
"_get_section_end_index",
"(",
"self",
",",
"section",
",",
"section_start",
")",
":",
"brace_count",
"=",
"0",
"in_quote",
"=",
"False",
"in_escape",
"=",
"False",
"for",
"index",
",",
"char",
"in",
"enumerate",
"(",
"self",
".",
"template_str",
"[",... | Get end of section's content.
In the loop to match braces, we must not count curly braces that are
within a doubly quoted string.
:param section: string name of section
:param section_start: integer index of section's beginning
:return: integer index of section's end
:r... | [
"Get",
"end",
"of",
"section",
"s",
"content",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/utils/iapp_parser.py#L80-L129 | train |
F5Networks/f5-common-python | f5/utils/iapp_parser.py | IappParser._get_section_start_index | def _get_section_start_index(self, section):
'''Get start of a section's content.
:param section: string name of section
:return: integer index of section's beginning
:raises: NonextantSectionException
'''
sec_start_re = r'%s\s*\{' % section
found = re.search(s... | python | def _get_section_start_index(self, section):
'''Get start of a section's content.
:param section: string name of section
:return: integer index of section's beginning
:raises: NonextantSectionException
'''
sec_start_re = r'%s\s*\{' % section
found = re.search(s... | [
"def",
"_get_section_start_index",
"(",
"self",
",",
"section",
")",
":",
"sec_start_re",
"=",
"r'%s\\s*\\{'",
"%",
"section",
"found",
"=",
"re",
".",
"search",
"(",
"sec_start_re",
",",
"self",
".",
"template_str",
")",
"if",
"found",
":",
"return",
"found... | Get start of a section's content.
:param section: string name of section
:return: integer index of section's beginning
:raises: NonextantSectionException | [
"Get",
"start",
"of",
"a",
"section",
"s",
"content",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/utils/iapp_parser.py#L131-L147 | train |
F5Networks/f5-common-python | f5/utils/iapp_parser.py | IappParser._get_template_name | def _get_template_name(self):
'''Find template name.
:returns: string of template name
:raises: NonextantTemplateNameException
'''
start_pattern = r"sys application template\s+" \
r"(\/[\w\.\-]+\/)?" \
r"(?P<name>[\w\.\-]+)\s*\{"
... | python | def _get_template_name(self):
'''Find template name.
:returns: string of template name
:raises: NonextantTemplateNameException
'''
start_pattern = r"sys application template\s+" \
r"(\/[\w\.\-]+\/)?" \
r"(?P<name>[\w\.\-]+)\s*\{"
... | [
"def",
"_get_template_name",
"(",
"self",
")",
":",
"start_pattern",
"=",
"r\"sys application template\\s+\"",
"r\"(\\/[\\w\\.\\-]+\\/)?\"",
"r\"(?P<name>[\\w\\.\\-]+)\\s*\\{\"",
"template_start",
"=",
"re",
".",
"search",
"(",
"start_pattern",
",",
"self",
".",
"template_s... | Find template name.
:returns: string of template name
:raises: NonextantTemplateNameException | [
"Find",
"template",
"name",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/utils/iapp_parser.py#L149-L164 | train |
F5Networks/f5-common-python | f5/utils/iapp_parser.py | IappParser._get_template_attr | def _get_template_attr(self, attr):
'''Find the attribute value for a specific attribute.
:param attr: string of attribute name
:returns: string of attribute value
'''
attr_re = r'{0}\s+.*'.format(attr)
attr_found = re.search(attr_re, self.template_str)
if attr... | python | def _get_template_attr(self, attr):
'''Find the attribute value for a specific attribute.
:param attr: string of attribute name
:returns: string of attribute value
'''
attr_re = r'{0}\s+.*'.format(attr)
attr_found = re.search(attr_re, self.template_str)
if attr... | [
"def",
"_get_template_attr",
"(",
"self",
",",
"attr",
")",
":",
"attr_re",
"=",
"r'{0}\\s+.*'",
".",
"format",
"(",
"attr",
")",
"attr_found",
"=",
"re",
".",
"search",
"(",
"attr_re",
",",
"self",
".",
"template_str",
")",
"if",
"attr_found",
":",
"att... | Find the attribute value for a specific attribute.
:param attr: string of attribute name
:returns: string of attribute value | [
"Find",
"the",
"attribute",
"value",
"for",
"a",
"specific",
"attribute",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/utils/iapp_parser.py#L166-L178 | train |
F5Networks/f5-common-python | f5/utils/iapp_parser.py | IappParser._add_sections | def _add_sections(self):
'''Add the found and required sections to the templ_dict.'''
for section in self.template_sections:
try:
sec_start = self._get_section_start_index(section)
except NonextantSectionException:
if section in self.sections_not_r... | python | def _add_sections(self):
'''Add the found and required sections to the templ_dict.'''
for section in self.template_sections:
try:
sec_start = self._get_section_start_index(section)
except NonextantSectionException:
if section in self.sections_not_r... | [
"def",
"_add_sections",
"(",
"self",
")",
":",
"for",
"section",
"in",
"self",
".",
"template_sections",
":",
"try",
":",
"sec_start",
"=",
"self",
".",
"_get_section_start_index",
"(",
"section",
")",
"except",
"NonextantSectionException",
":",
"if",
"section",... | Add the found and required sections to the templ_dict. | [
"Add",
"the",
"found",
"and",
"required",
"sections",
"to",
"the",
"templ_dict",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/utils/iapp_parser.py#L180-L198 | train |
F5Networks/f5-common-python | f5/utils/iapp_parser.py | IappParser._add_cli_scripts | def _add_cli_scripts(self):
'''Add the found external sections to the templ_dict.'''
pattern = r"cli script\s+" \
r"(\/[\w\.\-]+\/)?" \
r"(?P<name>[\w\.\-]+)\s*\{"
sections = re.finditer(pattern, self.template_str)
for section in sections:
... | python | def _add_cli_scripts(self):
'''Add the found external sections to the templ_dict.'''
pattern = r"cli script\s+" \
r"(\/[\w\.\-]+\/)?" \
r"(?P<name>[\w\.\-]+)\s*\{"
sections = re.finditer(pattern, self.template_str)
for section in sections:
... | [
"def",
"_add_cli_scripts",
"(",
"self",
")",
":",
"pattern",
"=",
"r\"cli script\\s+\"",
"r\"(\\/[\\w\\.\\-]+\\/)?\"",
"r\"(?P<name>[\\w\\.\\-]+)\\s*\\{\"",
"sections",
"=",
"re",
".",
"finditer",
"(",
"pattern",
",",
"self",
".",
"template_str",
")",
"for",
"section"... | Add the found external sections to the templ_dict. | [
"Add",
"the",
"found",
"external",
"sections",
"to",
"the",
"templ_dict",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/utils/iapp_parser.py#L200-L230 | train |
F5Networks/f5-common-python | f5/utils/iapp_parser.py | IappParser._add_attrs | def _add_attrs(self):
'''Add the found and required attrs to the templ_dict.'''
for attr in self.template_attrs:
attr_value = self._get_template_attr(attr)
if not attr_value:
continue
attr, attr_value = self._transform_key_value(
attr... | python | def _add_attrs(self):
'''Add the found and required attrs to the templ_dict.'''
for attr in self.template_attrs:
attr_value = self._get_template_attr(attr)
if not attr_value:
continue
attr, attr_value = self._transform_key_value(
attr... | [
"def",
"_add_attrs",
"(",
"self",
")",
":",
"for",
"attr",
"in",
"self",
".",
"template_attrs",
":",
"attr_value",
"=",
"self",
".",
"_get_template_attr",
"(",
"attr",
")",
"if",
"not",
"attr_value",
":",
"continue",
"attr",
",",
"attr_value",
"=",
"self",... | Add the found and required attrs to the templ_dict. | [
"Add",
"the",
"found",
"and",
"required",
"attrs",
"to",
"the",
"templ_dict",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/utils/iapp_parser.py#L232-L245 | train |
F5Networks/f5-common-python | f5/utils/iapp_parser.py | IappParser._parse_tcl_list | def _parse_tcl_list(self, attr, list_str):
'''Turns a string representation of a TCL list into a Python list.
:param attr: string name of attribute
:param list_str: string representation of a list
:returns: Python list
'''
list_str = list_str.strip()
if not lis... | python | def _parse_tcl_list(self, attr, list_str):
'''Turns a string representation of a TCL list into a Python list.
:param attr: string name of attribute
:param list_str: string representation of a list
:returns: Python list
'''
list_str = list_str.strip()
if not lis... | [
"def",
"_parse_tcl_list",
"(",
"self",
",",
"attr",
",",
"list_str",
")",
":",
"list_str",
"=",
"list_str",
".",
"strip",
"(",
")",
"if",
"not",
"list_str",
":",
"return",
"[",
"]",
"if",
"list_str",
"[",
"0",
"]",
"!=",
"'{'",
"and",
"list_str",
"["... | Turns a string representation of a TCL list into a Python list.
:param attr: string name of attribute
:param list_str: string representation of a list
:returns: Python list | [
"Turns",
"a",
"string",
"representation",
"of",
"a",
"TCL",
"list",
"into",
"a",
"Python",
"list",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/utils/iapp_parser.py#L247-L271 | train |
F5Networks/f5-common-python | f5/utils/iapp_parser.py | IappParser._transform_key_value | def _transform_key_value(self, key, value, map_dict):
'''Massage keys and values for iapp dict to look like JSON.
:param key: string dictionary key
:param value: string dictionary value
:param map_dict: dictionary to map key names
'''
if key in self.tcl_list_patterns:
... | python | def _transform_key_value(self, key, value, map_dict):
'''Massage keys and values for iapp dict to look like JSON.
:param key: string dictionary key
:param value: string dictionary value
:param map_dict: dictionary to map key names
'''
if key in self.tcl_list_patterns:
... | [
"def",
"_transform_key_value",
"(",
"self",
",",
"key",
",",
"value",
",",
"map_dict",
")",
":",
"if",
"key",
"in",
"self",
".",
"tcl_list_patterns",
":",
"value",
"=",
"self",
".",
"_parse_tcl_list",
"(",
"key",
",",
"value",
")",
"if",
"key",
"in",
"... | Massage keys and values for iapp dict to look like JSON.
:param key: string dictionary key
:param value: string dictionary value
:param map_dict: dictionary to map key names | [
"Massage",
"keys",
"and",
"values",
"for",
"iapp",
"dict",
"to",
"look",
"like",
"JSON",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/utils/iapp_parser.py#L273-L287 | train |
F5Networks/f5-common-python | f5/utils/iapp_parser.py | IappParser.parse_template | def parse_template(self):
'''Parse the template string into a dict.
Find the (large) inner sections first, save them, and remove them from
a modified string. Then find the template attributes in the modified
string.
:returns: dictionary of parsed template
'''
s... | python | def parse_template(self):
'''Parse the template string into a dict.
Find the (large) inner sections first, save them, and remove them from
a modified string. Then find the template attributes in the modified
string.
:returns: dictionary of parsed template
'''
s... | [
"def",
"parse_template",
"(",
"self",
")",
":",
"self",
".",
"templ_dict",
"=",
"{",
"'actions'",
":",
"{",
"'definition'",
":",
"{",
"}",
"}",
"}",
"self",
".",
"templ_dict",
"[",
"'name'",
"]",
"=",
"self",
".",
"_get_template_name",
"(",
")",
"self"... | Parse the template string into a dict.
Find the (large) inner sections first, save them, and remove them from
a modified string. Then find the template attributes in the modified
string.
:returns: dictionary of parsed template | [
"Parse",
"the",
"template",
"string",
"into",
"a",
"dict",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/utils/iapp_parser.py#L289-L307 | train |
F5Networks/f5-common-python | f5/bigip/shared/authn.py | Root._create | def _create(self, **kwargs):
"""wrapped by `create` override that in subclasses to customize"""
if 'uri' in self._meta_data:
error = "There was an attempt to assign a new uri to this "\
"resource, the _meta_data['uri'] is %s and it should"\
" not be ch... | python | def _create(self, **kwargs):
"""wrapped by `create` override that in subclasses to customize"""
if 'uri' in self._meta_data:
error = "There was an attempt to assign a new uri to this "\
"resource, the _meta_data['uri'] is %s and it should"\
" not be ch... | [
"def",
"_create",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"if",
"'uri'",
"in",
"self",
".",
"_meta_data",
":",
"error",
"=",
"\"There was an attempt to assign a new uri to this \"",
"\"resource, the _meta_data['uri'] is %s and it should\"",
"\" not be changed.\"",
"%",
... | wrapped by `create` override that in subclasses to customize | [
"wrapped",
"by",
"create",
"override",
"that",
"in",
"subclasses",
"to",
"customize"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/shared/authn.py#L55-L83 | train |
F5Networks/f5-common-python | f5sdk_plugins/fixtures.py | peer | def peer(opt_peer, opt_username, opt_password, scope="module"):
'''peer bigip fixture'''
p = BigIP(opt_peer, opt_username, opt_password)
return p | python | def peer(opt_peer, opt_username, opt_password, scope="module"):
'''peer bigip fixture'''
p = BigIP(opt_peer, opt_username, opt_password)
return p | [
"def",
"peer",
"(",
"opt_peer",
",",
"opt_username",
",",
"opt_password",
",",
"scope",
"=",
"\"module\"",
")",
":",
"p",
"=",
"BigIP",
"(",
"opt_peer",
",",
"opt_username",
",",
"opt_password",
")",
"return",
"p"
] | peer bigip fixture | [
"peer",
"bigip",
"fixture"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5sdk_plugins/fixtures.py#L116-L119 | train |
F5Networks/f5-common-python | f5/bigip/tm/gtm/topology.py | Topology.exists | def exists(self, **kwargs):
"""Providing a partition is not necessary on topology; causes errors"""
kwargs.pop('partition', None)
kwargs['transform_name'] = True
return self._exists(**kwargs) | python | def exists(self, **kwargs):
"""Providing a partition is not necessary on topology; causes errors"""
kwargs.pop('partition', None)
kwargs['transform_name'] = True
return self._exists(**kwargs) | [
"def",
"exists",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"kwargs",
".",
"pop",
"(",
"'partition'",
",",
"None",
")",
"kwargs",
"[",
"'transform_name'",
"]",
"=",
"True",
"return",
"self",
".",
"_exists",
"(",
"**",
"kwargs",
")"
] | Providing a partition is not necessary on topology; causes errors | [
"Providing",
"a",
"partition",
"is",
"not",
"necessary",
"on",
"topology",
";",
"causes",
"errors"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/tm/gtm/topology.py#L149-L153 | train |
F5Networks/f5-common-python | f5/utils/responses/handlers.py | Stats._key_dot_replace | def _key_dot_replace(self, rdict):
"""Replace fullstops in returned keynames"""
temp_dict = {}
for key, value in iteritems(rdict):
if isinstance(value, dict):
value = self._key_dot_replace(value)
temp_dict[key.replace('.', '_')] = value
return temp... | python | def _key_dot_replace(self, rdict):
"""Replace fullstops in returned keynames"""
temp_dict = {}
for key, value in iteritems(rdict):
if isinstance(value, dict):
value = self._key_dot_replace(value)
temp_dict[key.replace('.', '_')] = value
return temp... | [
"def",
"_key_dot_replace",
"(",
"self",
",",
"rdict",
")",
":",
"temp_dict",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"iteritems",
"(",
"rdict",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"value",
"=",
"self",
".",
"... | Replace fullstops in returned keynames | [
"Replace",
"fullstops",
"in",
"returned",
"keynames"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/utils/responses/handlers.py#L43-L50 | train |
F5Networks/f5-common-python | f5/utils/responses/handlers.py | Stats._get_nest_stats | def _get_nest_stats(self):
"""Helper method to deal with nestedStats
as json format changed in v12.x
"""
for x in self.rdict:
check = urlparse(x)
if check.scheme:
nested_dict = self.rdict[x]['nestedStats']
tmp_dict = nested_dict['e... | python | def _get_nest_stats(self):
"""Helper method to deal with nestedStats
as json format changed in v12.x
"""
for x in self.rdict:
check = urlparse(x)
if check.scheme:
nested_dict = self.rdict[x]['nestedStats']
tmp_dict = nested_dict['e... | [
"def",
"_get_nest_stats",
"(",
"self",
")",
":",
"for",
"x",
"in",
"self",
".",
"rdict",
":",
"check",
"=",
"urlparse",
"(",
"x",
")",
"if",
"check",
".",
"scheme",
":",
"nested_dict",
"=",
"self",
".",
"rdict",
"[",
"x",
"]",
"[",
"'nestedStats'",
... | Helper method to deal with nestedStats
as json format changed in v12.x | [
"Helper",
"method",
"to",
"deal",
"with",
"nestedStats"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/utils/responses/handlers.py#L52-L64 | train |
F5Networks/f5-common-python | f5/utils/responses/handlers.py | Stats.refresh | def refresh(self, **kwargs):
"""Refreshes stats attached to an object"""
self.resource.refresh(**kwargs)
self.rdict = self.resource.entries
self._update_stats() | python | def refresh(self, **kwargs):
"""Refreshes stats attached to an object"""
self.resource.refresh(**kwargs)
self.rdict = self.resource.entries
self._update_stats() | [
"def",
"refresh",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"resource",
".",
"refresh",
"(",
"**",
"kwargs",
")",
"self",
".",
"rdict",
"=",
"self",
".",
"resource",
".",
"entries",
"self",
".",
"_update_stats",
"(",
")"
] | Refreshes stats attached to an object | [
"Refreshes",
"stats",
"attached",
"to",
"an",
"object"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/utils/responses/handlers.py#L71-L75 | train |
F5Networks/f5-common-python | f5/bigip/tm/security/firewall.py | Rule.load | def load(self, **kwargs):
"""Custom load method to address issue in 11.6.0 Final,
where non existing objects would be True.
"""
if LooseVersion(self.tmos_ver) == LooseVersion('11.6.0'):
return self._load_11_6(**kwargs)
else:
return super(Rule, self)._load... | python | def load(self, **kwargs):
"""Custom load method to address issue in 11.6.0 Final,
where non existing objects would be True.
"""
if LooseVersion(self.tmos_ver) == LooseVersion('11.6.0'):
return self._load_11_6(**kwargs)
else:
return super(Rule, self)._load... | [
"def",
"load",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"if",
"LooseVersion",
"(",
"self",
".",
"tmos_ver",
")",
"==",
"LooseVersion",
"(",
"'11.6.0'",
")",
":",
"return",
"self",
".",
"_load_11_6",
"(",
"**",
"kwargs",
")",
"else",
":",
"return",
... | Custom load method to address issue in 11.6.0 Final,
where non existing objects would be True. | [
"Custom",
"load",
"method",
"to",
"address",
"issue",
"in",
"11",
".",
"6",
".",
"0",
"Final"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/tm/security/firewall.py#L169-L177 | train |
F5Networks/f5-common-python | f5/utils/decorators.py | poll_for_exceptionless_callable | def poll_for_exceptionless_callable(callable, attempts, interval):
'''Poll with a given callable for a specified number of times.
:param callable: callable to invoke in loop -- if no exception is raised
the call is considered succeeded
:param attempts: number of iterations to attempt
... | python | def poll_for_exceptionless_callable(callable, attempts, interval):
'''Poll with a given callable for a specified number of times.
:param callable: callable to invoke in loop -- if no exception is raised
the call is considered succeeded
:param attempts: number of iterations to attempt
... | [
"def",
"poll_for_exceptionless_callable",
"(",
"callable",
",",
"attempts",
",",
"interval",
")",
":",
"@",
"wraps",
"(",
"callable",
")",
"def",
"poll",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"for",
"attempt",
"in",
"range",
"(",
"attempts",
"... | Poll with a given callable for a specified number of times.
:param callable: callable to invoke in loop -- if no exception is raised
the call is considered succeeded
:param attempts: number of iterations to attempt
:param interval: seconds to wait before next attempt | [
"Poll",
"with",
"a",
"given",
"callable",
"for",
"a",
"specified",
"number",
"of",
"times",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/utils/decorators.py#L28-L47 | train |
F5Networks/f5-common-python | f5/bigip/tm/security/log.py | Network.exists | def exists(self, **kwargs):
"""Some objects when deleted still return when called by their
direct URI, this is a known issue in 11.6.0.
"""
if LooseVersion(self.tmos_ver) == LooseVersion('11.6.0'):
return self._exists_11_6(**kwargs)
else:
return super(Ne... | python | def exists(self, **kwargs):
"""Some objects when deleted still return when called by their
direct URI, this is a known issue in 11.6.0.
"""
if LooseVersion(self.tmos_ver) == LooseVersion('11.6.0'):
return self._exists_11_6(**kwargs)
else:
return super(Ne... | [
"def",
"exists",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"if",
"LooseVersion",
"(",
"self",
".",
"tmos_ver",
")",
"==",
"LooseVersion",
"(",
"'11.6.0'",
")",
":",
"return",
"self",
".",
"_exists_11_6",
"(",
"**",
"kwargs",
")",
"else",
":",
"return... | Some objects when deleted still return when called by their
direct URI, this is a known issue in 11.6.0. | [
"Some",
"objects",
"when",
"deleted",
"still",
"return",
"when",
"called",
"by",
"their"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/tm/security/log.py#L168-L177 | train |
F5Networks/f5-common-python | f5/bigip/mixins.py | CommandExecutionMixin._is_allowed_command | def _is_allowed_command(self, command):
"""Checking if the given command is allowed on a given endpoint."""
cmds = self._meta_data['allowed_commands']
if command not in self._meta_data['allowed_commands']:
error_message = "The command value {0} does not exist. " \
... | python | def _is_allowed_command(self, command):
"""Checking if the given command is allowed on a given endpoint."""
cmds = self._meta_data['allowed_commands']
if command not in self._meta_data['allowed_commands']:
error_message = "The command value {0} does not exist. " \
... | [
"def",
"_is_allowed_command",
"(",
"self",
",",
"command",
")",
":",
"cmds",
"=",
"self",
".",
"_meta_data",
"[",
"'allowed_commands'",
"]",
"if",
"command",
"not",
"in",
"self",
".",
"_meta_data",
"[",
"'allowed_commands'",
"]",
":",
"error_message",
"=",
"... | Checking if the given command is allowed on a given endpoint. | [
"Checking",
"if",
"the",
"given",
"command",
"is",
"allowed",
"on",
"a",
"given",
"endpoint",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/mixins.py#L212-L218 | train |
F5Networks/f5-common-python | f5/bigip/mixins.py | CommandExecutionMixin._check_command_result | def _check_command_result(self):
"""If command result exists run these checks."""
if self.commandResult.startswith('/bin/bash'):
raise UtilError('%s' % self.commandResult.split(' ', 1)[1])
if self.commandResult.startswith('/bin/mv'):
raise UtilError('%s' % self.commandRes... | python | def _check_command_result(self):
"""If command result exists run these checks."""
if self.commandResult.startswith('/bin/bash'):
raise UtilError('%s' % self.commandResult.split(' ', 1)[1])
if self.commandResult.startswith('/bin/mv'):
raise UtilError('%s' % self.commandRes... | [
"def",
"_check_command_result",
"(",
"self",
")",
":",
"if",
"self",
".",
"commandResult",
".",
"startswith",
"(",
"'/bin/bash'",
")",
":",
"raise",
"UtilError",
"(",
"'%s'",
"%",
"self",
".",
"commandResult",
".",
"split",
"(",
"' '",
",",
"1",
")",
"["... | If command result exists run these checks. | [
"If",
"command",
"result",
"exists",
"run",
"these",
"checks",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/mixins.py#L220-L235 | train |
F5Networks/f5-common-python | f5/bigip/mixins.py | CommandExecutionMixin.exec_cmd | def exec_cmd(self, command, **kwargs):
"""Wrapper method that can be changed in the inheriting classes."""
self._is_allowed_command(command)
self._check_command_parameters(**kwargs)
return self._exec_cmd(command, **kwargs) | python | def exec_cmd(self, command, **kwargs):
"""Wrapper method that can be changed in the inheriting classes."""
self._is_allowed_command(command)
self._check_command_parameters(**kwargs)
return self._exec_cmd(command, **kwargs) | [
"def",
"exec_cmd",
"(",
"self",
",",
"command",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"_is_allowed_command",
"(",
"command",
")",
"self",
".",
"_check_command_parameters",
"(",
"**",
"kwargs",
")",
"return",
"self",
".",
"_exec_cmd",
"(",
"command",
... | Wrapper method that can be changed in the inheriting classes. | [
"Wrapper",
"method",
"that",
"can",
"be",
"changed",
"in",
"the",
"inheriting",
"classes",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/mixins.py#L237-L241 | train |
F5Networks/f5-common-python | f5/bigip/mixins.py | CommandExecutionMixin._exec_cmd | def _exec_cmd(self, command, **kwargs):
"""Create a new method as command has specific requirements.
There is a handful of the TMSH global commands supported,
so this method requires them as a parameter.
:raises: InvalidCommand
"""
kwargs['command'] = command
s... | python | def _exec_cmd(self, command, **kwargs):
"""Create a new method as command has specific requirements.
There is a handful of the TMSH global commands supported,
so this method requires them as a parameter.
:raises: InvalidCommand
"""
kwargs['command'] = command
s... | [
"def",
"_exec_cmd",
"(",
"self",
",",
"command",
",",
"**",
"kwargs",
")",
":",
"kwargs",
"[",
"'command'",
"]",
"=",
"command",
"self",
".",
"_check_exclusive_parameters",
"(",
"**",
"kwargs",
")",
"requests_params",
"=",
"self",
".",
"_handle_requests_params... | Create a new method as command has specific requirements.
There is a handful of the TMSH global commands supported,
so this method requires them as a parameter.
:raises: InvalidCommand | [
"Create",
"a",
"new",
"method",
"as",
"command",
"has",
"specific",
"requirements",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/mixins.py#L243-L263 | train |
F5Networks/f5-common-python | f5/bigip/mixins.py | DeviceMixin.get_device_info | def get_device_info(self, bigip):
'''Get device information about a specific BigIP device.
:param bigip: bigip object --- device to inspect
:returns: bigip object
'''
coll = bigip.tm.cm.devices.get_collection()
device = [device for device in coll if device.selfDevice ==... | python | def get_device_info(self, bigip):
'''Get device information about a specific BigIP device.
:param bigip: bigip object --- device to inspect
:returns: bigip object
'''
coll = bigip.tm.cm.devices.get_collection()
device = [device for device in coll if device.selfDevice ==... | [
"def",
"get_device_info",
"(",
"self",
",",
"bigip",
")",
":",
"coll",
"=",
"bigip",
".",
"tm",
".",
"cm",
".",
"devices",
".",
"get_collection",
"(",
")",
"device",
"=",
"[",
"device",
"for",
"device",
"in",
"coll",
"if",
"device",
".",
"selfDevice",
... | Get device information about a specific BigIP device.
:param bigip: bigip object --- device to inspect
:returns: bigip object | [
"Get",
"device",
"information",
"about",
"a",
"specific",
"BigIP",
"device",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/mixins.py#L434-L444 | train |
F5Networks/f5-common-python | f5/bigip/mixins.py | CheckExistenceMixin._check_existence_by_collection | def _check_existence_by_collection(self, container, item_name):
'''Check existnce of item based on get collection call.
:param collection: container object -- capable of get_collection()
:param item_name: str -- name of item to search for in collection
'''
coll = container.get_... | python | def _check_existence_by_collection(self, container, item_name):
'''Check existnce of item based on get collection call.
:param collection: container object -- capable of get_collection()
:param item_name: str -- name of item to search for in collection
'''
coll = container.get_... | [
"def",
"_check_existence_by_collection",
"(",
"self",
",",
"container",
",",
"item_name",
")",
":",
"coll",
"=",
"container",
".",
"get_collection",
"(",
")",
"for",
"item",
"in",
"coll",
":",
"if",
"item",
".",
"name",
"==",
"item_name",
":",
"return",
"T... | Check existnce of item based on get collection call.
:param collection: container object -- capable of get_collection()
:param item_name: str -- name of item to search for in collection | [
"Check",
"existnce",
"of",
"item",
"based",
"on",
"get",
"collection",
"call",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/mixins.py#L450-L461 | train |
F5Networks/f5-common-python | f5/bigip/mixins.py | CheckExistenceMixin._return_object | def _return_object(self, container, item_name):
"""Helper method to retrieve the object"""
coll = container.get_collection()
for item in coll:
if item.name == item_name:
return item | python | def _return_object(self, container, item_name):
"""Helper method to retrieve the object"""
coll = container.get_collection()
for item in coll:
if item.name == item_name:
return item | [
"def",
"_return_object",
"(",
"self",
",",
"container",
",",
"item_name",
")",
":",
"coll",
"=",
"container",
".",
"get_collection",
"(",
")",
"for",
"item",
"in",
"coll",
":",
"if",
"item",
".",
"name",
"==",
"item_name",
":",
"return",
"item"
] | Helper method to retrieve the object | [
"Helper",
"method",
"to",
"retrieve",
"the",
"object"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/mixins.py#L463-L468 | train |
F5Networks/f5-common-python | f5/bigip/tm/sys/config.py | Config.exec_cmd | def exec_cmd(self, command, **kwargs):
"""Normal save and load only need the command.
To merge, just supply the merge and file arguments as kwargs like so:
exec_cmd('load', merge=True, file='/path/to/file.txt')
"""
if command == 'load':
if kwargs:
kw... | python | def exec_cmd(self, command, **kwargs):
"""Normal save and load only need the command.
To merge, just supply the merge and file arguments as kwargs like so:
exec_cmd('load', merge=True, file='/path/to/file.txt')
"""
if command == 'load':
if kwargs:
kw... | [
"def",
"exec_cmd",
"(",
"self",
",",
"command",
",",
"**",
"kwargs",
")",
":",
"if",
"command",
"==",
"'load'",
":",
"if",
"kwargs",
":",
"kwargs",
"=",
"dict",
"(",
"options",
"=",
"[",
"kwargs",
"]",
")",
"return",
"self",
".",
"_exec_cmd",
"(",
... | Normal save and load only need the command.
To merge, just supply the merge and file arguments as kwargs like so:
exec_cmd('load', merge=True, file='/path/to/file.txt') | [
"Normal",
"save",
"and",
"load",
"only",
"need",
"the",
"command",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/tm/sys/config.py#L52-L62 | train |
F5Networks/f5-common-python | f5/bigip/tm/sys/snmp.py | User.update | def update(self, **kwargs):
"""Due to a password decryption bug
we will disable update() method for 12.1.0 and up
"""
tmos_version = self._meta_data['bigip'].tmos_version
if LooseVersion(tmos_version) > LooseVersion('12.0.0'):
msg = "Update() is unsupported for User... | python | def update(self, **kwargs):
"""Due to a password decryption bug
we will disable update() method for 12.1.0 and up
"""
tmos_version = self._meta_data['bigip'].tmos_version
if LooseVersion(tmos_version) > LooseVersion('12.0.0'):
msg = "Update() is unsupported for User... | [
"def",
"update",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"tmos_version",
"=",
"self",
".",
"_meta_data",
"[",
"'bigip'",
"]",
".",
"tmos_version",
"if",
"LooseVersion",
"(",
"tmos_version",
")",
">",
"LooseVersion",
"(",
"'12.0.0'",
")",
":",
"msg",
... | Due to a password decryption bug
we will disable update() method for 12.1.0 and up | [
"Due",
"to",
"a",
"password",
"decryption",
"bug"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/tm/sys/snmp.py#L128-L140 | train |
F5Networks/f5-common-python | devtools/template_engine.py | TemplateEngine._process_config_with_kind | def _process_config_with_kind(self, raw_conf):
'''Use this to decide which format is called for by the kind.
NOTE, order matters since subsequent conditions are not evaluated is an
earlier condition is met. In the some cases, e.g. a kind contains both
"stats" and "state", this will bec... | python | def _process_config_with_kind(self, raw_conf):
'''Use this to decide which format is called for by the kind.
NOTE, order matters since subsequent conditions are not evaluated is an
earlier condition is met. In the some cases, e.g. a kind contains both
"stats" and "state", this will bec... | [
"def",
"_process_config_with_kind",
"(",
"self",
",",
"raw_conf",
")",
":",
"kind",
"=",
"raw_conf",
"[",
"u\"kind\"",
"]",
"org_match",
"=",
"re",
".",
"match",
"(",
"self",
".",
"OC_pattern",
",",
"kind",
")",
"if",
"org_match",
":",
"return",
"self",
... | Use this to decide which format is called for by the kind.
NOTE, order matters since subsequent conditions are not evaluated is an
earlier condition is met. In the some cases, e.g. a kind contains both
"stats" and "state", this will become an issue. | [
"Use",
"this",
"to",
"decide",
"which",
"format",
"is",
"called",
"for",
"by",
"the",
"kind",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/devtools/template_engine.py#L204-L220 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | _missing_required_parameters | def _missing_required_parameters(rqset, **kwargs):
"""Helper function to do operation on sets.
Checks for any missing required parameters.
Returns non-empty or empty list. With empty
list being False.
::returns list
"""
key_set = set(list(iterkeys(kwargs)))
required_minus_received = rq... | python | def _missing_required_parameters(rqset, **kwargs):
"""Helper function to do operation on sets.
Checks for any missing required parameters.
Returns non-empty or empty list. With empty
list being False.
::returns list
"""
key_set = set(list(iterkeys(kwargs)))
required_minus_received = rq... | [
"def",
"_missing_required_parameters",
"(",
"rqset",
",",
"**",
"kwargs",
")",
":",
"key_set",
"=",
"set",
"(",
"list",
"(",
"iterkeys",
"(",
"kwargs",
")",
")",
")",
"required_minus_received",
"=",
"rqset",
"-",
"key_set",
"if",
"required_minus_received",
"!=... | Helper function to do operation on sets.
Checks for any missing required parameters.
Returns non-empty or empty list. With empty
list being False.
::returns list | [
"Helper",
"function",
"to",
"do",
"operation",
"on",
"sets",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L137-L149 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | PathElement._format_collection_name | def _format_collection_name(self):
"""Formats a name from Collection format
Collections are of two name formats based on their actual URI
representation in the REST service.
1. For cases where the actual URI of a collection is singular, for
example,
/mgmt/tm/... | python | def _format_collection_name(self):
"""Formats a name from Collection format
Collections are of two name formats based on their actual URI
representation in the REST service.
1. For cases where the actual URI of a collection is singular, for
example,
/mgmt/tm/... | [
"def",
"_format_collection_name",
"(",
"self",
")",
":",
"base_uri",
"=",
"self",
".",
"_format_resource_name",
"(",
")",
"if",
"base_uri",
"[",
"-",
"2",
":",
"]",
"==",
"'_s'",
":",
"endind",
"=",
"2",
"else",
":",
"endind",
"=",
"1",
"return",
"base... | Formats a name from Collection format
Collections are of two name formats based on their actual URI
representation in the REST service.
1. For cases where the actual URI of a collection is singular, for
example,
/mgmt/tm/ltm/node
The name of the collectio... | [
"Formats",
"a",
"name",
"from",
"Collection",
"format"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L199-L238 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | PathElement._check_command_parameters | def _check_command_parameters(self, **kwargs):
"""Params given to exec_cmd should satisfy required params.
:params: kwargs
:raises: MissingRequiredCommandParameter
"""
rset = self._meta_data['required_command_parameters']
check = _missing_required_parameters(rset, **kwar... | python | def _check_command_parameters(self, **kwargs):
"""Params given to exec_cmd should satisfy required params.
:params: kwargs
:raises: MissingRequiredCommandParameter
"""
rset = self._meta_data['required_command_parameters']
check = _missing_required_parameters(rset, **kwar... | [
"def",
"_check_command_parameters",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"rset",
"=",
"self",
".",
"_meta_data",
"[",
"'required_command_parameters'",
"]",
"check",
"=",
"_missing_required_parameters",
"(",
"rset",
",",
"**",
"kwargs",
")",
"if",
"check",... | Params given to exec_cmd should satisfy required params.
:params: kwargs
:raises: MissingRequiredCommandParameter | [
"Params",
"given",
"to",
"exec_cmd",
"should",
"satisfy",
"required",
"params",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L264-L274 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | PathElement._handle_requests_params | def _handle_requests_params(self, kwargs):
"""Validate parameters that will be passed to the requests verbs.
This method validates that there is no conflict in the names of the
requests_params passed to the function and the other kwargs. It also
ensures that the required request parame... | python | def _handle_requests_params(self, kwargs):
"""Validate parameters that will be passed to the requests verbs.
This method validates that there is no conflict in the names of the
requests_params passed to the function and the other kwargs. It also
ensures that the required request parame... | [
"def",
"_handle_requests_params",
"(",
"self",
",",
"kwargs",
")",
":",
"requests_params",
"=",
"kwargs",
".",
"pop",
"(",
"'requests_params'",
",",
"{",
"}",
")",
"for",
"param",
"in",
"requests_params",
":",
"if",
"param",
"in",
"kwargs",
":",
"error_messa... | Validate parameters that will be passed to the requests verbs.
This method validates that there is no conflict in the names of the
requests_params passed to the function and the other kwargs. It also
ensures that the required request parameters for the object are
added to the request p... | [
"Validate",
"parameters",
"that",
"will",
"be",
"passed",
"to",
"the",
"requests",
"verbs",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L298-L319 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | PathElement._check_exclusive_parameters | def _check_exclusive_parameters(self, **kwargs):
"""Check for mutually exclusive attributes in kwargs.
:raises ExclusiveAttributesPresent
"""
if len(self._meta_data['exclusive_attributes']) > 0:
attr_set = set(list(iterkeys(kwargs)))
ex_set = set(self._meta_data[... | python | def _check_exclusive_parameters(self, **kwargs):
"""Check for mutually exclusive attributes in kwargs.
:raises ExclusiveAttributesPresent
"""
if len(self._meta_data['exclusive_attributes']) > 0:
attr_set = set(list(iterkeys(kwargs)))
ex_set = set(self._meta_data[... | [
"def",
"_check_exclusive_parameters",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"if",
"len",
"(",
"self",
".",
"_meta_data",
"[",
"'exclusive_attributes'",
"]",
")",
">",
"0",
":",
"attr_set",
"=",
"set",
"(",
"list",
"(",
"iterkeys",
"(",
"kwargs",
")... | Check for mutually exclusive attributes in kwargs.
:raises ExclusiveAttributesPresent | [
"Check",
"for",
"mutually",
"exclusive",
"attributes",
"in",
"kwargs",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L321-L335 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | ResourceBase._modify | def _modify(self, **patch):
"""Wrapped with modify, override in a subclass to customize."""
requests_params, patch_uri, session, read_only = \
self._prepare_put_or_patch(patch)
self._check_for_boolean_pair_reduction(patch)
read_only_mutations = []
for attr in read_on... | python | def _modify(self, **patch):
"""Wrapped with modify, override in a subclass to customize."""
requests_params, patch_uri, session, read_only = \
self._prepare_put_or_patch(patch)
self._check_for_boolean_pair_reduction(patch)
read_only_mutations = []
for attr in read_on... | [
"def",
"_modify",
"(",
"self",
",",
"**",
"patch",
")",
":",
"requests_params",
",",
"patch_uri",
",",
"session",
",",
"read_only",
"=",
"self",
".",
"_prepare_put_or_patch",
"(",
"patch",
")",
"self",
".",
"_check_for_boolean_pair_reduction",
"(",
"patch",
")... | Wrapped with modify, override in a subclass to customize. | [
"Wrapped",
"with",
"modify",
"override",
"in",
"a",
"subclass",
"to",
"customize",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L388-L405 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | ResourceBase._check_for_boolean_pair_reduction | def _check_for_boolean_pair_reduction(self, kwargs):
"""Check if boolean pairs should be reduced in this resource."""
if 'reduction_forcing_pairs' in self._meta_data:
for key1, key2 in self._meta_data['reduction_forcing_pairs']:
kwargs = self._reduce_boolean_pair(kwargs, key... | python | def _check_for_boolean_pair_reduction(self, kwargs):
"""Check if boolean pairs should be reduced in this resource."""
if 'reduction_forcing_pairs' in self._meta_data:
for key1, key2 in self._meta_data['reduction_forcing_pairs']:
kwargs = self._reduce_boolean_pair(kwargs, key... | [
"def",
"_check_for_boolean_pair_reduction",
"(",
"self",
",",
"kwargs",
")",
":",
"if",
"'reduction_forcing_pairs'",
"in",
"self",
".",
"_meta_data",
":",
"for",
"key1",
",",
"key2",
"in",
"self",
".",
"_meta_data",
"[",
"'reduction_forcing_pairs'",
"]",
":",
"k... | Check if boolean pairs should be reduced in this resource. | [
"Check",
"if",
"boolean",
"pairs",
"should",
"be",
"reduced",
"in",
"this",
"resource",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L413-L419 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | ResourceBase._prepare_put_or_patch | def _prepare_put_or_patch(self, kwargs):
"""Retrieve the appropriate request items for put or patch calls."""
requests_params = self._handle_requests_params(kwargs)
update_uri = self._meta_data['uri']
session = self._meta_data['bigip']._meta_data['icr_session']
read_only = self.... | python | def _prepare_put_or_patch(self, kwargs):
"""Retrieve the appropriate request items for put or patch calls."""
requests_params = self._handle_requests_params(kwargs)
update_uri = self._meta_data['uri']
session = self._meta_data['bigip']._meta_data['icr_session']
read_only = self.... | [
"def",
"_prepare_put_or_patch",
"(",
"self",
",",
"kwargs",
")",
":",
"requests_params",
"=",
"self",
".",
"_handle_requests_params",
"(",
"kwargs",
")",
"update_uri",
"=",
"self",
".",
"_meta_data",
"[",
"'uri'",
"]",
"session",
"=",
"self",
".",
"_meta_data"... | Retrieve the appropriate request items for put or patch calls. | [
"Retrieve",
"the",
"appropriate",
"request",
"items",
"for",
"put",
"or",
"patch",
"calls",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L421-L428 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | ResourceBase._prepare_request_json | def _prepare_request_json(self, kwargs):
"""Prepare request args for sending to device as JSON."""
# Check for python keywords in dict
kwargs = self._check_for_python_keywords(kwargs)
# Check for the key 'check' in kwargs
if 'check' in kwargs:
od = OrderedDict()
... | python | def _prepare_request_json(self, kwargs):
"""Prepare request args for sending to device as JSON."""
# Check for python keywords in dict
kwargs = self._check_for_python_keywords(kwargs)
# Check for the key 'check' in kwargs
if 'check' in kwargs:
od = OrderedDict()
... | [
"def",
"_prepare_request_json",
"(",
"self",
",",
"kwargs",
")",
":",
"kwargs",
"=",
"self",
".",
"_check_for_python_keywords",
"(",
"kwargs",
")",
"if",
"'check'",
"in",
"kwargs",
":",
"od",
"=",
"OrderedDict",
"(",
")",
"od",
"[",
"'check'",
"]",
"=",
... | Prepare request args for sending to device as JSON. | [
"Prepare",
"request",
"args",
"for",
"sending",
"to",
"device",
"as",
"JSON",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L430-L443 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | ResourceBase._iter_list_for_dicts | def _iter_list_for_dicts(self, check_list):
"""Iterate over list to find dicts and check for python keywords."""
list_copy = copy.deepcopy(check_list)
for index, elem in enumerate(check_list):
if isinstance(elem, dict):
list_copy[index] = self._check_for_python_keywo... | python | def _iter_list_for_dicts(self, check_list):
"""Iterate over list to find dicts and check for python keywords."""
list_copy = copy.deepcopy(check_list)
for index, elem in enumerate(check_list):
if isinstance(elem, dict):
list_copy[index] = self._check_for_python_keywo... | [
"def",
"_iter_list_for_dicts",
"(",
"self",
",",
"check_list",
")",
":",
"list_copy",
"=",
"copy",
".",
"deepcopy",
"(",
"check_list",
")",
"for",
"index",
",",
"elem",
"in",
"enumerate",
"(",
"check_list",
")",
":",
"if",
"isinstance",
"(",
"elem",
",",
... | Iterate over list to find dicts and check for python keywords. | [
"Iterate",
"over",
"list",
"to",
"find",
"dicts",
"and",
"check",
"for",
"python",
"keywords",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L445-L456 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | ResourceBase._check_for_python_keywords | def _check_for_python_keywords(self, kwargs):
"""When Python keywords seen, mutate to remove trailing underscore."""
kwargs_copy = copy.deepcopy(kwargs)
for key, val in iteritems(kwargs):
if isinstance(val, dict):
kwargs_copy[key] = self._check_for_python_keywords(va... | python | def _check_for_python_keywords(self, kwargs):
"""When Python keywords seen, mutate to remove trailing underscore."""
kwargs_copy = copy.deepcopy(kwargs)
for key, val in iteritems(kwargs):
if isinstance(val, dict):
kwargs_copy[key] = self._check_for_python_keywords(va... | [
"def",
"_check_for_python_keywords",
"(",
"self",
",",
"kwargs",
")",
":",
"kwargs_copy",
"=",
"copy",
".",
"deepcopy",
"(",
"kwargs",
")",
"for",
"key",
",",
"val",
"in",
"iteritems",
"(",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"dict",... | When Python keywords seen, mutate to remove trailing underscore. | [
"When",
"Python",
"keywords",
"seen",
"mutate",
"to",
"remove",
"trailing",
"underscore",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L458-L473 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | ResourceBase._check_keys | def _check_keys(self, rdict):
"""Call this from _local_update to validate response keys
disallowed server-response json keys:
1. The string-literal '_meta_data'
2. strings that are not valid Python 2.7 identifiers
3. strings beginning with '__'.
:param rdict: from respo... | python | def _check_keys(self, rdict):
"""Call this from _local_update to validate response keys
disallowed server-response json keys:
1. The string-literal '_meta_data'
2. strings that are not valid Python 2.7 identifiers
3. strings beginning with '__'.
:param rdict: from respo... | [
"def",
"_check_keys",
"(",
"self",
",",
"rdict",
")",
":",
"if",
"'_meta_data'",
"in",
"rdict",
":",
"error_message",
"=",
"\"Response contains key '_meta_data' which is \"",
"\"incompatible with this API!!\\n Response json: %r\"",
"%",
"rdict",
"raise",
"DeviceProvidesIncomp... | Call this from _local_update to validate response keys
disallowed server-response json keys:
1. The string-literal '_meta_data'
2. strings that are not valid Python 2.7 identifiers
3. strings beginning with '__'.
:param rdict: from response.json()
:raises: DeviceProvide... | [
"Call",
"this",
"from",
"_local_update",
"to",
"validate",
"response",
"keys"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L475-L504 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | ResourceBase._local_update | def _local_update(self, rdict):
"""Call this with a response dictionary to update instance attrs.
If the response has only valid keys, stash meta_data, replace __dict__,
and reassign meta_data.
:param rdict: response attributes derived from server JSON
"""
sanitized = s... | python | def _local_update(self, rdict):
"""Call this with a response dictionary to update instance attrs.
If the response has only valid keys, stash meta_data, replace __dict__,
and reassign meta_data.
:param rdict: response attributes derived from server JSON
"""
sanitized = s... | [
"def",
"_local_update",
"(",
"self",
",",
"rdict",
")",
":",
"sanitized",
"=",
"self",
".",
"_check_keys",
"(",
"rdict",
")",
"temp_meta",
"=",
"self",
".",
"_meta_data",
"self",
".",
"__dict__",
"=",
"sanitized",
"self",
".",
"_meta_data",
"=",
"temp_meta... | Call this with a response dictionary to update instance attrs.
If the response has only valid keys, stash meta_data, replace __dict__,
and reassign meta_data.
:param rdict: response attributes derived from server JSON | [
"Call",
"this",
"with",
"a",
"response",
"dictionary",
"to",
"update",
"instance",
"attrs",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L506-L517 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | ResourceBase._update | def _update(self, **kwargs):
"""wrapped with update, override that in a subclass to customize"""
requests_params, update_uri, session, read_only = \
self._prepare_put_or_patch(kwargs)
read_only_mutations = []
for attr in read_only:
if attr in kwargs:
... | python | def _update(self, **kwargs):
"""wrapped with update, override that in a subclass to customize"""
requests_params, update_uri, session, read_only = \
self._prepare_put_or_patch(kwargs)
read_only_mutations = []
for attr in read_only:
if attr in kwargs:
... | [
"def",
"_update",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"requests_params",
",",
"update_uri",
",",
"session",
",",
"read_only",
"=",
"self",
".",
"_prepare_put_or_patch",
"(",
"kwargs",
")",
"read_only_mutations",
"=",
"[",
"]",
"for",
"attr",
"in",
... | wrapped with update, override that in a subclass to customize | [
"wrapped",
"with",
"update",
"override",
"that",
"in",
"a",
"subclass",
"to",
"customize"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L519-L594 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | ResourceBase._refresh | def _refresh(self, **kwargs):
"""wrapped by `refresh` override that in a subclass to customize"""
requests_params = self._handle_requests_params(kwargs)
refresh_session = self._meta_data['bigip']._meta_data['icr_session']
if self._meta_data['uri'].endswith('/stats/'):
# Slic... | python | def _refresh(self, **kwargs):
"""wrapped by `refresh` override that in a subclass to customize"""
requests_params = self._handle_requests_params(kwargs)
refresh_session = self._meta_data['bigip']._meta_data['icr_session']
if self._meta_data['uri'].endswith('/stats/'):
# Slic... | [
"def",
"_refresh",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"requests_params",
"=",
"self",
".",
"_handle_requests_params",
"(",
"kwargs",
")",
"refresh_session",
"=",
"self",
".",
"_meta_data",
"[",
"'bigip'",
"]",
".",
"_meta_data",
"[",
"'icr_session'",
... | wrapped by `refresh` override that in a subclass to customize | [
"wrapped",
"by",
"refresh",
"override",
"that",
"in",
"a",
"subclass",
"to",
"customize"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L619-L635 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | ResourceBase._produce_instance | def _produce_instance(self, response):
'''Generate a new self, which is an instance of the self.'''
new_instance = self._stamp_out_core()
# Post-process the response
new_instance._local_update(response.json())
# Allow for example files, which are KindTypeMismatches
if ha... | python | def _produce_instance(self, response):
'''Generate a new self, which is an instance of the self.'''
new_instance = self._stamp_out_core()
# Post-process the response
new_instance._local_update(response.json())
# Allow for example files, which are KindTypeMismatches
if ha... | [
"def",
"_produce_instance",
"(",
"self",
",",
"response",
")",
":",
"new_instance",
"=",
"self",
".",
"_stamp_out_core",
"(",
")",
"new_instance",
".",
"_local_update",
"(",
"response",
".",
"json",
"(",
")",
")",
"if",
"hasattr",
"(",
"new_instance",
",",
... | Generate a new self, which is an instance of the self. | [
"Generate",
"a",
"new",
"self",
"which",
"is",
"an",
"instance",
"of",
"the",
"self",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L681-L714 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | ResourceBase._reduce_boolean_pair | def _reduce_boolean_pair(self, config_dict, key1, key2):
"""Ensure only one key with a boolean value is present in dict.
:param config_dict: dict -- dictionary of config or kwargs
:param key1: string -- first key name
:param key2: string -- second key name
:raises: BooleansToRed... | python | def _reduce_boolean_pair(self, config_dict, key1, key2):
"""Ensure only one key with a boolean value is present in dict.
:param config_dict: dict -- dictionary of config or kwargs
:param key1: string -- first key name
:param key2: string -- second key name
:raises: BooleansToRed... | [
"def",
"_reduce_boolean_pair",
"(",
"self",
",",
"config_dict",
",",
"key1",
",",
"key2",
")",
":",
"if",
"key1",
"in",
"config_dict",
"and",
"key2",
"in",
"config_dict",
"and",
"config_dict",
"[",
"key1",
"]",
"==",
"config_dict",
"[",
"key2",
"]",
":",
... | Ensure only one key with a boolean value is present in dict.
:param config_dict: dict -- dictionary of config or kwargs
:param key1: string -- first key name
:param key2: string -- second key name
:raises: BooleansToReduceHaveSameValue | [
"Ensure",
"only",
"one",
"key",
"with",
"a",
"boolean",
"value",
"is",
"present",
"in",
"dict",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L716-L738 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | Collection.get_collection | def get_collection(self, **kwargs):
"""Get an iterator of Python ``Resource`` objects that represent URIs.
The returned objects are Pythonic `Resource`s that map to the most
recently `refreshed` state of uris-resources published by the device.
In order to instantiate the correct types, ... | python | def get_collection(self, **kwargs):
"""Get an iterator of Python ``Resource`` objects that represent URIs.
The returned objects are Pythonic `Resource`s that map to the most
recently `refreshed` state of uris-resources published by the device.
In order to instantiate the correct types, ... | [
"def",
"get_collection",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"list_of_contents",
"=",
"[",
"]",
"self",
".",
"refresh",
"(",
"**",
"kwargs",
")",
"if",
"'items'",
"in",
"self",
".",
"__dict__",
":",
"for",
"item",
"in",
"self",
".",
"items",
... | Get an iterator of Python ``Resource`` objects that represent URIs.
The returned objects are Pythonic `Resource`s that map to the most
recently `refreshed` state of uris-resources published by the device.
In order to instantiate the correct types, the concrete subclass must
populate its... | [
"Get",
"an",
"iterator",
"of",
"Python",
"Resource",
"objects",
"that",
"represent",
"URIs",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L783-L819 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | Collection._delete_collection | def _delete_collection(self, **kwargs):
"""wrapped with delete_collection, override that in a sublcass to customize """
error_message = "The request must include \"requests_params\": {\"params\": \"options=<glob pattern>\"} as kwarg"
try:
if kwargs['requests_params']['params'].split(... | python | def _delete_collection(self, **kwargs):
"""wrapped with delete_collection, override that in a sublcass to customize """
error_message = "The request must include \"requests_params\": {\"params\": \"options=<glob pattern>\"} as kwarg"
try:
if kwargs['requests_params']['params'].split(... | [
"def",
"_delete_collection",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"error_message",
"=",
"\"The request must include \\\"requests_params\\\": {\\\"params\\\": \\\"options=<glob pattern>\\\"} as kwarg\"",
"try",
":",
"if",
"kwargs",
"[",
"'requests_params'",
"]",
"[",
"'... | wrapped with delete_collection, override that in a sublcass to customize | [
"wrapped",
"with",
"delete_collection",
"override",
"that",
"in",
"a",
"sublcass",
"to",
"customize"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L821-L834 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | Resource._activate_URI | def _activate_URI(self, selfLinkuri):
"""Call this with a selfLink, after it's returned in _create or _load.
Each instance is tightly bound to a particular service URI. When that
service is created by this library, or loaded from the device, the URI
is set to self._meta_data['uri']. ... | python | def _activate_URI(self, selfLinkuri):
"""Call this with a selfLink, after it's returned in _create or _load.
Each instance is tightly bound to a particular service URI. When that
service is created by this library, or loaded from the device, the URI
is set to self._meta_data['uri']. ... | [
"def",
"_activate_URI",
"(",
"self",
",",
"selfLinkuri",
")",
":",
"uri",
"=",
"urlparse",
".",
"urlsplit",
"(",
"str",
"(",
"self",
".",
"_meta_data",
"[",
"'bigip'",
"]",
".",
"_meta_data",
"[",
"'uri'",
"]",
")",
")",
"attribute_reg",
"=",
"self",
"... | Call this with a selfLink, after it's returned in _create or _load.
Each instance is tightly bound to a particular service URI. When that
service is created by this library, or loaded from the device, the URI
is set to self._meta_data['uri']. This operation can only occur once,
any s... | [
"Call",
"this",
"with",
"a",
"selfLink",
"after",
"it",
"s",
"returned",
"in",
"_create",
"or",
"_load",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L900-L949 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | Resource._check_create_parameters | def _check_create_parameters(self, **kwargs):
"""Params given to create should satisfy required params.
:params: kwargs
:raises: MissingRequiredCreateParameter
"""
rset = self._meta_data['required_creation_parameters']
check = _missing_required_parameters(rset, **kwargs)... | python | def _check_create_parameters(self, **kwargs):
"""Params given to create should satisfy required params.
:params: kwargs
:raises: MissingRequiredCreateParameter
"""
rset = self._meta_data['required_creation_parameters']
check = _missing_required_parameters(rset, **kwargs)... | [
"def",
"_check_create_parameters",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"rset",
"=",
"self",
".",
"_meta_data",
"[",
"'required_creation_parameters'",
"]",
"check",
"=",
"_missing_required_parameters",
"(",
"rset",
",",
"**",
"kwargs",
")",
"if",
"check",... | Params given to create should satisfy required params.
:params: kwargs
:raises: MissingRequiredCreateParameter | [
"Params",
"given",
"to",
"create",
"should",
"satisfy",
"required",
"params",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L956-L966 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | Resource._minimum_one_is_missing | def _minimum_one_is_missing(self, **kwargs):
"""Helper function to do operation on sets
Verify if at least one of the elements
is present in **kwargs. If no items of rqset
are contained in **kwargs the function
raises exception.
This check will only trigger if rqset is... | python | def _minimum_one_is_missing(self, **kwargs):
"""Helper function to do operation on sets
Verify if at least one of the elements
is present in **kwargs. If no items of rqset
are contained in **kwargs the function
raises exception.
This check will only trigger if rqset is... | [
"def",
"_minimum_one_is_missing",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"rqset",
"=",
"self",
".",
"_meta_data",
"[",
"'minimum_additional_parameters'",
"]",
"if",
"rqset",
":",
"kwarg_set",
"=",
"set",
"(",
"iterkeys",
"(",
"kwargs",
")",
")",
"if",
... | Helper function to do operation on sets
Verify if at least one of the elements
is present in **kwargs. If no items of rqset
are contained in **kwargs the function
raises exception.
This check will only trigger if rqset is not empty.
Raises:
MissingRequire... | [
"Helper",
"function",
"to",
"do",
"operation",
"on",
"sets"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L968-L989 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | Resource._check_load_parameters | def _check_load_parameters(self, **kwargs):
"""Params given to load should at least satisfy required params.
:params: kwargs
:raises: MissingRequiredReadParameter
"""
rset = self._meta_data['required_load_parameters']
check = _missing_required_parameters(rset, **kwargs)
... | python | def _check_load_parameters(self, **kwargs):
"""Params given to load should at least satisfy required params.
:params: kwargs
:raises: MissingRequiredReadParameter
"""
rset = self._meta_data['required_load_parameters']
check = _missing_required_parameters(rset, **kwargs)
... | [
"def",
"_check_load_parameters",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"rset",
"=",
"self",
".",
"_meta_data",
"[",
"'required_load_parameters'",
"]",
"check",
"=",
"_missing_required_parameters",
"(",
"rset",
",",
"**",
"kwargs",
")",
"if",
"check",
":"... | Params given to load should at least satisfy required params.
:params: kwargs
:raises: MissingRequiredReadParameter | [
"Params",
"given",
"to",
"load",
"should",
"at",
"least",
"satisfy",
"required",
"params",
"."
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L1055-L1066 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | Resource._load | def _load(self, **kwargs):
"""wrapped with load, override that in a subclass to customize"""
if 'uri' in self._meta_data:
error = "There was an attempt to assign a new uri to this "\
"resource, the _meta_data['uri'] is %s and it should"\
" not be chang... | python | def _load(self, **kwargs):
"""wrapped with load, override that in a subclass to customize"""
if 'uri' in self._meta_data:
error = "There was an attempt to assign a new uri to this "\
"resource, the _meta_data['uri'] is %s and it should"\
" not be chang... | [
"def",
"_load",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"if",
"'uri'",
"in",
"self",
".",
"_meta_data",
":",
"error",
"=",
"\"There was an attempt to assign a new uri to this \"",
"\"resource, the _meta_data['uri'] is %s and it should\"",
"\" not be changed.\"",
"%",
... | wrapped with load, override that in a subclass to customize | [
"wrapped",
"with",
"load",
"override",
"that",
"in",
"a",
"subclass",
"to",
"customize"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L1068-L1086 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | Resource._delete | def _delete(self, **kwargs):
"""wrapped with delete, override that in a subclass to customize """
requests_params = self._handle_requests_params(kwargs)
delete_uri = self._meta_data['uri']
session = self._meta_data['bigip']._meta_data['icr_session']
# Check the generation for m... | python | def _delete(self, **kwargs):
"""wrapped with delete, override that in a subclass to customize """
requests_params = self._handle_requests_params(kwargs)
delete_uri = self._meta_data['uri']
session = self._meta_data['bigip']._meta_data['icr_session']
# Check the generation for m... | [
"def",
"_delete",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"requests_params",
"=",
"self",
".",
"_handle_requests_params",
"(",
"kwargs",
")",
"delete_uri",
"=",
"self",
".",
"_meta_data",
"[",
"'uri'",
"]",
"session",
"=",
"self",
".",
"_meta_data",
"[... | wrapped with delete, override that in a subclass to customize | [
"wrapped",
"with",
"delete",
"override",
"that",
"in",
"a",
"subclass",
"to",
"customize"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L1112-L1126 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | AsmResource._delete | def _delete(self, **kwargs):
"""Wrapped with delete, override that in a subclass to customize """
requests_params = self._handle_requests_params(kwargs)
delete_uri = self._meta_data['uri']
session = self._meta_data['bigip']._meta_data['icr_session']
response = session.delete(del... | python | def _delete(self, **kwargs):
"""Wrapped with delete, override that in a subclass to customize """
requests_params = self._handle_requests_params(kwargs)
delete_uri = self._meta_data['uri']
session = self._meta_data['bigip']._meta_data['icr_session']
response = session.delete(del... | [
"def",
"_delete",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"requests_params",
"=",
"self",
".",
"_handle_requests_params",
"(",
"kwargs",
")",
"delete_uri",
"=",
"self",
".",
"_meta_data",
"[",
"'uri'",
"]",
"session",
"=",
"self",
".",
"_meta_data",
"[... | Wrapped with delete, override that in a subclass to customize | [
"Wrapped",
"with",
"delete",
"override",
"that",
"in",
"a",
"subclass",
"to",
"customize"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L1322-L1330 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | AsmResource.exists | def exists(self, **kwargs):
r"""Check for the existence of the ASM object on the BIG-IP
Sends an HTTP GET to the URI of the ASM object and if it fails with
a :exc:~requests.HTTPError` exception it checks the exception for
status code of 404 and returns :obj:`False` in that case.
... | python | def exists(self, **kwargs):
r"""Check for the existence of the ASM object on the BIG-IP
Sends an HTTP GET to the URI of the ASM object and if it fails with
a :exc:~requests.HTTPError` exception it checks the exception for
status code of 404 and returns :obj:`False` in that case.
... | [
"def",
"exists",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"r",
"requests_params",
"=",
"self",
".",
"_handle_requests_params",
"(",
"kwargs",
")",
"self",
".",
"_check_load_parameters",
"(",
"**",
"kwargs",
")",
"kwargs",
"[",
"'uri_as_parts'",
"]",
"=",
... | r"""Check for the existence of the ASM object on the BIG-IP
Sends an HTTP GET to the URI of the ASM object and if it fails with
a :exc:~requests.HTTPError` exception it checks the exception for
status code of 404 and returns :obj:`False` in that case.
If the GET is successful it return... | [
"r",
"Check",
"for",
"the",
"existence",
"of",
"the",
"ASM",
"object",
"on",
"the",
"BIG",
"-",
"IP"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L1350-L1392 | train |
F5Networks/f5-common-python | f5/bigip/resource.py | AsmTaskResource._fetch | def _fetch(self):
"""wrapped by `fetch` override that in subclasses to customize"""
if 'uri' in self._meta_data:
error = "There was an attempt to assign a new uri to this "\
"resource, the _meta_data['uri'] is %s and it should"\
" not be changed." % (s... | python | def _fetch(self):
"""wrapped by `fetch` override that in subclasses to customize"""
if 'uri' in self._meta_data:
error = "There was an attempt to assign a new uri to this "\
"resource, the _meta_data['uri'] is %s and it should"\
" not be changed." % (s... | [
"def",
"_fetch",
"(",
"self",
")",
":",
"if",
"'uri'",
"in",
"self",
".",
"_meta_data",
":",
"error",
"=",
"\"There was an attempt to assign a new uri to this \"",
"\"resource, the _meta_data['uri'] is %s and it should\"",
"\" not be changed.\"",
"%",
"(",
"self",
".",
"_... | wrapped by `fetch` override that in subclasses to customize | [
"wrapped",
"by",
"fetch",
"override",
"that",
"in",
"subclasses",
"to",
"customize"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L1423-L1436 | train |
F5Networks/f5-common-python | f5/multi_device/cluster/__init__.py | ClusterManager._check_device_number | def _check_device_number(self, devices):
'''Check if number of devices is between 2 and 4
:param kwargs: dict -- keyword args in dict
'''
if len(devices) < 2 or len(devices) > 4:
msg = 'The number of devices to cluster is not supported.'
raise ClusterNotSupporte... | python | def _check_device_number(self, devices):
'''Check if number of devices is between 2 and 4
:param kwargs: dict -- keyword args in dict
'''
if len(devices) < 2 or len(devices) > 4:
msg = 'The number of devices to cluster is not supported.'
raise ClusterNotSupporte... | [
"def",
"_check_device_number",
"(",
"self",
",",
"devices",
")",
":",
"if",
"len",
"(",
"devices",
")",
"<",
"2",
"or",
"len",
"(",
"devices",
")",
">",
"4",
":",
"msg",
"=",
"'The number of devices to cluster is not supported.'",
"raise",
"ClusterNotSupported",... | Check if number of devices is between 2 and 4
:param kwargs: dict -- keyword args in dict | [
"Check",
"if",
"number",
"of",
"devices",
"is",
"between",
"2",
"and",
"4"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/multi_device/cluster/__init__.py#L126-L134 | train |
F5Networks/f5-common-python | f5/multi_device/cluster/__init__.py | ClusterManager.manage_extant | def manage_extant(self, **kwargs):
'''Manage an existing cluster
:param kwargs: dict -- keyword args in dict
'''
self._check_device_number(kwargs['devices'])
self.trust_domain = TrustDomain(
devices=kwargs['devices'],
partition=kwargs['device_group_parti... | python | def manage_extant(self, **kwargs):
'''Manage an existing cluster
:param kwargs: dict -- keyword args in dict
'''
self._check_device_number(kwargs['devices'])
self.trust_domain = TrustDomain(
devices=kwargs['devices'],
partition=kwargs['device_group_parti... | [
"def",
"manage_extant",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"_check_device_number",
"(",
"kwargs",
"[",
"'devices'",
"]",
")",
"self",
".",
"trust_domain",
"=",
"TrustDomain",
"(",
"devices",
"=",
"kwargs",
"[",
"'devices'",
"]",
",",
... | Manage an existing cluster
:param kwargs: dict -- keyword args in dict | [
"Manage",
"an",
"existing",
"cluster"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/multi_device/cluster/__init__.py#L136-L148 | train |
F5Networks/f5-common-python | f5/bigip/tm/ltm/policy.py | Policy._filter_version_specific_options | def _filter_version_specific_options(self, tmos_ver, **kwargs):
'''Filter version-specific optional parameters
Some optional parameters only exist in v12.1.0 and greater,
filter these out for earlier versions to allow backward comatibility.
'''
if LooseVersion(tmos_ver) < Loose... | python | def _filter_version_specific_options(self, tmos_ver, **kwargs):
'''Filter version-specific optional parameters
Some optional parameters only exist in v12.1.0 and greater,
filter these out for earlier versions to allow backward comatibility.
'''
if LooseVersion(tmos_ver) < Loose... | [
"def",
"_filter_version_specific_options",
"(",
"self",
",",
"tmos_ver",
",",
"**",
"kwargs",
")",
":",
"if",
"LooseVersion",
"(",
"tmos_ver",
")",
"<",
"LooseVersion",
"(",
"'12.1.0'",
")",
":",
"for",
"k",
",",
"parms",
"in",
"self",
".",
"_meta_data",
"... | Filter version-specific optional parameters
Some optional parameters only exist in v12.1.0 and greater,
filter these out for earlier versions to allow backward comatibility. | [
"Filter",
"version",
"-",
"specific",
"optional",
"parameters"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/tm/ltm/policy.py#L64-L79 | train |
F5Networks/f5-common-python | f5/bigip/tm/ltm/policy.py | Policy._create | def _create(self, **kwargs):
'''Allow creation of draft policy and ability to publish a draft
Draft policies only exist in 12.1.0 and greater versions of TMOS.
But there must be a method to create a draft, then publish it.
:raises: MissingRequiredCreationParameter
'''
... | python | def _create(self, **kwargs):
'''Allow creation of draft policy and ability to publish a draft
Draft policies only exist in 12.1.0 and greater versions of TMOS.
But there must be a method to create a draft, then publish it.
:raises: MissingRequiredCreationParameter
'''
... | [
"def",
"_create",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"tmos_ver",
"=",
"self",
".",
"_meta_data",
"[",
"'bigip'",
"]",
".",
"_meta_data",
"[",
"'tmos_version'",
"]",
"legacy",
"=",
"kwargs",
".",
"pop",
"(",
"'legacy'",
",",
"False",
")",
"publ... | Allow creation of draft policy and ability to publish a draft
Draft policies only exist in 12.1.0 and greater versions of TMOS.
But there must be a method to create a draft, then publish it.
:raises: MissingRequiredCreationParameter | [
"Allow",
"creation",
"of",
"draft",
"policy",
"and",
"ability",
"to",
"publish",
"a",
"draft"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/tm/ltm/policy.py#L81-L108 | train |
F5Networks/f5-common-python | f5/bigip/tm/ltm/policy.py | Policy._modify | def _modify(self, **patch):
'''Modify only draft or legacy policies
Published policies cannot be modified
:raises: OperationNotSupportedOnPublishedPolicy
'''
legacy = patch.pop('legacy', False)
tmos_ver = self._meta_data['bigip']._meta_data['tmos_version']
self.... | python | def _modify(self, **patch):
'''Modify only draft or legacy policies
Published policies cannot be modified
:raises: OperationNotSupportedOnPublishedPolicy
'''
legacy = patch.pop('legacy', False)
tmos_ver = self._meta_data['bigip']._meta_data['tmos_version']
self.... | [
"def",
"_modify",
"(",
"self",
",",
"**",
"patch",
")",
":",
"legacy",
"=",
"patch",
".",
"pop",
"(",
"'legacy'",
",",
"False",
")",
"tmos_ver",
"=",
"self",
".",
"_meta_data",
"[",
"'bigip'",
"]",
".",
"_meta_data",
"[",
"'tmos_version'",
"]",
"self",... | Modify only draft or legacy policies
Published policies cannot be modified
:raises: OperationNotSupportedOnPublishedPolicy | [
"Modify",
"only",
"draft",
"or",
"legacy",
"policies"
] | 7e67d5acd757a60e3d5f8c88c534bd72208f5494 | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/tm/ltm/policy.py#L110-L125 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.