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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
sentinel-hub/sentinelhub-py | sentinelhub/download.py | _check_if_must_download | def _check_if_must_download(request_list, redownload):
"""
Updates request.will_download attribute of each request in request_list.
**Note:** the function mutates the elements of the list!
:param request_list: a list of ``DownloadRequest`` instances
:type: list[DownloadRequest]
:param redownlo... | python | def _check_if_must_download(request_list, redownload):
"""
Updates request.will_download attribute of each request in request_list.
**Note:** the function mutates the elements of the list!
:param request_list: a list of ``DownloadRequest`` instances
:type: list[DownloadRequest]
:param redownlo... | [
"def",
"_check_if_must_download",
"(",
"request_list",
",",
"redownload",
")",
":",
"for",
"request",
"in",
"request_list",
":",
"request",
".",
"will_download",
"=",
"(",
"request",
".",
"save_response",
"or",
"request",
".",
"return_data",
")",
"and",
"(",
"... | Updates request.will_download attribute of each request in request_list.
**Note:** the function mutates the elements of the list!
:param request_list: a list of ``DownloadRequest`` instances
:type: list[DownloadRequest]
:param redownload: tells whether to download the data again or not
:type: bool | [
"Updates",
"request",
".",
"will_download",
"attribute",
"of",
"each",
"request",
"in",
"request_list",
"."
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/download.py#L202-L215 | train |
sentinel-hub/sentinelhub-py | sentinelhub/download.py | execute_download_request | def execute_download_request(request):
""" Executes download request.
:param request: DownloadRequest to be executed
:type request: DownloadRequest
:return: downloaded data or None
:rtype: numpy array, other possible data type or None
:raises: DownloadFailedException
"""
if request.save... | python | def execute_download_request(request):
""" Executes download request.
:param request: DownloadRequest to be executed
:type request: DownloadRequest
:return: downloaded data or None
:rtype: numpy array, other possible data type or None
:raises: DownloadFailedException
"""
if request.save... | [
"def",
"execute_download_request",
"(",
"request",
")",
":",
"if",
"request",
".",
"save_response",
"and",
"request",
".",
"data_folder",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Data folder is not specified. '",
"'Please give a data folder name in the initializatio... | Executes download request.
:param request: DownloadRequest to be executed
:type request: DownloadRequest
:return: downloaded data or None
:rtype: numpy array, other possible data type or None
:raises: DownloadFailedException | [
"Executes",
"download",
"request",
"."
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/download.py#L218-L270 | train |
sentinel-hub/sentinelhub-py | sentinelhub/download.py | _is_temporal_problem | def _is_temporal_problem(exception):
""" Checks if the obtained exception is temporal and if download attempt should be repeated
:param exception: Exception raised during download
:type exception: Exception
:return: True if exception is temporal and False otherwise
:rtype: bool
"""
try:
... | python | def _is_temporal_problem(exception):
""" Checks if the obtained exception is temporal and if download attempt should be repeated
:param exception: Exception raised during download
:type exception: Exception
:return: True if exception is temporal and False otherwise
:rtype: bool
"""
try:
... | [
"def",
"_is_temporal_problem",
"(",
"exception",
")",
":",
"try",
":",
"return",
"isinstance",
"(",
"exception",
",",
"(",
"requests",
".",
"ConnectionError",
",",
"requests",
".",
"Timeout",
")",
")",
"except",
"AttributeError",
":",
"return",
"isinstance",
"... | Checks if the obtained exception is temporal and if download attempt should be repeated
:param exception: Exception raised during download
:type exception: Exception
:return: True if exception is temporal and False otherwise
:rtype: bool | [
"Checks",
"if",
"the",
"obtained",
"exception",
"is",
"temporal",
"and",
"if",
"download",
"attempt",
"should",
"be",
"repeated"
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/download.py#L325-L336 | train |
sentinel-hub/sentinelhub-py | sentinelhub/download.py | _create_download_failed_message | def _create_download_failed_message(exception, url):
""" Creates message describing why download has failed
:param exception: Exception raised during download
:type exception: Exception
:param url: An URL from where download was attempted
:type url: str
:return: Error message
:rtype: str
... | python | def _create_download_failed_message(exception, url):
""" Creates message describing why download has failed
:param exception: Exception raised during download
:type exception: Exception
:param url: An URL from where download was attempted
:type url: str
:return: Error message
:rtype: str
... | [
"def",
"_create_download_failed_message",
"(",
"exception",
",",
"url",
")",
":",
"message",
"=",
"'Failed to download from:\\n{}\\nwith {}:\\n{}'",
".",
"format",
"(",
"url",
",",
"exception",
".",
"__class__",
".",
"__name__",
",",
"exception",
")",
"if",
"_is_tem... | Creates message describing why download has failed
:param exception: Exception raised during download
:type exception: Exception
:param url: An URL from where download was attempted
:type url: str
:return: Error message
:rtype: str | [
"Creates",
"message",
"describing",
"why",
"download",
"has",
"failed"
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/download.py#L352-L380 | train |
sentinel-hub/sentinelhub-py | sentinelhub/download.py | decode_data | def decode_data(response_content, data_type, entire_response=None):
""" Interprets downloaded data and returns it.
:param response_content: downloaded data (i.e. json, png, tiff, xml, zip, ... file)
:type response_content: bytes
:param data_type: expected downloaded data type
:type data_type: const... | python | def decode_data(response_content, data_type, entire_response=None):
""" Interprets downloaded data and returns it.
:param response_content: downloaded data (i.e. json, png, tiff, xml, zip, ... file)
:type response_content: bytes
:param data_type: expected downloaded data type
:type data_type: const... | [
"def",
"decode_data",
"(",
"response_content",
",",
"data_type",
",",
"entire_response",
"=",
"None",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'data_type=%s'",
",",
"data_type",
")",
"if",
"data_type",
"is",
"MimeType",
".",
"JSON",
":",
"if",
"isinstance",
"... | Interprets downloaded data and returns it.
:param response_content: downloaded data (i.e. json, png, tiff, xml, zip, ... file)
:type response_content: bytes
:param data_type: expected downloaded data type
:type data_type: constants.MimeType
:param entire_response: A response obtained from execution... | [
"Interprets",
"downloaded",
"data",
"and",
"returns",
"it",
"."
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/download.py#L398-L430 | train |
sentinel-hub/sentinelhub-py | sentinelhub/download.py | decode_image | def decode_image(data, image_type):
""" Decodes the image provided in various formats, i.e. png, 16-bit float tiff, 32-bit float tiff, jp2
and returns it as an numpy array
:param data: image in its original format
:type data: any of possible image types
:param image_type: expected image format
... | python | def decode_image(data, image_type):
""" Decodes the image provided in various formats, i.e. png, 16-bit float tiff, 32-bit float tiff, jp2
and returns it as an numpy array
:param data: image in its original format
:type data: any of possible image types
:param image_type: expected image format
... | [
"def",
"decode_image",
"(",
"data",
",",
"image_type",
")",
":",
"bytes_data",
"=",
"BytesIO",
"(",
"data",
")",
"if",
"image_type",
".",
"is_tiff_format",
"(",
")",
":",
"image",
"=",
"tiff",
".",
"imread",
"(",
"bytes_data",
")",
"else",
":",
"image",
... | Decodes the image provided in various formats, i.e. png, 16-bit float tiff, 32-bit float tiff, jp2
and returns it as an numpy array
:param data: image in its original format
:type data: any of possible image types
:param image_type: expected image format
:type image_type: constants.MimeType
... | [
"Decodes",
"the",
"image",
"provided",
"in",
"various",
"formats",
"i",
".",
"e",
".",
"png",
"16",
"-",
"bit",
"float",
"tiff",
"32",
"-",
"bit",
"float",
"tiff",
"jp2",
"and",
"returns",
"it",
"as",
"an",
"numpy",
"array"
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/download.py#L433-L460 | train |
sentinel-hub/sentinelhub-py | sentinelhub/download.py | get_json | def get_json(url, post_values=None, headers=None):
""" Download request as JSON data type
:param url: url to Sentinel Hub's services or other sources from where the data is downloaded
:type url: str
:param post_values: form encoded data to send in POST request. Default is ``None``
:type post_values... | python | def get_json(url, post_values=None, headers=None):
""" Download request as JSON data type
:param url: url to Sentinel Hub's services or other sources from where the data is downloaded
:type url: str
:param post_values: form encoded data to send in POST request. Default is ``None``
:type post_values... | [
"def",
"get_json",
"(",
"url",
",",
"post_values",
"=",
"None",
",",
"headers",
"=",
"None",
")",
":",
"json_headers",
"=",
"{",
"}",
"if",
"headers",
"is",
"None",
"else",
"headers",
".",
"copy",
"(",
")",
"if",
"post_values",
"is",
"None",
":",
"re... | Download request as JSON data type
:param url: url to Sentinel Hub's services or other sources from where the data is downloaded
:type url: str
:param post_values: form encoded data to send in POST request. Default is ``None``
:type post_values: dict
:param headers: add HTTP headers to request. Def... | [
"Download",
"request",
"as",
"JSON",
"data",
"type"
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/download.py#L463-L488 | train |
sentinel-hub/sentinelhub-py | sentinelhub/download.py | get_xml | def get_xml(url):
""" Download request as XML data type
:param url: url to Sentinel Hub's services or other sources from where the data is downloaded
:type url: str
:return: request response as XML instance
:rtype: XML instance or None
:raises: RunTimeError
"""
request = DownloadRequest... | python | def get_xml(url):
""" Download request as XML data type
:param url: url to Sentinel Hub's services or other sources from where the data is downloaded
:type url: str
:return: request response as XML instance
:rtype: XML instance or None
:raises: RunTimeError
"""
request = DownloadRequest... | [
"def",
"get_xml",
"(",
"url",
")",
":",
"request",
"=",
"DownloadRequest",
"(",
"url",
"=",
"url",
",",
"request_type",
"=",
"RequestType",
".",
"GET",
",",
"save_response",
"=",
"False",
",",
"return_data",
"=",
"True",
",",
"data_type",
"=",
"MimeType",
... | Download request as XML data type
:param url: url to Sentinel Hub's services or other sources from where the data is downloaded
:type url: str
:return: request response as XML instance
:rtype: XML instance or None
:raises: RunTimeError | [
"Download",
"request",
"as",
"XML",
"data",
"type"
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/download.py#L491-L503 | train |
sentinel-hub/sentinelhub-py | sentinelhub/download.py | DownloadRequest.is_downloaded | def is_downloaded(self):
""" Checks if data for this request has already been downloaded and is saved to disk.
:return: returns ``True`` if data for this request has already been downloaded and is saved to disk.
:rtype: bool
"""
if self.file_path is None:
return Fals... | python | def is_downloaded(self):
""" Checks if data for this request has already been downloaded and is saved to disk.
:return: returns ``True`` if data for this request has already been downloaded and is saved to disk.
:rtype: bool
"""
if self.file_path is None:
return Fals... | [
"def",
"is_downloaded",
"(",
"self",
")",
":",
"if",
"self",
".",
"file_path",
"is",
"None",
":",
"return",
"False",
"return",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"file_path",
")"
] | Checks if data for this request has already been downloaded and is saved to disk.
:return: returns ``True`` if data for this request has already been downloaded and is saved to disk.
:rtype: bool | [
"Checks",
"if",
"data",
"for",
"this",
"request",
"has",
"already",
"been",
"downloaded",
"and",
"is",
"saved",
"to",
"disk",
"."
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/download.py#L159-L167 | train |
sentinel-hub/sentinelhub-py | sentinelhub/opensearch.py | get_area_info | def get_area_info(bbox, date_interval, maxcc=None):
""" Get information about all images from specified area and time range
:param bbox: bounding box of requested area
:type bbox: geometry.BBox
:param date_interval: a pair of time strings in ISO8601 format
:type date_interval: tuple(str)
:param... | python | def get_area_info(bbox, date_interval, maxcc=None):
""" Get information about all images from specified area and time range
:param bbox: bounding box of requested area
:type bbox: geometry.BBox
:param date_interval: a pair of time strings in ISO8601 format
:type date_interval: tuple(str)
:param... | [
"def",
"get_area_info",
"(",
"bbox",
",",
"date_interval",
",",
"maxcc",
"=",
"None",
")",
":",
"result_list",
"=",
"search_iter",
"(",
"bbox",
"=",
"bbox",
",",
"start_date",
"=",
"date_interval",
"[",
"0",
"]",
",",
"end_date",
"=",
"date_interval",
"[",... | Get information about all images from specified area and time range
:param bbox: bounding box of requested area
:type bbox: geometry.BBox
:param date_interval: a pair of time strings in ISO8601 format
:type date_interval: tuple(str)
:param maxcc: filter images by maximum percentage of cloud coverag... | [
"Get",
"information",
"about",
"all",
"images",
"from",
"specified",
"area",
"and",
"time",
"range"
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/opensearch.py#L79-L94 | train |
sentinel-hub/sentinelhub-py | sentinelhub/opensearch.py | get_area_dates | def get_area_dates(bbox, date_interval, maxcc=None):
""" Get list of times of existing images from specified area and time range
:param bbox: bounding box of requested area
:type bbox: geometry.BBox
:param date_interval: a pair of time strings in ISO8601 format
:type date_interval: tuple(str)
:... | python | def get_area_dates(bbox, date_interval, maxcc=None):
""" Get list of times of existing images from specified area and time range
:param bbox: bounding box of requested area
:type bbox: geometry.BBox
:param date_interval: a pair of time strings in ISO8601 format
:type date_interval: tuple(str)
:... | [
"def",
"get_area_dates",
"(",
"bbox",
",",
"date_interval",
",",
"maxcc",
"=",
"None",
")",
":",
"area_info",
"=",
"get_area_info",
"(",
"bbox",
",",
"date_interval",
",",
"maxcc",
"=",
"maxcc",
")",
"return",
"sorted",
"(",
"{",
"datetime",
".",
"datetime... | Get list of times of existing images from specified area and time range
:param bbox: bounding box of requested area
:type bbox: geometry.BBox
:param date_interval: a pair of time strings in ISO8601 format
:type date_interval: tuple(str)
:param maxcc: filter images by maximum percentage of cloud cov... | [
"Get",
"list",
"of",
"times",
"of",
"existing",
"images",
"from",
"specified",
"area",
"and",
"time",
"range"
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/opensearch.py#L97-L113 | train |
sentinel-hub/sentinelhub-py | sentinelhub/opensearch.py | search_iter | def search_iter(tile_id=None, bbox=None, start_date=None, end_date=None, absolute_orbit=None):
""" A generator function that implements OpenSearch search queries and returns results
All parameters for search are optional.
:param tile_id: original tile identification string provided by ESA (e.g.
... | python | def search_iter(tile_id=None, bbox=None, start_date=None, end_date=None, absolute_orbit=None):
""" A generator function that implements OpenSearch search queries and returns results
All parameters for search are optional.
:param tile_id: original tile identification string provided by ESA (e.g.
... | [
"def",
"search_iter",
"(",
"tile_id",
"=",
"None",
",",
"bbox",
"=",
"None",
",",
"start_date",
"=",
"None",
",",
"end_date",
"=",
"None",
",",
"absolute_orbit",
"=",
"None",
")",
":",
"if",
"bbox",
"and",
"bbox",
".",
"crs",
"is",
"not",
"CRS",
".",... | A generator function that implements OpenSearch search queries and returns results
All parameters for search are optional.
:param tile_id: original tile identification string provided by ESA (e.g.
'S2A_OPER_MSI_L1C_TL_SGS__20160109T230542_A002870_T10UEV_N02.01')
:type tile_id: str
... | [
"A",
"generator",
"function",
"that",
"implements",
"OpenSearch",
"search",
"queries",
"and",
"returns",
"results"
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/opensearch.py#L129-L168 | train |
sentinel-hub/sentinelhub-py | sentinelhub/opensearch.py | _prepare_url_params | def _prepare_url_params(tile_id, bbox, end_date, start_date, absolute_orbit):
""" Constructs dict with URL params
:param tile_id: original tile identification string provided by ESA (e.g.
'S2A_OPER_MSI_L1C_TL_SGS__20160109T230542_A002870_T10UEV_N02.01')
:type tile_id: str
:param bbo... | python | def _prepare_url_params(tile_id, bbox, end_date, start_date, absolute_orbit):
""" Constructs dict with URL params
:param tile_id: original tile identification string provided by ESA (e.g.
'S2A_OPER_MSI_L1C_TL_SGS__20160109T230542_A002870_T10UEV_N02.01')
:type tile_id: str
:param bbo... | [
"def",
"_prepare_url_params",
"(",
"tile_id",
",",
"bbox",
",",
"end_date",
",",
"start_date",
",",
"absolute_orbit",
")",
":",
"url_params",
"=",
"{",
"'identifier'",
":",
"tile_id",
",",
"'startDate'",
":",
"start_date",
",",
"'completionDate'",
":",
"end_date... | Constructs dict with URL params
:param tile_id: original tile identification string provided by ESA (e.g.
'S2A_OPER_MSI_L1C_TL_SGS__20160109T230542_A002870_T10UEV_N02.01')
:type tile_id: str
:param bbox: bounding box of requested area in WGS84 CRS
:type bbox: geometry.BBox
:para... | [
"Constructs",
"dict",
"with",
"URL",
"params"
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/opensearch.py#L171-L195 | train |
sentinel-hub/sentinelhub-py | sentinelhub/aws_safe.py | _edit_name | def _edit_name(name, code, add_code=None, delete_end=False):
"""
Helping function for creating file names in .SAFE format
:param name: initial string
:type name: str
:param code:
:type code: str
:param add_code:
:type add_code: str or None
:param delete_end:
:type delete_end: bo... | python | def _edit_name(name, code, add_code=None, delete_end=False):
"""
Helping function for creating file names in .SAFE format
:param name: initial string
:type name: str
:param code:
:type code: str
:param add_code:
:type add_code: str or None
:param delete_end:
:type delete_end: bo... | [
"def",
"_edit_name",
"(",
"name",
",",
"code",
",",
"add_code",
"=",
"None",
",",
"delete_end",
"=",
"False",
")",
":",
"info",
"=",
"name",
".",
"split",
"(",
"'_'",
")",
"info",
"[",
"2",
"]",
"=",
"code",
"if",
"add_code",
"is",
"not",
"None",
... | Helping function for creating file names in .SAFE format
:param name: initial string
:type name: str
:param code:
:type code: str
:param add_code:
:type add_code: str or None
:param delete_end:
:type delete_end: bool
:return: edited string
:rtype: str | [
"Helping",
"function",
"for",
"creating",
"file",
"names",
"in",
".",
"SAFE",
"format"
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws_safe.py#L362-L383 | train |
sentinel-hub/sentinelhub-py | sentinelhub/aws_safe.py | SafeProduct.get_requests | def get_requests(self):
"""
Creates product structure and returns list of files for download
:return: list of download requests
:rtype: list(download.DownloadRequest)
"""
safe = self.get_safe_struct()
self.download_list = []
self.structure_recursion(safe... | python | def get_requests(self):
"""
Creates product structure and returns list of files for download
:return: list of download requests
:rtype: list(download.DownloadRequest)
"""
safe = self.get_safe_struct()
self.download_list = []
self.structure_recursion(safe... | [
"def",
"get_requests",
"(",
"self",
")",
":",
"safe",
"=",
"self",
".",
"get_safe_struct",
"(",
")",
"self",
".",
"download_list",
"=",
"[",
"]",
"self",
".",
"structure_recursion",
"(",
"safe",
",",
"self",
".",
"parent_folder",
")",
"self",
".",
"sort_... | Creates product structure and returns list of files for download
:return: list of download requests
:rtype: list(download.DownloadRequest) | [
"Creates",
"product",
"structure",
"and",
"returns",
"list",
"of",
"files",
"for",
"download"
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws_safe.py#L14-L26 | train |
sentinel-hub/sentinelhub-py | sentinelhub/aws_safe.py | SafeProduct.get_safe_struct | def get_safe_struct(self):
"""
Describes a structure inside tile folder of ESA product .SAFE structure
:return: nested dictionaries representing .SAFE structure
:rtype: dict
"""
safe = {}
main_folder = self.get_main_folder()
safe[main_folder] = {}
... | python | def get_safe_struct(self):
"""
Describes a structure inside tile folder of ESA product .SAFE structure
:return: nested dictionaries representing .SAFE structure
:rtype: dict
"""
safe = {}
main_folder = self.get_main_folder()
safe[main_folder] = {}
... | [
"def",
"get_safe_struct",
"(",
"self",
")",
":",
"safe",
"=",
"{",
"}",
"main_folder",
"=",
"self",
".",
"get_main_folder",
"(",
")",
"safe",
"[",
"main_folder",
"]",
"=",
"{",
"}",
"safe",
"[",
"main_folder",
"]",
"[",
"AwsConstants",
".",
"AUX_DATA",
... | Describes a structure inside tile folder of ESA product .SAFE structure
:return: nested dictionaries representing .SAFE structure
:rtype: dict | [
"Describes",
"a",
"structure",
"inside",
"tile",
"folder",
"of",
"ESA",
"product",
".",
"SAFE",
"structure"
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws_safe.py#L28-L81 | train |
sentinel-hub/sentinelhub-py | sentinelhub/aws_safe.py | SafeTile.get_tile_id | def get_tile_id(self):
"""Creates ESA tile ID
:return: ESA tile ID
:rtype: str
"""
tree = get_xml(self.get_url(AwsConstants.METADATA))
tile_id_tag = 'TILE_ID_2A' if self.data_source is DataSource.SENTINEL2_L2A and self.baseline <= '02.06' else\
'TILE_ID'
... | python | def get_tile_id(self):
"""Creates ESA tile ID
:return: ESA tile ID
:rtype: str
"""
tree = get_xml(self.get_url(AwsConstants.METADATA))
tile_id_tag = 'TILE_ID_2A' if self.data_source is DataSource.SENTINEL2_L2A and self.baseline <= '02.06' else\
'TILE_ID'
... | [
"def",
"get_tile_id",
"(",
"self",
")",
":",
"tree",
"=",
"get_xml",
"(",
"self",
".",
"get_url",
"(",
"AwsConstants",
".",
"METADATA",
")",
")",
"tile_id_tag",
"=",
"'TILE_ID_2A'",
"if",
"self",
".",
"data_source",
"is",
"DataSource",
".",
"SENTINEL2_L2A",
... | Creates ESA tile ID
:return: ESA tile ID
:rtype: str | [
"Creates",
"ESA",
"tile",
"ID"
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws_safe.py#L250-L264 | train |
sentinel-hub/sentinelhub-py | sentinelhub/areas.py | AreaSplitter._parse_shape_list | def _parse_shape_list(shape_list, crs):
""" Checks if the given list of shapes is in correct format and parses geometry objects
:param shape_list: The parameter `shape_list` from class initialization
:type shape_list: list(shapely.geometry.multipolygon.MultiPolygon or shapely.geometry.polygon.P... | python | def _parse_shape_list(shape_list, crs):
""" Checks if the given list of shapes is in correct format and parses geometry objects
:param shape_list: The parameter `shape_list` from class initialization
:type shape_list: list(shapely.geometry.multipolygon.MultiPolygon or shapely.geometry.polygon.P... | [
"def",
"_parse_shape_list",
"(",
"shape_list",
",",
"crs",
")",
":",
"if",
"not",
"isinstance",
"(",
"shape_list",
",",
"list",
")",
":",
"raise",
"ValueError",
"(",
"'Splitter must be initialized with a list of shapes'",
")",
"return",
"[",
"AreaSplitter",
".",
"... | Checks if the given list of shapes is in correct format and parses geometry objects
:param shape_list: The parameter `shape_list` from class initialization
:type shape_list: list(shapely.geometry.multipolygon.MultiPolygon or shapely.geometry.polygon.Polygon)
:raises: ValueError | [
"Checks",
"if",
"the",
"given",
"list",
"of",
"shapes",
"is",
"in",
"correct",
"format",
"and",
"parses",
"geometry",
"objects"
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/areas.py#L40-L50 | train |
sentinel-hub/sentinelhub-py | sentinelhub/areas.py | AreaSplitter.get_bbox_list | def get_bbox_list(self, crs=None, buffer=None, reduce_bbox_sizes=None):
"""Returns a list of bounding boxes that are the result of the split
:param crs: Coordinate reference system in which the bounding boxes should be returned. If None the CRS will
be the default CRS of the splitte... | python | def get_bbox_list(self, crs=None, buffer=None, reduce_bbox_sizes=None):
"""Returns a list of bounding boxes that are the result of the split
:param crs: Coordinate reference system in which the bounding boxes should be returned. If None the CRS will
be the default CRS of the splitte... | [
"def",
"get_bbox_list",
"(",
"self",
",",
"crs",
"=",
"None",
",",
"buffer",
"=",
"None",
",",
"reduce_bbox_sizes",
"=",
"None",
")",
":",
"bbox_list",
"=",
"self",
".",
"bbox_list",
"if",
"buffer",
":",
"bbox_list",
"=",
"[",
"bbox",
".",
"buffer",
"(... | Returns a list of bounding boxes that are the result of the split
:param crs: Coordinate reference system in which the bounding boxes should be returned. If None the CRS will
be the default CRS of the splitter.
:type crs: CRS or None
:param buffer: A percentage of each BBox ... | [
"Returns",
"a",
"list",
"of",
"bounding",
"boxes",
"that",
"are",
"the",
"result",
"of",
"the",
"split"
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/areas.py#L78-L103 | train |
sentinel-hub/sentinelhub-py | sentinelhub/areas.py | AreaSplitter.get_area_bbox | def get_area_bbox(self, crs=None):
"""Returns a bounding box of the entire area
:param crs: Coordinate reference system in which the bounding box should be returned. If None the CRS will
be the default CRS of the splitter.
:type crs: CRS or None
:return: A bounding b... | python | def get_area_bbox(self, crs=None):
"""Returns a bounding box of the entire area
:param crs: Coordinate reference system in which the bounding box should be returned. If None the CRS will
be the default CRS of the splitter.
:type crs: CRS or None
:return: A bounding b... | [
"def",
"get_area_bbox",
"(",
"self",
",",
"crs",
"=",
"None",
")",
":",
"bbox_list",
"=",
"[",
"BBox",
"(",
"shape",
".",
"bounds",
",",
"crs",
"=",
"self",
".",
"crs",
")",
"for",
"shape",
"in",
"self",
".",
"shape_list",
"]",
"area_minx",
"=",
"m... | Returns a bounding box of the entire area
:param crs: Coordinate reference system in which the bounding box should be returned. If None the CRS will
be the default CRS of the splitter.
:type crs: CRS or None
:return: A bounding box of the area defined by the `shape_list`
... | [
"Returns",
"a",
"bounding",
"box",
"of",
"the",
"entire",
"area"
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/areas.py#L131-L148 | train |
sentinel-hub/sentinelhub-py | sentinelhub/areas.py | AreaSplitter._bbox_to_area_polygon | def _bbox_to_area_polygon(self, bbox):
"""Transforms bounding box into a polygon object in the area CRS.
:param bbox: A bounding box
:type bbox: BBox
:return: A polygon
:rtype: shapely.geometry.polygon.Polygon
"""
projected_bbox = bbox.transform(self.crs)
... | python | def _bbox_to_area_polygon(self, bbox):
"""Transforms bounding box into a polygon object in the area CRS.
:param bbox: A bounding box
:type bbox: BBox
:return: A polygon
:rtype: shapely.geometry.polygon.Polygon
"""
projected_bbox = bbox.transform(self.crs)
... | [
"def",
"_bbox_to_area_polygon",
"(",
"self",
",",
"bbox",
")",
":",
"projected_bbox",
"=",
"bbox",
".",
"transform",
"(",
"self",
".",
"crs",
")",
"return",
"projected_bbox",
".",
"geometry"
] | Transforms bounding box into a polygon object in the area CRS.
:param bbox: A bounding box
:type bbox: BBox
:return: A polygon
:rtype: shapely.geometry.polygon.Polygon | [
"Transforms",
"bounding",
"box",
"into",
"a",
"polygon",
"object",
"in",
"the",
"area",
"CRS",
"."
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/areas.py#L170-L179 | train |
sentinel-hub/sentinelhub-py | sentinelhub/areas.py | AreaSplitter._reduce_sizes | def _reduce_sizes(self, bbox_list):
"""Reduces sizes of bounding boxes
"""
return [BBox(self._intersection_area(bbox).bounds, self.crs).transform(bbox.crs) for bbox in bbox_list] | python | def _reduce_sizes(self, bbox_list):
"""Reduces sizes of bounding boxes
"""
return [BBox(self._intersection_area(bbox).bounds, self.crs).transform(bbox.crs) for bbox in bbox_list] | [
"def",
"_reduce_sizes",
"(",
"self",
",",
"bbox_list",
")",
":",
"return",
"[",
"BBox",
"(",
"self",
".",
"_intersection_area",
"(",
"bbox",
")",
".",
"bounds",
",",
"self",
".",
"crs",
")",
".",
"transform",
"(",
"bbox",
".",
"crs",
")",
"for",
"bbo... | Reduces sizes of bounding boxes | [
"Reduces",
"sizes",
"of",
"bounding",
"boxes"
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/areas.py#L181-L184 | train |
sentinel-hub/sentinelhub-py | sentinelhub/areas.py | BBoxSplitter._parse_split_shape | def _parse_split_shape(split_shape):
"""Parses the parameter `split_shape`
:param split_shape: The parameter `split_shape` from class initialization
:type split_shape: int or (int, int)
:return: A tuple of n
:rtype: (int, int)
:raises: ValueError
"""
if i... | python | def _parse_split_shape(split_shape):
"""Parses the parameter `split_shape`
:param split_shape: The parameter `split_shape` from class initialization
:type split_shape: int or (int, int)
:return: A tuple of n
:rtype: (int, int)
:raises: ValueError
"""
if i... | [
"def",
"_parse_split_shape",
"(",
"split_shape",
")",
":",
"if",
"isinstance",
"(",
"split_shape",
",",
"int",
")",
":",
"return",
"split_shape",
",",
"split_shape",
"if",
"isinstance",
"(",
"split_shape",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"if... | Parses the parameter `split_shape`
:param split_shape: The parameter `split_shape` from class initialization
:type split_shape: int or (int, int)
:return: A tuple of n
:rtype: (int, int)
:raises: ValueError | [
"Parses",
"the",
"parameter",
"split_shape"
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/areas.py#L212-L227 | train |
sentinel-hub/sentinelhub-py | sentinelhub/areas.py | OsmSplitter._recursive_split | def _recursive_split(self, bbox, zoom_level, column, row):
"""Method that recursively creates bounding boxes of OSM grid that intersect the area.
:param bbox: Bounding box
:type bbox: BBox
:param zoom_level: OSM zoom level
:type zoom_level: int
:param column: Column in t... | python | def _recursive_split(self, bbox, zoom_level, column, row):
"""Method that recursively creates bounding boxes of OSM grid that intersect the area.
:param bbox: Bounding box
:type bbox: BBox
:param zoom_level: OSM zoom level
:type zoom_level: int
:param column: Column in t... | [
"def",
"_recursive_split",
"(",
"self",
",",
"bbox",
",",
"zoom_level",
",",
"column",
",",
"row",
")",
":",
"if",
"zoom_level",
"==",
"self",
".",
"zoom_level",
":",
"self",
".",
"bbox_list",
".",
"append",
"(",
"bbox",
")",
"self",
".",
"info_list",
... | Method that recursively creates bounding boxes of OSM grid that intersect the area.
:param bbox: Bounding box
:type bbox: BBox
:param zoom_level: OSM zoom level
:type zoom_level: int
:param column: Column in the OSM grid
:type column: int
:param row: Row in the O... | [
"Method",
"that",
"recursively",
"creates",
"bounding",
"boxes",
"of",
"OSM",
"grid",
"that",
"intersect",
"the",
"area",
"."
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/areas.py#L303-L325 | train |
sentinel-hub/sentinelhub-py | sentinelhub/areas.py | CustomGridSplitter._parse_bbox_grid | def _parse_bbox_grid(bbox_grid):
""" Helper method for parsing bounding box grid. It will try to parse it into `BBoxCollection`
"""
if isinstance(bbox_grid, BBoxCollection):
return bbox_grid
if isinstance(bbox_grid, list):
return BBoxCollection(bbox_grid)
... | python | def _parse_bbox_grid(bbox_grid):
""" Helper method for parsing bounding box grid. It will try to parse it into `BBoxCollection`
"""
if isinstance(bbox_grid, BBoxCollection):
return bbox_grid
if isinstance(bbox_grid, list):
return BBoxCollection(bbox_grid)
... | [
"def",
"_parse_bbox_grid",
"(",
"bbox_grid",
")",
":",
"if",
"isinstance",
"(",
"bbox_grid",
",",
"BBoxCollection",
")",
":",
"return",
"bbox_grid",
"if",
"isinstance",
"(",
"bbox_grid",
",",
"list",
")",
":",
"return",
"BBoxCollection",
"(",
"bbox_grid",
")",... | Helper method for parsing bounding box grid. It will try to parse it into `BBoxCollection` | [
"Helper",
"method",
"for",
"parsing",
"bounding",
"box",
"grid",
".",
"It",
"will",
"try",
"to",
"parse",
"it",
"into",
"BBoxCollection"
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/areas.py#L446-L455 | train |
sentinel-hub/sentinelhub-py | sentinelhub/aws.py | AwsService._parse_metafiles | def _parse_metafiles(self, metafile_input):
"""
Parses class input and verifies metadata file names.
:param metafile_input: class input parameter `metafiles`
:type metafile_input: str or list(str) or None
:return: verified list of metadata files
:rtype: list(str)
... | python | def _parse_metafiles(self, metafile_input):
"""
Parses class input and verifies metadata file names.
:param metafile_input: class input parameter `metafiles`
:type metafile_input: str or list(str) or None
:return: verified list of metadata files
:rtype: list(str)
... | [
"def",
"_parse_metafiles",
"(",
"self",
",",
"metafile_input",
")",
":",
"all_metafiles",
"=",
"AwsConstants",
".",
"S2_L1C_METAFILES",
"if",
"self",
".",
"data_source",
"is",
"DataSource",
".",
"SENTINEL2_L1C",
"else",
"AwsConstants",
".",
"S2_L2A_METAFILES",
"if",... | Parses class input and verifies metadata file names.
:param metafile_input: class input parameter `metafiles`
:type metafile_input: str or list(str) or None
:return: verified list of metadata files
:rtype: list(str) | [
"Parses",
"class",
"input",
"and",
"verifies",
"metadata",
"file",
"names",
"."
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws.py#L74-L102 | train |
sentinel-hub/sentinelhub-py | sentinelhub/aws.py | AwsService.get_base_url | def get_base_url(self, force_http=False):
""" Creates base URL path
:param force_http: `True` if HTTP base URL should be used and `False` otherwise
:type force_http: str
:return: base url string
:rtype: str
"""
base_url = SHConfig().aws_metadata_url.rstrip('/') i... | python | def get_base_url(self, force_http=False):
""" Creates base URL path
:param force_http: `True` if HTTP base URL should be used and `False` otherwise
:type force_http: str
:return: base url string
:rtype: str
"""
base_url = SHConfig().aws_metadata_url.rstrip('/') i... | [
"def",
"get_base_url",
"(",
"self",
",",
"force_http",
"=",
"False",
")",
":",
"base_url",
"=",
"SHConfig",
"(",
")",
".",
"aws_metadata_url",
".",
"rstrip",
"(",
"'/'",
")",
"if",
"force_http",
"else",
"'s3:/'",
"aws_bucket",
"=",
"SHConfig",
"(",
")",
... | Creates base URL path
:param force_http: `True` if HTTP base URL should be used and `False` otherwise
:type force_http: str
:return: base url string
:rtype: str | [
"Creates",
"base",
"URL",
"path"
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws.py#L104-L116 | train |
sentinel-hub/sentinelhub-py | sentinelhub/aws.py | AwsService.get_safe_type | def get_safe_type(self):
"""Determines the type of ESA product.
In 2016 ESA changed structure and naming of data. Therefore the class must
distinguish between old product type and compact (new) product type.
:return: type of ESA product
:rtype: constants.EsaSafeType
:ra... | python | def get_safe_type(self):
"""Determines the type of ESA product.
In 2016 ESA changed structure and naming of data. Therefore the class must
distinguish between old product type and compact (new) product type.
:return: type of ESA product
:rtype: constants.EsaSafeType
:ra... | [
"def",
"get_safe_type",
"(",
"self",
")",
":",
"product_type",
"=",
"self",
".",
"product_id",
".",
"split",
"(",
"'_'",
")",
"[",
"1",
"]",
"if",
"product_type",
".",
"startswith",
"(",
"'MSI'",
")",
":",
"return",
"EsaSafeType",
".",
"COMPACT_TYPE",
"i... | Determines the type of ESA product.
In 2016 ESA changed structure and naming of data. Therefore the class must
distinguish between old product type and compact (new) product type.
:return: type of ESA product
:rtype: constants.EsaSafeType
:raises: ValueError | [
"Determines",
"the",
"type",
"of",
"ESA",
"product",
"."
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws.py#L118-L133 | train |
sentinel-hub/sentinelhub-py | sentinelhub/aws.py | AwsService._read_baseline_from_info | def _read_baseline_from_info(self):
"""Tries to find and return baseline number from either tileInfo or productInfo file.
:return: Baseline ID
:rtype: str
:raises: ValueError
"""
if hasattr(self, 'tile_info'):
return self.tile_info['datastrip']['id'][-5:]
... | python | def _read_baseline_from_info(self):
"""Tries to find and return baseline number from either tileInfo or productInfo file.
:return: Baseline ID
:rtype: str
:raises: ValueError
"""
if hasattr(self, 'tile_info'):
return self.tile_info['datastrip']['id'][-5:]
... | [
"def",
"_read_baseline_from_info",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'tile_info'",
")",
":",
"return",
"self",
".",
"tile_info",
"[",
"'datastrip'",
"]",
"[",
"'id'",
"]",
"[",
"-",
"5",
":",
"]",
"if",
"hasattr",
"(",
"self",
... | Tries to find and return baseline number from either tileInfo or productInfo file.
:return: Baseline ID
:rtype: str
:raises: ValueError | [
"Tries",
"to",
"find",
"and",
"return",
"baseline",
"number",
"from",
"either",
"tileInfo",
"or",
"productInfo",
"file",
"."
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws.py#L149-L160 | train |
sentinel-hub/sentinelhub-py | sentinelhub/aws.py | AwsService.url_to_tile | def url_to_tile(url):
"""
Extracts tile name, date and AWS index from tile url on AWS.
:param url: class input parameter 'metafiles'
:type url: str
:return: Name of tile, date and AWS index which uniquely identifies tile on AWS
:rtype: (str, str, int)
"""
... | python | def url_to_tile(url):
"""
Extracts tile name, date and AWS index from tile url on AWS.
:param url: class input parameter 'metafiles'
:type url: str
:return: Name of tile, date and AWS index which uniquely identifies tile on AWS
:rtype: (str, str, int)
"""
... | [
"def",
"url_to_tile",
"(",
"url",
")",
":",
"info",
"=",
"url",
".",
"strip",
"(",
"'/'",
")",
".",
"split",
"(",
"'/'",
")",
"name",
"=",
"''",
".",
"join",
"(",
"info",
"[",
"-",
"7",
":",
"-",
"4",
"]",
")",
"date",
"=",
"'-'",
".",
"joi... | Extracts tile name, date and AWS index from tile url on AWS.
:param url: class input parameter 'metafiles'
:type url: str
:return: Name of tile, date and AWS index which uniquely identifies tile on AWS
:rtype: (str, str, int) | [
"Extracts",
"tile",
"name",
"date",
"and",
"AWS",
"index",
"from",
"tile",
"url",
"on",
"AWS",
"."
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws.py#L163-L175 | train |
sentinel-hub/sentinelhub-py | sentinelhub/aws.py | AwsService.structure_recursion | def structure_recursion(self, struct, folder):
"""
From nested dictionaries representing .SAFE structure it recursively extracts all the files that need to be
downloaded and stores them into class attribute `download_list`.
:param struct: nested dictionaries representing a part of .SAFE... | python | def structure_recursion(self, struct, folder):
"""
From nested dictionaries representing .SAFE structure it recursively extracts all the files that need to be
downloaded and stores them into class attribute `download_list`.
:param struct: nested dictionaries representing a part of .SAFE... | [
"def",
"structure_recursion",
"(",
"self",
",",
"struct",
",",
"folder",
")",
":",
"has_subfolder",
"=",
"False",
"for",
"name",
",",
"substruct",
"in",
"struct",
".",
"items",
"(",
")",
":",
"subfolder",
"=",
"os",
".",
"path",
".",
"join",
"(",
"fold... | From nested dictionaries representing .SAFE structure it recursively extracts all the files that need to be
downloaded and stores them into class attribute `download_list`.
:param struct: nested dictionaries representing a part of .SAFE structure
:type struct: dict
:param folder: name o... | [
"From",
"nested",
"dictionaries",
"representing",
".",
"SAFE",
"structure",
"it",
"recursively",
"extracts",
"all",
"the",
"files",
"that",
"need",
"to",
"be",
"downloaded",
"and",
"stores",
"them",
"into",
"class",
"attribute",
"download_list",
"."
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws.py#L194-L221 | train |
sentinel-hub/sentinelhub-py | sentinelhub/aws.py | AwsService.add_file_extension | def add_file_extension(filename, data_format=None, remove_path=False):
"""Joins filename and corresponding file extension if it has one.
:param filename: Name of the file without extension
:type filename: str
:param data_format: format of file, if None it will be set automatically
... | python | def add_file_extension(filename, data_format=None, remove_path=False):
"""Joins filename and corresponding file extension if it has one.
:param filename: Name of the file without extension
:type filename: str
:param data_format: format of file, if None it will be set automatically
... | [
"def",
"add_file_extension",
"(",
"filename",
",",
"data_format",
"=",
"None",
",",
"remove_path",
"=",
"False",
")",
":",
"if",
"data_format",
"is",
"None",
":",
"data_format",
"=",
"AwsConstants",
".",
"AWS_FILES",
"[",
"filename",
"]",
"if",
"remove_path",
... | Joins filename and corresponding file extension if it has one.
:param filename: Name of the file without extension
:type filename: str
:param data_format: format of file, if None it will be set automatically
:type data_format: constants.MimeType or None
:param remove_path: True ... | [
"Joins",
"filename",
"and",
"corresponding",
"file",
"extension",
"if",
"it",
"has",
"one",
"."
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws.py#L244-L264 | train |
sentinel-hub/sentinelhub-py | sentinelhub/aws.py | AwsService.is_early_compact_l2a | def is_early_compact_l2a(self):
"""Check if product is early version of compact L2A product
:return: True if product is early version of compact L2A product and False otherwise
:rtype: bool
"""
return self.data_source is DataSource.SENTINEL2_L2A and self.safe_type is EsaSafeType... | python | def is_early_compact_l2a(self):
"""Check if product is early version of compact L2A product
:return: True if product is early version of compact L2A product and False otherwise
:rtype: bool
"""
return self.data_source is DataSource.SENTINEL2_L2A and self.safe_type is EsaSafeType... | [
"def",
"is_early_compact_l2a",
"(",
"self",
")",
":",
"return",
"self",
".",
"data_source",
"is",
"DataSource",
".",
"SENTINEL2_L2A",
"and",
"self",
".",
"safe_type",
"is",
"EsaSafeType",
".",
"COMPACT_TYPE",
"and",
"self",
".",
"baseline",
"<=",
"'02.06'"
] | Check if product is early version of compact L2A product
:return: True if product is early version of compact L2A product and False otherwise
:rtype: bool | [
"Check",
"if",
"product",
"is",
"early",
"version",
"of",
"compact",
"L2A",
"product"
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws.py#L275-L282 | train |
sentinel-hub/sentinelhub-py | sentinelhub/aws.py | AwsProduct.get_requests | def get_requests(self):
"""
Creates product structure and returns list of files for download.
:return: List of download requests and list of empty folders that need to be created
:rtype: (list(download.DownloadRequest), list(str))
"""
self.download_list = [DownloadReques... | python | def get_requests(self):
"""
Creates product structure and returns list of files for download.
:return: List of download requests and list of empty folders that need to be created
:rtype: (list(download.DownloadRequest), list(str))
"""
self.download_list = [DownloadReques... | [
"def",
"get_requests",
"(",
"self",
")",
":",
"self",
".",
"download_list",
"=",
"[",
"DownloadRequest",
"(",
"url",
"=",
"self",
".",
"get_url",
"(",
"metafile",
")",
",",
"filename",
"=",
"self",
".",
"get_filepath",
"(",
"metafile",
")",
",",
"data_ty... | Creates product structure and returns list of files for download.
:return: List of download requests and list of empty folders that need to be created
:rtype: (list(download.DownloadRequest), list(str)) | [
"Creates",
"product",
"structure",
"and",
"returns",
"list",
"of",
"files",
"for",
"download",
"."
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws.py#L337-L358 | train |
sentinel-hub/sentinelhub-py | sentinelhub/aws.py | AwsProduct.get_data_source | def get_data_source(self):
"""The method determines data source from product ID.
:return: Data source of the product
:rtype: DataSource
:raises: ValueError
"""
product_type = self.product_id.split('_')[1]
if product_type.endswith('L1C') or product_type == 'OPER':... | python | def get_data_source(self):
"""The method determines data source from product ID.
:return: Data source of the product
:rtype: DataSource
:raises: ValueError
"""
product_type = self.product_id.split('_')[1]
if product_type.endswith('L1C') or product_type == 'OPER':... | [
"def",
"get_data_source",
"(",
"self",
")",
":",
"product_type",
"=",
"self",
".",
"product_id",
".",
"split",
"(",
"'_'",
")",
"[",
"1",
"]",
"if",
"product_type",
".",
"endswith",
"(",
"'L1C'",
")",
"or",
"product_type",
"==",
"'OPER'",
":",
"return",
... | The method determines data source from product ID.
:return: Data source of the product
:rtype: DataSource
:raises: ValueError | [
"The",
"method",
"determines",
"data",
"source",
"from",
"product",
"ID",
"."
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws.py#L360-L372 | train |
sentinel-hub/sentinelhub-py | sentinelhub/aws.py | AwsProduct.get_date | def get_date(self):
""" Collects sensing date of the product.
:return: Sensing date
:rtype: str
"""
if self.safe_type == EsaSafeType.OLD_TYPE:
name = self.product_id.split('_')[-2]
date = [name[1:5], name[5:7], name[7:9]]
else:
name = ... | python | def get_date(self):
""" Collects sensing date of the product.
:return: Sensing date
:rtype: str
"""
if self.safe_type == EsaSafeType.OLD_TYPE:
name = self.product_id.split('_')[-2]
date = [name[1:5], name[5:7], name[7:9]]
else:
name = ... | [
"def",
"get_date",
"(",
"self",
")",
":",
"if",
"self",
".",
"safe_type",
"==",
"EsaSafeType",
".",
"OLD_TYPE",
":",
"name",
"=",
"self",
".",
"product_id",
".",
"split",
"(",
"'_'",
")",
"[",
"-",
"2",
"]",
"date",
"=",
"[",
"name",
"[",
"1",
":... | Collects sensing date of the product.
:return: Sensing date
:rtype: str | [
"Collects",
"sensing",
"date",
"of",
"the",
"product",
"."
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws.py#L374-L386 | train |
sentinel-hub/sentinelhub-py | sentinelhub/aws.py | AwsProduct.get_product_url | def get_product_url(self, force_http=False):
"""
Creates base url of product location on AWS.
:param force_http: True if HTTP base URL should be used and False otherwise
:type force_http: str
:return: url of product location
:rtype: str
"""
base_url = sel... | python | def get_product_url(self, force_http=False):
"""
Creates base url of product location on AWS.
:param force_http: True if HTTP base URL should be used and False otherwise
:type force_http: str
:return: url of product location
:rtype: str
"""
base_url = sel... | [
"def",
"get_product_url",
"(",
"self",
",",
"force_http",
"=",
"False",
")",
":",
"base_url",
"=",
"self",
".",
"base_http_url",
"if",
"force_http",
"else",
"self",
".",
"base_url",
"return",
"'{}products/{}/{}'",
".",
"format",
"(",
"base_url",
",",
"self",
... | Creates base url of product location on AWS.
:param force_http: True if HTTP base URL should be used and False otherwise
:type force_http: str
:return: url of product location
:rtype: str | [
"Creates",
"base",
"url",
"of",
"product",
"location",
"on",
"AWS",
"."
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws.py#L405-L415 | train |
sentinel-hub/sentinelhub-py | sentinelhub/aws.py | AwsTile.parse_tile_name | def parse_tile_name(name):
"""
Parses and verifies tile name.
:param name: class input parameter `tile_name`
:type name: str
:return: parsed tile name
:rtype: str
"""
tile_name = name.lstrip('T0')
if len(tile_name) == 4:
tile_name = '0... | python | def parse_tile_name(name):
"""
Parses and verifies tile name.
:param name: class input parameter `tile_name`
:type name: str
:return: parsed tile name
:rtype: str
"""
tile_name = name.lstrip('T0')
if len(tile_name) == 4:
tile_name = '0... | [
"def",
"parse_tile_name",
"(",
"name",
")",
":",
"tile_name",
"=",
"name",
".",
"lstrip",
"(",
"'T0'",
")",
"if",
"len",
"(",
"tile_name",
")",
"==",
"4",
":",
"tile_name",
"=",
"'0'",
"+",
"tile_name",
"if",
"len",
"(",
"tile_name",
")",
"!=",
"5",
... | Parses and verifies tile name.
:param name: class input parameter `tile_name`
:type name: str
:return: parsed tile name
:rtype: str | [
"Parses",
"and",
"verifies",
"tile",
"name",
"."
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws.py#L485-L499 | train |
sentinel-hub/sentinelhub-py | sentinelhub/aws.py | AwsTile.get_requests | def get_requests(self):
"""
Creates tile structure and returns list of files for download.
:return: List of download requests and list of empty folders that need to be created
:rtype: (list(download.DownloadRequest), list(str))
"""
self.download_list = []
for dat... | python | def get_requests(self):
"""
Creates tile structure and returns list of files for download.
:return: List of download requests and list of empty folders that need to be created
:rtype: (list(download.DownloadRequest), list(str))
"""
self.download_list = []
for dat... | [
"def",
"get_requests",
"(",
"self",
")",
":",
"self",
".",
"download_list",
"=",
"[",
"]",
"for",
"data_name",
"in",
"[",
"band",
"for",
"band",
"in",
"self",
".",
"bands",
"if",
"self",
".",
"_band_exists",
"(",
"band",
")",
"]",
"+",
"self",
".",
... | Creates tile structure and returns list of files for download.
:return: List of download requests and list of empty folders that need to be created
:rtype: (list(download.DownloadRequest), list(str)) | [
"Creates",
"tile",
"structure",
"and",
"returns",
"list",
"of",
"files",
"for",
"download",
"."
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws.py#L516-L532 | train |
sentinel-hub/sentinelhub-py | sentinelhub/aws.py | AwsTile.get_aws_index | def get_aws_index(self):
"""
Returns tile index on AWS. If `tile_index` was not set during class initialization it will be determined
according to existing tiles on AWS.
:return: Index of tile on AWS
:rtype: int
"""
if self.aws_index is not None:
retu... | python | def get_aws_index(self):
"""
Returns tile index on AWS. If `tile_index` was not set during class initialization it will be determined
according to existing tiles on AWS.
:return: Index of tile on AWS
:rtype: int
"""
if self.aws_index is not None:
retu... | [
"def",
"get_aws_index",
"(",
"self",
")",
":",
"if",
"self",
".",
"aws_index",
"is",
"not",
"None",
":",
"return",
"self",
".",
"aws_index",
"tile_info_list",
"=",
"get_tile_info",
"(",
"self",
".",
"tile_name",
",",
"self",
".",
"datetime",
",",
"all_tile... | Returns tile index on AWS. If `tile_index` was not set during class initialization it will be determined
according to existing tiles on AWS.
:return: Index of tile on AWS
:rtype: int | [
"Returns",
"tile",
"index",
"on",
"AWS",
".",
"If",
"tile_index",
"was",
"not",
"set",
"during",
"class",
"initialization",
"it",
"will",
"be",
"determined",
"according",
"to",
"existing",
"tiles",
"on",
"AWS",
"."
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws.py#L534-L557 | train |
sentinel-hub/sentinelhub-py | sentinelhub/aws.py | AwsTile.tile_is_valid | def tile_is_valid(self):
""" Checks if tile has tile info and valid timestamp
:return: `True` if tile is valid and `False` otherwise
:rtype: bool
"""
return self.tile_info is not None \
and (self.datetime == self.date or self.datetime == self.parse_datetime(self.tile... | python | def tile_is_valid(self):
""" Checks if tile has tile info and valid timestamp
:return: `True` if tile is valid and `False` otherwise
:rtype: bool
"""
return self.tile_info is not None \
and (self.datetime == self.date or self.datetime == self.parse_datetime(self.tile... | [
"def",
"tile_is_valid",
"(",
"self",
")",
":",
"return",
"self",
".",
"tile_info",
"is",
"not",
"None",
"and",
"(",
"self",
".",
"datetime",
"==",
"self",
".",
"date",
"or",
"self",
".",
"datetime",
"==",
"self",
".",
"parse_datetime",
"(",
"self",
"."... | Checks if tile has tile info and valid timestamp
:return: `True` if tile is valid and `False` otherwise
:rtype: bool | [
"Checks",
"if",
"tile",
"has",
"tile",
"info",
"and",
"valid",
"timestamp"
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws.py#L570-L577 | train |
sentinel-hub/sentinelhub-py | sentinelhub/aws.py | AwsTile.get_tile_url | def get_tile_url(self, force_http=False):
"""
Creates base url of tile location on AWS.
:param force_http: True if HTTP base URL should be used and False otherwise
:type force_http: str
:return: url of tile location
:rtype: str
"""
base_url = self.base_ht... | python | def get_tile_url(self, force_http=False):
"""
Creates base url of tile location on AWS.
:param force_http: True if HTTP base URL should be used and False otherwise
:type force_http: str
:return: url of tile location
:rtype: str
"""
base_url = self.base_ht... | [
"def",
"get_tile_url",
"(",
"self",
",",
"force_http",
"=",
"False",
")",
":",
"base_url",
"=",
"self",
".",
"base_http_url",
"if",
"force_http",
"else",
"self",
".",
"base_url",
"url",
"=",
"'{}tiles/{}/{}/{}/'",
".",
"format",
"(",
"base_url",
",",
"self",... | Creates base url of tile location on AWS.
:param force_http: True if HTTP base URL should be used and False otherwise
:type force_http: str
:return: url of tile location
:rtype: str | [
"Creates",
"base",
"url",
"of",
"tile",
"location",
"on",
"AWS",
"."
] | 08a83b7f1e289187159a643336995d8369860fea | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws.py#L603-L618 | train |
ethereum/pyethereum | ethereum/abi.py | split32 | def split32(data):
""" Split data into pieces of 32 bytes. """
all_pieces = []
for position in range(0, len(data), 32):
piece = data[position:position + 32]
all_pieces.append(piece)
return all_pieces | python | def split32(data):
""" Split data into pieces of 32 bytes. """
all_pieces = []
for position in range(0, len(data), 32):
piece = data[position:position + 32]
all_pieces.append(piece)
return all_pieces | [
"def",
"split32",
"(",
"data",
")",
":",
"all_pieces",
"=",
"[",
"]",
"for",
"position",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"data",
")",
",",
"32",
")",
":",
"piece",
"=",
"data",
"[",
"position",
":",
"position",
"+",
"32",
"]",
"all_piec... | Split data into pieces of 32 bytes. | [
"Split",
"data",
"into",
"pieces",
"of",
"32",
"bytes",
"."
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/abi.py#L38-L46 | train |
ethereum/pyethereum | ethereum/abi.py | _canonical_type | def _canonical_type(name): # pylint: disable=too-many-return-statements
""" Replace aliases to the corresponding type to compute the ids. """
if name == 'int':
return 'int256'
if name == 'uint':
return 'uint256'
if name == 'fixed':
return 'fixed128x128'
if name == 'ufixe... | python | def _canonical_type(name): # pylint: disable=too-many-return-statements
""" Replace aliases to the corresponding type to compute the ids. """
if name == 'int':
return 'int256'
if name == 'uint':
return 'uint256'
if name == 'fixed':
return 'fixed128x128'
if name == 'ufixe... | [
"def",
"_canonical_type",
"(",
"name",
")",
":",
"if",
"name",
"==",
"'int'",
":",
"return",
"'int256'",
"if",
"name",
"==",
"'uint'",
":",
"return",
"'uint256'",
"if",
"name",
"==",
"'fixed'",
":",
"return",
"'fixed128x128'",
"if",
"name",
"==",
"'ufixed'... | Replace aliases to the corresponding type to compute the ids. | [
"Replace",
"aliases",
"to",
"the",
"corresponding",
"type",
"to",
"compute",
"the",
"ids",
"."
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/abi.py#L49-L76 | train |
ethereum/pyethereum | ethereum/abi.py | method_id | def method_id(name, encode_types):
""" Return the unique method id.
The signature is defined as the canonical expression of the basic
prototype, i.e. the function name with the parenthesised list of parameter
types. Parameter types are split by a single comma - no spaces are used.
The method id is... | python | def method_id(name, encode_types):
""" Return the unique method id.
The signature is defined as the canonical expression of the basic
prototype, i.e. the function name with the parenthesised list of parameter
types. Parameter types are split by a single comma - no spaces are used.
The method id is... | [
"def",
"method_id",
"(",
"name",
",",
"encode_types",
")",
":",
"function_types",
"=",
"[",
"_canonical_type",
"(",
"type_",
")",
"for",
"type_",
"in",
"encode_types",
"]",
"function_signature",
"=",
"'{function_name}({canonical_types})'",
".",
"format",
"(",
"fun... | Return the unique method id.
The signature is defined as the canonical expression of the basic
prototype, i.e. the function name with the parenthesised list of parameter
types. Parameter types are split by a single comma - no spaces are used.
The method id is defined as the first four bytes (left, hig... | [
"Return",
"the",
"unique",
"method",
"id",
"."
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/abi.py#L87-L110 | train |
ethereum/pyethereum | ethereum/abi.py | event_id | def event_id(name, encode_types):
""" Return the event id.
Defined as:
`keccak(EVENT_NAME+"("+EVENT_ARGS.map(canonical_type_of).join(",")+")")`
Where `canonical_type_of` is a function that simply returns the canonical
type of a given argument, e.g. for uint indexed foo, it would return
ui... | python | def event_id(name, encode_types):
""" Return the event id.
Defined as:
`keccak(EVENT_NAME+"("+EVENT_ARGS.map(canonical_type_of).join(",")+")")`
Where `canonical_type_of` is a function that simply returns the canonical
type of a given argument, e.g. for uint indexed foo, it would return
ui... | [
"def",
"event_id",
"(",
"name",
",",
"encode_types",
")",
":",
"event_types",
"=",
"[",
"_canonical_type",
"(",
"type_",
")",
"for",
"type_",
"in",
"encode_types",
"]",
"event_signature",
"=",
"'{event_name}({canonical_types})'",
".",
"format",
"(",
"event_name",
... | Return the event id.
Defined as:
`keccak(EVENT_NAME+"("+EVENT_ARGS.map(canonical_type_of).join(",")+")")`
Where `canonical_type_of` is a function that simply returns the canonical
type of a given argument, e.g. for uint indexed foo, it would return
uint256). Note the lack of spaces. | [
"Return",
"the",
"event",
"id",
"."
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/abi.py#L113-L135 | train |
ethereum/pyethereum | ethereum/abi.py | ContractTranslator.encode_function_call | def encode_function_call(self, function_name, args):
""" Return the encoded function call.
Args:
function_name (str): One of the existing functions described in the
contract interface.
args (List[object]): The function arguments that wll be encoded and
... | python | def encode_function_call(self, function_name, args):
""" Return the encoded function call.
Args:
function_name (str): One of the existing functions described in the
contract interface.
args (List[object]): The function arguments that wll be encoded and
... | [
"def",
"encode_function_call",
"(",
"self",
",",
"function_name",
",",
"args",
")",
":",
"if",
"function_name",
"not",
"in",
"self",
".",
"function_data",
":",
"raise",
"ValueError",
"(",
"'Unkown function {}'",
".",
"format",
"(",
"function_name",
")",
")",
"... | Return the encoded function call.
Args:
function_name (str): One of the existing functions described in the
contract interface.
args (List[object]): The function arguments that wll be encoded and
used in the contract execution in the vm.
Return:
... | [
"Return",
"the",
"encoded",
"function",
"call",
"."
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/abi.py#L502-L524 | train |
ethereum/pyethereum | ethereum/abi.py | ContractTranslator.decode_function_result | def decode_function_result(self, function_name, data):
""" Return the function call result decoded.
Args:
function_name (str): One of the existing functions described in the
contract interface.
data (bin): The encoded result from calling `function_name`.
... | python | def decode_function_result(self, function_name, data):
""" Return the function call result decoded.
Args:
function_name (str): One of the existing functions described in the
contract interface.
data (bin): The encoded result from calling `function_name`.
... | [
"def",
"decode_function_result",
"(",
"self",
",",
"function_name",
",",
"data",
")",
":",
"description",
"=",
"self",
".",
"function_data",
"[",
"function_name",
"]",
"arguments",
"=",
"decode_abi",
"(",
"description",
"[",
"'decode_types'",
"]",
",",
"data",
... | Return the function call result decoded.
Args:
function_name (str): One of the existing functions described in the
contract interface.
data (bin): The encoded result from calling `function_name`.
Return:
List[object]: The values returned by the call ... | [
"Return",
"the",
"function",
"call",
"result",
"decoded",
"."
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/abi.py#L526-L539 | train |
ethereum/pyethereum | ethereum/abi.py | ContractTranslator.encode_constructor_arguments | def encode_constructor_arguments(self, args):
""" Return the encoded constructor call. """
if self.constructor_data is None:
raise ValueError(
"The contract interface didn't have a constructor")
return encode_abi(self.constructor_data['encode_types'], args) | python | def encode_constructor_arguments(self, args):
""" Return the encoded constructor call. """
if self.constructor_data is None:
raise ValueError(
"The contract interface didn't have a constructor")
return encode_abi(self.constructor_data['encode_types'], args) | [
"def",
"encode_constructor_arguments",
"(",
"self",
",",
"args",
")",
":",
"if",
"self",
".",
"constructor_data",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"The contract interface didn't have a constructor\"",
")",
"return",
"encode_abi",
"(",
"self",
".",
"c... | Return the encoded constructor call. | [
"Return",
"the",
"encoded",
"constructor",
"call",
"."
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/abi.py#L541-L547 | train |
ethereum/pyethereum | ethereum/abi.py | ContractTranslator.decode_event | def decode_event(self, log_topics, log_data):
""" Return a dictionary representation the log.
Note:
This function won't work with anonymous events.
Args:
log_topics (List[bin]): The log's indexed arguments.
log_data (bin): The encoded non-indexed arguments.
... | python | def decode_event(self, log_topics, log_data):
""" Return a dictionary representation the log.
Note:
This function won't work with anonymous events.
Args:
log_topics (List[bin]): The log's indexed arguments.
log_data (bin): The encoded non-indexed arguments.
... | [
"def",
"decode_event",
"(",
"self",
",",
"log_topics",
",",
"log_data",
")",
":",
"if",
"not",
"len",
"(",
"log_topics",
")",
"or",
"log_topics",
"[",
"0",
"]",
"not",
"in",
"self",
".",
"event_data",
":",
"raise",
"ValueError",
"(",
"'Unknown log type'",
... | Return a dictionary representation the log.
Note:
This function won't work with anonymous events.
Args:
log_topics (List[bin]): The log's indexed arguments.
log_data (bin): The encoded non-indexed arguments. | [
"Return",
"a",
"dictionary",
"representation",
"the",
"log",
"."
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/abi.py#L549-L601 | train |
ethereum/pyethereum | ethereum/abi.py | ContractTranslator.listen | def listen(self, log, noprint=True):
"""
Return a dictionary representation of the Log instance.
Note:
This function won't work with anonymous events.
Args:
log (processblock.Log): The Log instance that needs to be parsed.
noprint (bool): Flag to tur... | python | def listen(self, log, noprint=True):
"""
Return a dictionary representation of the Log instance.
Note:
This function won't work with anonymous events.
Args:
log (processblock.Log): The Log instance that needs to be parsed.
noprint (bool): Flag to tur... | [
"def",
"listen",
"(",
"self",
",",
"log",
",",
"noprint",
"=",
"True",
")",
":",
"try",
":",
"result",
"=",
"self",
".",
"decode_event",
"(",
"log",
".",
"topics",
",",
"log",
".",
"data",
")",
"except",
"ValueError",
":",
"return",
"if",
"not",
"n... | Return a dictionary representation of the Log instance.
Note:
This function won't work with anonymous events.
Args:
log (processblock.Log): The Log instance that needs to be parsed.
noprint (bool): Flag to turn off priting of the decoded log instance. | [
"Return",
"a",
"dictionary",
"representation",
"of",
"the",
"Log",
"instance",
"."
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/abi.py#L603-L622 | train |
ethereum/pyethereum | ethereum/experimental/pruning_trie.py | unpack_to_nibbles | def unpack_to_nibbles(bindata):
"""unpack packed binary data to nibbles
:param bindata: binary packed from nibbles
:return: nibbles sequence, may have a terminator
"""
o = bin_to_nibbles(bindata)
flags = o[0]
if flags & 2:
o.append(NIBBLE_TERMINATOR)
if flags & 1 == 1:
o... | python | def unpack_to_nibbles(bindata):
"""unpack packed binary data to nibbles
:param bindata: binary packed from nibbles
:return: nibbles sequence, may have a terminator
"""
o = bin_to_nibbles(bindata)
flags = o[0]
if flags & 2:
o.append(NIBBLE_TERMINATOR)
if flags & 1 == 1:
o... | [
"def",
"unpack_to_nibbles",
"(",
"bindata",
")",
":",
"o",
"=",
"bin_to_nibbles",
"(",
"bindata",
")",
"flags",
"=",
"o",
"[",
"0",
"]",
"if",
"flags",
"&",
"2",
":",
"o",
".",
"append",
"(",
"NIBBLE_TERMINATOR",
")",
"if",
"flags",
"&",
"1",
"==",
... | unpack packed binary data to nibbles
:param bindata: binary packed from nibbles
:return: nibbles sequence, may have a terminator | [
"unpack",
"packed",
"binary",
"data",
"to",
"nibbles"
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/experimental/pruning_trie.py#L154-L168 | train |
ethereum/pyethereum | ethereum/experimental/pruning_trie.py | starts_with | def starts_with(full, part):
""" test whether the items in the part is
the leading items of the full
"""
if len(full) < len(part):
return False
return full[:len(part)] == part | python | def starts_with(full, part):
""" test whether the items in the part is
the leading items of the full
"""
if len(full) < len(part):
return False
return full[:len(part)] == part | [
"def",
"starts_with",
"(",
"full",
",",
"part",
")",
":",
"if",
"len",
"(",
"full",
")",
"<",
"len",
"(",
"part",
")",
":",
"return",
"False",
"return",
"full",
"[",
":",
"len",
"(",
"part",
")",
"]",
"==",
"part"
] | test whether the items in the part is
the leading items of the full | [
"test",
"whether",
"the",
"items",
"in",
"the",
"part",
"is",
"the",
"leading",
"items",
"of",
"the",
"full"
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/experimental/pruning_trie.py#L171-L177 | train |
ethereum/pyethereum | ethereum/experimental/pruning_trie.py | Trie._get_node_type | def _get_node_type(self, node):
""" get node type and content
:param node: node in form of list, or BLANK_NODE
:return: node type
"""
if node == BLANK_NODE:
return NODE_TYPE_BLANK
if len(node) == 2:
nibbles = unpack_to_nibbles(node[0])
... | python | def _get_node_type(self, node):
""" get node type and content
:param node: node in form of list, or BLANK_NODE
:return: node type
"""
if node == BLANK_NODE:
return NODE_TYPE_BLANK
if len(node) == 2:
nibbles = unpack_to_nibbles(node[0])
... | [
"def",
"_get_node_type",
"(",
"self",
",",
"node",
")",
":",
"if",
"node",
"==",
"BLANK_NODE",
":",
"return",
"NODE_TYPE_BLANK",
"if",
"len",
"(",
"node",
")",
"==",
"2",
":",
"nibbles",
"=",
"unpack_to_nibbles",
"(",
"node",
"[",
"0",
"]",
")",
"has_t... | get node type and content
:param node: node in form of list, or BLANK_NODE
:return: node type | [
"get",
"node",
"type",
"and",
"content"
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/experimental/pruning_trie.py#L353-L368 | train |
ethereum/pyethereum | ethereum/experimental/pruning_trie.py | Trie._get | def _get(self, node, key):
""" get value inside a node
:param node: node in form of list, or BLANK_NODE
:param key: nibble list without terminator
:return:
BLANK_NODE if does not exist, otherwise value or hash
"""
node_type = self._get_node_type(node)
... | python | def _get(self, node, key):
""" get value inside a node
:param node: node in form of list, or BLANK_NODE
:param key: nibble list without terminator
:return:
BLANK_NODE if does not exist, otherwise value or hash
"""
node_type = self._get_node_type(node)
... | [
"def",
"_get",
"(",
"self",
",",
"node",
",",
"key",
")",
":",
"node_type",
"=",
"self",
".",
"_get_node_type",
"(",
"node",
")",
"if",
"node_type",
"==",
"NODE_TYPE_BLANK",
":",
"return",
"BLANK_NODE",
"if",
"node_type",
"==",
"NODE_TYPE_BRANCH",
":",
"if... | get value inside a node
:param node: node in form of list, or BLANK_NODE
:param key: nibble list without terminator
:return:
BLANK_NODE if does not exist, otherwise value or hash | [
"get",
"value",
"inside",
"a",
"node"
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/experimental/pruning_trie.py#L370-L401 | train |
ethereum/pyethereum | ethereum/experimental/pruning_trie.py | Trie._normalize_branch_node | def _normalize_branch_node(self, node):
# sys.stderr.write('nbn\n')
"""node should have only one item changed
"""
not_blank_items_count = sum(1 for x in range(17) if node[x])
assert not_blank_items_count >= 1
if not_blank_items_count > 1:
self._encode_node(no... | python | def _normalize_branch_node(self, node):
# sys.stderr.write('nbn\n')
"""node should have only one item changed
"""
not_blank_items_count = sum(1 for x in range(17) if node[x])
assert not_blank_items_count >= 1
if not_blank_items_count > 1:
self._encode_node(no... | [
"def",
"_normalize_branch_node",
"(",
"self",
",",
"node",
")",
":",
"not_blank_items_count",
"=",
"sum",
"(",
"1",
"for",
"x",
"in",
"range",
"(",
"17",
")",
"if",
"node",
"[",
"x",
"]",
")",
"assert",
"not_blank_items_count",
">=",
"1",
"if",
"not_blan... | node should have only one item changed | [
"node",
"should",
"have",
"only",
"one",
"item",
"changed"
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/experimental/pruning_trie.py#L650-L688 | train |
ethereum/pyethereum | ethereum/slogging.py | DEBUG | def DEBUG(msg, *args, **kwargs):
"""temporary logger during development that is always on"""
logger = getLogger("DEBUG")
if len(logger.handlers) == 0:
logger.addHandler(StreamHandler())
logger.propagate = False
logger.setLevel(logging.DEBUG)
logger.DEV(msg, *args, **kwargs) | python | def DEBUG(msg, *args, **kwargs):
"""temporary logger during development that is always on"""
logger = getLogger("DEBUG")
if len(logger.handlers) == 0:
logger.addHandler(StreamHandler())
logger.propagate = False
logger.setLevel(logging.DEBUG)
logger.DEV(msg, *args, **kwargs) | [
"def",
"DEBUG",
"(",
"msg",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"logger",
"=",
"getLogger",
"(",
"\"DEBUG\"",
")",
"if",
"len",
"(",
"logger",
".",
"handlers",
")",
"==",
"0",
":",
"logger",
".",
"addHandler",
"(",
"StreamHandler",
"(",
... | temporary logger during development that is always on | [
"temporary",
"logger",
"during",
"development",
"that",
"is",
"always",
"on"
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/slogging.py#L349-L356 | train |
ethereum/pyethereum | ethereum/vm.py | vm_trace | def vm_trace(ext, msg, compustate, opcode, pushcache, tracer=log_vm_op):
"""
This diverges from normal logging, as we use the logging namespace
only to decide which features get logged in 'eth.vm.op'
i.e. tracing can not be activated by activating a sub
like 'eth.vm.op.stack'
"""
op, in_arg... | python | def vm_trace(ext, msg, compustate, opcode, pushcache, tracer=log_vm_op):
"""
This diverges from normal logging, as we use the logging namespace
only to decide which features get logged in 'eth.vm.op'
i.e. tracing can not be activated by activating a sub
like 'eth.vm.op.stack'
"""
op, in_arg... | [
"def",
"vm_trace",
"(",
"ext",
",",
"msg",
",",
"compustate",
",",
"opcode",
",",
"pushcache",
",",
"tracer",
"=",
"log_vm_op",
")",
":",
"op",
",",
"in_args",
",",
"out_args",
",",
"fee",
"=",
"opcodes",
".",
"opcodes",
"[",
"opcode",
"]",
"trace_data... | This diverges from normal logging, as we use the logging namespace
only to decide which features get logged in 'eth.vm.op'
i.e. tracing can not be activated by activating a sub
like 'eth.vm.op.stack' | [
"This",
"diverges",
"from",
"normal",
"logging",
"as",
"we",
"use",
"the",
"logging",
"namespace",
"only",
"to",
"decide",
"which",
"features",
"get",
"logged",
"in",
"eth",
".",
"vm",
".",
"op",
"i",
".",
"e",
".",
"tracing",
"can",
"not",
"be",
"acti... | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/vm.py#L202-L242 | train |
ethereum/pyethereum | ethereum/transactions.py | Transaction.sign | def sign(self, key, network_id=None):
"""Sign this transaction with a private key.
A potentially already existing signature would be overridden.
"""
if network_id is None:
rawhash = utils.sha3(rlp.encode(unsigned_tx_from_tx(self), UnsignedTransaction))
else:
... | python | def sign(self, key, network_id=None):
"""Sign this transaction with a private key.
A potentially already existing signature would be overridden.
"""
if network_id is None:
rawhash = utils.sha3(rlp.encode(unsigned_tx_from_tx(self), UnsignedTransaction))
else:
... | [
"def",
"sign",
"(",
"self",
",",
"key",
",",
"network_id",
"=",
"None",
")",
":",
"if",
"network_id",
"is",
"None",
":",
"rawhash",
"=",
"utils",
".",
"sha3",
"(",
"rlp",
".",
"encode",
"(",
"unsigned_tx_from_tx",
"(",
"self",
")",
",",
"UnsignedTransa... | Sign this transaction with a private key.
A potentially already existing signature would be overridden. | [
"Sign",
"this",
"transaction",
"with",
"a",
"private",
"key",
"."
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/transactions.py#L118-L141 | train |
ethereum/pyethereum | ethereum/transactions.py | Transaction.creates | def creates(self):
"returns the address of a contract created by this tx"
if self.to in (b'', '\0' * 20):
return mk_contract_address(self.sender, self.nonce) | python | def creates(self):
"returns the address of a contract created by this tx"
if self.to in (b'', '\0' * 20):
return mk_contract_address(self.sender, self.nonce) | [
"def",
"creates",
"(",
"self",
")",
":",
"\"returns the address of a contract created by this tx\"",
"if",
"self",
".",
"to",
"in",
"(",
"b''",
",",
"'\\0'",
"*",
"20",
")",
":",
"return",
"mk_contract_address",
"(",
"self",
".",
"sender",
",",
"self",
".",
... | returns the address of a contract created by this tx | [
"returns",
"the",
"address",
"of",
"a",
"contract",
"created",
"by",
"this",
"tx"
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/transactions.py#L167-L170 | train |
ethereum/pyethereum | ethereum/pow/ethpow.py | check_pow | def check_pow(block_number, header_hash, mixhash, nonce, difficulty):
"""Check if the proof-of-work of the block is valid.
:param nonce: if given the proof of work function will be evaluated
with this nonce instead of the one already present in
the header
:returns: `True... | python | def check_pow(block_number, header_hash, mixhash, nonce, difficulty):
"""Check if the proof-of-work of the block is valid.
:param nonce: if given the proof of work function will be evaluated
with this nonce instead of the one already present in
the header
:returns: `True... | [
"def",
"check_pow",
"(",
"block_number",
",",
"header_hash",
",",
"mixhash",
",",
"nonce",
",",
"difficulty",
")",
":",
"log",
".",
"debug",
"(",
"'checking pow'",
",",
"block_number",
"=",
"block_number",
")",
"if",
"len",
"(",
"mixhash",
")",
"!=",
"32",... | Check if the proof-of-work of the block is valid.
:param nonce: if given the proof of work function will be evaluated
with this nonce instead of the one already present in
the header
:returns: `True` or `False` | [
"Check",
"if",
"the",
"proof",
"-",
"of",
"-",
"work",
"of",
"the",
"block",
"is",
"valid",
"."
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/pow/ethpow.py#L62-L80 | train |
ethereum/pyethereum | ethereum/block.py | BlockHeader.to_dict | def to_dict(self):
"""Serialize the header to a readable dictionary."""
d = {}
for field in ('prevhash', 'uncles_hash', 'extra_data', 'nonce',
'mixhash'):
d[field] = '0x' + encode_hex(getattr(self, field))
for field in ('state_root', 'tx_list_root', 'rec... | python | def to_dict(self):
"""Serialize the header to a readable dictionary."""
d = {}
for field in ('prevhash', 'uncles_hash', 'extra_data', 'nonce',
'mixhash'):
d[field] = '0x' + encode_hex(getattr(self, field))
for field in ('state_root', 'tx_list_root', 'rec... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"d",
"=",
"{",
"}",
"for",
"field",
"in",
"(",
"'prevhash'",
",",
"'uncles_hash'",
",",
"'extra_data'",
",",
"'nonce'",
",",
"'mixhash'",
")",
":",
"d",
"[",
"field",
"]",
"=",
"'0x'",
"+",
"encode_hex",
"(",
... | Serialize the header to a readable dictionary. | [
"Serialize",
"the",
"header",
"to",
"a",
"readable",
"dictionary",
"."
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/block.py#L137-L151 | train |
ethereum/pyethereum | ethereum/utils.py | decode_int | def decode_int(v):
"""decodes and integer from serialization"""
if len(v) > 0 and (v[0] == b'\x00' or v[0] == 0):
raise Exception("No leading zero bytes allowed for integers")
return big_endian_to_int(v) | python | def decode_int(v):
"""decodes and integer from serialization"""
if len(v) > 0 and (v[0] == b'\x00' or v[0] == 0):
raise Exception("No leading zero bytes allowed for integers")
return big_endian_to_int(v) | [
"def",
"decode_int",
"(",
"v",
")",
":",
"if",
"len",
"(",
"v",
")",
">",
"0",
"and",
"(",
"v",
"[",
"0",
"]",
"==",
"b'\\x00'",
"or",
"v",
"[",
"0",
"]",
"==",
"0",
")",
":",
"raise",
"Exception",
"(",
"\"No leading zero bytes allowed for integers\"... | decodes and integer from serialization | [
"decodes",
"and",
"integer",
"from",
"serialization"
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/utils.py#L350-L354 | train |
ethereum/pyethereum | ethereum/utils.py | encode_int | def encode_int(v):
"""encodes an integer into serialization"""
if not is_numeric(v) or v < 0 or v >= TT256:
raise Exception("Integer invalid or out of range: %r" % v)
return int_to_big_endian(v) | python | def encode_int(v):
"""encodes an integer into serialization"""
if not is_numeric(v) or v < 0 or v >= TT256:
raise Exception("Integer invalid or out of range: %r" % v)
return int_to_big_endian(v) | [
"def",
"encode_int",
"(",
"v",
")",
":",
"if",
"not",
"is_numeric",
"(",
"v",
")",
"or",
"v",
"<",
"0",
"or",
"v",
">=",
"TT256",
":",
"raise",
"Exception",
"(",
"\"Integer invalid or out of range: %r\"",
"%",
"v",
")",
"return",
"int_to_big_endian",
"(",
... | encodes an integer into serialization | [
"encodes",
"an",
"integer",
"into",
"serialization"
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/utils.py#L371-L375 | train |
ethereum/pyethereum | ethereum/utils.py | print_func_call | def print_func_call(ignore_first_arg=False, max_call_number=100):
""" utility function to facilitate debug, it will print input args before
function call, and print return value after function call
usage:
@print_func_call
def some_func_to_be_debu():
pass
:param ignore_firs... | python | def print_func_call(ignore_first_arg=False, max_call_number=100):
""" utility function to facilitate debug, it will print input args before
function call, and print return value after function call
usage:
@print_func_call
def some_func_to_be_debu():
pass
:param ignore_firs... | [
"def",
"print_func_call",
"(",
"ignore_first_arg",
"=",
"False",
",",
"max_call_number",
"=",
"100",
")",
":",
"from",
"functools",
"import",
"wraps",
"def",
"display",
"(",
"x",
")",
":",
"x",
"=",
"to_string",
"(",
"x",
")",
"try",
":",
"x",
".",
"de... | utility function to facilitate debug, it will print input args before
function call, and print return value after function call
usage:
@print_func_call
def some_func_to_be_debu():
pass
:param ignore_first_arg: whether print the first arg or not.
useful when ignore the `sel... | [
"utility",
"function",
"to",
"facilitate",
"debug",
"it",
"will",
"print",
"input",
"args",
"before",
"function",
"call",
"and",
"print",
"return",
"value",
"after",
"function",
"call"
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/utils.py#L449-L498 | train |
ethereum/pyethereum | ethereum/tools/_solidity.py | get_compiler_path | def get_compiler_path():
""" Return the path to the solc compiler.
This funtion will search for the solc binary in the $PATH and return the
path of the first executable occurence.
"""
# If the user provides a specific solc binary let's use that
given_binary = os.environ.get('SOLC_BINARY')
i... | python | def get_compiler_path():
""" Return the path to the solc compiler.
This funtion will search for the solc binary in the $PATH and return the
path of the first executable occurence.
"""
# If the user provides a specific solc binary let's use that
given_binary = os.environ.get('SOLC_BINARY')
i... | [
"def",
"get_compiler_path",
"(",
")",
":",
"given_binary",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'SOLC_BINARY'",
")",
"if",
"given_binary",
":",
"return",
"given_binary",
"for",
"path",
"in",
"os",
".",
"getenv",
"(",
"'PATH'",
",",
"''",
")",
"."... | Return the path to the solc compiler.
This funtion will search for the solc binary in the $PATH and return the
path of the first executable occurence. | [
"Return",
"the",
"path",
"to",
"the",
"solc",
"compiler",
"."
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/tools/_solidity.py#L24-L43 | train |
ethereum/pyethereum | ethereum/tools/_solidity.py | solc_arguments | def solc_arguments(libraries=None, combined='bin,abi',
optimize=True, extra_args=None):
""" Build the arguments to call the solc binary. """
args = [
'--combined-json', combined,
]
def str_of(address):
"""cast address to string. py2/3 compatability. """
try:
... | python | def solc_arguments(libraries=None, combined='bin,abi',
optimize=True, extra_args=None):
""" Build the arguments to call the solc binary. """
args = [
'--combined-json', combined,
]
def str_of(address):
"""cast address to string. py2/3 compatability. """
try:
... | [
"def",
"solc_arguments",
"(",
"libraries",
"=",
"None",
",",
"combined",
"=",
"'bin,abi'",
",",
"optimize",
"=",
"True",
",",
"extra_args",
"=",
"None",
")",
":",
"args",
"=",
"[",
"'--combined-json'",
",",
"combined",
",",
"]",
"def",
"str_of",
"(",
"ad... | Build the arguments to call the solc binary. | [
"Build",
"the",
"arguments",
"to",
"call",
"the",
"solc",
"binary",
"."
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/tools/_solidity.py#L54-L89 | train |
ethereum/pyethereum | ethereum/tools/_solidity.py | solc_parse_output | def solc_parse_output(compiler_output):
""" Parses the compiler output. """
# At the moment some solc output like --hashes or -- gas will not output
# json at all so if used with those arguments the logic here will break.
# Perhaps solidity will slowly switch to a json only output and this comment
#... | python | def solc_parse_output(compiler_output):
""" Parses the compiler output. """
# At the moment some solc output like --hashes or -- gas will not output
# json at all so if used with those arguments the logic here will break.
# Perhaps solidity will slowly switch to a json only output and this comment
#... | [
"def",
"solc_parse_output",
"(",
"compiler_output",
")",
":",
"result",
"=",
"yaml",
".",
"safe_load",
"(",
"compiler_output",
")",
"[",
"'contracts'",
"]",
"if",
"'bin'",
"in",
"tuple",
"(",
"result",
".",
"values",
"(",
")",
")",
"[",
"0",
"]",
":",
... | Parses the compiler output. | [
"Parses",
"the",
"compiler",
"output",
"."
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/tools/_solidity.py#L92-L121 | train |
ethereum/pyethereum | ethereum/tools/_solidity.py | compiler_version | def compiler_version():
""" Return the version of the installed solc. """
version_info = subprocess.check_output(['solc', '--version'])
match = re.search(b'^Version: ([0-9a-z.-]+)/', version_info, re.MULTILINE)
if match:
return match.group(1) | python | def compiler_version():
""" Return the version of the installed solc. """
version_info = subprocess.check_output(['solc', '--version'])
match = re.search(b'^Version: ([0-9a-z.-]+)/', version_info, re.MULTILINE)
if match:
return match.group(1) | [
"def",
"compiler_version",
"(",
")",
":",
"version_info",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"'solc'",
",",
"'--version'",
"]",
")",
"match",
"=",
"re",
".",
"search",
"(",
"b'^Version: ([0-9a-z.-]+)/'",
",",
"version_info",
",",
"re",
".",
"M... | Return the version of the installed solc. | [
"Return",
"the",
"version",
"of",
"the",
"installed",
"solc",
"."
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/tools/_solidity.py#L124-L130 | train |
ethereum/pyethereum | ethereum/tools/_solidity.py | solidity_names | def solidity_names(code): # pylint: disable=too-many-branches
""" Return the library and contract names in order of appearence. """
names = []
in_string = None
backslash = False
comment = None
# "parse" the code by hand to handle the corner cases:
# - the contract or library can be inside... | python | def solidity_names(code): # pylint: disable=too-many-branches
""" Return the library and contract names in order of appearence. """
names = []
in_string = None
backslash = False
comment = None
# "parse" the code by hand to handle the corner cases:
# - the contract or library can be inside... | [
"def",
"solidity_names",
"(",
"code",
")",
":",
"names",
"=",
"[",
"]",
"in_string",
"=",
"None",
"backslash",
"=",
"False",
"comment",
"=",
"None",
"for",
"pos",
",",
"char",
"in",
"enumerate",
"(",
"code",
")",
":",
"if",
"in_string",
":",
"if",
"n... | Return the library and contract names in order of appearence. | [
"Return",
"the",
"library",
"and",
"contract",
"names",
"in",
"order",
"of",
"appearence",
"."
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/tools/_solidity.py#L133-L194 | train |
ethereum/pyethereum | ethereum/tools/_solidity.py | compile_file | def compile_file(filepath, libraries=None, combined='bin,abi',
optimize=True, extra_args=None):
""" Return the compile contract code.
Args:
filepath (str): The path to the contract source code.
libraries (dict): A dictionary mapping library name to it's address.
combine... | python | def compile_file(filepath, libraries=None, combined='bin,abi',
optimize=True, extra_args=None):
""" Return the compile contract code.
Args:
filepath (str): The path to the contract source code.
libraries (dict): A dictionary mapping library name to it's address.
combine... | [
"def",
"compile_file",
"(",
"filepath",
",",
"libraries",
"=",
"None",
",",
"combined",
"=",
"'bin,abi'",
",",
"optimize",
"=",
"True",
",",
"extra_args",
"=",
"None",
")",
":",
"workdir",
",",
"filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"fi... | Return the compile contract code.
Args:
filepath (str): The path to the contract source code.
libraries (dict): A dictionary mapping library name to it's address.
combined (str): The argument for solc's --combined-json.
optimize (bool): Enable/disables compiler optimization.
Re... | [
"Return",
"the",
"compile",
"contract",
"code",
"."
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/tools/_solidity.py#L265-L291 | train |
ethereum/pyethereum | ethereum/tools/_solidity.py | solidity_get_contract_key | def solidity_get_contract_key(all_contracts, filepath, contract_name):
""" A backwards compatible method of getting the key to the all_contracts
dictionary for a particular contract"""
if contract_name in all_contracts:
return contract_name
else:
if filepath is None:
filename... | python | def solidity_get_contract_key(all_contracts, filepath, contract_name):
""" A backwards compatible method of getting the key to the all_contracts
dictionary for a particular contract"""
if contract_name in all_contracts:
return contract_name
else:
if filepath is None:
filename... | [
"def",
"solidity_get_contract_key",
"(",
"all_contracts",
",",
"filepath",
",",
"contract_name",
")",
":",
"if",
"contract_name",
"in",
"all_contracts",
":",
"return",
"contract_name",
"else",
":",
"if",
"filepath",
"is",
"None",
":",
"filename",
"=",
"'<stdin>'",... | A backwards compatible method of getting the key to the all_contracts
dictionary for a particular contract | [
"A",
"backwards",
"compatible",
"method",
"of",
"getting",
"the",
"key",
"to",
"the",
"all_contracts",
"dictionary",
"for",
"a",
"particular",
"contract"
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/tools/_solidity.py#L308-L319 | train |
ethereum/pyethereum | ethereum/tools/_solidity.py | Solc.compile | def compile(cls, code, path=None, libraries=None,
contract_name='', extra_args=None):
""" Return the binary of last contract in code. """
result = cls._code_or_path(
code,
path,
contract_name,
libraries,
'bin',
extra... | python | def compile(cls, code, path=None, libraries=None,
contract_name='', extra_args=None):
""" Return the binary of last contract in code. """
result = cls._code_or_path(
code,
path,
contract_name,
libraries,
'bin',
extra... | [
"def",
"compile",
"(",
"cls",
",",
"code",
",",
"path",
"=",
"None",
",",
"libraries",
"=",
"None",
",",
"contract_name",
"=",
"''",
",",
"extra_args",
"=",
"None",
")",
":",
"result",
"=",
"cls",
".",
"_code_or_path",
"(",
"code",
",",
"path",
",",
... | Return the binary of last contract in code. | [
"Return",
"the",
"binary",
"of",
"last",
"contract",
"in",
"code",
"."
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/tools/_solidity.py#L420-L430 | train |
ethereum/pyethereum | ethereum/tools/_solidity.py | Solc.combined | def combined(cls, code, path=None, extra_args=None):
""" Compile combined-json with abi,bin,devdoc,userdoc.
@param code: literal solidity code as a string.
@param path: absolute path to solidity-file. Note: code & path are
mutually exclusive!
@param extra_args: Eith... | python | def combined(cls, code, path=None, extra_args=None):
""" Compile combined-json with abi,bin,devdoc,userdoc.
@param code: literal solidity code as a string.
@param path: absolute path to solidity-file. Note: code & path are
mutually exclusive!
@param extra_args: Eith... | [
"def",
"combined",
"(",
"cls",
",",
"code",
",",
"path",
"=",
"None",
",",
"extra_args",
"=",
"None",
")",
":",
"if",
"code",
"and",
"path",
":",
"raise",
"ValueError",
"(",
"'sourcecode and path are mutually exclusive.'",
")",
"if",
"path",
":",
"contracts"... | Compile combined-json with abi,bin,devdoc,userdoc.
@param code: literal solidity code as a string.
@param path: absolute path to solidity-file. Note: code & path are
mutually exclusive!
@param extra_args: Either a space separated string or a list of extra
... | [
"Compile",
"combined",
"-",
"json",
"with",
"abi",
"bin",
"devdoc",
"userdoc",
"."
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/tools/_solidity.py#L447-L480 | train |
ethereum/pyethereum | ethereum/tools/_solidity.py | Solc.compile_rich | def compile_rich(cls, code, path=None, extra_args=None):
"""full format as returned by jsonrpc"""
return {
contract_name: {
'code': '0x' + contract.get('bin_hex'),
'info': {
'abiDefinition': contract.get('abi'),
'compil... | python | def compile_rich(cls, code, path=None, extra_args=None):
"""full format as returned by jsonrpc"""
return {
contract_name: {
'code': '0x' + contract.get('bin_hex'),
'info': {
'abiDefinition': contract.get('abi'),
'compil... | [
"def",
"compile_rich",
"(",
"cls",
",",
"code",
",",
"path",
"=",
"None",
",",
"extra_args",
"=",
"None",
")",
":",
"return",
"{",
"contract_name",
":",
"{",
"'code'",
":",
"'0x'",
"+",
"contract",
".",
"get",
"(",
"'bin_hex'",
")",
",",
"'info'",
":... | full format as returned by jsonrpc | [
"full",
"format",
"as",
"returned",
"by",
"jsonrpc"
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/tools/_solidity.py#L483-L501 | train |
ethereum/pyethereum | ethereum/pow/consensus.py | validate_uncles | def validate_uncles(state, block):
"""Validate the uncles of this block."""
# Make sure hash matches up
if utils.sha3(rlp.encode(block.uncles)) != block.header.uncles_hash:
raise VerificationFailed("Uncle hash mismatch")
# Enforce maximum number of uncles
if len(block.uncles) > state.config[... | python | def validate_uncles(state, block):
"""Validate the uncles of this block."""
# Make sure hash matches up
if utils.sha3(rlp.encode(block.uncles)) != block.header.uncles_hash:
raise VerificationFailed("Uncle hash mismatch")
# Enforce maximum number of uncles
if len(block.uncles) > state.config[... | [
"def",
"validate_uncles",
"(",
"state",
",",
"block",
")",
":",
"if",
"utils",
".",
"sha3",
"(",
"rlp",
".",
"encode",
"(",
"block",
".",
"uncles",
")",
")",
"!=",
"block",
".",
"header",
".",
"uncles_hash",
":",
"raise",
"VerificationFailed",
"(",
"\"... | Validate the uncles of this block. | [
"Validate",
"the",
"uncles",
"of",
"this",
"block",
"."
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/pow/consensus.py#L63-L106 | train |
ethereum/pyethereum | ethereum/pow/consensus.py | finalize | def finalize(state, block):
"""Apply rewards and commit."""
if state.is_METROPOLIS():
br = state.config['BYZANTIUM_BLOCK_REWARD']
nr = state.config['BYZANTIUM_NEPHEW_REWARD']
else:
br = state.config['BLOCK_REWARD']
nr = state.config['NEPHEW_REWARD']
delta = int(... | python | def finalize(state, block):
"""Apply rewards and commit."""
if state.is_METROPOLIS():
br = state.config['BYZANTIUM_BLOCK_REWARD']
nr = state.config['BYZANTIUM_NEPHEW_REWARD']
else:
br = state.config['BLOCK_REWARD']
nr = state.config['NEPHEW_REWARD']
delta = int(... | [
"def",
"finalize",
"(",
"state",
",",
"block",
")",
":",
"if",
"state",
".",
"is_METROPOLIS",
"(",
")",
":",
"br",
"=",
"state",
".",
"config",
"[",
"'BYZANTIUM_BLOCK_REWARD'",
"]",
"nr",
"=",
"state",
".",
"config",
"[",
"'BYZANTIUM_NEPHEW_REWARD'",
"]",
... | Apply rewards and commit. | [
"Apply",
"rewards",
"and",
"commit",
"."
] | b704a5c6577863edc539a1ec3d2620a443b950fb | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/pow/consensus.py#L110-L132 | train |
Microsoft/knack | knack/deprecation.py | Deprecated.ensure_new_style_deprecation | def ensure_new_style_deprecation(cli_ctx, kwargs, object_type):
""" Helper method to make the previous string-based deprecate_info kwarg
work with the new style. """
deprecate_info = kwargs.get('deprecate_info', None)
if isinstance(deprecate_info, Deprecated):
deprecate_i... | python | def ensure_new_style_deprecation(cli_ctx, kwargs, object_type):
""" Helper method to make the previous string-based deprecate_info kwarg
work with the new style. """
deprecate_info = kwargs.get('deprecate_info', None)
if isinstance(deprecate_info, Deprecated):
deprecate_i... | [
"def",
"ensure_new_style_deprecation",
"(",
"cli_ctx",
",",
"kwargs",
",",
"object_type",
")",
":",
"deprecate_info",
"=",
"kwargs",
".",
"get",
"(",
"'deprecate_info'",
",",
"None",
")",
"if",
"isinstance",
"(",
"deprecate_info",
",",
"Deprecated",
")",
":",
... | Helper method to make the previous string-based deprecate_info kwarg
work with the new style. | [
"Helper",
"method",
"to",
"make",
"the",
"previous",
"string",
"-",
"based",
"deprecate_info",
"kwarg",
"work",
"with",
"the",
"new",
"style",
"."
] | 5f1a480a33f103e2688c46eef59fb2d9eaf2baad | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/deprecation.py#L53-L62 | train |
Microsoft/knack | knack/deprecation.py | Deprecated._version_less_than_or_equal_to | def _version_less_than_or_equal_to(self, v1, v2):
""" Returns true if v1 <= v2. """
# pylint: disable=no-name-in-module, import-error
from distutils.version import LooseVersion
return LooseVersion(v1) <= LooseVersion(v2) | python | def _version_less_than_or_equal_to(self, v1, v2):
""" Returns true if v1 <= v2. """
# pylint: disable=no-name-in-module, import-error
from distutils.version import LooseVersion
return LooseVersion(v1) <= LooseVersion(v2) | [
"def",
"_version_less_than_or_equal_to",
"(",
"self",
",",
"v1",
",",
"v2",
")",
":",
"from",
"distutils",
".",
"version",
"import",
"LooseVersion",
"return",
"LooseVersion",
"(",
"v1",
")",
"<=",
"LooseVersion",
"(",
"v2",
")"
] | Returns true if v1 <= v2. | [
"Returns",
"true",
"if",
"v1",
"<",
"=",
"v2",
"."
] | 5f1a480a33f103e2688c46eef59fb2d9eaf2baad | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/deprecation.py#L127-L131 | train |
Microsoft/knack | knack/prompting.py | prompt_choice_list | def prompt_choice_list(msg, a_list, default=1, help_string=None):
"""Prompt user to select from a list of possible choices.
:param msg:A message displayed to the user before the choice list
:type msg: str
:param a_list:The list of choices (list of strings or list of dicts with 'name' & 'desc')
"typ... | python | def prompt_choice_list(msg, a_list, default=1, help_string=None):
"""Prompt user to select from a list of possible choices.
:param msg:A message displayed to the user before the choice list
:type msg: str
:param a_list:The list of choices (list of strings or list of dicts with 'name' & 'desc')
"typ... | [
"def",
"prompt_choice_list",
"(",
"msg",
",",
"a_list",
",",
"default",
"=",
"1",
",",
"help_string",
"=",
"None",
")",
":",
"verify_is_a_tty",
"(",
")",
"options",
"=",
"'\\n'",
".",
"join",
"(",
"[",
"' [{}] {}{}'",
".",
"format",
"(",
"i",
"+",
"1",... | Prompt user to select from a list of possible choices.
:param msg:A message displayed to the user before the choice list
:type msg: str
:param a_list:The list of choices (list of strings or list of dicts with 'name' & 'desc')
"type a_list: list
:param default:The default option that should be chose... | [
"Prompt",
"user",
"to",
"select",
"from",
"a",
"list",
"of",
"possible",
"choices",
"."
] | 5f1a480a33f103e2688c46eef59fb2d9eaf2baad | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/prompting.py#L99-L131 | train |
Microsoft/knack | knack/parser.py | CLICommandParser._add_argument | def _add_argument(obj, arg):
""" Only pass valid argparse kwargs to argparse.ArgumentParser.add_argument """
argparse_options = {name: value for name, value in arg.options.items() if name in ARGPARSE_SUPPORTED_KWARGS}
if arg.options_list:
scrubbed_options_list = []
for it... | python | def _add_argument(obj, arg):
""" Only pass valid argparse kwargs to argparse.ArgumentParser.add_argument """
argparse_options = {name: value for name, value in arg.options.items() if name in ARGPARSE_SUPPORTED_KWARGS}
if arg.options_list:
scrubbed_options_list = []
for it... | [
"def",
"_add_argument",
"(",
"obj",
",",
"arg",
")",
":",
"argparse_options",
"=",
"{",
"name",
":",
"value",
"for",
"name",
",",
"value",
"in",
"arg",
".",
"options",
".",
"items",
"(",
")",
"if",
"name",
"in",
"ARGPARSE_SUPPORTED_KWARGS",
"}",
"if",
... | Only pass valid argparse kwargs to argparse.ArgumentParser.add_argument | [
"Only",
"pass",
"valid",
"argparse",
"kwargs",
"to",
"argparse",
".",
"ArgumentParser",
".",
"add_argument"
] | 5f1a480a33f103e2688c46eef59fb2d9eaf2baad | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/parser.py#L42-L69 | train |
Microsoft/knack | knack/parser.py | CLICommandParser.load_command_table | def load_command_table(self, command_loader):
""" Process the command table and load it into the parser
:param cmd_tbl: A dictionary containing the commands
:type cmd_tbl: dict
"""
cmd_tbl = command_loader.command_table
grp_tbl = command_loader.command_group_table
... | python | def load_command_table(self, command_loader):
""" Process the command table and load it into the parser
:param cmd_tbl: A dictionary containing the commands
:type cmd_tbl: dict
"""
cmd_tbl = command_loader.command_table
grp_tbl = command_loader.command_group_table
... | [
"def",
"load_command_table",
"(",
"self",
",",
"command_loader",
")",
":",
"cmd_tbl",
"=",
"command_loader",
".",
"command_table",
"grp_tbl",
"=",
"command_loader",
".",
"command_group_table",
"if",
"not",
"cmd_tbl",
":",
"raise",
"ValueError",
"(",
"'The command ta... | Process the command table and load it into the parser
:param cmd_tbl: A dictionary containing the commands
:type cmd_tbl: dict | [
"Process",
"the",
"command",
"table",
"and",
"load",
"it",
"into",
"the",
"parser"
] | 5f1a480a33f103e2688c46eef59fb2d9eaf2baad | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/parser.py#L111-L178 | train |
Microsoft/knack | knack/parser.py | CLICommandParser._get_subparser | def _get_subparser(self, path, group_table=None):
"""For each part of the path, walk down the tree of
subparsers, creating new ones if one doesn't already exist.
"""
group_table = group_table or {}
for length in range(0, len(path)):
parent_path = path[:length]
... | python | def _get_subparser(self, path, group_table=None):
"""For each part of the path, walk down the tree of
subparsers, creating new ones if one doesn't already exist.
"""
group_table = group_table or {}
for length in range(0, len(path)):
parent_path = path[:length]
... | [
"def",
"_get_subparser",
"(",
"self",
",",
"path",
",",
"group_table",
"=",
"None",
")",
":",
"group_table",
"=",
"group_table",
"or",
"{",
"}",
"for",
"length",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"path",
")",
")",
":",
"parent_path",
"=",
"pa... | For each part of the path, walk down the tree of
subparsers, creating new ones if one doesn't already exist. | [
"For",
"each",
"part",
"of",
"the",
"path",
"walk",
"down",
"the",
"tree",
"of",
"subparsers",
"creating",
"new",
"ones",
"if",
"one",
"doesn",
"t",
"already",
"exist",
"."
] | 5f1a480a33f103e2688c46eef59fb2d9eaf2baad | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/parser.py#L180-L217 | train |
Microsoft/knack | knack/parser.py | CLICommandParser.parse_args | def parse_args(self, args=None, namespace=None):
""" Overrides argparse.ArgumentParser.parse_args
Enables '@'-prefixed files to be expanded before arguments are processed
by ArgumentParser.parse_args as usual
"""
self._expand_prefixed_files(args)
return super(CLICommandP... | python | def parse_args(self, args=None, namespace=None):
""" Overrides argparse.ArgumentParser.parse_args
Enables '@'-prefixed files to be expanded before arguments are processed
by ArgumentParser.parse_args as usual
"""
self._expand_prefixed_files(args)
return super(CLICommandP... | [
"def",
"parse_args",
"(",
"self",
",",
"args",
"=",
"None",
",",
"namespace",
"=",
"None",
")",
":",
"self",
".",
"_expand_prefixed_files",
"(",
"args",
")",
"return",
"super",
"(",
"CLICommandParser",
",",
"self",
")",
".",
"parse_args",
"(",
"args",
")... | Overrides argparse.ArgumentParser.parse_args
Enables '@'-prefixed files to be expanded before arguments are processed
by ArgumentParser.parse_args as usual | [
"Overrides",
"argparse",
".",
"ArgumentParser",
".",
"parse_args"
] | 5f1a480a33f103e2688c46eef59fb2d9eaf2baad | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/parser.py#L249-L256 | train |
Microsoft/knack | knack/introspection.py | extract_full_summary_from_signature | def extract_full_summary_from_signature(operation):
""" Extract the summary from the docstring of the command. """
lines = inspect.getdoc(operation)
regex = r'\s*(:param)\s+(.+?)\s*:(.*)'
summary = ''
if lines:
match = re.search(regex, lines)
summary = lines[:match.regs[0][0]] if mat... | python | def extract_full_summary_from_signature(operation):
""" Extract the summary from the docstring of the command. """
lines = inspect.getdoc(operation)
regex = r'\s*(:param)\s+(.+?)\s*:(.*)'
summary = ''
if lines:
match = re.search(regex, lines)
summary = lines[:match.regs[0][0]] if mat... | [
"def",
"extract_full_summary_from_signature",
"(",
"operation",
")",
":",
"lines",
"=",
"inspect",
".",
"getdoc",
"(",
"operation",
")",
"regex",
"=",
"r'\\s*(:param)\\s+(.+?)\\s*:(.*)'",
"summary",
"=",
"''",
"if",
"lines",
":",
"match",
"=",
"re",
".",
"search... | Extract the summary from the docstring of the command. | [
"Extract",
"the",
"summary",
"from",
"the",
"docstring",
"of",
"the",
"command",
"."
] | 5f1a480a33f103e2688c46eef59fb2d9eaf2baad | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/introspection.py#L15-L25 | train |
Microsoft/knack | knack/cli.py | CLI.get_runtime_version | def get_runtime_version(self): # pylint: disable=no-self-use
""" Get the runtime information.
:return: Runtime information
:rtype: str
"""
import platform
version_info = '\n\n'
version_info += 'Python ({}) {}'.format(platform.system(), sys.version)
vers... | python | def get_runtime_version(self): # pylint: disable=no-self-use
""" Get the runtime information.
:return: Runtime information
:rtype: str
"""
import platform
version_info = '\n\n'
version_info += 'Python ({}) {}'.format(platform.system(), sys.version)
vers... | [
"def",
"get_runtime_version",
"(",
"self",
")",
":",
"import",
"platform",
"version_info",
"=",
"'\\n\\n'",
"version_info",
"+=",
"'Python ({}) {}'",
".",
"format",
"(",
"platform",
".",
"system",
"(",
")",
",",
"sys",
".",
"version",
")",
"version_info",
"+="... | Get the runtime information.
:return: Runtime information
:rtype: str | [
"Get",
"the",
"runtime",
"information",
"."
] | 5f1a480a33f103e2688c46eef59fb2d9eaf2baad | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/cli.py#L107-L120 | train |
Microsoft/knack | knack/cli.py | CLI.show_version | def show_version(self):
""" Print version information to the out file. """
version_info = self.get_cli_version()
version_info += self.get_runtime_version()
print(version_info, file=self.out_file) | python | def show_version(self):
""" Print version information to the out file. """
version_info = self.get_cli_version()
version_info += self.get_runtime_version()
print(version_info, file=self.out_file) | [
"def",
"show_version",
"(",
"self",
")",
":",
"version_info",
"=",
"self",
".",
"get_cli_version",
"(",
")",
"version_info",
"+=",
"self",
".",
"get_runtime_version",
"(",
")",
"print",
"(",
"version_info",
",",
"file",
"=",
"self",
".",
"out_file",
")"
] | Print version information to the out file. | [
"Print",
"version",
"information",
"to",
"the",
"out",
"file",
"."
] | 5f1a480a33f103e2688c46eef59fb2d9eaf2baad | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/cli.py#L122-L126 | train |
Microsoft/knack | knack/cli.py | CLI.unregister_event | def unregister_event(self, event_name, handler):
""" Unregister a callable that will be called when event is raised.
:param event_name: The name of the event (see knack.events for in-built events)
:type event_name: str
:param handler: The callback that was used to register the event
... | python | def unregister_event(self, event_name, handler):
""" Unregister a callable that will be called when event is raised.
:param event_name: The name of the event (see knack.events for in-built events)
:type event_name: str
:param handler: The callback that was used to register the event
... | [
"def",
"unregister_event",
"(",
"self",
",",
"event_name",
",",
"handler",
")",
":",
"try",
":",
"self",
".",
"_event_handlers",
"[",
"event_name",
"]",
".",
"remove",
"(",
"handler",
")",
"except",
"ValueError",
":",
"pass"
] | Unregister a callable that will be called when event is raised.
:param event_name: The name of the event (see knack.events for in-built events)
:type event_name: str
:param handler: The callback that was used to register the event
:type handler: function | [
"Unregister",
"a",
"callable",
"that",
"will",
"be",
"called",
"when",
"event",
"is",
"raised",
"."
] | 5f1a480a33f103e2688c46eef59fb2d9eaf2baad | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/cli.py#L139-L150 | train |
Microsoft/knack | knack/cli.py | CLI.raise_event | def raise_event(self, event_name, **kwargs):
""" Raise an event. Calls each handler in turn with kwargs
:param event_name: The name of the event to raise
:type event_name: str
:param kwargs: Kwargs to be passed to all event handlers
"""
handlers = list(self._event_handle... | python | def raise_event(self, event_name, **kwargs):
""" Raise an event. Calls each handler in turn with kwargs
:param event_name: The name of the event to raise
:type event_name: str
:param kwargs: Kwargs to be passed to all event handlers
"""
handlers = list(self._event_handle... | [
"def",
"raise_event",
"(",
"self",
",",
"event_name",
",",
"**",
"kwargs",
")",
":",
"handlers",
"=",
"list",
"(",
"self",
".",
"_event_handlers",
"[",
"event_name",
"]",
")",
"logger",
".",
"debug",
"(",
"'Event: %s %s'",
",",
"event_name",
",",
"handlers... | Raise an event. Calls each handler in turn with kwargs
:param event_name: The name of the event to raise
:type event_name: str
:param kwargs: Kwargs to be passed to all event handlers | [
"Raise",
"an",
"event",
".",
"Calls",
"each",
"handler",
"in",
"turn",
"with",
"kwargs"
] | 5f1a480a33f103e2688c46eef59fb2d9eaf2baad | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/cli.py#L152-L162 | train |
Microsoft/knack | knack/cli.py | CLI.exception_handler | def exception_handler(self, ex): # pylint: disable=no-self-use
""" The default exception handler """
if isinstance(ex, CLIError):
logger.error(ex)
else:
logger.exception(ex)
return 1 | python | def exception_handler(self, ex): # pylint: disable=no-self-use
""" The default exception handler """
if isinstance(ex, CLIError):
logger.error(ex)
else:
logger.exception(ex)
return 1 | [
"def",
"exception_handler",
"(",
"self",
",",
"ex",
")",
":",
"if",
"isinstance",
"(",
"ex",
",",
"CLIError",
")",
":",
"logger",
".",
"error",
"(",
"ex",
")",
"else",
":",
"logger",
".",
"exception",
"(",
"ex",
")",
"return",
"1"
] | The default exception handler | [
"The",
"default",
"exception",
"handler"
] | 5f1a480a33f103e2688c46eef59fb2d9eaf2baad | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/cli.py#L164-L170 | train |
Microsoft/knack | knack/cli.py | CLI.invoke | def invoke(self, args, initial_invocation_data=None, out_file=None):
""" Invoke a command.
:param args: The arguments that represent the command
:type args: list, tuple
:param initial_invocation_data: Prime the in memory collection of key-value data for this invocation.
:type in... | python | def invoke(self, args, initial_invocation_data=None, out_file=None):
""" Invoke a command.
:param args: The arguments that represent the command
:type args: list, tuple
:param initial_invocation_data: Prime the in memory collection of key-value data for this invocation.
:type in... | [
"def",
"invoke",
"(",
"self",
",",
"args",
",",
"initial_invocation_data",
"=",
"None",
",",
"out_file",
"=",
"None",
")",
":",
"from",
".",
"util",
"import",
"CommandResultItem",
"if",
"not",
"isinstance",
"(",
"args",
",",
"(",
"list",
",",
"tuple",
")... | Invoke a command.
:param args: The arguments that represent the command
:type args: list, tuple
:param initial_invocation_data: Prime the in memory collection of key-value data for this invocation.
:type initial_invocation_data: dict
:param out_file: The file to send output to. ... | [
"Invoke",
"a",
"command",
"."
] | 5f1a480a33f103e2688c46eef59fb2d9eaf2baad | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/cli.py#L172-L223 | train |
Microsoft/knack | knack/log.py | get_logger | def get_logger(module_name=None):
""" Get the logger for a module. If no module name is given, the current CLI logger is returned.
Example:
get_logger(__name__)
:param module_name: The module to get the logger for
:type module_name: str
:return: The logger
:rtype: logger
"""
if... | python | def get_logger(module_name=None):
""" Get the logger for a module. If no module name is given, the current CLI logger is returned.
Example:
get_logger(__name__)
:param module_name: The module to get the logger for
:type module_name: str
:return: The logger
:rtype: logger
"""
if... | [
"def",
"get_logger",
"(",
"module_name",
"=",
"None",
")",
":",
"if",
"module_name",
":",
"logger_name",
"=",
"'{}.{}'",
".",
"format",
"(",
"CLI_LOGGER_NAME",
",",
"module_name",
")",
"else",
":",
"logger_name",
"=",
"CLI_LOGGER_NAME",
"return",
"logging",
".... | Get the logger for a module. If no module name is given, the current CLI logger is returned.
Example:
get_logger(__name__)
:param module_name: The module to get the logger for
:type module_name: str
:return: The logger
:rtype: logger | [
"Get",
"the",
"logger",
"for",
"a",
"module",
".",
"If",
"no",
"module",
"name",
"is",
"given",
"the",
"current",
"CLI",
"logger",
"is",
"returned",
"."
] | 5f1a480a33f103e2688c46eef59fb2d9eaf2baad | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/log.py#L16-L31 | train |
Microsoft/knack | knack/log.py | CLILogging.configure | def configure(self, args):
""" Configure the loggers with the appropriate log level etc.
:param args: The arguments from the command line
:type args: list
"""
verbose_level = self._determine_verbose_level(args)
log_level_config = self.console_log_configs[verbose_level]
... | python | def configure(self, args):
""" Configure the loggers with the appropriate log level etc.
:param args: The arguments from the command line
:type args: list
"""
verbose_level = self._determine_verbose_level(args)
log_level_config = self.console_log_configs[verbose_level]
... | [
"def",
"configure",
"(",
"self",
",",
"args",
")",
":",
"verbose_level",
"=",
"self",
".",
"_determine_verbose_level",
"(",
"args",
")",
"log_level_config",
"=",
"self",
".",
"console_log_configs",
"[",
"verbose_level",
"]",
"root_logger",
"=",
"logging",
".",
... | Configure the loggers with the appropriate log level etc.
:param args: The arguments from the command line
:type args: list | [
"Configure",
"the",
"loggers",
"with",
"the",
"appropriate",
"log",
"level",
"etc",
"."
] | 5f1a480a33f103e2688c46eef59fb2d9eaf2baad | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/log.py#L120-L141 | train |
Microsoft/knack | knack/log.py | CLILogging._determine_verbose_level | def _determine_verbose_level(self, args):
""" Get verbose level by reading the arguments. """
verbose_level = 0
for arg in args:
if arg == CLILogging.VERBOSE_FLAG:
verbose_level += 1
elif arg == CLILogging.DEBUG_FLAG:
verbose_level += 2
... | python | def _determine_verbose_level(self, args):
""" Get verbose level by reading the arguments. """
verbose_level = 0
for arg in args:
if arg == CLILogging.VERBOSE_FLAG:
verbose_level += 1
elif arg == CLILogging.DEBUG_FLAG:
verbose_level += 2
... | [
"def",
"_determine_verbose_level",
"(",
"self",
",",
"args",
")",
":",
"verbose_level",
"=",
"0",
"for",
"arg",
"in",
"args",
":",
"if",
"arg",
"==",
"CLILogging",
".",
"VERBOSE_FLAG",
":",
"verbose_level",
"+=",
"1",
"elif",
"arg",
"==",
"CLILogging",
"."... | Get verbose level by reading the arguments. | [
"Get",
"verbose",
"level",
"by",
"reading",
"the",
"arguments",
"."
] | 5f1a480a33f103e2688c46eef59fb2d9eaf2baad | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/log.py#L143-L152 | train |
Microsoft/knack | knack/arguments.py | enum_choice_list | def enum_choice_list(data):
""" Creates the argparse choices and type kwargs for a supplied enum type or list of strings """
# transform enum types, otherwise assume list of string choices
if not data:
return {}
try:
choices = [x.value for x in data]
except AttributeError:
c... | python | def enum_choice_list(data):
""" Creates the argparse choices and type kwargs for a supplied enum type or list of strings """
# transform enum types, otherwise assume list of string choices
if not data:
return {}
try:
choices = [x.value for x in data]
except AttributeError:
c... | [
"def",
"enum_choice_list",
"(",
"data",
")",
":",
"if",
"not",
"data",
":",
"return",
"{",
"}",
"try",
":",
"choices",
"=",
"[",
"x",
".",
"value",
"for",
"x",
"in",
"data",
"]",
"except",
"AttributeError",
":",
"choices",
"=",
"data",
"def",
"_type"... | Creates the argparse choices and type kwargs for a supplied enum type or list of strings | [
"Creates",
"the",
"argparse",
"choices",
"and",
"type",
"kwargs",
"for",
"a",
"supplied",
"enum",
"type",
"or",
"list",
"of",
"strings"
] | 5f1a480a33f103e2688c46eef59fb2d9eaf2baad | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/arguments.py#L359-L376 | train |
Microsoft/knack | knack/arguments.py | ArgumentRegistry.register_cli_argument | def register_cli_argument(self, scope, dest, argtype, **kwargs):
""" Add an argument to the argument registry
:param scope: The command level to apply the argument registration (e.g. 'mygroup mycommand')
:type scope: str
:param dest: The parameter/destination that this argument is for
... | python | def register_cli_argument(self, scope, dest, argtype, **kwargs):
""" Add an argument to the argument registry
:param scope: The command level to apply the argument registration (e.g. 'mygroup mycommand')
:type scope: str
:param dest: The parameter/destination that this argument is for
... | [
"def",
"register_cli_argument",
"(",
"self",
",",
"scope",
",",
"dest",
",",
"argtype",
",",
"**",
"kwargs",
")",
":",
"argument",
"=",
"CLIArgumentType",
"(",
"overrides",
"=",
"argtype",
",",
"**",
"kwargs",
")",
"self",
".",
"arguments",
"[",
"scope",
... | Add an argument to the argument registry
:param scope: The command level to apply the argument registration (e.g. 'mygroup mycommand')
:type scope: str
:param dest: The parameter/destination that this argument is for
:type dest: str
:param argtype: The argument type for this com... | [
"Add",
"an",
"argument",
"to",
"the",
"argument",
"registry"
] | 5f1a480a33f103e2688c46eef59fb2d9eaf2baad | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/arguments.py#L93-L105 | train |
Microsoft/knack | knack/arguments.py | ArgumentRegistry.get_cli_argument | def get_cli_argument(self, command, name):
""" Get the argument for the command after applying the scope hierarchy
:param command: The command that we want the argument for
:type command: str
:param name: The name of the argument
:type name: str
:return: The CLI command ... | python | def get_cli_argument(self, command, name):
""" Get the argument for the command after applying the scope hierarchy
:param command: The command that we want the argument for
:type command: str
:param name: The name of the argument
:type name: str
:return: The CLI command ... | [
"def",
"get_cli_argument",
"(",
"self",
",",
"command",
",",
"name",
")",
":",
"parts",
"=",
"command",
".",
"split",
"(",
")",
"result",
"=",
"CLIArgumentType",
"(",
")",
"for",
"index",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"parts",
")",
"+",
... | Get the argument for the command after applying the scope hierarchy
:param command: The command that we want the argument for
:type command: str
:param name: The name of the argument
:type name: str
:return: The CLI command after all overrides in the scope hierarchy have been ap... | [
"Get",
"the",
"argument",
"for",
"the",
"command",
"after",
"applying",
"the",
"scope",
"hierarchy"
] | 5f1a480a33f103e2688c46eef59fb2d9eaf2baad | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/arguments.py#L107-L124 | train |
Microsoft/knack | knack/arguments.py | ArgumentsContext.argument | def argument(self, argument_dest, arg_type=None, **kwargs):
""" Register an argument for the given command scope using a knack.arguments.CLIArgumentType
:param argument_dest: The destination argument to add this argument type to
:type argument_dest: str
:param arg_type: Predefined CLIAr... | python | def argument(self, argument_dest, arg_type=None, **kwargs):
""" Register an argument for the given command scope using a knack.arguments.CLIArgumentType
:param argument_dest: The destination argument to add this argument type to
:type argument_dest: str
:param arg_type: Predefined CLIAr... | [
"def",
"argument",
"(",
"self",
",",
"argument_dest",
",",
"arg_type",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"_check_stale",
"(",
")",
"if",
"not",
"self",
".",
"_applicable",
"(",
")",
":",
"return",
"deprecate_action",
"=",
"self",
... | Register an argument for the given command scope using a knack.arguments.CLIArgumentType
:param argument_dest: The destination argument to add this argument type to
:type argument_dest: str
:param arg_type: Predefined CLIArgumentType definition to register, as modified by any provided kwargs.
... | [
"Register",
"an",
"argument",
"for",
"the",
"given",
"command",
"scope",
"using",
"a",
"knack",
".",
"arguments",
".",
"CLIArgumentType"
] | 5f1a480a33f103e2688c46eef59fb2d9eaf2baad | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/arguments.py#L247-L267 | train |
Microsoft/knack | knack/arguments.py | ArgumentsContext.positional | def positional(self, argument_dest, arg_type=None, **kwargs):
""" Register a positional argument for the given command scope using a knack.arguments.CLIArgumentType
:param argument_dest: The destination argument to add this argument type to
:type argument_dest: str
:param arg_type: Pred... | python | def positional(self, argument_dest, arg_type=None, **kwargs):
""" Register a positional argument for the given command scope using a knack.arguments.CLIArgumentType
:param argument_dest: The destination argument to add this argument type to
:type argument_dest: str
:param arg_type: Pred... | [
"def",
"positional",
"(",
"self",
",",
"argument_dest",
",",
"arg_type",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"_check_stale",
"(",
")",
"if",
"not",
"self",
".",
"_applicable",
"(",
")",
":",
"return",
"if",
"self",
".",
"command_sc... | Register a positional argument for the given command scope using a knack.arguments.CLIArgumentType
:param argument_dest: The destination argument to add this argument type to
:type argument_dest: str
:param arg_type: Predefined CLIArgumentType definition to register, as modified by any provided... | [
"Register",
"a",
"positional",
"argument",
"for",
"the",
"given",
"command",
"scope",
"using",
"a",
"knack",
".",
"arguments",
".",
"CLIArgumentType"
] | 5f1a480a33f103e2688c46eef59fb2d9eaf2baad | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/arguments.py#L269-L304 | train |
Microsoft/knack | knack/arguments.py | ArgumentsContext.extra | def extra(self, argument_dest, **kwargs):
"""Register extra parameters for the given command. Typically used to augment auto-command built
commands to add more parameters than the specific SDK method introspected.
:param argument_dest: The destination argument to add this argument type to
... | python | def extra(self, argument_dest, **kwargs):
"""Register extra parameters for the given command. Typically used to augment auto-command built
commands to add more parameters than the specific SDK method introspected.
:param argument_dest: The destination argument to add this argument type to
... | [
"def",
"extra",
"(",
"self",
",",
"argument_dest",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"_check_stale",
"(",
")",
"if",
"not",
"self",
".",
"_applicable",
"(",
")",
":",
"return",
"if",
"self",
".",
"command_scope",
"in",
"self",
".",
"command_l... | Register extra parameters for the given command. Typically used to augment auto-command built
commands to add more parameters than the specific SDK method introspected.
:param argument_dest: The destination argument to add this argument type to
:type argument_dest: str
:param kwargs: Po... | [
"Register",
"extra",
"parameters",
"for",
"the",
"given",
"command",
".",
"Typically",
"used",
"to",
"augment",
"auto",
"-",
"command",
"built",
"commands",
"to",
"add",
"more",
"parameters",
"than",
"the",
"specific",
"SDK",
"method",
"introspected",
"."
] | 5f1a480a33f103e2688c46eef59fb2d9eaf2baad | https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/arguments.py#L319-L341 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.