partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | _keywords.wait_until_page_does_not_contain_these_elements | Waits until all of the specified elements are not found on the page.
| *Argument* | *Description* | *Example* |
| timeout | maximum time to wait, if set to ${None} it will use Selenium's default timeout | 5s |
| *locators | Selenium 2 element locator(s) | id=MyId | | src/Selenium2LibraryExtension/keywords/__init__.py | def wait_until_page_does_not_contain_these_elements(self, timeout, *locators):
"""Waits until all of the specified elements are not found on the page.
| *Argument* | *Description* | *Example* |
| timeout | maximum time to wait, if set to ${None} it will use Selenium's default timeout | 5s |
| *locators | Selen... | def wait_until_page_does_not_contain_these_elements(self, timeout, *locators):
"""Waits until all of the specified elements are not found on the page.
| *Argument* | *Description* | *Example* |
| timeout | maximum time to wait, if set to ${None} it will use Selenium's default timeout | 5s |
| *locators | Selen... | [
"Waits",
"until",
"all",
"of",
"the",
"specified",
"elements",
"are",
"not",
"found",
"on",
"the",
"page",
"."
] | ASKIDA/Selenium2LibraryExtension | python | https://github.com/ASKIDA/Selenium2LibraryExtension/blob/5ca3fa776063c6046dff317cb2575e4772d7541f/src/Selenium2LibraryExtension/keywords/__init__.py#L411-L418 | [
"def",
"wait_until_page_does_not_contain_these_elements",
"(",
"self",
",",
"timeout",
",",
"*",
"locators",
")",
":",
"self",
".",
"_wait_until_no_error",
"(",
"timeout",
",",
"self",
".",
"_wait_for_elements_to_go_away",
",",
"locators",
")"
] | 5ca3fa776063c6046dff317cb2575e4772d7541f |
train | _keywords.tap_key | Presses the specified `key`. The `complementKey` defines the key to hold
when pressing the specified `key`. For example, you could use ${VK_TAB} as `key` and
use ${VK_SHIFT} as `complementKey' in order to press Shift + Tab (back tab)
| =Argument= | =Description= | =Example= |
| key | the key to press | ${VK_F4... | src/Selenium2LibraryExtension/keywords/__init__.py | def tap_key(self, key, complementKey=None) :
"""Presses the specified `key`. The `complementKey` defines the key to hold
when pressing the specified `key`. For example, you could use ${VK_TAB} as `key` and
use ${VK_SHIFT} as `complementKey' in order to press Shift + Tab (back tab)
| =Argument= | =Description= ... | def tap_key(self, key, complementKey=None) :
"""Presses the specified `key`. The `complementKey` defines the key to hold
when pressing the specified `key`. For example, you could use ${VK_TAB} as `key` and
use ${VK_SHIFT} as `complementKey' in order to press Shift + Tab (back tab)
| =Argument= | =Description= ... | [
"Presses",
"the",
"specified",
"key",
".",
"The",
"complementKey",
"defines",
"the",
"key",
"to",
"hold",
"when",
"pressing",
"the",
"specified",
"key",
".",
"For",
"example",
"you",
"could",
"use",
"$",
"{",
"VK_TAB",
"}",
"as",
"key",
"and",
"use",
"$"... | ASKIDA/Selenium2LibraryExtension | python | https://github.com/ASKIDA/Selenium2LibraryExtension/blob/5ca3fa776063c6046dff317cb2575e4772d7541f/src/Selenium2LibraryExtension/keywords/__init__.py#L426-L441 | [
"def",
"tap_key",
"(",
"self",
",",
"key",
",",
"complementKey",
"=",
"None",
")",
":",
"driver",
"=",
"self",
".",
"_current_browser",
"(",
")",
"if",
"(",
"complementKey",
"is",
"not",
"None",
")",
":",
"ActionChains",
"(",
"driver",
")",
".",
"key_d... | 5ca3fa776063c6046dff317cb2575e4772d7541f |
train | _keywords.wait_until_element_is_clickable | Clicks the element specified by `locator` until the operation succeeds. This should be
used with buttons that are generated in real-time and that don't have their click handling available
immediately. This keyword avoids unclickable element exceptions.
| =Argument= | =Description= | =Example= |
| locator | Sel... | src/Selenium2LibraryExtension/keywords/__init__.py | def wait_until_element_is_clickable(self, locator, timeout=None):
"""Clicks the element specified by `locator` until the operation succeeds. This should be
used with buttons that are generated in real-time and that don't have their click handling available
immediately. This keyword avoids unclickable element exce... | def wait_until_element_is_clickable(self, locator, timeout=None):
"""Clicks the element specified by `locator` until the operation succeeds. This should be
used with buttons that are generated in real-time and that don't have their click handling available
immediately. This keyword avoids unclickable element exce... | [
"Clicks",
"the",
"element",
"specified",
"by",
"locator",
"until",
"the",
"operation",
"succeeds",
".",
"This",
"should",
"be",
"used",
"with",
"buttons",
"that",
"are",
"generated",
"in",
"real",
"-",
"time",
"and",
"that",
"don",
"t",
"have",
"their",
"c... | ASKIDA/Selenium2LibraryExtension | python | https://github.com/ASKIDA/Selenium2LibraryExtension/blob/5ca3fa776063c6046dff317cb2575e4772d7541f/src/Selenium2LibraryExtension/keywords/__init__.py#L449-L458 | [
"def",
"wait_until_element_is_clickable",
"(",
"self",
",",
"locator",
",",
"timeout",
"=",
"None",
")",
":",
"self",
".",
"_wait_until_no_error",
"(",
"timeout",
",",
"self",
".",
"_wait_for_click_to_succeed",
",",
"locator",
")"
] | 5ca3fa776063c6046dff317cb2575e4772d7541f |
train | _visitor_impl | Actual visitor method implementation. | luaparser/utils/visitor.py | def _visitor_impl(self, arg):
"""Actual visitor method implementation."""
if (_qualname(type(self)), type(arg)) in _methods:
method = _methods[(_qualname(type(self)), type(arg))]
return method(self, arg)
else:
# if no visitor method found for this arg type,
# search in parent... | def _visitor_impl(self, arg):
"""Actual visitor method implementation."""
if (_qualname(type(self)), type(arg)) in _methods:
method = _methods[(_qualname(type(self)), type(arg))]
return method(self, arg)
else:
# if no visitor method found for this arg type,
# search in parent... | [
"Actual",
"visitor",
"method",
"implementation",
"."
] | boolangery/py-lua-parser | python | https://github.com/boolangery/py-lua-parser/blob/578f2bf75f6f84c4b52c2affba56a4ec569d7ce7/luaparser/utils/visitor.py#L25-L40 | [
"def",
"_visitor_impl",
"(",
"self",
",",
"arg",
")",
":",
"if",
"(",
"_qualname",
"(",
"type",
"(",
"self",
")",
")",
",",
"type",
"(",
"arg",
")",
")",
"in",
"_methods",
":",
"method",
"=",
"_methods",
"[",
"(",
"_qualname",
"(",
"type",
"(",
"... | 578f2bf75f6f84c4b52c2affba56a4ec569d7ce7 |
train | visitor | Decorator that creates a visitor method. | luaparser/utils/visitor.py | def visitor(arg_type):
"""Decorator that creates a visitor method."""
def decorator(fn):
declaring_class = _declaring_class(fn)
_methods[(declaring_class, arg_type)] = fn
# Replace all decorated methods with _visitor_impl
return _visitor_impl
return decorator | def visitor(arg_type):
"""Decorator that creates a visitor method."""
def decorator(fn):
declaring_class = _declaring_class(fn)
_methods[(declaring_class, arg_type)] = fn
# Replace all decorated methods with _visitor_impl
return _visitor_impl
return decorator | [
"Decorator",
"that",
"creates",
"a",
"visitor",
"method",
"."
] | boolangery/py-lua-parser | python | https://github.com/boolangery/py-lua-parser/blob/578f2bf75f6f84c4b52c2affba56a4ec569d7ce7/luaparser/utils/visitor.py#L44-L54 | [
"def",
"visitor",
"(",
"arg_type",
")",
":",
"def",
"decorator",
"(",
"fn",
")",
":",
"declaring_class",
"=",
"_declaring_class",
"(",
"fn",
")",
"_methods",
"[",
"(",
"declaring_class",
",",
"arg_type",
")",
"]",
"=",
"fn",
"# Replace all decorated methods wi... | 578f2bf75f6f84c4b52c2affba56a4ec569d7ce7 |
train | absolute | Returns a full absolute URL based on the request host.
This template tag takes exactly the same paramters as url template tag. | absolute/templatetags/absolute.py | def absolute(parser, token):
'''
Returns a full absolute URL based on the request host.
This template tag takes exactly the same paramters as url template tag.
'''
node = url(parser, token)
return AbsoluteUrlNode(
view_name=node.view_name,
args=node.args,
kwargs=node.kwa... | def absolute(parser, token):
'''
Returns a full absolute URL based on the request host.
This template tag takes exactly the same paramters as url template tag.
'''
node = url(parser, token)
return AbsoluteUrlNode(
view_name=node.view_name,
args=node.args,
kwargs=node.kwa... | [
"Returns",
"a",
"full",
"absolute",
"URL",
"based",
"on",
"the",
"request",
"host",
"."
] | noirbizarre/django-absolute | python | https://github.com/noirbizarre/django-absolute/blob/0358fd39c641afdb589f448c0dae72d816c4e5f2/absolute/templatetags/absolute.py#L24-L36 | [
"def",
"absolute",
"(",
"parser",
",",
"token",
")",
":",
"node",
"=",
"url",
"(",
"parser",
",",
"token",
")",
"return",
"AbsoluteUrlNode",
"(",
"view_name",
"=",
"node",
".",
"view_name",
",",
"args",
"=",
"node",
".",
"args",
",",
"kwargs",
"=",
"... | 0358fd39c641afdb589f448c0dae72d816c4e5f2 |
train | site | Returns a full absolute URL based on the current site.
This template tag takes exactly the same paramters as url template tag. | absolute/templatetags/absolute.py | def site(parser, token):
'''
Returns a full absolute URL based on the current site.
This template tag takes exactly the same paramters as url template tag.
'''
node = url(parser, token)
return SiteUrlNode(
view_name=node.view_name,
args=node.args,
kwargs=node.kwargs,
... | def site(parser, token):
'''
Returns a full absolute URL based on the current site.
This template tag takes exactly the same paramters as url template tag.
'''
node = url(parser, token)
return SiteUrlNode(
view_name=node.view_name,
args=node.args,
kwargs=node.kwargs,
... | [
"Returns",
"a",
"full",
"absolute",
"URL",
"based",
"on",
"the",
"current",
"site",
"."
] | noirbizarre/django-absolute | python | https://github.com/noirbizarre/django-absolute/blob/0358fd39c641afdb589f448c0dae72d816c4e5f2/absolute/templatetags/absolute.py#L59-L71 | [
"def",
"site",
"(",
"parser",
",",
"token",
")",
":",
"node",
"=",
"url",
"(",
"parser",
",",
"token",
")",
"return",
"SiteUrlNode",
"(",
"view_name",
"=",
"node",
".",
"view_name",
",",
"args",
"=",
"node",
".",
"args",
",",
"kwargs",
"=",
"node",
... | 0358fd39c641afdb589f448c0dae72d816c4e5f2 |
train | _patches._wait_until_exp | This replaces the method from Selenium2Library to fix the major logic error in it | src/Selenium2LibraryExtension/patches/__init__.py | def _wait_until_exp(self, timeout, error, function, *args):
"""This replaces the method from Selenium2Library to fix the major logic error in it"""
error = error.replace('<TIMEOUT>', self._format_timeout(timeout))
def wait_func():
return None if function(*args) else error
self._wait_until_no_error_ex... | def _wait_until_exp(self, timeout, error, function, *args):
"""This replaces the method from Selenium2Library to fix the major logic error in it"""
error = error.replace('<TIMEOUT>', self._format_timeout(timeout))
def wait_func():
return None if function(*args) else error
self._wait_until_no_error_ex... | [
"This",
"replaces",
"the",
"method",
"from",
"Selenium2Library",
"to",
"fix",
"the",
"major",
"logic",
"error",
"in",
"it"
] | ASKIDA/Selenium2LibraryExtension | python | https://github.com/ASKIDA/Selenium2LibraryExtension/blob/5ca3fa776063c6046dff317cb2575e4772d7541f/src/Selenium2LibraryExtension/patches/__init__.py#L13-L21 | [
"def",
"_wait_until_exp",
"(",
"self",
",",
"timeout",
",",
"error",
",",
"function",
",",
"*",
"args",
")",
":",
"error",
"=",
"error",
".",
"replace",
"(",
"'<TIMEOUT>'",
",",
"self",
".",
"_format_timeout",
"(",
"timeout",
")",
")",
"def",
"wait_func"... | 5ca3fa776063c6046dff317cb2575e4772d7541f |
train | _patches._wait_until_no_error_exp | This replaces the method from Selenium2Library to fix the major logic error in it | src/Selenium2LibraryExtension/patches/__init__.py | def _wait_until_no_error_exp(self, timeout, wait_func, *args):
"""This replaces the method from Selenium2Library to fix the major logic error in it"""
timeout = robot.utils.timestr_to_secs(timeout) if timeout is not None else self._timeout_in_secs
maxtime = time.time() + timeout
while True:
try:
... | def _wait_until_no_error_exp(self, timeout, wait_func, *args):
"""This replaces the method from Selenium2Library to fix the major logic error in it"""
timeout = robot.utils.timestr_to_secs(timeout) if timeout is not None else self._timeout_in_secs
maxtime = time.time() + timeout
while True:
try:
... | [
"This",
"replaces",
"the",
"method",
"from",
"Selenium2Library",
"to",
"fix",
"the",
"major",
"logic",
"error",
"in",
"it"
] | ASKIDA/Selenium2LibraryExtension | python | https://github.com/ASKIDA/Selenium2LibraryExtension/blob/5ca3fa776063c6046dff317cb2575e4772d7541f/src/Selenium2LibraryExtension/patches/__init__.py#L23-L44 | [
"def",
"_wait_until_no_error_exp",
"(",
"self",
",",
"timeout",
",",
"wait_func",
",",
"*",
"args",
")",
":",
"timeout",
"=",
"robot",
".",
"utils",
".",
"timestr_to_secs",
"(",
"timeout",
")",
"if",
"timeout",
"is",
"not",
"None",
"else",
"self",
".",
"... | 5ca3fa776063c6046dff317cb2575e4772d7541f |
train | rst | Load rst file and sanitize it for PyPI.
Remove unsupported github tags:
- code-block directive | setup.py | def rst(filename):
'''
Load rst file and sanitize it for PyPI.
Remove unsupported github tags:
- code-block directive
'''
content = open(filename).read()
return re.sub(r'\.\.\s? code-block::\s*(\w|\+)+', '::', content) | def rst(filename):
'''
Load rst file and sanitize it for PyPI.
Remove unsupported github tags:
- code-block directive
'''
content = open(filename).read()
return re.sub(r'\.\.\s? code-block::\s*(\w|\+)+', '::', content) | [
"Load",
"rst",
"file",
"and",
"sanitize",
"it",
"for",
"PyPI",
".",
"Remove",
"unsupported",
"github",
"tags",
":",
"-",
"code",
"-",
"block",
"directive"
] | noirbizarre/django-absolute | python | https://github.com/noirbizarre/django-absolute/blob/0358fd39c641afdb589f448c0dae72d816c4e5f2/setup.py#L7-L14 | [
"def",
"rst",
"(",
"filename",
")",
":",
"content",
"=",
"open",
"(",
"filename",
")",
".",
"read",
"(",
")",
"return",
"re",
".",
"sub",
"(",
"r'\\.\\.\\s? code-block::\\s*(\\w|\\+)+'",
",",
"'::'",
",",
"content",
")"
] | 0358fd39c641afdb589f448c0dae72d816c4e5f2 |
train | get_callable_method_dict | Returns a dictionary of callable methods of object `obj`.
@param obj: ZOS API Python COM object
@return: a dictionary of callable methods
Notes:
the function only returns the callable attributes that are listed by dir()
function. Properties are not returned. | pyzos/zosutils.py | def get_callable_method_dict(obj):
"""Returns a dictionary of callable methods of object `obj`.
@param obj: ZOS API Python COM object
@return: a dictionary of callable methods
Notes:
the function only returns the callable attributes that are listed by dir()
function. Properties are not r... | def get_callable_method_dict(obj):
"""Returns a dictionary of callable methods of object `obj`.
@param obj: ZOS API Python COM object
@return: a dictionary of callable methods
Notes:
the function only returns the callable attributes that are listed by dir()
function. Properties are not r... | [
"Returns",
"a",
"dictionary",
"of",
"callable",
"methods",
"of",
"object",
"obj",
"."
] | indranilsinharoy/pyzos | python | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zosutils.py#L14-L29 | [
"def",
"get_callable_method_dict",
"(",
"obj",
")",
":",
"methodDict",
"=",
"{",
"}",
"for",
"methodStr",
"in",
"dir",
"(",
"obj",
")",
":",
"method",
"=",
"getattr",
"(",
"obj",
",",
"methodStr",
",",
"'none'",
")",
"if",
"callable",
"(",
"method",
")... | da6bf3296b0154ccee44ad9a4286055ae031ecc7 |
train | replicate_methods | Replicate callable methods from a `srcObj` to `dstObj` (generally a wrapper object).
@param srcObj: source object
@param dstObj: destination object of the same type.
@return : none
Implementer notes:
1. Once the methods are mapped from the `srcObj` to the `dstObj`, the method calls will ... | pyzos/zosutils.py | def replicate_methods(srcObj, dstObj):
"""Replicate callable methods from a `srcObj` to `dstObj` (generally a wrapper object).
@param srcObj: source object
@param dstObj: destination object of the same type.
@return : none
Implementer notes:
1. Once the methods are mapped from the `s... | def replicate_methods(srcObj, dstObj):
"""Replicate callable methods from a `srcObj` to `dstObj` (generally a wrapper object).
@param srcObj: source object
@param dstObj: destination object of the same type.
@return : none
Implementer notes:
1. Once the methods are mapped from the `s... | [
"Replicate",
"callable",
"methods",
"from",
"a",
"srcObj",
"to",
"dstObj",
"(",
"generally",
"a",
"wrapper",
"object",
")",
"."
] | indranilsinharoy/pyzos | python | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zosutils.py#L31-L64 | [
"def",
"replicate_methods",
"(",
"srcObj",
",",
"dstObj",
")",
":",
"# prevent methods that we intend to specialize from being mapped. The specialized ",
"# (overridden) methods are methods with the same name as the corresponding method in ",
"# the source ZOS API COM object written for each ZOS... | da6bf3296b0154ccee44ad9a4286055ae031ecc7 |
train | get_properties | Returns a lists of properties bound to the object `zos_obj`
@param zos_obj: ZOS API Python COM object
@return prop_get: list of properties that are only getters
@return prop_set: list of properties that are both getters and setters | pyzos/zosutils.py | def get_properties(zos_obj):
"""Returns a lists of properties bound to the object `zos_obj`
@param zos_obj: ZOS API Python COM object
@return prop_get: list of properties that are only getters
@return prop_set: list of properties that are both getters and setters
"""
prop_get = set(zos_obj._pro... | def get_properties(zos_obj):
"""Returns a lists of properties bound to the object `zos_obj`
@param zos_obj: ZOS API Python COM object
@return prop_get: list of properties that are only getters
@return prop_set: list of properties that are both getters and setters
"""
prop_get = set(zos_obj._pro... | [
"Returns",
"a",
"lists",
"of",
"properties",
"bound",
"to",
"the",
"object",
"zos_obj"
] | indranilsinharoy/pyzos | python | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zosutils.py#L66-L80 | [
"def",
"get_properties",
"(",
"zos_obj",
")",
":",
"prop_get",
"=",
"set",
"(",
"zos_obj",
".",
"_prop_map_get_",
".",
"keys",
"(",
")",
")",
"prop_set",
"=",
"set",
"(",
"zos_obj",
".",
"_prop_map_put_",
".",
"keys",
"(",
")",
")",
"if",
"prop_set",
"... | da6bf3296b0154ccee44ad9a4286055ae031ecc7 |
train | managed_wrapper_class_factory | Creates and returns a wrapper class of a ZOS object, exposing the ZOS objects
methods and propertis, and patching custom specialized attributes
@param zos_obj: ZOS API Python COM object | pyzos/zosutils.py | def managed_wrapper_class_factory(zos_obj):
"""Creates and returns a wrapper class of a ZOS object, exposing the ZOS objects
methods and propertis, and patching custom specialized attributes
@param zos_obj: ZOS API Python COM object
"""
cls_name = repr(zos_obj).split()[0].split('.')[-1]
disp... | def managed_wrapper_class_factory(zos_obj):
"""Creates and returns a wrapper class of a ZOS object, exposing the ZOS objects
methods and propertis, and patching custom specialized attributes
@param zos_obj: ZOS API Python COM object
"""
cls_name = repr(zos_obj).split()[0].split('.')[-1]
disp... | [
"Creates",
"and",
"returns",
"a",
"wrapper",
"class",
"of",
"a",
"ZOS",
"object",
"exposing",
"the",
"ZOS",
"objects",
"methods",
"and",
"propertis",
"and",
"patching",
"custom",
"specialized",
"attributes"
] | indranilsinharoy/pyzos | python | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zosutils.py#L115-L192 | [
"def",
"managed_wrapper_class_factory",
"(",
"zos_obj",
")",
":",
"cls_name",
"=",
"repr",
"(",
"zos_obj",
")",
".",
"split",
"(",
")",
"[",
"0",
"]",
".",
"split",
"(",
"'.'",
")",
"[",
"-",
"1",
"]",
"dispatch_attr",
"=",
"'_'",
"+",
"cls_name",
".... | da6bf3296b0154ccee44ad9a4286055ae031ecc7 |
train | wrapped_zos_object | Helper function to wrap ZOS API COM objects.
@param zos_obj : ZOS API Python COM object
@return: instance of the wrapped ZOS API class. If the input object is not a ZOS-API
COM object or if it is already wrapped, then the object is returned without
wrapping.
Notes:
The funct... | pyzos/zosutils.py | def wrapped_zos_object(zos_obj):
"""Helper function to wrap ZOS API COM objects.
@param zos_obj : ZOS API Python COM object
@return: instance of the wrapped ZOS API class. If the input object is not a ZOS-API
COM object or if it is already wrapped, then the object is returned without
... | def wrapped_zos_object(zos_obj):
"""Helper function to wrap ZOS API COM objects.
@param zos_obj : ZOS API Python COM object
@return: instance of the wrapped ZOS API class. If the input object is not a ZOS-API
COM object or if it is already wrapped, then the object is returned without
... | [
"Helper",
"function",
"to",
"wrap",
"ZOS",
"API",
"COM",
"objects",
"."
] | indranilsinharoy/pyzos | python | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zosutils.py#L194-L210 | [
"def",
"wrapped_zos_object",
"(",
"zos_obj",
")",
":",
"if",
"hasattr",
"(",
"zos_obj",
",",
"'_wrapped'",
")",
"or",
"(",
"'CLSID'",
"not",
"in",
"dir",
"(",
"zos_obj",
")",
")",
":",
"return",
"zos_obj",
"else",
":",
"Class",
"=",
"managed_wrapper_class_... | da6bf3296b0154ccee44ad9a4286055ae031ecc7 |
train | generate_public_and_private | <Purpose>
Generate a pair of ECDSA public and private keys with one of the supported,
external cryptography libraries. The public and private keys returned
conform to 'securesystemslib.formats.PEMECDSA_SCHEMA' and
'securesystemslib.formats.PEMECDSA_SCHEMA', respectively.
The public ECDSA public ke... | securesystemslib/ecdsa_keys.py | def generate_public_and_private(scheme='ecdsa-sha2-nistp256'):
"""
<Purpose>
Generate a pair of ECDSA public and private keys with one of the supported,
external cryptography libraries. The public and private keys returned
conform to 'securesystemslib.formats.PEMECDSA_SCHEMA' and
'securesystemslib.... | def generate_public_and_private(scheme='ecdsa-sha2-nistp256'):
"""
<Purpose>
Generate a pair of ECDSA public and private keys with one of the supported,
external cryptography libraries. The public and private keys returned
conform to 'securesystemslib.formats.PEMECDSA_SCHEMA' and
'securesystemslib.... | [
"<Purpose",
">",
"Generate",
"a",
"pair",
"of",
"ECDSA",
"public",
"and",
"private",
"keys",
"with",
"one",
"of",
"the",
"supported",
"external",
"cryptography",
"libraries",
".",
"The",
"public",
"and",
"private",
"keys",
"returned",
"conform",
"to",
"secures... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/ecdsa_keys.py#L67-L155 | [
"def",
"generate_public_and_private",
"(",
"scheme",
"=",
"'ecdsa-sha2-nistp256'",
")",
":",
"# Does 'scheme' have the correct format?",
"# Verify that 'scheme' is of the correct type, and that it's one of the",
"# supported ECDSA . It must conform to",
"# 'securesystemslib.formats.ECDSA_SCHE... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | create_signature | <Purpose>
Return a (signature, scheme) tuple.
>>> requested_scheme = 'ecdsa-sha2-nistp256'
>>> public, private = generate_public_and_private(requested_scheme)
>>> data = b'The quick brown fox jumps over the lazy dog'
>>> signature, scheme = create_signature(public, private, data, requested_scheme)
... | securesystemslib/ecdsa_keys.py | def create_signature(public_key, private_key, data, scheme='ecdsa-sha2-nistp256'):
"""
<Purpose>
Return a (signature, scheme) tuple.
>>> requested_scheme = 'ecdsa-sha2-nistp256'
>>> public, private = generate_public_and_private(requested_scheme)
>>> data = b'The quick brown fox jumps over the lazy ... | def create_signature(public_key, private_key, data, scheme='ecdsa-sha2-nistp256'):
"""
<Purpose>
Return a (signature, scheme) tuple.
>>> requested_scheme = 'ecdsa-sha2-nistp256'
>>> public, private = generate_public_and_private(requested_scheme)
>>> data = b'The quick brown fox jumps over the lazy ... | [
"<Purpose",
">",
"Return",
"a",
"(",
"signature",
"scheme",
")",
"tuple",
"."
] | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/ecdsa_keys.py#L161-L240 | [
"def",
"create_signature",
"(",
"public_key",
",",
"private_key",
",",
"data",
",",
"scheme",
"=",
"'ecdsa-sha2-nistp256'",
")",
":",
"# Do 'public_key' and 'private_key' have the correct format?",
"# This check will ensure that the arguments conform to",
"# 'securesystemslib.formats... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | verify_signature | <Purpose>
Verify that 'signature' was produced by the private key associated with
'public_key'.
>>> scheme = 'ecdsa-sha2-nistp256'
>>> public, private = generate_public_and_private(scheme)
>>> data = b'The quick brown fox jumps over the lazy dog'
>>> signature, scheme = create_signature(public,... | securesystemslib/ecdsa_keys.py | def verify_signature(public_key, scheme, signature, data):
"""
<Purpose>
Verify that 'signature' was produced by the private key associated with
'public_key'.
>>> scheme = 'ecdsa-sha2-nistp256'
>>> public, private = generate_public_and_private(scheme)
>>> data = b'The quick brown fox jumps over... | def verify_signature(public_key, scheme, signature, data):
"""
<Purpose>
Verify that 'signature' was produced by the private key associated with
'public_key'.
>>> scheme = 'ecdsa-sha2-nistp256'
>>> public, private = generate_public_and_private(scheme)
>>> data = b'The quick brown fox jumps over... | [
"<Purpose",
">",
"Verify",
"that",
"signature",
"was",
"produced",
"by",
"the",
"private",
"key",
"associated",
"with",
"public_key",
"."
] | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/ecdsa_keys.py#L246-L315 | [
"def",
"verify_signature",
"(",
"public_key",
",",
"scheme",
",",
"signature",
",",
"data",
")",
":",
"# Are the arguments properly formatted?",
"# If not, raise 'securesystemslib.exceptions.FormatError'.",
"securesystemslib",
".",
"formats",
".",
"PEMECDSA_SCHEMA",
".",
"che... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | create_ecdsa_public_and_private_from_pem | <Purpose>
Create public and private ECDSA keys from a private 'pem'. The public and
private keys are strings in PEM format:
public: '-----BEGIN PUBLIC KEY----- ... -----END PUBLIC KEY-----',
private: '-----BEGIN EC PRIVATE KEY----- ... -----END EC PRIVATE KEY-----'}}
>>> junk, private = generate_... | securesystemslib/ecdsa_keys.py | def create_ecdsa_public_and_private_from_pem(pem, password=None):
"""
<Purpose>
Create public and private ECDSA keys from a private 'pem'. The public and
private keys are strings in PEM format:
public: '-----BEGIN PUBLIC KEY----- ... -----END PUBLIC KEY-----',
private: '-----BEGIN EC PRIVATE KEY--... | def create_ecdsa_public_and_private_from_pem(pem, password=None):
"""
<Purpose>
Create public and private ECDSA keys from a private 'pem'. The public and
private keys are strings in PEM format:
public: '-----BEGIN PUBLIC KEY----- ... -----END PUBLIC KEY-----',
private: '-----BEGIN EC PRIVATE KEY--... | [
"<Purpose",
">",
"Create",
"public",
"and",
"private",
"ECDSA",
"keys",
"from",
"a",
"private",
"pem",
".",
"The",
"public",
"and",
"private",
"keys",
"are",
"strings",
"in",
"PEM",
"format",
":"
] | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/ecdsa_keys.py#L321-L405 | [
"def",
"create_ecdsa_public_and_private_from_pem",
"(",
"pem",
",",
"password",
"=",
"None",
")",
":",
"# Does 'pem' have the correct format?",
"# This check will ensure 'pem' conforms to",
"# 'securesystemslib.formats.ECDSARSA_SCHEMA'.",
"securesystemslib",
".",
"formats",
".",
"P... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | create_ecdsa_encrypted_pem | <Purpose>
Return a string in PEM format, where the private part of the ECDSA key is
encrypted. The private part of the ECDSA key is encrypted as done by
pyca/cryptography: "Encrypt using the best available encryption for a given
key's backend. This is a curated encryption choice and the algorithm may
... | securesystemslib/ecdsa_keys.py | def create_ecdsa_encrypted_pem(private_pem, passphrase):
"""
<Purpose>
Return a string in PEM format, where the private part of the ECDSA key is
encrypted. The private part of the ECDSA key is encrypted as done by
pyca/cryptography: "Encrypt using the best available encryption for a given
key's back... | def create_ecdsa_encrypted_pem(private_pem, passphrase):
"""
<Purpose>
Return a string in PEM format, where the private part of the ECDSA key is
encrypted. The private part of the ECDSA key is encrypted as done by
pyca/cryptography: "Encrypt using the best available encryption for a given
key's back... | [
"<Purpose",
">",
"Return",
"a",
"string",
"in",
"PEM",
"format",
"where",
"the",
"private",
"part",
"of",
"the",
"ECDSA",
"key",
"is",
"encrypted",
".",
"The",
"private",
"part",
"of",
"the",
"ECDSA",
"key",
"is",
"encrypted",
"as",
"done",
"by",
"pyca",... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/ecdsa_keys.py#L411-L467 | [
"def",
"create_ecdsa_encrypted_pem",
"(",
"private_pem",
",",
"passphrase",
")",
":",
"# Does 'private_key' have the correct format?",
"# Raise 'securesystemslib.exceptions.FormatError' if the check fails.",
"securesystemslib",
".",
"formats",
".",
"PEMRSA_SCHEMA",
".",
"check_match"... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | OldHEPData.reset | Clean any processing data, and prepare object for reuse | hepdata_converter/parsers/oldhepdata_parser.py | def reset(self):
"""Clean any processing data, and prepare object for reuse
"""
self.current_table = None
self.tables = []
self.data = [{}]
self.additional_data = {}
self.lines = []
self.set_state('document')
self.current_file = None
self.s... | def reset(self):
"""Clean any processing data, and prepare object for reuse
"""
self.current_table = None
self.tables = []
self.data = [{}]
self.additional_data = {}
self.lines = []
self.set_state('document')
self.current_file = None
self.s... | [
"Clean",
"any",
"processing",
"data",
"and",
"prepare",
"object",
"for",
"reuse"
] | HEPData/hepdata-converter | python | https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/parsers/oldhepdata_parser.py#L34-L44 | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"current_table",
"=",
"None",
"self",
".",
"tables",
"=",
"[",
"]",
"self",
".",
"data",
"=",
"[",
"{",
"}",
"]",
"self",
".",
"additional_data",
"=",
"{",
"}",
"self",
".",
"lines",
"=",
"[",
... | 354271448980efba86f2f3d27b99d818e75fd90d |
train | OldHEPData._parse_line | Parse single line (or more if particular keyword actually demands it)
:param file:
:type file: file | hepdata_converter/parsers/oldhepdata_parser.py | def _parse_line(self, file):
"""Parse single line (or more if particular keyword actually demands it)
:param file:
:type file: file
"""
line = self._strip_comments(file.readline())
# check if the file ended
if not line:
return False
# line w... | def _parse_line(self, file):
"""Parse single line (or more if particular keyword actually demands it)
:param file:
:type file: file
"""
line = self._strip_comments(file.readline())
# check if the file ended
if not line:
return False
# line w... | [
"Parse",
"single",
"line",
"(",
"or",
"more",
"if",
"particular",
"keyword",
"actually",
"demands",
"it",
")"
] | HEPData/hepdata-converter | python | https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/parsers/oldhepdata_parser.py#L136-L165 | [
"def",
"_parse_line",
"(",
"self",
",",
"file",
")",
":",
"line",
"=",
"self",
".",
"_strip_comments",
"(",
"file",
".",
"readline",
"(",
")",
")",
"# check if the file ended",
"if",
"not",
"line",
":",
"return",
"False",
"# line was empty or it was a comment, c... | 354271448980efba86f2f3d27b99d818e75fd90d |
train | OldHEPData._set_table | Set current parsing state to 'table',
create new table object and add it to tables collection | hepdata_converter/parsers/oldhepdata_parser.py | def _set_table(self, data):
"""Set current parsing state to 'table',
create new table object and add it to tables collection
"""
self.set_state('table')
self.current_table = HEPTable(index=len(self.tables) + 1)
self.tables.append(self.current_table)
self.data.appe... | def _set_table(self, data):
"""Set current parsing state to 'table',
create new table object and add it to tables collection
"""
self.set_state('table')
self.current_table = HEPTable(index=len(self.tables) + 1)
self.tables.append(self.current_table)
self.data.appe... | [
"Set",
"current",
"parsing",
"state",
"to",
"table",
"create",
"new",
"table",
"object",
"and",
"add",
"it",
"to",
"tables",
"collection"
] | HEPData/hepdata-converter | python | https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/parsers/oldhepdata_parser.py#L183-L190 | [
"def",
"_set_table",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"set_state",
"(",
"'table'",
")",
"self",
".",
"current_table",
"=",
"HEPTable",
"(",
"index",
"=",
"len",
"(",
"self",
".",
"tables",
")",
"+",
"1",
")",
"self",
".",
"tables",
... | 354271448980efba86f2f3d27b99d818e75fd90d |
train | OldHEPData._parse_table_data | Parse dataset data of the original HEPData format
:param data: header of the table to be parsed
:raise ValueError: | hepdata_converter/parsers/oldhepdata_parser.py | def _parse_table_data(self, data):
"""Parse dataset data of the original HEPData format
:param data: header of the table to be parsed
:raise ValueError:
"""
header = data.split(':')
self.current_table.data_header = header
for i, h in enumerate(header):
... | def _parse_table_data(self, data):
"""Parse dataset data of the original HEPData format
:param data: header of the table to be parsed
:raise ValueError:
"""
header = data.split(':')
self.current_table.data_header = header
for i, h in enumerate(header):
... | [
"Parse",
"dataset",
"data",
"of",
"the",
"original",
"HEPData",
"format"
] | HEPData/hepdata-converter | python | https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/parsers/oldhepdata_parser.py#L204-L406 | [
"def",
"_parse_table_data",
"(",
"self",
",",
"data",
")",
":",
"header",
"=",
"data",
".",
"split",
"(",
"':'",
")",
"self",
".",
"current_table",
".",
"data_header",
"=",
"header",
"for",
"i",
",",
"h",
"in",
"enumerate",
"(",
"header",
")",
":",
"... | 354271448980efba86f2f3d27b99d818e75fd90d |
train | OldHEPData._reformat_matrix | Transform a square matrix into a format with two independent variables and one dependent variable. | hepdata_converter/parsers/oldhepdata_parser.py | def _reformat_matrix(self):
"""Transform a square matrix into a format with two independent variables and one dependent variable.
"""
nxax = len(self.current_table.data['independent_variables'])
nyax = len(self.current_table.data['dependent_variables'])
npts = len(self.current_ta... | def _reformat_matrix(self):
"""Transform a square matrix into a format with two independent variables and one dependent variable.
"""
nxax = len(self.current_table.data['independent_variables'])
nyax = len(self.current_table.data['dependent_variables'])
npts = len(self.current_ta... | [
"Transform",
"a",
"square",
"matrix",
"into",
"a",
"format",
"with",
"two",
"independent",
"variables",
"and",
"one",
"dependent",
"variable",
"."
] | HEPData/hepdata-converter | python | https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/parsers/oldhepdata_parser.py#L408-L454 | [
"def",
"_reformat_matrix",
"(",
"self",
")",
":",
"nxax",
"=",
"len",
"(",
"self",
".",
"current_table",
".",
"data",
"[",
"'independent_variables'",
"]",
")",
"nyax",
"=",
"len",
"(",
"self",
".",
"current_table",
".",
"data",
"[",
"'dependent_variables'",
... | 354271448980efba86f2f3d27b99d818e75fd90d |
train | OldHEPData._parse_qual | Parse qual attribute of the old HEPData format
example qual:
*qual: RE : P P --> Z0 Z0 X
:param data: data to be parsed
:type data: str | hepdata_converter/parsers/oldhepdata_parser.py | def _parse_qual(self, data):
"""Parse qual attribute of the old HEPData format
example qual:
*qual: RE : P P --> Z0 Z0 X
:param data: data to be parsed
:type data: str
"""
list = []
headers = data.split(':')
name = headers[0].strip()
nam... | def _parse_qual(self, data):
"""Parse qual attribute of the old HEPData format
example qual:
*qual: RE : P P --> Z0 Z0 X
:param data: data to be parsed
:type data: str
"""
list = []
headers = data.split(':')
name = headers[0].strip()
nam... | [
"Parse",
"qual",
"attribute",
"of",
"the",
"old",
"HEPData",
"format"
] | HEPData/hepdata-converter | python | https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/parsers/oldhepdata_parser.py#L510-L550 | [
"def",
"_parse_qual",
"(",
"self",
",",
"data",
")",
":",
"list",
"=",
"[",
"]",
"headers",
"=",
"data",
".",
"split",
"(",
"':'",
")",
"name",
"=",
"headers",
"[",
"0",
"]",
".",
"strip",
"(",
")",
"name",
"=",
"re",
".",
"split",
"(",
"' IN '... | 354271448980efba86f2f3d27b99d818e75fd90d |
train | OldHEPData._parse_header | Parse header (xheader or yheader)
:param data: data to be parsed
:type data: str
:return: list with header's data
:rtype: list | hepdata_converter/parsers/oldhepdata_parser.py | def _parse_header(self, data):
"""Parse header (xheader or yheader)
:param data: data to be parsed
:type data: str
:return: list with header's data
:rtype: list
"""
return_list = []
headers = data.split(':')
for header in headers:
he... | def _parse_header(self, data):
"""Parse header (xheader or yheader)
:param data: data to be parsed
:type data: str
:return: list with header's data
:rtype: list
"""
return_list = []
headers = data.split(':')
for header in headers:
he... | [
"Parse",
"header",
"(",
"xheader",
"or",
"yheader",
")"
] | HEPData/hepdata-converter | python | https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/parsers/oldhepdata_parser.py#L552-L571 | [
"def",
"_parse_header",
"(",
"self",
",",
"data",
")",
":",
"return_list",
"=",
"[",
"]",
"headers",
"=",
"data",
".",
"split",
"(",
"':'",
")",
"for",
"header",
"in",
"headers",
":",
"header",
"=",
"re",
".",
"split",
"(",
"' IN '",
",",
"header",
... | 354271448980efba86f2f3d27b99d818e75fd90d |
train | OldHEPData._strip_comments | Processes line stripping any comments from it
:param line: line to be processed
:type line: str
:return: line with removed comments
:rtype: str | hepdata_converter/parsers/oldhepdata_parser.py | def _strip_comments(line):
"""Processes line stripping any comments from it
:param line: line to be processed
:type line: str
:return: line with removed comments
:rtype: str
"""
if line == '':
return line
r = re.search('(?P<line>[^#]*)(#(?P<co... | def _strip_comments(line):
"""Processes line stripping any comments from it
:param line: line to be processed
:type line: str
:return: line with removed comments
:rtype: str
"""
if line == '':
return line
r = re.search('(?P<line>[^#]*)(#(?P<co... | [
"Processes",
"line",
"stripping",
"any",
"comments",
"from",
"it"
] | HEPData/hepdata-converter | python | https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/parsers/oldhepdata_parser.py#L590-L606 | [
"def",
"_strip_comments",
"(",
"line",
")",
":",
"if",
"line",
"==",
"''",
":",
"return",
"line",
"r",
"=",
"re",
".",
"search",
"(",
"'(?P<line>[^#]*)(#(?P<comment>.*))?'",
",",
"line",
")",
"if",
"r",
":",
"line",
"=",
"r",
".",
"group",
"(",
"'line'... | 354271448980efba86f2f3d27b99d818e75fd90d |
train | OldHEPData._read_multiline | Reads multiline symbols (ususally comments)
:param init_data: initial data (parsed from the line containing keyword)
:return: parsed value of the multiline symbol
:rtype: str | hepdata_converter/parsers/oldhepdata_parser.py | def _read_multiline(self, init_data):
"""Reads multiline symbols (ususally comments)
:param init_data: initial data (parsed from the line containing keyword)
:return: parsed value of the multiline symbol
:rtype: str
"""
result = init_data
first = True
wh... | def _read_multiline(self, init_data):
"""Reads multiline symbols (ususally comments)
:param init_data: initial data (parsed from the line containing keyword)
:return: parsed value of the multiline symbol
:rtype: str
"""
result = init_data
first = True
wh... | [
"Reads",
"multiline",
"symbols",
"(",
"ususally",
"comments",
")"
] | HEPData/hepdata-converter | python | https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/parsers/oldhepdata_parser.py#L608-L648 | [
"def",
"_read_multiline",
"(",
"self",
",",
"init_data",
")",
":",
"result",
"=",
"init_data",
"first",
"=",
"True",
"while",
"True",
":",
"last_index",
"=",
"self",
".",
"current_file",
".",
"tell",
"(",
")",
"line_raw",
"=",
"self",
".",
"current_file",
... | 354271448980efba86f2f3d27b99d818e75fd90d |
train | OldHEPData._bind_set_table_metadata | Returns parsing function which will parse data as text, and add it to the table metatadata dictionary
with the provided key
:param key: dictionary key under which parsed data will be added to table.metadata
:type key: str
:param multiline: if True this attribute will be treated as multi... | hepdata_converter/parsers/oldhepdata_parser.py | def _bind_set_table_metadata(self, key, multiline=False):
"""Returns parsing function which will parse data as text, and add it to the table metatadata dictionary
with the provided key
:param key: dictionary key under which parsed data will be added to table.metadata
:type key: str
... | def _bind_set_table_metadata(self, key, multiline=False):
"""Returns parsing function which will parse data as text, and add it to the table metatadata dictionary
with the provided key
:param key: dictionary key under which parsed data will be added to table.metadata
:type key: str
... | [
"Returns",
"parsing",
"function",
"which",
"will",
"parse",
"data",
"as",
"text",
"and",
"add",
"it",
"to",
"the",
"table",
"metatadata",
"dictionary",
"with",
"the",
"provided",
"key"
] | HEPData/hepdata-converter | python | https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/parsers/oldhepdata_parser.py#L653-L672 | [
"def",
"_bind_set_table_metadata",
"(",
"self",
",",
"key",
",",
"multiline",
"=",
"False",
")",
":",
"def",
"set_table_metadata",
"(",
"self",
",",
"data",
")",
":",
"if",
"multiline",
":",
"data",
"=",
"self",
".",
"_read_multiline",
"(",
"data",
")",
... | 354271448980efba86f2f3d27b99d818e75fd90d |
train | OldHEPData._bind_parse_additional_data | Returns parsing function which will parse data as text, and add it to the table additional data dictionary
with the provided key
:param key: dictionary key under which parsed data will be added to table.metadata
:type key: str
:param multiline: if True this attribute will be treated as ... | hepdata_converter/parsers/oldhepdata_parser.py | def _bind_parse_additional_data(self, key, multiline=False):
"""Returns parsing function which will parse data as text, and add it to the table additional data dictionary
with the provided key
:param key: dictionary key under which parsed data will be added to table.metadata
:type key: ... | def _bind_parse_additional_data(self, key, multiline=False):
"""Returns parsing function which will parse data as text, and add it to the table additional data dictionary
with the provided key
:param key: dictionary key under which parsed data will be added to table.metadata
:type key: ... | [
"Returns",
"parsing",
"function",
"which",
"will",
"parse",
"data",
"as",
"text",
"and",
"add",
"it",
"to",
"the",
"table",
"additional",
"data",
"dictionary",
"with",
"the",
"provided",
"key"
] | HEPData/hepdata-converter | python | https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/parsers/oldhepdata_parser.py#L689-L715 | [
"def",
"_bind_parse_additional_data",
"(",
"self",
",",
"key",
",",
"multiline",
"=",
"False",
")",
":",
"def",
"_set_additional_data_bound",
"(",
"self",
",",
"data",
")",
":",
"\"\"\"Concrete method for setting additional data\n :param self:\n :type se... | 354271448980efba86f2f3d27b99d818e75fd90d |
train | error_value_processor | If an error is a percentage, we convert to a float, then
calculate the percentage of the supplied value.
:param value: base value, e.g. 10
:param error: e.g. 20.0%
:return: the absolute error, e.g. 12 for the above case. | hepdata_converter/writers/utils.py | def error_value_processor(value, error):
"""
If an error is a percentage, we convert to a float, then
calculate the percentage of the supplied value.
:param value: base value, e.g. 10
:param error: e.g. 20.0%
:return: the absolute error, e.g. 12 for the above case.
"""
if isinstance(err... | def error_value_processor(value, error):
"""
If an error is a percentage, we convert to a float, then
calculate the percentage of the supplied value.
:param value: base value, e.g. 10
:param error: e.g. 20.0%
:return: the absolute error, e.g. 12 for the above case.
"""
if isinstance(err... | [
"If",
"an",
"error",
"is",
"a",
"percentage",
"we",
"convert",
"to",
"a",
"float",
"then",
"calculate",
"the",
"percentage",
"of",
"the",
"supplied",
"value",
"."
] | HEPData/hepdata-converter | python | https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/writers/utils.py#L2-L24 | [
"def",
"error_value_processor",
"(",
"value",
",",
"error",
")",
":",
"if",
"isinstance",
"(",
"error",
",",
"(",
"str",
",",
"unicode",
")",
")",
":",
"try",
":",
"if",
"\"%\"",
"in",
"error",
":",
"error_float",
"=",
"float",
"(",
"error",
".",
"re... | 354271448980efba86f2f3d27b99d818e75fd90d |
train | get_file_details | <Purpose>
To get file's length and hash information. The hash is computed using the
sha256 algorithm. This function is used in the signerlib.py and updater.py
modules.
<Arguments>
filepath:
Absolute file path of a file.
hash_algorithms:
<Exceptions>
securesystemslib.exceptions.For... | securesystemslib/util.py | def get_file_details(filepath, hash_algorithms=['sha256']):
"""
<Purpose>
To get file's length and hash information. The hash is computed using the
sha256 algorithm. This function is used in the signerlib.py and updater.py
modules.
<Arguments>
filepath:
Absolute file path of a file.
... | def get_file_details(filepath, hash_algorithms=['sha256']):
"""
<Purpose>
To get file's length and hash information. The hash is computed using the
sha256 algorithm. This function is used in the signerlib.py and updater.py
modules.
<Arguments>
filepath:
Absolute file path of a file.
... | [
"<Purpose",
">",
"To",
"get",
"file",
"s",
"length",
"and",
"hash",
"information",
".",
"The",
"hash",
"is",
"computed",
"using",
"the",
"sha256",
"algorithm",
".",
"This",
"function",
"is",
"used",
"in",
"the",
"signerlib",
".",
"py",
"and",
"updater",
... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/util.py#L349-L399 | [
"def",
"get_file_details",
"(",
"filepath",
",",
"hash_algorithms",
"=",
"[",
"'sha256'",
"]",
")",
":",
"# Making sure that the format of 'filepath' is a path string.",
"# 'securesystemslib.exceptions.FormatError' is raised on incorrect format.",
"securesystemslib",
".",
"formats",
... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | ensure_parent_dir | <Purpose>
To ensure existence of the parent directory of 'filename'. If the parent
directory of 'name' does not exist, create it.
Example: If 'filename' is '/a/b/c/d.txt', and only the directory '/a/b/'
exists, then directory '/a/b/c/d/' will be created.
<Arguments>
filename:
A path strin... | securesystemslib/util.py | def ensure_parent_dir(filename):
"""
<Purpose>
To ensure existence of the parent directory of 'filename'. If the parent
directory of 'name' does not exist, create it.
Example: If 'filename' is '/a/b/c/d.txt', and only the directory '/a/b/'
exists, then directory '/a/b/c/d/' will be created.
<Ar... | def ensure_parent_dir(filename):
"""
<Purpose>
To ensure existence of the parent directory of 'filename'. If the parent
directory of 'name' does not exist, create it.
Example: If 'filename' is '/a/b/c/d.txt', and only the directory '/a/b/'
exists, then directory '/a/b/c/d/' will be created.
<Ar... | [
"<Purpose",
">",
"To",
"ensure",
"existence",
"of",
"the",
"parent",
"directory",
"of",
"filename",
".",
"If",
"the",
"parent",
"directory",
"of",
"name",
"does",
"not",
"exist",
"create",
"it",
"."
] | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/util.py#L402-L436 | [
"def",
"ensure_parent_dir",
"(",
"filename",
")",
":",
"# Ensure 'filename' corresponds to 'PATH_SCHEMA'.",
"# Raise 'securesystemslib.exceptions.FormatError' on a mismatch.",
"securesystemslib",
".",
"formats",
".",
"PATH_SCHEMA",
".",
"check_match",
"(",
"filename",
")",
"# Spl... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | file_in_confined_directories | <Purpose>
Check if the directory containing 'filepath' is in the list/tuple of
'confined_directories'.
<Arguments>
filepath:
A string representing the path of a file. The following example path
strings are viewed as files and not directories: 'a/b/c', 'a/b/c.txt'.
confined_directories:
... | securesystemslib/util.py | def file_in_confined_directories(filepath, confined_directories):
"""
<Purpose>
Check if the directory containing 'filepath' is in the list/tuple of
'confined_directories'.
<Arguments>
filepath:
A string representing the path of a file. The following example path
strings are viewed as fi... | def file_in_confined_directories(filepath, confined_directories):
"""
<Purpose>
Check if the directory containing 'filepath' is in the list/tuple of
'confined_directories'.
<Arguments>
filepath:
A string representing the path of a file. The following example path
strings are viewed as fi... | [
"<Purpose",
">",
"Check",
"if",
"the",
"directory",
"containing",
"filepath",
"is",
"in",
"the",
"list",
"/",
"tuple",
"of",
"confined_directories",
"."
] | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/util.py#L439-L485 | [
"def",
"file_in_confined_directories",
"(",
"filepath",
",",
"confined_directories",
")",
":",
"# Do the arguments have the correct format?",
"# Raise 'securesystemslib.exceptions.FormatError' if there is a mismatch.",
"securesystemslib",
".",
"formats",
".",
"RELPATH_SCHEMA",
".",
"... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | find_delegated_role | <Purpose>
Find the index, if any, of a role with a given name in a list of roles.
<Arguments>
roles:
The list of roles, each of which must have a 'name' attribute.
delegated_role:
The name of the role to be found in the list of roles.
<Exceptions>
securesystemslib.exceptions.Repositor... | securesystemslib/util.py | def find_delegated_role(roles, delegated_role):
"""
<Purpose>
Find the index, if any, of a role with a given name in a list of roles.
<Arguments>
roles:
The list of roles, each of which must have a 'name' attribute.
delegated_role:
The name of the role to be found in the list of roles.
... | def find_delegated_role(roles, delegated_role):
"""
<Purpose>
Find the index, if any, of a role with a given name in a list of roles.
<Arguments>
roles:
The list of roles, each of which must have a 'name' attribute.
delegated_role:
The name of the role to be found in the list of roles.
... | [
"<Purpose",
">",
"Find",
"the",
"index",
"if",
"any",
"of",
"a",
"role",
"with",
"a",
"given",
"name",
"in",
"a",
"list",
"of",
"roles",
"."
] | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/util.py#L488-L549 | [
"def",
"find_delegated_role",
"(",
"roles",
",",
"delegated_role",
")",
":",
"# Do the arguments have the correct format?",
"# Ensure the arguments have the appropriate number of objects and object",
"# types, and that all dict keys are properly named. Raise",
"# 'securesystemslib.exceptions.... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | ensure_all_targets_allowed | <Purpose>
Ensure that the list of targets specified by 'rolename' are allowed; this
is determined by inspecting the 'delegations' field of the parent role of
'rolename'. If a target specified by 'rolename' is not found in the
delegations field of 'metadata_object_of_parent', raise an exception. The
... | securesystemslib/util.py | def ensure_all_targets_allowed(rolename, list_of_targets, parent_delegations):
"""
<Purpose>
Ensure that the list of targets specified by 'rolename' are allowed; this
is determined by inspecting the 'delegations' field of the parent role of
'rolename'. If a target specified by 'rolename' is not found i... | def ensure_all_targets_allowed(rolename, list_of_targets, parent_delegations):
"""
<Purpose>
Ensure that the list of targets specified by 'rolename' are allowed; this
is determined by inspecting the 'delegations' field of the parent role of
'rolename'. If a target specified by 'rolename' is not found i... | [
"<Purpose",
">",
"Ensure",
"that",
"the",
"list",
"of",
"targets",
"specified",
"by",
"rolename",
"are",
"allowed",
";",
"this",
"is",
"determined",
"by",
"inspecting",
"the",
"delegations",
"field",
"of",
"the",
"parent",
"role",
"of",
"rolename",
".",
"If"... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/util.py#L552-L684 | [
"def",
"ensure_all_targets_allowed",
"(",
"rolename",
",",
"list_of_targets",
",",
"parent_delegations",
")",
":",
"# Do the arguments have the correct format?",
"# Ensure the arguments have the appropriate number of objects and object",
"# types, and that all dict keys are properly named. ... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | paths_are_consistent_with_hash_prefixes | <Purpose>
Determine whether a list of paths are consistent with their alleged path
hash prefixes. By default, the SHA256 hash function is used.
<Arguments>
paths:
A list of paths for which their hashes will be checked.
path_hash_prefixes:
The list of path hash prefixes with which to chec... | securesystemslib/util.py | def paths_are_consistent_with_hash_prefixes(paths, path_hash_prefixes):
"""
<Purpose>
Determine whether a list of paths are consistent with their alleged path
hash prefixes. By default, the SHA256 hash function is used.
<Arguments>
paths:
A list of paths for which their hashes will be checked.
... | def paths_are_consistent_with_hash_prefixes(paths, path_hash_prefixes):
"""
<Purpose>
Determine whether a list of paths are consistent with their alleged path
hash prefixes. By default, the SHA256 hash function is used.
<Arguments>
paths:
A list of paths for which their hashes will be checked.
... | [
"<Purpose",
">",
"Determine",
"whether",
"a",
"list",
"of",
"paths",
"are",
"consistent",
"with",
"their",
"alleged",
"path",
"hash",
"prefixes",
".",
"By",
"default",
"the",
"SHA256",
"hash",
"function",
"is",
"used",
"."
] | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/util.py#L687-L740 | [
"def",
"paths_are_consistent_with_hash_prefixes",
"(",
"paths",
",",
"path_hash_prefixes",
")",
":",
"# Do the arguments have the correct format?",
"# Ensure the arguments have the appropriate number of objects and object",
"# types, and that all dict keys are properly named. Raise",
"# 'secu... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | get_target_hash | <Purpose>
Compute the hash of 'target_filepath'. This is useful in conjunction with
the "path_hash_prefixes" attribute in a delegated targets role, which tells
us which paths it is implicitly responsible for.
The repository may optionally organize targets into hashed bins to ease
target delegations... | securesystemslib/util.py | def get_target_hash(target_filepath):
"""
<Purpose>
Compute the hash of 'target_filepath'. This is useful in conjunction with
the "path_hash_prefixes" attribute in a delegated targets role, which tells
us which paths it is implicitly responsible for.
The repository may optionally organize targets i... | def get_target_hash(target_filepath):
"""
<Purpose>
Compute the hash of 'target_filepath'. This is useful in conjunction with
the "path_hash_prefixes" attribute in a delegated targets role, which tells
us which paths it is implicitly responsible for.
The repository may optionally organize targets i... | [
"<Purpose",
">",
"Compute",
"the",
"hash",
"of",
"target_filepath",
".",
"This",
"is",
"useful",
"in",
"conjunction",
"with",
"the",
"path_hash_prefixes",
"attribute",
"in",
"a",
"delegated",
"targets",
"role",
"which",
"tells",
"us",
"which",
"paths",
"it",
"... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/util.py#L743-L783 | [
"def",
"get_target_hash",
"(",
"target_filepath",
")",
":",
"# Does 'target_filepath' have the correct format?",
"# Ensure the arguments have the appropriate number of objects and object",
"# types, and that all dict keys are properly named.",
"# Raise 'securesystemslib.exceptions.FormatError' if ... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | import_json | <Purpose>
Tries to import json module. We used to fall back to the simplejson module,
but we have dropped support for that module. We are keeping this interface
intact for backwards compatibility.
<Arguments>
None.
<Exceptions>
ImportError: on failure to import the json module.
<Side Effect... | securesystemslib/util.py | def import_json():
"""
<Purpose>
Tries to import json module. We used to fall back to the simplejson module,
but we have dropped support for that module. We are keeping this interface
intact for backwards compatibility.
<Arguments>
None.
<Exceptions>
ImportError: on failure to import the j... | def import_json():
"""
<Purpose>
Tries to import json module. We used to fall back to the simplejson module,
but we have dropped support for that module. We are keeping this interface
intact for backwards compatibility.
<Arguments>
None.
<Exceptions>
ImportError: on failure to import the j... | [
"<Purpose",
">",
"Tries",
"to",
"import",
"json",
"module",
".",
"We",
"used",
"to",
"fall",
"back",
"to",
"the",
"simplejson",
"module",
"but",
"we",
"have",
"dropped",
"support",
"for",
"that",
"module",
".",
"We",
"are",
"keeping",
"this",
"interface",
... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/util.py#L788-L824 | [
"def",
"import_json",
"(",
")",
":",
"global",
"_json_module",
"if",
"_json_module",
"is",
"not",
"None",
":",
"return",
"_json_module",
"else",
":",
"try",
":",
"module",
"=",
"__import__",
"(",
"'json'",
")",
"# The 'json' module is available in Python > 2.6, and ... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | load_json_string | <Purpose>
Deserialize 'data' (JSON string) to a Python object.
<Arguments>
data:
A JSON string.
<Exceptions>
securesystemslib.exceptions.Error, if 'data' cannot be deserialized to a
Python object.
<Side Effects>
None.
<Returns>
Deserialized object. For example, a dictionary. | securesystemslib/util.py | def load_json_string(data):
"""
<Purpose>
Deserialize 'data' (JSON string) to a Python object.
<Arguments>
data:
A JSON string.
<Exceptions>
securesystemslib.exceptions.Error, if 'data' cannot be deserialized to a
Python object.
<Side Effects>
None.
<Returns>
Deserialized o... | def load_json_string(data):
"""
<Purpose>
Deserialize 'data' (JSON string) to a Python object.
<Arguments>
data:
A JSON string.
<Exceptions>
securesystemslib.exceptions.Error, if 'data' cannot be deserialized to a
Python object.
<Side Effects>
None.
<Returns>
Deserialized o... | [
"<Purpose",
">",
"Deserialize",
"data",
"(",
"JSON",
"string",
")",
"to",
"a",
"Python",
"object",
"."
] | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/util.py#L829-L863 | [
"def",
"load_json_string",
"(",
"data",
")",
":",
"deserialized_object",
"=",
"None",
"try",
":",
"deserialized_object",
"=",
"json",
".",
"loads",
"(",
"data",
")",
"except",
"TypeError",
":",
"message",
"=",
"'Invalid JSON string: '",
"+",
"repr",
"(",
"data... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | load_json_file | <Purpose>
Deserialize a JSON object from a file containing the object.
<Arguments>
filepath:
Absolute path of JSON file.
<Exceptions>
securesystemslib.exceptions.FormatError: If 'filepath' is improperly
formatted.
securesystemslib.exceptions.Error: If 'filepath' cannot be deserialized t... | securesystemslib/util.py | def load_json_file(filepath):
"""
<Purpose>
Deserialize a JSON object from a file containing the object.
<Arguments>
filepath:
Absolute path of JSON file.
<Exceptions>
securesystemslib.exceptions.FormatError: If 'filepath' is improperly
formatted.
securesystemslib.exceptions.Error: ... | def load_json_file(filepath):
"""
<Purpose>
Deserialize a JSON object from a file containing the object.
<Arguments>
filepath:
Absolute path of JSON file.
<Exceptions>
securesystemslib.exceptions.FormatError: If 'filepath' is improperly
formatted.
securesystemslib.exceptions.Error: ... | [
"<Purpose",
">",
"Deserialize",
"a",
"JSON",
"object",
"from",
"a",
"file",
"containing",
"the",
"object",
"."
] | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/util.py#L866-L918 | [
"def",
"load_json_file",
"(",
"filepath",
")",
":",
"# Making sure that the format of 'filepath' is a path string.",
"# securesystemslib.exceptions.FormatError is raised on incorrect format.",
"securesystemslib",
".",
"formats",
".",
"PATH_SCHEMA",
".",
"check_match",
"(",
"filepath"... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | digests_are_equal | <Purpose>
While protecting against timing attacks, compare the hexadecimal arguments
and determine if they are equal.
<Arguments>
digest1:
The first hexadecimal string value to compare.
digest2:
The second hexadecimal string value to compare.
<Exceptions>
securesystemslib.exceptio... | securesystemslib/util.py | def digests_are_equal(digest1, digest2):
"""
<Purpose>
While protecting against timing attacks, compare the hexadecimal arguments
and determine if they are equal.
<Arguments>
digest1:
The first hexadecimal string value to compare.
digest2:
The second hexadecimal string value to compa... | def digests_are_equal(digest1, digest2):
"""
<Purpose>
While protecting against timing attacks, compare the hexadecimal arguments
and determine if they are equal.
<Arguments>
digest1:
The first hexadecimal string value to compare.
digest2:
The second hexadecimal string value to compa... | [
"<Purpose",
">",
"While",
"protecting",
"against",
"timing",
"attacks",
"compare",
"the",
"hexadecimal",
"arguments",
"and",
"determine",
"if",
"they",
"are",
"equal",
"."
] | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/util.py#L921-L960 | [
"def",
"digests_are_equal",
"(",
"digest1",
",",
"digest2",
")",
":",
"# Ensure the arguments have the appropriate number of objects and object",
"# types, and that all dict keys are properly named.",
"# Raise 'securesystemslib.exceptions.FormatError' if there is a mismatch.",
"securesystemsli... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | TempFile._default_temporary_directory | __init__ helper. | securesystemslib/util.py | def _default_temporary_directory(self, prefix):
"""__init__ helper."""
try:
self.temporary_file = tempfile.NamedTemporaryFile(prefix=prefix)
except OSError as err: # pragma: no cover
logger.critical('Cannot create a system temporary directory: '+repr(err))
raise securesystemslib.exception... | def _default_temporary_directory(self, prefix):
"""__init__ helper."""
try:
self.temporary_file = tempfile.NamedTemporaryFile(prefix=prefix)
except OSError as err: # pragma: no cover
logger.critical('Cannot create a system temporary directory: '+repr(err))
raise securesystemslib.exception... | [
"__init__",
"helper",
"."
] | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/util.py#L64-L71 | [
"def",
"_default_temporary_directory",
"(",
"self",
",",
"prefix",
")",
":",
"try",
":",
"self",
".",
"temporary_file",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"prefix",
"=",
"prefix",
")",
"except",
"OSError",
"as",
"err",
":",
"# pragma: no cover",
... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | TempFile.read | <Purpose>
Read specified number of bytes. If size is not specified then the whole
file is read and the file pointer is placed at the beginning of the file.
<Arguments>
size:
Number of bytes to be read.
<Exceptions>
securesystemslib.exceptions.FormatError: if 'size' is invalid.... | securesystemslib/util.py | def read(self, size=None):
"""
<Purpose>
Read specified number of bytes. If size is not specified then the whole
file is read and the file pointer is placed at the beginning of the file.
<Arguments>
size:
Number of bytes to be read.
<Exceptions>
securesystemslib.except... | def read(self, size=None):
"""
<Purpose>
Read specified number of bytes. If size is not specified then the whole
file is read and the file pointer is placed at the beginning of the file.
<Arguments>
size:
Number of bytes to be read.
<Exceptions>
securesystemslib.except... | [
"<Purpose",
">",
"Read",
"specified",
"number",
"of",
"bytes",
".",
"If",
"size",
"is",
"not",
"specified",
"then",
"the",
"whole",
"file",
"is",
"read",
"and",
"the",
"file",
"pointer",
"is",
"placed",
"at",
"the",
"beginning",
"of",
"the",
"file",
"."
... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/util.py#L147-L175 | [
"def",
"read",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"if",
"size",
"is",
"None",
":",
"self",
".",
"temporary_file",
".",
"seek",
"(",
"0",
")",
"data",
"=",
"self",
".",
"temporary_file",
".",
"read",
"(",
")",
"self",
".",
"temporary_f... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | TempFile.write | <Purpose>
Writes a data string to the file.
<Arguments>
data:
A string containing some data.
auto_flush:
Boolean argument, if set to 'True', all data will be flushed from
internal buffer.
<Exceptions>
None.
<Return>
None. | securesystemslib/util.py | def write(self, data, auto_flush=True):
"""
<Purpose>
Writes a data string to the file.
<Arguments>
data:
A string containing some data.
auto_flush:
Boolean argument, if set to 'True', all data will be flushed from
internal buffer.
<Exceptions>
None.
... | def write(self, data, auto_flush=True):
"""
<Purpose>
Writes a data string to the file.
<Arguments>
data:
A string containing some data.
auto_flush:
Boolean argument, if set to 'True', all data will be flushed from
internal buffer.
<Exceptions>
None.
... | [
"<Purpose",
">",
"Writes",
"a",
"data",
"string",
"to",
"the",
"file",
"."
] | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/util.py#L178-L200 | [
"def",
"write",
"(",
"self",
",",
"data",
",",
"auto_flush",
"=",
"True",
")",
":",
"self",
".",
"temporary_file",
".",
"write",
"(",
"data",
")",
"if",
"auto_flush",
":",
"self",
".",
"flush",
"(",
")"
] | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | TempFile.move | <Purpose>
Copies 'self.temporary_file' to a non-temp file at 'destination_path' and
closes 'self.temporary_file' so that it is removed.
<Arguments>
destination_path:
Path to store the file in.
<Exceptions>
None.
<Return>
None. | securesystemslib/util.py | def move(self, destination_path):
"""
<Purpose>
Copies 'self.temporary_file' to a non-temp file at 'destination_path' and
closes 'self.temporary_file' so that it is removed.
<Arguments>
destination_path:
Path to store the file in.
<Exceptions>
None.
<Return>
... | def move(self, destination_path):
"""
<Purpose>
Copies 'self.temporary_file' to a non-temp file at 'destination_path' and
closes 'self.temporary_file' so that it is removed.
<Arguments>
destination_path:
Path to store the file in.
<Exceptions>
None.
<Return>
... | [
"<Purpose",
">",
"Copies",
"self",
".",
"temporary_file",
"to",
"a",
"non",
"-",
"temp",
"file",
"at",
"destination_path",
"and",
"closes",
"self",
".",
"temporary_file",
"so",
"that",
"it",
"is",
"removed",
"."
] | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/util.py#L203-L231 | [
"def",
"move",
"(",
"self",
",",
"destination_path",
")",
":",
"self",
".",
"flush",
"(",
")",
"self",
".",
"seek",
"(",
"0",
")",
"destination_file",
"=",
"open",
"(",
"destination_path",
",",
"'wb'",
")",
"shutil",
".",
"copyfileobj",
"(",
"self",
".... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | TempFile.decompress_temp_file_object | <Purpose>
To decompress a compressed temp file object. Decompression is performed
on a temp file object that is compressed, this occurs after downloading
a compressed file. For instance if a compressed version of some meta
file in the repository is downloaded, the temp file containing the
... | securesystemslib/util.py | def decompress_temp_file_object(self, compression):
"""
<Purpose>
To decompress a compressed temp file object. Decompression is performed
on a temp file object that is compressed, this occurs after downloading
a compressed file. For instance if a compressed version of some meta
file in... | def decompress_temp_file_object(self, compression):
"""
<Purpose>
To decompress a compressed temp file object. Decompression is performed
on a temp file object that is compressed, this occurs after downloading
a compressed file. For instance if a compressed version of some meta
file in... | [
"<Purpose",
">",
"To",
"decompress",
"a",
"compressed",
"temp",
"file",
"object",
".",
"Decompression",
"is",
"performed",
"on",
"a",
"temp",
"file",
"object",
"that",
"is",
"compressed",
"this",
"occurs",
"after",
"downloading",
"a",
"compressed",
"file",
"."... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/util.py#L256-L317 | [
"def",
"decompress_temp_file_object",
"(",
"self",
",",
"compression",
")",
":",
"# Does 'compression' have the correct format?",
"# Raise 'securesystemslib.exceptions.FormatError' if there is a mismatch.",
"securesystemslib",
".",
"formats",
".",
"NAME_SCHEMA",
".",
"check_match",
... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | TempFile.close_temp_file | <Purpose>
Closes the temporary file object. 'close_temp_file' mimics usual
file.close(), however temporary file destroys itself when
'close_temp_file' is called. Further if compression is set, second
temporary file instance 'self._orig_file' is also closed so that no open
temporary files a... | securesystemslib/util.py | def close_temp_file(self):
"""
<Purpose>
Closes the temporary file object. 'close_temp_file' mimics usual
file.close(), however temporary file destroys itself when
'close_temp_file' is called. Further if compression is set, second
temporary file instance 'self._orig_file' is also closed ... | def close_temp_file(self):
"""
<Purpose>
Closes the temporary file object. 'close_temp_file' mimics usual
file.close(), however temporary file destroys itself when
'close_temp_file' is called. Further if compression is set, second
temporary file instance 'self._orig_file' is also closed ... | [
"<Purpose",
">",
"Closes",
"the",
"temporary",
"file",
"object",
".",
"close_temp_file",
"mimics",
"usual",
"file",
".",
"close",
"()",
"however",
"temporary",
"file",
"destroys",
"itself",
"when",
"close_temp_file",
"is",
"called",
".",
"Further",
"if",
"compre... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/util.py#L320-L346 | [
"def",
"close_temp_file",
"(",
"self",
")",
":",
"self",
".",
"temporary_file",
".",
"close",
"(",
")",
"# If compression has been set, we need to explicitly close the original",
"# file object.",
"if",
"self",
".",
"_orig_file",
"is",
"not",
"None",
":",
"self",
".",... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | Schema.matches | <Purpose>
Return True if 'object' matches this schema, False if it doesn't.
If the caller wishes to signal an error on a failed match, check_match()
should be called, which will raise a 'exceptions.FormatError' exception. | securesystemslib/schema.py | def matches(self, object):
"""
<Purpose>
Return True if 'object' matches this schema, False if it doesn't.
If the caller wishes to signal an error on a failed match, check_match()
should be called, which will raise a 'exceptions.FormatError' exception.
"""
try:
self.check_match(... | def matches(self, object):
"""
<Purpose>
Return True if 'object' matches this schema, False if it doesn't.
If the caller wishes to signal an error on a failed match, check_match()
should be called, which will raise a 'exceptions.FormatError' exception.
"""
try:
self.check_match(... | [
"<Purpose",
">",
"Return",
"True",
"if",
"object",
"matches",
"this",
"schema",
"False",
"if",
"it",
"doesn",
"t",
".",
"If",
"the",
"caller",
"wishes",
"to",
"signal",
"an",
"error",
"on",
"a",
"failed",
"match",
"check_match",
"()",
"should",
"be",
"ca... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/schema.py#L70-L83 | [
"def",
"matches",
"(",
"self",
",",
"object",
")",
":",
"try",
":",
"self",
".",
"check_match",
"(",
"object",
")",
"except",
"securesystemslib",
".",
"exceptions",
".",
"FormatError",
":",
"return",
"False",
"else",
":",
"return",
"True"
] | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | SlackSocket.get_event | Return a single event object or block until an event is
received and return it.
- etypes(str): If defined, Slack event type(s) not matching
the filter will be ignored. See https://api.slack.com/events for
a listing of valid event types.
- timeout(int): Max time, in second... | slacksocket/client.py | def get_event(self, *etypes, timeout=None):
"""
Return a single event object or block until an event is
received and return it.
- etypes(str): If defined, Slack event type(s) not matching
the filter will be ignored. See https://api.slack.com/events for
a listing of... | def get_event(self, *etypes, timeout=None):
"""
Return a single event object or block until an event is
received and return it.
- etypes(str): If defined, Slack event type(s) not matching
the filter will be ignored. See https://api.slack.com/events for
a listing of... | [
"Return",
"a",
"single",
"event",
"object",
"or",
"block",
"until",
"an",
"event",
"is",
"received",
"and",
"return",
"it",
".",
"-",
"etypes",
"(",
"str",
")",
":",
"If",
"defined",
"Slack",
"event",
"type",
"(",
"s",
")",
"not",
"matching",
"the",
... | vektorlab/slacksocket | python | https://github.com/vektorlab/slacksocket/blob/8eb8b0f14fe80740217ea0aaf6feb7f736bdf57f/slacksocket/client.py#L85-L109 | [
"def",
"get_event",
"(",
"self",
",",
"*",
"etypes",
",",
"timeout",
"=",
"None",
")",
":",
"self",
".",
"_validate_etypes",
"(",
"*",
"etypes",
")",
"start",
"=",
"time",
".",
"time",
"(",
")",
"e",
"=",
"self",
".",
"_eventq",
".",
"get",
"(",
... | 8eb8b0f14fe80740217ea0aaf6feb7f736bdf57f |
train | SlackSocket.events | returns a blocking generator yielding Slack event objects
params:
- etypes(str): If defined, Slack event type(s) not matching
the filter will be ignored. See https://api.slack.com/events for
a listing of valid event types.
- idle_timeout(int): optional maximum amount of t... | slacksocket/client.py | def events(self, *etypes, idle_timeout=None):
"""
returns a blocking generator yielding Slack event objects
params:
- etypes(str): If defined, Slack event type(s) not matching
the filter will be ignored. See https://api.slack.com/events for
a listing of valid event... | def events(self, *etypes, idle_timeout=None):
"""
returns a blocking generator yielding Slack event objects
params:
- etypes(str): If defined, Slack event type(s) not matching
the filter will be ignored. See https://api.slack.com/events for
a listing of valid event... | [
"returns",
"a",
"blocking",
"generator",
"yielding",
"Slack",
"event",
"objects",
"params",
":",
"-",
"etypes",
"(",
"str",
")",
":",
"If",
"defined",
"Slack",
"event",
"type",
"(",
"s",
")",
"not",
"matching",
"the",
"filter",
"will",
"be",
"ignored",
"... | vektorlab/slacksocket | python | https://github.com/vektorlab/slacksocket/blob/8eb8b0f14fe80740217ea0aaf6feb7f736bdf57f/slacksocket/client.py#L111-L127 | [
"def",
"events",
"(",
"self",
",",
"*",
"etypes",
",",
"idle_timeout",
"=",
"None",
")",
":",
"while",
"self",
".",
"_state",
"!=",
"STATE_STOPPED",
":",
"try",
":",
"yield",
"self",
".",
"get_event",
"(",
"*",
"etypes",
",",
"timeout",
"=",
"idle_time... | 8eb8b0f14fe80740217ea0aaf6feb7f736bdf57f |
train | SlackSocket.send_msg | Send a message to a channel or group via Slack RTM socket, returning
the resulting message object
params:
- text(str): Message text to send
- channel(Channel): Target channel
- confirm(bool): If True, wait for a reply-to confirmation before returning. | slacksocket/client.py | def send_msg(self, text, channel, confirm=True):
"""
Send a message to a channel or group via Slack RTM socket, returning
the resulting message object
params:
- text(str): Message text to send
- channel(Channel): Target channel
- confirm(bool): If True, wait f... | def send_msg(self, text, channel, confirm=True):
"""
Send a message to a channel or group via Slack RTM socket, returning
the resulting message object
params:
- text(str): Message text to send
- channel(Channel): Target channel
- confirm(bool): If True, wait f... | [
"Send",
"a",
"message",
"to",
"a",
"channel",
"or",
"group",
"via",
"Slack",
"RTM",
"socket",
"returning",
"the",
"resulting",
"message",
"object"
] | vektorlab/slacksocket | python | https://github.com/vektorlab/slacksocket/blob/8eb8b0f14fe80740217ea0aaf6feb7f736bdf57f/slacksocket/client.py#L129-L153 | [
"def",
"send_msg",
"(",
"self",
",",
"text",
",",
"channel",
",",
"confirm",
"=",
"True",
")",
":",
"self",
".",
"_send_id",
"+=",
"1",
"msg",
"=",
"SlackMsg",
"(",
"self",
".",
"_send_id",
",",
"channel",
".",
"id",
",",
"text",
")",
"self",
".",
... | 8eb8b0f14fe80740217ea0aaf6feb7f736bdf57f |
train | SlackSocket._process_event | Extend event object with User and Channel objects | slacksocket/client.py | def _process_event(self, event):
""" Extend event object with User and Channel objects """
if event.get('user'):
event.user = self.lookup_user(event.get('user'))
if event.get('channel'):
event.channel = self.lookup_channel(event.get('channel'))
if self.user.id i... | def _process_event(self, event):
""" Extend event object with User and Channel objects """
if event.get('user'):
event.user = self.lookup_user(event.get('user'))
if event.get('channel'):
event.channel = self.lookup_channel(event.get('channel'))
if self.user.id i... | [
"Extend",
"event",
"object",
"with",
"User",
"and",
"Channel",
"objects"
] | vektorlab/slacksocket | python | https://github.com/vektorlab/slacksocket/blob/8eb8b0f14fe80740217ea0aaf6feb7f736bdf57f/slacksocket/client.py#L179-L192 | [
"def",
"_process_event",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"get",
"(",
"'user'",
")",
":",
"event",
".",
"user",
"=",
"self",
".",
"lookup_user",
"(",
"event",
".",
"get",
"(",
"'user'",
")",
")",
"if",
"event",
".",
"get",
... | 8eb8b0f14fe80740217ea0aaf6feb7f736bdf57f |
train | convert | Converts a supported ``input_format`` (*oldhepdata*, *yaml*)
to a supported ``output_format`` (*csv*, *root*, *yaml*, *yoda*).
:param input: location of input file for *oldhepdata* format or input directory for *yaml* format
:param output: location of output directory to which converted files will be writt... | hepdata_converter/__init__.py | def convert(input, output=None, options={}):
"""Converts a supported ``input_format`` (*oldhepdata*, *yaml*)
to a supported ``output_format`` (*csv*, *root*, *yaml*, *yoda*).
:param input: location of input file for *oldhepdata* format or input directory for *yaml* format
:param output: location of out... | def convert(input, output=None, options={}):
"""Converts a supported ``input_format`` (*oldhepdata*, *yaml*)
to a supported ``output_format`` (*csv*, *root*, *yaml*, *yoda*).
:param input: location of input file for *oldhepdata* format or input directory for *yaml* format
:param output: location of out... | [
"Converts",
"a",
"supported",
"input_format",
"(",
"*",
"oldhepdata",
"*",
"*",
"yaml",
"*",
")",
"to",
"a",
"supported",
"output_format",
"(",
"*",
"csv",
"*",
"*",
"root",
"*",
"*",
"yaml",
"*",
"*",
"yoda",
"*",
")",
"."
] | HEPData/hepdata-converter | python | https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/__init__.py#L9-L43 | [
"def",
"convert",
"(",
"input",
",",
"output",
"=",
"None",
",",
"options",
"=",
"{",
"}",
")",
":",
"if",
"'input_format'",
"not",
"in",
"options",
"and",
"'output_format'",
"not",
"in",
"options",
":",
"raise",
"ValueError",
"(",
"\"no input_format and out... | 354271448980efba86f2f3d27b99d818e75fd90d |
train | CSV._write_packed_data | This is kind of legacy function - this functionality may be useful for some people, so even though
now the default of writing CSV is writing unpacked data (divided by independent variable) this method is
still available and accessible if ```pack``` flag is specified in Writer's options
:param o... | hepdata_converter/writers/csv_writer.py | def _write_packed_data(self, data_out, table):
"""This is kind of legacy function - this functionality may be useful for some people, so even though
now the default of writing CSV is writing unpacked data (divided by independent variable) this method is
still available and accessible if ```pack`... | def _write_packed_data(self, data_out, table):
"""This is kind of legacy function - this functionality may be useful for some people, so even though
now the default of writing CSV is writing unpacked data (divided by independent variable) this method is
still available and accessible if ```pack`... | [
"This",
"is",
"kind",
"of",
"legacy",
"function",
"-",
"this",
"functionality",
"may",
"be",
"useful",
"for",
"some",
"people",
"so",
"even",
"though",
"now",
"the",
"default",
"of",
"writing",
"CSV",
"is",
"writing",
"unpacked",
"data",
"(",
"divided",
"b... | HEPData/hepdata-converter | python | https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/writers/csv_writer.py#L82-L102 | [
"def",
"_write_packed_data",
"(",
"self",
",",
"data_out",
",",
"table",
")",
":",
"headers",
"=",
"[",
"]",
"data",
"=",
"[",
"]",
"qualifiers_marks",
"=",
"[",
"]",
"qualifiers",
"=",
"{",
"}",
"self",
".",
"_extract_independent_variables",
"(",
"table",... | 354271448980efba86f2f3d27b99d818e75fd90d |
train | digest | <Purpose>
Provide the caller with the ability to create digest objects without having
to worry about crypto library availability or which library to use. The
caller also has the option of specifying which hash algorithm and/or
library to use.
# Creation of a digest object using defaults or by spec... | securesystemslib/hash.py | def digest(algorithm=DEFAULT_HASH_ALGORITHM, hash_library=DEFAULT_HASH_LIBRARY):
"""
<Purpose>
Provide the caller with the ability to create digest objects without having
to worry about crypto library availability or which library to use. The
caller also has the option of specifying which hash algorith... | def digest(algorithm=DEFAULT_HASH_ALGORITHM, hash_library=DEFAULT_HASH_LIBRARY):
"""
<Purpose>
Provide the caller with the ability to create digest objects without having
to worry about crypto library availability or which library to use. The
caller also has the option of specifying which hash algorith... | [
"<Purpose",
">",
"Provide",
"the",
"caller",
"with",
"the",
"ability",
"to",
"create",
"digest",
"objects",
"without",
"having",
"to",
"worry",
"about",
"crypto",
"library",
"availability",
"or",
"which",
"library",
"to",
"use",
".",
"The",
"caller",
"also",
... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/hash.py#L50-L122 | [
"def",
"digest",
"(",
"algorithm",
"=",
"DEFAULT_HASH_ALGORITHM",
",",
"hash_library",
"=",
"DEFAULT_HASH_LIBRARY",
")",
":",
"# Are the arguments properly formatted? If not, raise",
"# 'securesystemslib.exceptions.FormatError'.",
"securesystemslib",
".",
"formats",
".",
"NAME_S... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | digest_fileobject | <Purpose>
Generate a digest object given a file object. The new digest object
is updated with the contents of 'file_object' prior to returning the
object to the caller.
<Arguments>
file_object:
File object whose contents will be used as the data
to update the hash of a digest object to b... | securesystemslib/hash.py | def digest_fileobject(file_object, algorithm=DEFAULT_HASH_ALGORITHM,
hash_library=DEFAULT_HASH_LIBRARY, normalize_line_endings=False):
"""
<Purpose>
Generate a digest object given a file object. The new digest object
is updated with the contents of 'file_object' prior to returning the
object to the... | def digest_fileobject(file_object, algorithm=DEFAULT_HASH_ALGORITHM,
hash_library=DEFAULT_HASH_LIBRARY, normalize_line_endings=False):
"""
<Purpose>
Generate a digest object given a file object. The new digest object
is updated with the contents of 'file_object' prior to returning the
object to the... | [
"<Purpose",
">",
"Generate",
"a",
"digest",
"object",
"given",
"a",
"file",
"object",
".",
"The",
"new",
"digest",
"object",
"is",
"updated",
"with",
"the",
"contents",
"of",
"file_object",
"prior",
"to",
"returning",
"the",
"object",
"to",
"the",
"caller",
... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/hash.py#L128-L217 | [
"def",
"digest_fileobject",
"(",
"file_object",
",",
"algorithm",
"=",
"DEFAULT_HASH_ALGORITHM",
",",
"hash_library",
"=",
"DEFAULT_HASH_LIBRARY",
",",
"normalize_line_endings",
"=",
"False",
")",
":",
"# Are the arguments properly formatted? If not, raise",
"# 'securesystemsl... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | digest_filename | <Purpose>
Generate a digest object, update its hash using a file object
specified by filename, and then return it to the caller.
<Arguments>
filename:
The filename belonging to the file object to be used.
algorithm:
The hash algorithm (e.g., 'md5', 'sha1', 'sha256').
hash_library:
... | securesystemslib/hash.py | def digest_filename(filename, algorithm=DEFAULT_HASH_ALGORITHM,
hash_library=DEFAULT_HASH_LIBRARY, normalize_line_endings=False):
"""
<Purpose>
Generate a digest object, update its hash using a file object
specified by filename, and then return it to the caller.
<Arguments>
filename:
The fi... | def digest_filename(filename, algorithm=DEFAULT_HASH_ALGORITHM,
hash_library=DEFAULT_HASH_LIBRARY, normalize_line_endings=False):
"""
<Purpose>
Generate a digest object, update its hash using a file object
specified by filename, and then return it to the caller.
<Arguments>
filename:
The fi... | [
"<Purpose",
">",
"Generate",
"a",
"digest",
"object",
"update",
"its",
"hash",
"using",
"a",
"file",
"object",
"specified",
"by",
"filename",
"and",
"then",
"return",
"it",
"to",
"the",
"caller",
"."
] | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/hash.py#L223-L276 | [
"def",
"digest_filename",
"(",
"filename",
",",
"algorithm",
"=",
"DEFAULT_HASH_ALGORITHM",
",",
"hash_library",
"=",
"DEFAULT_HASH_LIBRARY",
",",
"normalize_line_endings",
"=",
"False",
")",
":",
"# Are the arguments properly formatted? If not, raise",
"# 'securesystemslib.ex... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | get_token_stream | Get the antlr token stream. | luaparser/ast.py | def get_token_stream(source: str) -> CommonTokenStream:
""" Get the antlr token stream.
"""
lexer = LuaLexer(InputStream(source))
stream = CommonTokenStream(lexer)
return stream | def get_token_stream(source: str) -> CommonTokenStream:
""" Get the antlr token stream.
"""
lexer = LuaLexer(InputStream(source))
stream = CommonTokenStream(lexer)
return stream | [
"Get",
"the",
"antlr",
"token",
"stream",
"."
] | boolangery/py-lua-parser | python | https://github.com/boolangery/py-lua-parser/blob/578f2bf75f6f84c4b52c2affba56a4ec569d7ce7/luaparser/ast.py#L18-L23 | [
"def",
"get_token_stream",
"(",
"source",
":",
"str",
")",
"->",
"CommonTokenStream",
":",
"lexer",
"=",
"LuaLexer",
"(",
"InputStream",
"(",
"source",
")",
")",
"stream",
"=",
"CommonTokenStream",
"(",
"lexer",
")",
"return",
"stream"
] | 578f2bf75f6f84c4b52c2affba56a4ec569d7ce7 |
train | Pokedex.get_evolution_stone | Returns a Evolution Stone object containing the details about the
evolution stone. | pokedex/pokedex.py | def get_evolution_stone(self, slug):
"""
Returns a Evolution Stone object containing the details about the
evolution stone.
"""
endpoint = '/evolution-stone/' + slug
return self.make_request(self.BASE_URL + endpoint) | def get_evolution_stone(self, slug):
"""
Returns a Evolution Stone object containing the details about the
evolution stone.
"""
endpoint = '/evolution-stone/' + slug
return self.make_request(self.BASE_URL + endpoint) | [
"Returns",
"a",
"Evolution",
"Stone",
"object",
"containing",
"the",
"details",
"about",
"the",
"evolution",
"stone",
"."
] | PokeDevs/pokedex.py | python | https://github.com/PokeDevs/pokedex.py/blob/dc1280f34176b0ecea633a87ab9e7eed02c1d32b/pokedex/pokedex.py#L66-L72 | [
"def",
"get_evolution_stone",
"(",
"self",
",",
"slug",
")",
":",
"endpoint",
"=",
"'/evolution-stone/'",
"+",
"slug",
"return",
"self",
".",
"make_request",
"(",
"self",
".",
"BASE_URL",
"+",
"endpoint",
")"
] | dc1280f34176b0ecea633a87ab9e7eed02c1d32b |
train | Pokedex.get_league | Returns a Pokemon League object containing the details about the
league. | pokedex/pokedex.py | def get_league(self, slug):
"""
Returns a Pokemon League object containing the details about the
league.
"""
endpoint = '/league/' + slug
return self.make_request(self.BASE_URL + endpoint) | def get_league(self, slug):
"""
Returns a Pokemon League object containing the details about the
league.
"""
endpoint = '/league/' + slug
return self.make_request(self.BASE_URL + endpoint) | [
"Returns",
"a",
"Pokemon",
"League",
"object",
"containing",
"the",
"details",
"about",
"the",
"league",
"."
] | PokeDevs/pokedex.py | python | https://github.com/PokeDevs/pokedex.py/blob/dc1280f34176b0ecea633a87ab9e7eed02c1d32b/pokedex/pokedex.py#L82-L88 | [
"def",
"get_league",
"(",
"self",
",",
"slug",
")",
":",
"endpoint",
"=",
"'/league/'",
"+",
"slug",
"return",
"self",
".",
"make_request",
"(",
"self",
".",
"BASE_URL",
"+",
"endpoint",
")"
] | dc1280f34176b0ecea633a87ab9e7eed02c1d32b |
train | Pokedex.get_pokemon_by_name | Returns an array of Pokemon objects containing all the forms of the
Pokemon specified the name of the Pokemon. | pokedex/pokedex.py | def get_pokemon_by_name(self, name):
"""
Returns an array of Pokemon objects containing all the forms of the
Pokemon specified the name of the Pokemon.
"""
endpoint = '/pokemon/' + str(name)
return self.make_request(self.BASE_URL + endpoint) | def get_pokemon_by_name(self, name):
"""
Returns an array of Pokemon objects containing all the forms of the
Pokemon specified the name of the Pokemon.
"""
endpoint = '/pokemon/' + str(name)
return self.make_request(self.BASE_URL + endpoint) | [
"Returns",
"an",
"array",
"of",
"Pokemon",
"objects",
"containing",
"all",
"the",
"forms",
"of",
"the",
"Pokemon",
"specified",
"the",
"name",
"of",
"the",
"Pokemon",
"."
] | PokeDevs/pokedex.py | python | https://github.com/PokeDevs/pokedex.py/blob/dc1280f34176b0ecea633a87ab9e7eed02c1d32b/pokedex/pokedex.py#L91-L97 | [
"def",
"get_pokemon_by_name",
"(",
"self",
",",
"name",
")",
":",
"endpoint",
"=",
"'/pokemon/'",
"+",
"str",
"(",
"name",
")",
"return",
"self",
".",
"make_request",
"(",
"self",
".",
"BASE_URL",
"+",
"endpoint",
")"
] | dc1280f34176b0ecea633a87ab9e7eed02c1d32b |
train | Pokedex.get_pokemon_by_number | Returns an array of Pokemon objects containing all the forms of the
Pokemon specified the Pokedex number. | pokedex/pokedex.py | def get_pokemon_by_number(self, number):
"""
Returns an array of Pokemon objects containing all the forms of the
Pokemon specified the Pokedex number.
"""
endpoint = '/pokemon/' + str(number)
return self.make_request(self.BASE_URL + endpoint) | def get_pokemon_by_number(self, number):
"""
Returns an array of Pokemon objects containing all the forms of the
Pokemon specified the Pokedex number.
"""
endpoint = '/pokemon/' + str(number)
return self.make_request(self.BASE_URL + endpoint) | [
"Returns",
"an",
"array",
"of",
"Pokemon",
"objects",
"containing",
"all",
"the",
"forms",
"of",
"the",
"Pokemon",
"specified",
"the",
"Pokedex",
"number",
"."
] | PokeDevs/pokedex.py | python | https://github.com/PokeDevs/pokedex.py/blob/dc1280f34176b0ecea633a87ab9e7eed02c1d32b/pokedex/pokedex.py#L99-L105 | [
"def",
"get_pokemon_by_number",
"(",
"self",
",",
"number",
")",
":",
"endpoint",
"=",
"'/pokemon/'",
"+",
"str",
"(",
"number",
")",
"return",
"self",
".",
"make_request",
"(",
"self",
".",
"BASE_URL",
"+",
"endpoint",
")"
] | dc1280f34176b0ecea633a87ab9e7eed02c1d32b |
train | generate_rsa_public_and_private | <Purpose>
Generate public and private RSA keys with modulus length 'bits'. The
public and private keys returned conform to
'securesystemslib.formats.PEMRSA_SCHEMA' and have the form:
'-----BEGIN RSA PUBLIC KEY----- ...'
or
'-----BEGIN RSA PRIVATE KEY----- ...'
The public and private key... | securesystemslib/pyca_crypto_keys.py | def generate_rsa_public_and_private(bits=_DEFAULT_RSA_KEY_BITS):
"""
<Purpose>
Generate public and private RSA keys with modulus length 'bits'. The
public and private keys returned conform to
'securesystemslib.formats.PEMRSA_SCHEMA' and have the form:
'-----BEGIN RSA PUBLIC KEY----- ...'
or
... | def generate_rsa_public_and_private(bits=_DEFAULT_RSA_KEY_BITS):
"""
<Purpose>
Generate public and private RSA keys with modulus length 'bits'. The
public and private keys returned conform to
'securesystemslib.formats.PEMRSA_SCHEMA' and have the form:
'-----BEGIN RSA PUBLIC KEY----- ...'
or
... | [
"<Purpose",
">",
"Generate",
"public",
"and",
"private",
"RSA",
"keys",
"with",
"modulus",
"length",
"bits",
".",
"The",
"public",
"and",
"private",
"keys",
"returned",
"conform",
"to",
"securesystemslib",
".",
"formats",
".",
"PEMRSA_SCHEMA",
"and",
"have",
"... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/pyca_crypto_keys.py#L160-L229 | [
"def",
"generate_rsa_public_and_private",
"(",
"bits",
"=",
"_DEFAULT_RSA_KEY_BITS",
")",
":",
"# Does 'bits' have the correct format?",
"# This check will ensure 'bits' conforms to",
"# 'securesystemslib.formats.RSAKEYBITS_SCHEMA'. 'bits' must be an integer",
"# object, with a minimum value ... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | create_rsa_signature | <Purpose>
Generate a 'scheme' signature. The signature, and the signature scheme
used, is returned as a (signature, scheme) tuple.
The signing process will use 'private_key' to generate the signature of
'data'.
RFC3447 - RSASSA-PSS
http://www.ietf.org/rfc/rfc3447.txt
>>> public, private ... | securesystemslib/pyca_crypto_keys.py | def create_rsa_signature(private_key, data, scheme='rsassa-pss-sha256'):
"""
<Purpose>
Generate a 'scheme' signature. The signature, and the signature scheme
used, is returned as a (signature, scheme) tuple.
The signing process will use 'private_key' to generate the signature of
'data'.
RFC34... | def create_rsa_signature(private_key, data, scheme='rsassa-pss-sha256'):
"""
<Purpose>
Generate a 'scheme' signature. The signature, and the signature scheme
used, is returned as a (signature, scheme) tuple.
The signing process will use 'private_key' to generate the signature of
'data'.
RFC34... | [
"<Purpose",
">",
"Generate",
"a",
"scheme",
"signature",
".",
"The",
"signature",
"and",
"the",
"signature",
"scheme",
"used",
"is",
"returned",
"as",
"a",
"(",
"signature",
"scheme",
")",
"tuple",
"."
] | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/pyca_crypto_keys.py#L235-L354 | [
"def",
"create_rsa_signature",
"(",
"private_key",
",",
"data",
",",
"scheme",
"=",
"'rsassa-pss-sha256'",
")",
":",
"# Does the arguments have the correct format?",
"# If not, raise 'securesystemslib.exceptions.FormatError' if any of the",
"# checks fail.",
"securesystemslib",
".",
... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | verify_rsa_signature | <Purpose>
Determine whether the corresponding private key of 'public_key' produced
'signature'. verify_signature() will use the public key, signature scheme,
and 'data' to complete the verification.
>>> public, private = generate_rsa_public_and_private(2048)
>>> data = b'The quick brown fox jumps ... | securesystemslib/pyca_crypto_keys.py | def verify_rsa_signature(signature, signature_scheme, public_key, data):
"""
<Purpose>
Determine whether the corresponding private key of 'public_key' produced
'signature'. verify_signature() will use the public key, signature scheme,
and 'data' to complete the verification.
>>> public, private = ... | def verify_rsa_signature(signature, signature_scheme, public_key, data):
"""
<Purpose>
Determine whether the corresponding private key of 'public_key' produced
'signature'. verify_signature() will use the public key, signature scheme,
and 'data' to complete the verification.
>>> public, private = ... | [
"<Purpose",
">",
"Determine",
"whether",
"the",
"corresponding",
"private",
"key",
"of",
"public_key",
"produced",
"signature",
".",
"verify_signature",
"()",
"will",
"use",
"the",
"public",
"key",
"signature",
"scheme",
"and",
"data",
"to",
"complete",
"the",
"... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/pyca_crypto_keys.py#L360-L452 | [
"def",
"verify_rsa_signature",
"(",
"signature",
",",
"signature_scheme",
",",
"public_key",
",",
"data",
")",
":",
"# Does 'public_key' have the correct format?",
"# This check will ensure 'public_key' conforms to",
"# 'securesystemslib.formats.PEMRSA_SCHEMA'. Raise",
"# 'securesyste... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | create_rsa_encrypted_pem | <Purpose>
Return a string in PEM format (TraditionalOpenSSL), where the private part
of the RSA key is encrypted using the best available encryption for a given
key's backend. This is a curated (by cryptography.io) encryption choice and
the algorithm may change over time.
c.f. cryptography.io/en/la... | securesystemslib/pyca_crypto_keys.py | def create_rsa_encrypted_pem(private_key, passphrase):
"""
<Purpose>
Return a string in PEM format (TraditionalOpenSSL), where the private part
of the RSA key is encrypted using the best available encryption for a given
key's backend. This is a curated (by cryptography.io) encryption choice and
the ... | def create_rsa_encrypted_pem(private_key, passphrase):
"""
<Purpose>
Return a string in PEM format (TraditionalOpenSSL), where the private part
of the RSA key is encrypted using the best available encryption for a given
key's backend. This is a curated (by cryptography.io) encryption choice and
the ... | [
"<Purpose",
">",
"Return",
"a",
"string",
"in",
"PEM",
"format",
"(",
"TraditionalOpenSSL",
")",
"where",
"the",
"private",
"part",
"of",
"the",
"RSA",
"key",
"is",
"encrypted",
"using",
"the",
"best",
"available",
"encryption",
"for",
"a",
"given",
"key",
... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/pyca_crypto_keys.py#L455-L522 | [
"def",
"create_rsa_encrypted_pem",
"(",
"private_key",
",",
"passphrase",
")",
":",
"# This check will ensure 'private_key' has the appropriate number",
"# of objects and object types, and that all dict keys are properly named.",
"# Raise 'securesystemslib.exceptions.FormatError' if the check fa... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | create_rsa_public_and_private_from_pem | <Purpose>
Generate public and private RSA keys from an optionally encrypted PEM. The
public and private keys returned conform to
'securesystemslib.formats.PEMRSA_SCHEMA' and have the form:
'-----BEGIN RSA PUBLIC KEY----- ... -----END RSA PUBLIC KEY-----'
and
'-----BEGIN RSA PRIVATE KEY----- ... | securesystemslib/pyca_crypto_keys.py | def create_rsa_public_and_private_from_pem(pem, passphrase=None):
"""
<Purpose>
Generate public and private RSA keys from an optionally encrypted PEM. The
public and private keys returned conform to
'securesystemslib.formats.PEMRSA_SCHEMA' and have the form:
'-----BEGIN RSA PUBLIC KEY----- ... ---... | def create_rsa_public_and_private_from_pem(pem, passphrase=None):
"""
<Purpose>
Generate public and private RSA keys from an optionally encrypted PEM. The
public and private keys returned conform to
'securesystemslib.formats.PEMRSA_SCHEMA' and have the form:
'-----BEGIN RSA PUBLIC KEY----- ... ---... | [
"<Purpose",
">",
"Generate",
"public",
"and",
"private",
"RSA",
"keys",
"from",
"an",
"optionally",
"encrypted",
"PEM",
".",
"The",
"public",
"and",
"private",
"keys",
"returned",
"conform",
"to",
"securesystemslib",
".",
"formats",
".",
"PEMRSA_SCHEMA",
"and",
... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/pyca_crypto_keys.py#L528-L643 | [
"def",
"create_rsa_public_and_private_from_pem",
"(",
"pem",
",",
"passphrase",
"=",
"None",
")",
":",
"# Does 'encryped_pem' have the correct format?",
"# This check will ensure 'pem' has the appropriate number",
"# of objects and object types, and that all dict keys are properly named.",
... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | encrypt_key | <Purpose>
Return a string containing 'key_object' in encrypted form. Encrypted
strings may be safely saved to a file. The corresponding decrypt_key()
function can be applied to the encrypted string to restore the original key
object. 'key_object' is a TUF key (e.g., RSAKEY_SCHEMA,
ED25519KEY_SCHEM... | securesystemslib/pyca_crypto_keys.py | def encrypt_key(key_object, password):
"""
<Purpose>
Return a string containing 'key_object' in encrypted form. Encrypted
strings may be safely saved to a file. The corresponding decrypt_key()
function can be applied to the encrypted string to restore the original key
object. 'key_object' is a TUF... | def encrypt_key(key_object, password):
"""
<Purpose>
Return a string containing 'key_object' in encrypted form. Encrypted
strings may be safely saved to a file. The corresponding decrypt_key()
function can be applied to the encrypted string to restore the original key
object. 'key_object' is a TUF... | [
"<Purpose",
">",
"Return",
"a",
"string",
"containing",
"key_object",
"in",
"encrypted",
"form",
".",
"Encrypted",
"strings",
"may",
"be",
"safely",
"saved",
"to",
"a",
"file",
".",
"The",
"corresponding",
"decrypt_key",
"()",
"function",
"can",
"be",
"applied... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/pyca_crypto_keys.py#L649-L739 | [
"def",
"encrypt_key",
"(",
"key_object",
",",
"password",
")",
":",
"# Do the arguments have the correct format?",
"# Ensure the arguments have the appropriate number of objects and object",
"# types, and that all dict keys are properly named.",
"# Raise 'securesystemslib.exceptions.FormatErro... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | decrypt_key | <Purpose>
Return a string containing 'encrypted_key' in non-encrypted form.
The decrypt_key() function can be applied to the encrypted string to restore
the original key object, a TUF key (e.g., RSAKEY_SCHEMA, ED25519KEY_SCHEMA).
This function calls the appropriate cryptography module (i.e.,
pyca_cr... | securesystemslib/pyca_crypto_keys.py | def decrypt_key(encrypted_key, password):
"""
<Purpose>
Return a string containing 'encrypted_key' in non-encrypted form.
The decrypt_key() function can be applied to the encrypted string to restore
the original key object, a TUF key (e.g., RSAKEY_SCHEMA, ED25519KEY_SCHEMA).
This function calls the ... | def decrypt_key(encrypted_key, password):
"""
<Purpose>
Return a string containing 'encrypted_key' in non-encrypted form.
The decrypt_key() function can be applied to the encrypted string to restore
the original key object, a TUF key (e.g., RSAKEY_SCHEMA, ED25519KEY_SCHEMA).
This function calls the ... | [
"<Purpose",
">",
"Return",
"a",
"string",
"containing",
"encrypted_key",
"in",
"non",
"-",
"encrypted",
"form",
".",
"The",
"decrypt_key",
"()",
"function",
"can",
"be",
"applied",
"to",
"the",
"encrypted",
"string",
"to",
"restore",
"the",
"original",
"key",
... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/pyca_crypto_keys.py#L745-L827 | [
"def",
"decrypt_key",
"(",
"encrypted_key",
",",
"password",
")",
":",
"# Do the arguments have the correct format?",
"# Ensure the arguments have the appropriate number of objects and object",
"# types, and that all dict keys are properly named.",
"# Raise 'securesystemslib.exceptions.FormatE... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | _generate_derived_key | Generate a derived key by feeding 'password' to the Password-Based Key
Derivation Function (PBKDF2). pyca/cryptography's PBKDF2 implementation is
used in this module. 'salt' may be specified so that a previous derived key
may be regenerated, otherwise '_SALT_SIZE' is used by default. 'iterations'
is the numb... | securesystemslib/pyca_crypto_keys.py | def _generate_derived_key(password, salt=None, iterations=None):
"""
Generate a derived key by feeding 'password' to the Password-Based Key
Derivation Function (PBKDF2). pyca/cryptography's PBKDF2 implementation is
used in this module. 'salt' may be specified so that a previous derived key
may be regenerate... | def _generate_derived_key(password, salt=None, iterations=None):
"""
Generate a derived key by feeding 'password' to the Password-Based Key
Derivation Function (PBKDF2). pyca/cryptography's PBKDF2 implementation is
used in this module. 'salt' may be specified so that a previous derived key
may be regenerate... | [
"Generate",
"a",
"derived",
"key",
"by",
"feeding",
"password",
"to",
"the",
"Password",
"-",
"Based",
"Key",
"Derivation",
"Function",
"(",
"PBKDF2",
")",
".",
"pyca",
"/",
"cryptography",
"s",
"PBKDF2",
"implementation",
"is",
"used",
"in",
"this",
"module... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/pyca_crypto_keys.py#L833-L864 | [
"def",
"_generate_derived_key",
"(",
"password",
",",
"salt",
"=",
"None",
",",
"iterations",
"=",
"None",
")",
":",
"# Use pyca/cryptography's default backend (e.g., openSSL, CommonCrypto, etc.)",
"# The default backend is not fixed and can be changed by pyca/cryptography",
"# over ... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | _encrypt | Encrypt 'key_data' using the Advanced Encryption Standard (AES-256) algorithm.
'derived_key_information' should contain a key strengthened by PBKDF2. The
key size is 256 bits and AES's mode of operation is set to CTR (CounTeR Mode).
The HMAC of the ciphertext is generated to ensure the ciphertext has not been
... | securesystemslib/pyca_crypto_keys.py | def _encrypt(key_data, derived_key_information):
"""
Encrypt 'key_data' using the Advanced Encryption Standard (AES-256) algorithm.
'derived_key_information' should contain a key strengthened by PBKDF2. The
key size is 256 bits and AES's mode of operation is set to CTR (CounTeR Mode).
The HMAC of the ciphert... | def _encrypt(key_data, derived_key_information):
"""
Encrypt 'key_data' using the Advanced Encryption Standard (AES-256) algorithm.
'derived_key_information' should contain a key strengthened by PBKDF2. The
key size is 256 bits and AES's mode of operation is set to CTR (CounTeR Mode).
The HMAC of the ciphert... | [
"Encrypt",
"key_data",
"using",
"the",
"Advanced",
"Encryption",
"Standard",
"(",
"AES",
"-",
"256",
")",
"algorithm",
".",
"derived_key_information",
"should",
"contain",
"a",
"key",
"strengthened",
"by",
"PBKDF2",
".",
"The",
"key",
"size",
"is",
"256",
"bit... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/pyca_crypto_keys.py#L870-L939 | [
"def",
"_encrypt",
"(",
"key_data",
",",
"derived_key_information",
")",
":",
"# Generate a random Initialization Vector (IV). Follow the provably secure",
"# encrypt-then-MAC approach, which affords the ability to verify ciphertext",
"# without needing to decrypt it and preventing an attacker ... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | _decrypt | The corresponding decryption routine for _encrypt().
'securesystemslib.exceptions.CryptoError' raised if the decryption fails. | securesystemslib/pyca_crypto_keys.py | def _decrypt(file_contents, password):
"""
The corresponding decryption routine for _encrypt().
'securesystemslib.exceptions.CryptoError' raised if the decryption fails.
"""
# Extract the salt, iterations, hmac, initialization vector, and ciphertext
# from 'file_contents'. These five values are delimited... | def _decrypt(file_contents, password):
"""
The corresponding decryption routine for _encrypt().
'securesystemslib.exceptions.CryptoError' raised if the decryption fails.
"""
# Extract the salt, iterations, hmac, initialization vector, and ciphertext
# from 'file_contents'. These five values are delimited... | [
"The",
"corresponding",
"decryption",
"routine",
"for",
"_encrypt",
"()",
"."
] | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/pyca_crypto_keys.py#L945-L999 | [
"def",
"_decrypt",
"(",
"file_contents",
",",
"password",
")",
":",
"# Extract the salt, iterations, hmac, initialization vector, and ciphertext",
"# from 'file_contents'. These five values are delimited by",
"# '_ENCRYPTION_DELIMITER'. This delimiter is arbitrarily chosen and should",
"# no... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | create_environment | Creates a new environment in ``home_dir``.
If ``site_packages`` is true (the default) then the global
``site-packages/`` directory will be on the path.
If ``clear`` is true (default False) then the environment will
first be cleared. | virtualenv.py | def create_environment(home_dir, site_packages=True, clear=False,
unzip_setuptools=False, use_distribute=False):
"""
Creates a new environment in ``home_dir``.
If ``site_packages`` is true (the default) then the global
``site-packages/`` directory will be on the path.
If ``c... | def create_environment(home_dir, site_packages=True, clear=False,
unzip_setuptools=False, use_distribute=False):
"""
Creates a new environment in ``home_dir``.
If ``site_packages`` is true (the default) then the global
``site-packages/`` directory will be on the path.
If ``c... | [
"Creates",
"a",
"new",
"environment",
"in",
"home_dir",
"."
] | Tristramg/mumoro | python | https://github.com/Tristramg/mumoro/blob/e37d6ddb72fd23fb485c80fd8a5cda520ca08187/virtualenv.py#L594-L620 | [
"def",
"create_environment",
"(",
"home_dir",
",",
"site_packages",
"=",
"True",
",",
"clear",
"=",
"False",
",",
"unzip_setuptools",
"=",
"False",
",",
"use_distribute",
"=",
"False",
")",
":",
"home_dir",
",",
"lib_dir",
",",
"inc_dir",
",",
"bin_dir",
"="... | e37d6ddb72fd23fb485c80fd8a5cda520ca08187 |
train | path_locations | Return the path locations for the environment (where libraries are,
where scripts go, etc) | virtualenv.py | def path_locations(home_dir):
"""Return the path locations for the environment (where libraries are,
where scripts go, etc)"""
# XXX: We'd use distutils.sysconfig.get_python_inc/lib but its
# prefix arg is broken: http://bugs.python.org/issue3386
if sys.platform == 'win32':
# Windows has lot... | def path_locations(home_dir):
"""Return the path locations for the environment (where libraries are,
where scripts go, etc)"""
# XXX: We'd use distutils.sysconfig.get_python_inc/lib but its
# prefix arg is broken: http://bugs.python.org/issue3386
if sys.platform == 'win32':
# Windows has lot... | [
"Return",
"the",
"path",
"locations",
"for",
"the",
"environment",
"(",
"where",
"libraries",
"are",
"where",
"scripts",
"go",
"etc",
")"
] | Tristramg/mumoro | python | https://github.com/Tristramg/mumoro/blob/e37d6ddb72fd23fb485c80fd8a5cda520ca08187/virtualenv.py#L622-L652 | [
"def",
"path_locations",
"(",
"home_dir",
")",
":",
"# XXX: We'd use distutils.sysconfig.get_python_inc/lib but its",
"# prefix arg is broken: http://bugs.python.org/issue3386",
"if",
"sys",
".",
"platform",
"==",
"'win32'",
":",
"# Windows has lots of problems with executables with sp... | e37d6ddb72fd23fb485c80fd8a5cda520ca08187 |
train | install_python | Install just the base environment, no distutils patches etc | virtualenv.py | def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear):
"""Install just the base environment, no distutils patches etc"""
if sys.executable.startswith(bin_dir):
print 'Please use the *system* python to run this script'
return
if clear:
rmtree(lib_dir)
... | def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear):
"""Install just the base environment, no distutils patches etc"""
if sys.executable.startswith(bin_dir):
print 'Please use the *system* python to run this script'
return
if clear:
rmtree(lib_dir)
... | [
"Install",
"just",
"the",
"base",
"environment",
"no",
"distutils",
"patches",
"etc"
] | Tristramg/mumoro | python | https://github.com/Tristramg/mumoro/blob/e37d6ddb72fd23fb485c80fd8a5cda520ca08187/virtualenv.py#L654-L857 | [
"def",
"install_python",
"(",
"home_dir",
",",
"lib_dir",
",",
"inc_dir",
",",
"bin_dir",
",",
"site_packages",
",",
"clear",
")",
":",
"if",
"sys",
".",
"executable",
".",
"startswith",
"(",
"bin_dir",
")",
":",
"print",
"'Please use the *system* python to run ... | e37d6ddb72fd23fb485c80fd8a5cda520ca08187 |
train | fix_lib64 | Some platforms (particularly Gentoo on x64) put things in lib64/pythonX.Y
instead of lib/pythonX.Y. If this is such a platform we'll just create a
symlink so lib64 points to lib | virtualenv.py | def fix_lib64(lib_dir):
"""
Some platforms (particularly Gentoo on x64) put things in lib64/pythonX.Y
instead of lib/pythonX.Y. If this is such a platform we'll just create a
symlink so lib64 points to lib
"""
if [p for p in distutils.sysconfig.get_config_vars().values()
if isinstance(p... | def fix_lib64(lib_dir):
"""
Some platforms (particularly Gentoo on x64) put things in lib64/pythonX.Y
instead of lib/pythonX.Y. If this is such a platform we'll just create a
symlink so lib64 points to lib
"""
if [p for p in distutils.sysconfig.get_config_vars().values()
if isinstance(p... | [
"Some",
"platforms",
"(",
"particularly",
"Gentoo",
"on",
"x64",
")",
"put",
"things",
"in",
"lib64",
"/",
"pythonX",
".",
"Y",
"instead",
"of",
"lib",
"/",
"pythonX",
".",
"Y",
".",
"If",
"this",
"is",
"such",
"a",
"platform",
"we",
"ll",
"just",
"c... | Tristramg/mumoro | python | https://github.com/Tristramg/mumoro/blob/e37d6ddb72fd23fb485c80fd8a5cda520ca08187/virtualenv.py#L885-L899 | [
"def",
"fix_lib64",
"(",
"lib_dir",
")",
":",
"if",
"[",
"p",
"for",
"p",
"in",
"distutils",
".",
"sysconfig",
".",
"get_config_vars",
"(",
")",
".",
"values",
"(",
")",
"if",
"isinstance",
"(",
"p",
",",
"basestring",
")",
"and",
"'lib64'",
"in",
"p... | e37d6ddb72fd23fb485c80fd8a5cda520ca08187 |
train | resolve_interpreter | If the executable given isn't an absolute path, search $PATH for the interpreter | virtualenv.py | def resolve_interpreter(exe):
"""
If the executable given isn't an absolute path, search $PATH for the interpreter
"""
if os.path.abspath(exe) != exe:
paths = os.environ.get('PATH', '').split(os.pathsep)
for path in paths:
if os.path.exists(os.path.join(path, exe)):
... | def resolve_interpreter(exe):
"""
If the executable given isn't an absolute path, search $PATH for the interpreter
"""
if os.path.abspath(exe) != exe:
paths = os.environ.get('PATH', '').split(os.pathsep)
for path in paths:
if os.path.exists(os.path.join(path, exe)):
... | [
"If",
"the",
"executable",
"given",
"isn",
"t",
"an",
"absolute",
"path",
"search",
"$PATH",
"for",
"the",
"interpreter"
] | Tristramg/mumoro | python | https://github.com/Tristramg/mumoro/blob/e37d6ddb72fd23fb485c80fd8a5cda520ca08187/virtualenv.py#L901-L914 | [
"def",
"resolve_interpreter",
"(",
"exe",
")",
":",
"if",
"os",
".",
"path",
".",
"abspath",
"(",
"exe",
")",
"!=",
"exe",
":",
"paths",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'PATH'",
",",
"''",
")",
".",
"split",
"(",
"os",
".",
"pathsep"... | e37d6ddb72fd23fb485c80fd8a5cda520ca08187 |
train | make_environment_relocatable | Makes the already-existing environment use relative paths, and takes out
the #!-based environment selection in scripts. | virtualenv.py | def make_environment_relocatable(home_dir):
"""
Makes the already-existing environment use relative paths, and takes out
the #!-based environment selection in scripts.
"""
activate_this = os.path.join(home_dir, 'bin', 'activate_this.py')
if not os.path.exists(activate_this):
logger.fatal... | def make_environment_relocatable(home_dir):
"""
Makes the already-existing environment use relative paths, and takes out
the #!-based environment selection in scripts.
"""
activate_this = os.path.join(home_dir, 'bin', 'activate_this.py')
if not os.path.exists(activate_this):
logger.fatal... | [
"Makes",
"the",
"already",
"-",
"existing",
"environment",
"use",
"relative",
"paths",
"and",
"takes",
"out",
"the",
"#!",
"-",
"based",
"environment",
"selection",
"in",
"scripts",
"."
] | Tristramg/mumoro | python | https://github.com/Tristramg/mumoro/blob/e37d6ddb72fd23fb485c80fd8a5cda520ca08187/virtualenv.py#L919-L930 | [
"def",
"make_environment_relocatable",
"(",
"home_dir",
")",
":",
"activate_this",
"=",
"os",
".",
"path",
".",
"join",
"(",
"home_dir",
",",
"'bin'",
",",
"'activate_this.py'",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"activate_this",
")",
... | e37d6ddb72fd23fb485c80fd8a5cda520ca08187 |
train | generate_rsa_key | <Purpose>
Generate public and private RSA keys, with modulus length 'bits'. In
addition, a keyid identifier for the RSA key is generated. The object
returned conforms to 'securesystemslib.formats.RSAKEY_SCHEMA' and has the
form:
{'keytype': 'rsa',
'scheme': 'rsassa-pss-sha256',
'keyid':... | securesystemslib/keys.py | def generate_rsa_key(bits=_DEFAULT_RSA_KEY_BITS, scheme='rsassa-pss-sha256'):
"""
<Purpose>
Generate public and private RSA keys, with modulus length 'bits'. In
addition, a keyid identifier for the RSA key is generated. The object
returned conforms to 'securesystemslib.formats.RSAKEY_SCHEMA' and has t... | def generate_rsa_key(bits=_DEFAULT_RSA_KEY_BITS, scheme='rsassa-pss-sha256'):
"""
<Purpose>
Generate public and private RSA keys, with modulus length 'bits'. In
addition, a keyid identifier for the RSA key is generated. The object
returned conforms to 'securesystemslib.formats.RSAKEY_SCHEMA' and has t... | [
"<Purpose",
">",
"Generate",
"public",
"and",
"private",
"RSA",
"keys",
"with",
"modulus",
"length",
"bits",
".",
"In",
"addition",
"a",
"keyid",
"identifier",
"for",
"the",
"RSA",
"key",
"is",
"generated",
".",
"The",
"object",
"returned",
"conforms",
"to",... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L127-L230 | [
"def",
"generate_rsa_key",
"(",
"bits",
"=",
"_DEFAULT_RSA_KEY_BITS",
",",
"scheme",
"=",
"'rsassa-pss-sha256'",
")",
":",
"# Does 'bits' have the correct format? This check will ensure 'bits'",
"# conforms to 'securesystemslib.formats.RSAKEYBITS_SCHEMA'. 'bits' must be",
"# an integer... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | generate_ecdsa_key | <Purpose>
Generate public and private ECDSA keys, with NIST P-256 + SHA256 (for
hashing) being the default scheme. In addition, a keyid identifier for the
ECDSA key is generated. The object returned conforms to
'securesystemslib.formats.ECDSAKEY_SCHEMA' and has the form:
{'keytype': 'ecdsa-sha2-n... | securesystemslib/keys.py | def generate_ecdsa_key(scheme='ecdsa-sha2-nistp256'):
"""
<Purpose>
Generate public and private ECDSA keys, with NIST P-256 + SHA256 (for
hashing) being the default scheme. In addition, a keyid identifier for the
ECDSA key is generated. The object returned conforms to
'securesystemslib.formats.ECD... | def generate_ecdsa_key(scheme='ecdsa-sha2-nistp256'):
"""
<Purpose>
Generate public and private ECDSA keys, with NIST P-256 + SHA256 (for
hashing) being the default scheme. In addition, a keyid identifier for the
ECDSA key is generated. The object returned conforms to
'securesystemslib.formats.ECD... | [
"<Purpose",
">",
"Generate",
"public",
"and",
"private",
"ECDSA",
"keys",
"with",
"NIST",
"P",
"-",
"256",
"+",
"SHA256",
"(",
"for",
"hashing",
")",
"being",
"the",
"default",
"scheme",
".",
"In",
"addition",
"a",
"keyid",
"identifier",
"for",
"the",
"E... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L236-L315 | [
"def",
"generate_ecdsa_key",
"(",
"scheme",
"=",
"'ecdsa-sha2-nistp256'",
")",
":",
"# Does 'scheme' have the correct format?",
"# This check will ensure 'scheme' is properly formatted and is a supported",
"# ECDSA signature scheme. Raise 'securesystemslib.exceptions.FormatError' if",
"# the ... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | generate_ed25519_key | <Purpose>
Generate public and private ED25519 keys, both of length 32-bytes, although
they are hexlified to 64 bytes. In addition, a keyid identifier generated
for the returned ED25519 object. The object returned conforms to
'securesystemslib.formats.ED25519KEY_SCHEMA' and has the form:
{'keytype... | securesystemslib/keys.py | def generate_ed25519_key(scheme='ed25519'):
"""
<Purpose>
Generate public and private ED25519 keys, both of length 32-bytes, although
they are hexlified to 64 bytes. In addition, a keyid identifier generated
for the returned ED25519 object. The object returned conforms to
'securesystemslib.formats... | def generate_ed25519_key(scheme='ed25519'):
"""
<Purpose>
Generate public and private ED25519 keys, both of length 32-bytes, although
they are hexlified to 64 bytes. In addition, a keyid identifier generated
for the returned ED25519 object. The object returned conforms to
'securesystemslib.formats... | [
"<Purpose",
">",
"Generate",
"public",
"and",
"private",
"ED25519",
"keys",
"both",
"of",
"length",
"32",
"-",
"bytes",
"although",
"they",
"are",
"hexlified",
"to",
"64",
"bytes",
".",
"In",
"addition",
"a",
"keyid",
"identifier",
"generated",
"for",
"the",... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L321-L394 | [
"def",
"generate_ed25519_key",
"(",
"scheme",
"=",
"'ed25519'",
")",
":",
"# Are the arguments properly formatted? If not, raise an",
"# 'securesystemslib.exceptions.FormatError' exceptions.",
"securesystemslib",
".",
"formats",
".",
"ED25519_SIG_SCHEMA",
".",
"check_match",
"(",
... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | format_keyval_to_metadata | <Purpose>
Return a dictionary conformant to 'securesystemslib.formats.KEY_SCHEMA'.
If 'private' is True, include the private key. The dictionary
returned has the form:
{'keytype': keytype,
'scheme' : scheme,
'keyval': {'public': '...',
'private': '...'}}
or if 'private' ... | securesystemslib/keys.py | def format_keyval_to_metadata(keytype, scheme, key_value, private=False):
"""
<Purpose>
Return a dictionary conformant to 'securesystemslib.formats.KEY_SCHEMA'.
If 'private' is True, include the private key. The dictionary
returned has the form:
{'keytype': keytype,
'scheme' : scheme,
'k... | def format_keyval_to_metadata(keytype, scheme, key_value, private=False):
"""
<Purpose>
Return a dictionary conformant to 'securesystemslib.formats.KEY_SCHEMA'.
If 'private' is True, include the private key. The dictionary
returned has the form:
{'keytype': keytype,
'scheme' : scheme,
'k... | [
"<Purpose",
">",
"Return",
"a",
"dictionary",
"conformant",
"to",
"securesystemslib",
".",
"formats",
".",
"KEY_SCHEMA",
".",
"If",
"private",
"is",
"True",
"include",
"the",
"private",
"key",
".",
"The",
"dictionary",
"returned",
"has",
"the",
"form",
":"
] | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L400-L490 | [
"def",
"format_keyval_to_metadata",
"(",
"keytype",
",",
"scheme",
",",
"key_value",
",",
"private",
"=",
"False",
")",
":",
"# Does 'keytype' have the correct format?",
"# This check will ensure 'keytype' has the appropriate number",
"# of objects and object types, and that all dict... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | format_metadata_to_key | <Purpose>
Construct a key dictionary (e.g., securesystemslib.formats.RSAKEY_SCHEMA)
according to the keytype of 'key_metadata'. The dict returned by this
function has the exact format as the dict returned by one of the key
generations functions, like generate_ed25519_key(). The dict returned
has t... | securesystemslib/keys.py | def format_metadata_to_key(key_metadata):
"""
<Purpose>
Construct a key dictionary (e.g., securesystemslib.formats.RSAKEY_SCHEMA)
according to the keytype of 'key_metadata'. The dict returned by this
function has the exact format as the dict returned by one of the key
generations functions, like ge... | def format_metadata_to_key(key_metadata):
"""
<Purpose>
Construct a key dictionary (e.g., securesystemslib.formats.RSAKEY_SCHEMA)
according to the keytype of 'key_metadata'. The dict returned by this
function has the exact format as the dict returned by one of the key
generations functions, like ge... | [
"<Purpose",
">",
"Construct",
"a",
"key",
"dictionary",
"(",
"e",
".",
"g",
".",
"securesystemslib",
".",
"formats",
".",
"RSAKEY_SCHEMA",
")",
"according",
"to",
"the",
"keytype",
"of",
"key_metadata",
".",
"The",
"dict",
"returned",
"by",
"this",
"function... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L496-L582 | [
"def",
"format_metadata_to_key",
"(",
"key_metadata",
")",
":",
"# Does 'key_metadata' have the correct format?",
"# This check will ensure 'key_metadata' has the appropriate number",
"# of objects and object types, and that all dict keys are properly named.",
"# Raise 'securesystemslib.exceptions... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | _get_keyid | Return the keyid of 'key_value'. | securesystemslib/keys.py | def _get_keyid(keytype, scheme, key_value, hash_algorithm = 'sha256'):
"""Return the keyid of 'key_value'."""
# 'keyid' will be generated from an object conformant to KEY_SCHEMA,
# which is the format Metadata files (e.g., root.json) store keys.
# 'format_keyval_to_metadata()' returns the object needed by _get... | def _get_keyid(keytype, scheme, key_value, hash_algorithm = 'sha256'):
"""Return the keyid of 'key_value'."""
# 'keyid' will be generated from an object conformant to KEY_SCHEMA,
# which is the format Metadata files (e.g., root.json) store keys.
# 'format_keyval_to_metadata()' returns the object needed by _get... | [
"Return",
"the",
"keyid",
"of",
"key_value",
"."
] | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L586-L606 | [
"def",
"_get_keyid",
"(",
"keytype",
",",
"scheme",
",",
"key_value",
",",
"hash_algorithm",
"=",
"'sha256'",
")",
":",
"# 'keyid' will be generated from an object conformant to KEY_SCHEMA,",
"# which is the format Metadata files (e.g., root.json) store keys.",
"# 'format_keyval_to_m... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | create_signature | <Purpose>
Return a signature dictionary of the form:
{'keyid': 'f30a0870d026980100c0573bd557394f8c1bbd6...',
'sig': '...'}.
The signing process will use the private key in
key_dict['keyval']['private'] and 'data' to generate the signature.
The following signature schemes are supported:
'... | securesystemslib/keys.py | def create_signature(key_dict, data):
"""
<Purpose>
Return a signature dictionary of the form:
{'keyid': 'f30a0870d026980100c0573bd557394f8c1bbd6...',
'sig': '...'}.
The signing process will use the private key in
key_dict['keyval']['private'] and 'data' to generate the signature.
The fol... | def create_signature(key_dict, data):
"""
<Purpose>
Return a signature dictionary of the form:
{'keyid': 'f30a0870d026980100c0573bd557394f8c1bbd6...',
'sig': '...'}.
The signing process will use the private key in
key_dict['keyval']['private'] and 'data' to generate the signature.
The fol... | [
"<Purpose",
">",
"Return",
"a",
"signature",
"dictionary",
"of",
"the",
"form",
":",
"{",
"keyid",
":",
"f30a0870d026980100c0573bd557394f8c1bbd6",
"...",
"sig",
":",
"...",
"}",
"."
] | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L612-L738 | [
"def",
"create_signature",
"(",
"key_dict",
",",
"data",
")",
":",
"# Does 'key_dict' have the correct format?",
"# This check will ensure 'key_dict' has the appropriate number of objects",
"# and object types, and that all dict keys are properly named.",
"# Raise 'securesystemslib.exceptions.... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | verify_signature | <Purpose>
Determine whether the private key belonging to 'key_dict' produced
'signature'. verify_signature() will use the public key found in
'key_dict', the 'sig' objects contained in 'signature', and 'data' to
complete the verification.
>>> ed25519_key = generate_ed25519_key()
>>> data = 'Th... | securesystemslib/keys.py | def verify_signature(key_dict, signature, data):
"""
<Purpose>
Determine whether the private key belonging to 'key_dict' produced
'signature'. verify_signature() will use the public key found in
'key_dict', the 'sig' objects contained in 'signature', and 'data' to
complete the verification.
>>... | def verify_signature(key_dict, signature, data):
"""
<Purpose>
Determine whether the private key belonging to 'key_dict' produced
'signature'. verify_signature() will use the public key found in
'key_dict', the 'sig' objects contained in 'signature', and 'data' to
complete the verification.
>>... | [
"<Purpose",
">",
"Determine",
"whether",
"the",
"private",
"key",
"belonging",
"to",
"key_dict",
"produced",
"signature",
".",
"verify_signature",
"()",
"will",
"use",
"the",
"public",
"key",
"found",
"in",
"key_dict",
"the",
"sig",
"objects",
"contained",
"in",... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L744-L882 | [
"def",
"verify_signature",
"(",
"key_dict",
",",
"signature",
",",
"data",
")",
":",
"# Does 'key_dict' have the correct format?",
"# This check will ensure 'key_dict' has the appropriate number",
"# of objects and object types, and that all dict keys are properly named.",
"# Raise 'secure... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | import_rsakey_from_private_pem | <Purpose>
Import the private RSA key stored in 'pem', and generate its public key
(which will also be included in the returned rsakey object). In addition,
a keyid identifier for the RSA key is generated. The object returned
conforms to 'securesystemslib.formats.RSAKEY_SCHEMA' and has the form:
{... | securesystemslib/keys.py | def import_rsakey_from_private_pem(pem, scheme='rsassa-pss-sha256', password=None):
"""
<Purpose>
Import the private RSA key stored in 'pem', and generate its public key
(which will also be included in the returned rsakey object). In addition,
a keyid identifier for the RSA key is generated. The objec... | def import_rsakey_from_private_pem(pem, scheme='rsassa-pss-sha256', password=None):
"""
<Purpose>
Import the private RSA key stored in 'pem', and generate its public key
(which will also be included in the returned rsakey object). In addition,
a keyid identifier for the RSA key is generated. The objec... | [
"<Purpose",
">",
"Import",
"the",
"private",
"RSA",
"key",
"stored",
"in",
"pem",
"and",
"generate",
"its",
"public",
"key",
"(",
"which",
"will",
"also",
"be",
"included",
"in",
"the",
"returned",
"rsakey",
"object",
")",
".",
"In",
"addition",
"a",
"ke... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L888-L991 | [
"def",
"import_rsakey_from_private_pem",
"(",
"pem",
",",
"scheme",
"=",
"'rsassa-pss-sha256'",
",",
"password",
"=",
"None",
")",
":",
"# Does 'pem' have the correct format?",
"# This check will ensure 'pem' conforms to",
"# 'securesystemslib.formats.PEMRSA_SCHEMA'.",
"securesyste... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | import_rsakey_from_public_pem | <Purpose>
Generate an RSA key object from 'pem'. In addition, a keyid identifier for
the RSA key is generated. The object returned conforms to
'securesystemslib.formats.RSAKEY_SCHEMA' and has the form:
{'keytype': 'rsa',
'keyid': keyid,
'keyval': {'public': '-----BEGIN PUBLIC KEY----- ...',... | securesystemslib/keys.py | def import_rsakey_from_public_pem(pem, scheme='rsassa-pss-sha256'):
"""
<Purpose>
Generate an RSA key object from 'pem'. In addition, a keyid identifier for
the RSA key is generated. The object returned conforms to
'securesystemslib.formats.RSAKEY_SCHEMA' and has the form:
{'keytype': 'rsa',
... | def import_rsakey_from_public_pem(pem, scheme='rsassa-pss-sha256'):
"""
<Purpose>
Generate an RSA key object from 'pem'. In addition, a keyid identifier for
the RSA key is generated. The object returned conforms to
'securesystemslib.formats.RSAKEY_SCHEMA' and has the form:
{'keytype': 'rsa',
... | [
"<Purpose",
">",
"Generate",
"an",
"RSA",
"key",
"object",
"from",
"pem",
".",
"In",
"addition",
"a",
"keyid",
"identifier",
"for",
"the",
"RSA",
"key",
"is",
"generated",
".",
"The",
"object",
"returned",
"conforms",
"to",
"securesystemslib",
".",
"formats"... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L997-L1081 | [
"def",
"import_rsakey_from_public_pem",
"(",
"pem",
",",
"scheme",
"=",
"'rsassa-pss-sha256'",
")",
":",
"# Does 'pem' have the correct format?",
"# This check will ensure arguments has the appropriate number",
"# of objects and object types, and that all dict keys are properly named.",
"#... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | extract_pem | <Purpose>
Extract only the portion of the pem that includes the header and footer,
with any leading and trailing characters removed. The string returned has
the following form:
'-----BEGIN PUBLIC KEY----- ... -----END PUBLIC KEY-----'
or
'-----BEGIN RSA PRIVATE KEY----- ... -----END RSA PRIV... | securesystemslib/keys.py | def extract_pem(pem, private_pem=False):
"""
<Purpose>
Extract only the portion of the pem that includes the header and footer,
with any leading and trailing characters removed. The string returned has
the following form:
'-----BEGIN PUBLIC KEY----- ... -----END PUBLIC KEY-----'
or
'----... | def extract_pem(pem, private_pem=False):
"""
<Purpose>
Extract only the portion of the pem that includes the header and footer,
with any leading and trailing characters removed. The string returned has
the following form:
'-----BEGIN PUBLIC KEY----- ... -----END PUBLIC KEY-----'
or
'----... | [
"<Purpose",
">",
"Extract",
"only",
"the",
"portion",
"of",
"the",
"pem",
"that",
"includes",
"the",
"header",
"and",
"footer",
"with",
"any",
"leading",
"and",
"trailing",
"characters",
"removed",
".",
"The",
"string",
"returned",
"has",
"the",
"following",
... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1170-L1254 | [
"def",
"extract_pem",
"(",
"pem",
",",
"private_pem",
"=",
"False",
")",
":",
"if",
"private_pem",
":",
"pem_header",
"=",
"'-----BEGIN RSA PRIVATE KEY-----'",
"pem_footer",
"=",
"'-----END RSA PRIVATE KEY-----'",
"else",
":",
"pem_header",
"=",
"'-----BEGIN PUBLIC KEY-... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | encrypt_key | <Purpose>
Return a string containing 'key_object' in encrypted form. Encrypted
strings may be safely saved to a file. The corresponding decrypt_key()
function can be applied to the encrypted string to restore the original key
object. 'key_object' is a key (e.g., RSAKEY_SCHEMA, ED25519KEY_SCHEMA).
... | securesystemslib/keys.py | def encrypt_key(key_object, password):
"""
<Purpose>
Return a string containing 'key_object' in encrypted form. Encrypted
strings may be safely saved to a file. The corresponding decrypt_key()
function can be applied to the encrypted string to restore the original key
object. 'key_object' is a key... | def encrypt_key(key_object, password):
"""
<Purpose>
Return a string containing 'key_object' in encrypted form. Encrypted
strings may be safely saved to a file. The corresponding decrypt_key()
function can be applied to the encrypted string to restore the original key
object. 'key_object' is a key... | [
"<Purpose",
">",
"Return",
"a",
"string",
"containing",
"key_object",
"in",
"encrypted",
"form",
".",
"Encrypted",
"strings",
"may",
"be",
"safely",
"saved",
"to",
"a",
"file",
".",
"The",
"corresponding",
"decrypt_key",
"()",
"function",
"can",
"be",
"applied... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1260-L1326 | [
"def",
"encrypt_key",
"(",
"key_object",
",",
"password",
")",
":",
"# Does 'key_object' have the correct format?",
"# This check will ensure 'key_object' has the appropriate number",
"# of objects and object types, and that all dict keys are properly named.",
"# Raise 'securesystemslib.except... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | decrypt_key | <Purpose>
Return a string containing 'encrypted_key' in non-encrypted form. The
decrypt_key() function can be applied to the encrypted string to restore
the original key object, a key (e.g., RSAKEY_SCHEMA, ED25519KEY_SCHEMA).
This function calls pyca_crypto_keys.py to perform the actual decryption.
... | securesystemslib/keys.py | def decrypt_key(encrypted_key, passphrase):
"""
<Purpose>
Return a string containing 'encrypted_key' in non-encrypted form. The
decrypt_key() function can be applied to the encrypted string to restore
the original key object, a key (e.g., RSAKEY_SCHEMA, ED25519KEY_SCHEMA).
This function calls pyca_... | def decrypt_key(encrypted_key, passphrase):
"""
<Purpose>
Return a string containing 'encrypted_key' in non-encrypted form. The
decrypt_key() function can be applied to the encrypted string to restore
the original key object, a key (e.g., RSAKEY_SCHEMA, ED25519KEY_SCHEMA).
This function calls pyca_... | [
"<Purpose",
">",
"Return",
"a",
"string",
"containing",
"encrypted_key",
"in",
"non",
"-",
"encrypted",
"form",
".",
"The",
"decrypt_key",
"()",
"function",
"can",
"be",
"applied",
"to",
"the",
"encrypted",
"string",
"to",
"restore",
"the",
"original",
"key",
... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1332-L1407 | [
"def",
"decrypt_key",
"(",
"encrypted_key",
",",
"passphrase",
")",
":",
"# Does 'encrypted_key' have the correct format?",
"# This check ensures 'encrypted_key' has the appropriate number",
"# of objects and object types, and that all dict keys are properly named.",
"# Raise 'securesystemslib... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | create_rsa_encrypted_pem | <Purpose>
Return a string in PEM format (TraditionalOpenSSL), where the private part
of the RSA key is encrypted using the best available encryption for a given
key's backend. This is a curated (by cryptography.io) encryption choice and
the algorithm may change over time.
c.f. cryptography.io/en/la... | securesystemslib/keys.py | def create_rsa_encrypted_pem(private_key, passphrase):
"""
<Purpose>
Return a string in PEM format (TraditionalOpenSSL), where the private part
of the RSA key is encrypted using the best available encryption for a given
key's backend. This is a curated (by cryptography.io) encryption choice and
the ... | def create_rsa_encrypted_pem(private_key, passphrase):
"""
<Purpose>
Return a string in PEM format (TraditionalOpenSSL), where the private part
of the RSA key is encrypted using the best available encryption for a given
key's backend. This is a curated (by cryptography.io) encryption choice and
the ... | [
"<Purpose",
">",
"Return",
"a",
"string",
"in",
"PEM",
"format",
"(",
"TraditionalOpenSSL",
")",
"where",
"the",
"private",
"part",
"of",
"the",
"RSA",
"key",
"is",
"encrypted",
"using",
"the",
"best",
"available",
"encryption",
"for",
"a",
"given",
"key",
... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1413-L1474 | [
"def",
"create_rsa_encrypted_pem",
"(",
"private_key",
",",
"passphrase",
")",
":",
"# Does 'private_key' have the correct format?",
"# This check will ensure 'private_key' has the appropriate number",
"# of objects and object types, and that all dict keys are properly named.",
"# Raise 'secur... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | is_pem_public | <Purpose>
Checks if a passed PEM formatted string is a PUBLIC key, by looking for the
following pattern:
'-----BEGIN PUBLIC KEY----- ... -----END PUBLIC KEY-----'
>>> rsa_key = generate_rsa_key()
>>> public = rsa_key['keyval']['public']
>>> private = rsa_key['keyval']['private']
>>> is_pem... | securesystemslib/keys.py | def is_pem_public(pem):
"""
<Purpose>
Checks if a passed PEM formatted string is a PUBLIC key, by looking for the
following pattern:
'-----BEGIN PUBLIC KEY----- ... -----END PUBLIC KEY-----'
>>> rsa_key = generate_rsa_key()
>>> public = rsa_key['keyval']['public']
>>> private = rsa_key['ke... | def is_pem_public(pem):
"""
<Purpose>
Checks if a passed PEM formatted string is a PUBLIC key, by looking for the
following pattern:
'-----BEGIN PUBLIC KEY----- ... -----END PUBLIC KEY-----'
>>> rsa_key = generate_rsa_key()
>>> public = rsa_key['keyval']['public']
>>> private = rsa_key['ke... | [
"<Purpose",
">",
"Checks",
"if",
"a",
"passed",
"PEM",
"formatted",
"string",
"is",
"a",
"PUBLIC",
"key",
"by",
"looking",
"for",
"the",
"following",
"pattern",
":"
] | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1479-L1525 | [
"def",
"is_pem_public",
"(",
"pem",
")",
":",
"# Do the arguments have the correct format?",
"# This check will ensure arguments have the appropriate number",
"# of objects and object types, and that all dict keys are properly named.",
"# Raise 'securesystemslib.exceptions.FormatError' if the chec... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | is_pem_private | <Purpose>
Checks if a passed PEM formatted string is a PRIVATE key, by looking for
the following patterns:
'-----BEGIN RSA PRIVATE KEY----- ... -----END RSA PRIVATE KEY-----'
'-----BEGIN EC PRIVATE KEY----- ... -----END EC PRIVATE KEY-----'
>>> rsa_key = generate_rsa_key()
>>> private = rsa_ke... | securesystemslib/keys.py | def is_pem_private(pem, keytype='rsa'):
"""
<Purpose>
Checks if a passed PEM formatted string is a PRIVATE key, by looking for
the following patterns:
'-----BEGIN RSA PRIVATE KEY----- ... -----END RSA PRIVATE KEY-----'
'-----BEGIN EC PRIVATE KEY----- ... -----END EC PRIVATE KEY-----'
>>> rsa_k... | def is_pem_private(pem, keytype='rsa'):
"""
<Purpose>
Checks if a passed PEM formatted string is a PRIVATE key, by looking for
the following patterns:
'-----BEGIN RSA PRIVATE KEY----- ... -----END RSA PRIVATE KEY-----'
'-----BEGIN EC PRIVATE KEY----- ... -----END EC PRIVATE KEY-----'
>>> rsa_k... | [
"<Purpose",
">",
"Checks",
"if",
"a",
"passed",
"PEM",
"formatted",
"string",
"is",
"a",
"PRIVATE",
"key",
"by",
"looking",
"for",
"the",
"following",
"patterns",
":"
] | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1530-L1588 | [
"def",
"is_pem_private",
"(",
"pem",
",",
"keytype",
"=",
"'rsa'",
")",
":",
"# Do the arguments have the correct format?",
"# This check will ensure arguments have the appropriate number",
"# of objects and object types, and that all dict keys are properly named.",
"# Raise 'securesystems... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | import_ecdsakey_from_private_pem | <Purpose>
Import the private ECDSA key stored in 'pem', and generate its public key
(which will also be included in the returned ECDSA key object). In addition,
a keyid identifier for the ECDSA key is generated. The object returned
conforms to:
{'keytype': 'ecdsa-sha2-nistp256',
'scheme': 'e... | securesystemslib/keys.py | def import_ecdsakey_from_private_pem(pem, scheme='ecdsa-sha2-nistp256', password=None):
"""
<Purpose>
Import the private ECDSA key stored in 'pem', and generate its public key
(which will also be included in the returned ECDSA key object). In addition,
a keyid identifier for the ECDSA key is generated.... | def import_ecdsakey_from_private_pem(pem, scheme='ecdsa-sha2-nistp256', password=None):
"""
<Purpose>
Import the private ECDSA key stored in 'pem', and generate its public key
(which will also be included in the returned ECDSA key object). In addition,
a keyid identifier for the ECDSA key is generated.... | [
"<Purpose",
">",
"Import",
"the",
"private",
"ECDSA",
"key",
"stored",
"in",
"pem",
"and",
"generate",
"its",
"public",
"key",
"(",
"which",
"will",
"also",
"be",
"included",
"in",
"the",
"returned",
"ECDSA",
"key",
"object",
")",
".",
"In",
"addition",
... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1637-L1735 | [
"def",
"import_ecdsakey_from_private_pem",
"(",
"pem",
",",
"scheme",
"=",
"'ecdsa-sha2-nistp256'",
",",
"password",
"=",
"None",
")",
":",
"# Does 'pem' have the correct format?",
"# This check will ensure 'pem' conforms to",
"# 'securesystemslib.formats.ECDSARSA_SCHEMA'.",
"secur... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | import_ecdsakey_from_public_pem | <Purpose>
Generate an ECDSA key object from 'pem'. In addition, a keyid identifier
for the ECDSA key is generated. The object returned conforms to
'securesystemslib.formats.ECDSAKEY_SCHEMA' and has the form:
{'keytype': 'ecdsa-sha2-nistp256',
'scheme': 'ecdsa-sha2-nistp256',
'keyid': keyid,... | securesystemslib/keys.py | def import_ecdsakey_from_public_pem(pem, scheme='ecdsa-sha2-nistp256'):
"""
<Purpose>
Generate an ECDSA key object from 'pem'. In addition, a keyid identifier
for the ECDSA key is generated. The object returned conforms to
'securesystemslib.formats.ECDSAKEY_SCHEMA' and has the form:
{'keytype': '... | def import_ecdsakey_from_public_pem(pem, scheme='ecdsa-sha2-nistp256'):
"""
<Purpose>
Generate an ECDSA key object from 'pem'. In addition, a keyid identifier
for the ECDSA key is generated. The object returned conforms to
'securesystemslib.formats.ECDSAKEY_SCHEMA' and has the form:
{'keytype': '... | [
"<Purpose",
">",
"Generate",
"an",
"ECDSA",
"key",
"object",
"from",
"pem",
".",
"In",
"addition",
"a",
"keyid",
"identifier",
"for",
"the",
"ECDSA",
"key",
"is",
"generated",
".",
"The",
"object",
"returned",
"conforms",
"to",
"securesystemslib",
".",
"form... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1741-L1830 | [
"def",
"import_ecdsakey_from_public_pem",
"(",
"pem",
",",
"scheme",
"=",
"'ecdsa-sha2-nistp256'",
")",
":",
"# Does 'pem' have the correct format?",
"# This check will ensure arguments has the appropriate number",
"# of objects and object types, and that all dict keys are properly named.",
... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | import_ecdsakey_from_pem | <Purpose>
Import either a public or private ECDSA PEM. In contrast to the other
explicit import functions (import_ecdsakey_from_public_pem and
import_ecdsakey_from_private_pem), this function is useful for when it is
not known whether 'pem' is private or public.
<Arguments>
pem:
A string i... | securesystemslib/keys.py | def import_ecdsakey_from_pem(pem, scheme='ecdsa-sha2-nistp256'):
"""
<Purpose>
Import either a public or private ECDSA PEM. In contrast to the other
explicit import functions (import_ecdsakey_from_public_pem and
import_ecdsakey_from_private_pem), this function is useful for when it is
not known whe... | def import_ecdsakey_from_pem(pem, scheme='ecdsa-sha2-nistp256'):
"""
<Purpose>
Import either a public or private ECDSA PEM. In contrast to the other
explicit import functions (import_ecdsakey_from_public_pem and
import_ecdsakey_from_private_pem), this function is useful for when it is
not known whe... | [
"<Purpose",
">",
"Import",
"either",
"a",
"public",
"or",
"private",
"ECDSA",
"PEM",
".",
"In",
"contrast",
"to",
"the",
"other",
"explicit",
"import",
"functions",
"(",
"import_ecdsakey_from_public_pem",
"and",
"import_ecdsakey_from_private_pem",
")",
"this",
"func... | secure-systems-lab/securesystemslib | python | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1836-L1908 | [
"def",
"import_ecdsakey_from_pem",
"(",
"pem",
",",
"scheme",
"=",
"'ecdsa-sha2-nistp256'",
")",
":",
"# Does 'pem' have the correct format?",
"# This check will ensure arguments has the appropriate number",
"# of objects and object types, and that all dict keys are properly named.",
"# Ra... | beb3109d5bb462e5a60eed88fb40ed1167bd354e |
train | Builder.parse_func_body | If success, return a tuple (args, body) | luaparser/builder.py | def parse_func_body(self):
"""If success, return a tuple (args, body)"""
self.save()
self._expected = []
if self.next_is_rc(Tokens.OPAR, False): # do not render right hidden
self.handle_hidden_right() # render hidden after new level
args = self.parse_param_list(... | def parse_func_body(self):
"""If success, return a tuple (args, body)"""
self.save()
self._expected = []
if self.next_is_rc(Tokens.OPAR, False): # do not render right hidden
self.handle_hidden_right() # render hidden after new level
args = self.parse_param_list(... | [
"If",
"success",
"return",
"a",
"tuple",
"(",
"args",
"body",
")"
] | boolangery/py-lua-parser | python | https://github.com/boolangery/py-lua-parser/blob/578f2bf75f6f84c4b52c2affba56a4ec569d7ce7/luaparser/builder.py#L793-L815 | [
"def",
"parse_func_body",
"(",
"self",
")",
":",
"self",
".",
"save",
"(",
")",
"self",
".",
"_expected",
"=",
"[",
"]",
"if",
"self",
".",
"next_is_rc",
"(",
"Tokens",
".",
"OPAR",
",",
"False",
")",
":",
"# do not render right hidden",
"self",
".",
"... | 578f2bf75f6f84c4b52c2affba56a4ec569d7ce7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.