repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
Tristramg/mumoro | virtualenv.py | install_python | 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)
... | python | 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",
")",
":",
"if",
"sys",
".",
"executable",
".",
"startswith",
"(",
"bin_dir",
")",
":",
"print",
"'Please use the *system* python to run ... | Install just the base environment, no distutils patches etc | [
"Install",
"just",
"the",
"base",
"environment",
"no",
"distutils",
"patches",
"etc"
] | e37d6ddb72fd23fb485c80fd8a5cda520ca08187 | https://github.com/Tristramg/mumoro/blob/e37d6ddb72fd23fb485c80fd8a5cda520ca08187/virtualenv.py#L654-L857 | train |
Tristramg/mumoro | virtualenv.py | fix_lib64 | 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... | python | 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",
")",
":",
"if",
"[",
"p",
"for",
"p",
"in",
"distutils",
".",
"sysconfig",
".",
"get_config_vars",
"(",
")",
".",
"values",
"(",
")",
"if",
"isinstance",
"(",
"p",
",",
"basestring",
")",
"and",
"'lib64'",
"in",
"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 create a
symlink so lib64 points to lib | [
"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... | e37d6ddb72fd23fb485c80fd8a5cda520ca08187 | https://github.com/Tristramg/mumoro/blob/e37d6ddb72fd23fb485c80fd8a5cda520ca08187/virtualenv.py#L885-L899 | train |
Tristramg/mumoro | virtualenv.py | resolve_interpreter | 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)):
... | python | 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",
"os",
".",
"path",
".",
"abspath",
"(",
"exe",
")",
"!=",
"exe",
":",
"paths",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'PATH'",
",",
"''",
")",
".",
"split",
"(",
"os",
".",
"pathsep"... | If the executable given isn't an absolute path, search $PATH for the interpreter | [
"If",
"the",
"executable",
"given",
"isn",
"t",
"an",
"absolute",
"path",
"search",
"$PATH",
"for",
"the",
"interpreter"
] | e37d6ddb72fd23fb485c80fd8a5cda520ca08187 | https://github.com/Tristramg/mumoro/blob/e37d6ddb72fd23fb485c80fd8a5cda520ca08187/virtualenv.py#L901-L914 | train |
Tristramg/mumoro | virtualenv.py | make_environment_relocatable | 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... | python | 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",
")",
":",
"activate_this",
"=",
"os",
".",
"path",
".",
"join",
"(",
"home_dir",
",",
"'bin'",
",",
"'activate_this.py'",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"activate_this",
")",
... | Makes the already-existing environment use relative paths, and takes out
the #!-based environment selection in scripts. | [
"Makes",
"the",
"already",
"-",
"existing",
"environment",
"use",
"relative",
"paths",
"and",
"takes",
"out",
"the",
"#!",
"-",
"based",
"environment",
"selection",
"in",
"scripts",
"."
] | e37d6ddb72fd23fb485c80fd8a5cda520ca08187 | https://github.com/Tristramg/mumoro/blob/e37d6ddb72fd23fb485c80fd8a5cda520ca08187/virtualenv.py#L919-L930 | train |
secure-systems-lab/securesystemslib | securesystemslib/keys.py | generate_rsa_key | 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... | python | 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'",
")",
":",
"# Does 'bits' have the correct format? This check will ensure 'bits'",
"# conforms to 'securesystemslib.formats.RSAKEYBITS_SCHEMA'. 'bits' must be",
"# an integer... | <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':... | [
"<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",... | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L127-L230 | train |
secure-systems-lab/securesystemslib | securesystemslib/keys.py | generate_ecdsa_key | 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... | python | 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'",
")",
":",
"# 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 ... | <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... | [
"<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... | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L236-L315 | train |
secure-systems-lab/securesystemslib | securesystemslib/keys.py | generate_ed25519_key | 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... | python | 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'",
")",
":",
"# Are the arguments properly formatted? If not, raise an",
"# 'securesystemslib.exceptions.FormatError' exceptions.",
"securesystemslib",
".",
"formats",
".",
"ED25519_SIG_SCHEMA",
".",
"check_match",
"(",
... | <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... | [
"<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",... | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L321-L394 | train |
secure-systems-lab/securesystemslib | securesystemslib/keys.py | format_keyval_to_metadata | 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... | python | 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",
")",
":",
"# Does 'keytype' have the correct format?",
"# This check will ensure 'keytype' has the appropriate number",
"# of objects and object types, and that all dict... | <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' ... | [
"<Purpose",
">",
"Return",
"a",
"dictionary",
"conformant",
"to",
"securesystemslib",
".",
"formats",
".",
"KEY_SCHEMA",
".",
"If",
"private",
"is",
"True",
"include",
"the",
"private",
"key",
".",
"The",
"dictionary",
"returned",
"has",
"the",
"form",
":"
] | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L400-L490 | train |
secure-systems-lab/securesystemslib | securesystemslib/keys.py | format_metadata_to_key | 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... | python | 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",
")",
":",
"# 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... | <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... | [
"<Purpose",
">",
"Construct",
"a",
"key",
"dictionary",
"(",
"e",
".",
"g",
".",
"securesystemslib",
".",
"formats",
".",
"RSAKEY_SCHEMA",
")",
"according",
"to",
"the",
"keytype",
"of",
"key_metadata",
".",
"The",
"dict",
"returned",
"by",
"this",
"function... | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L496-L582 | train |
secure-systems-lab/securesystemslib | securesystemslib/keys.py | _get_keyid | 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... | python | 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'",
")",
":",
"# '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... | Return the keyid of 'key_value'. | [
"Return",
"the",
"keyid",
"of",
"key_value",
"."
] | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L586-L606 | train |
secure-systems-lab/securesystemslib | securesystemslib/keys.py | create_signature | 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... | python | 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",
")",
":",
"# 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.... | <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:
'... | [
"<Purpose",
">",
"Return",
"a",
"signature",
"dictionary",
"of",
"the",
"form",
":",
"{",
"keyid",
":",
"f30a0870d026980100c0573bd557394f8c1bbd6",
"...",
"sig",
":",
"...",
"}",
"."
] | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L612-L738 | train |
secure-systems-lab/securesystemslib | securesystemslib/keys.py | verify_signature | 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.
>>... | python | 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",
")",
":",
"# 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... | <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... | [
"<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",... | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L744-L882 | train |
secure-systems-lab/securesystemslib | securesystemslib/keys.py | import_rsakey_from_private_pem | 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... | python | 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",
")",
":",
"# Does 'pem' have the correct format?",
"# This check will ensure 'pem' conforms to",
"# 'securesystemslib.formats.PEMRSA_SCHEMA'.",
"securesyste... | <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:
{... | [
"<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... | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L888-L991 | train |
secure-systems-lab/securesystemslib | securesystemslib/keys.py | import_rsakey_from_public_pem | 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',
... | python | 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'",
")",
":",
"# 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.",
"#... | <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----- ...',... | [
"<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"... | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L997-L1081 | train |
secure-systems-lab/securesystemslib | securesystemslib/keys.py | extract_pem | 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
'----... | python | 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",
")",
":",
"if",
"private_pem",
":",
"pem_header",
"=",
"'-----BEGIN RSA PRIVATE KEY-----'",
"pem_footer",
"=",
"'-----END RSA PRIVATE KEY-----'",
"else",
":",
"pem_header",
"=",
"'-----BEGIN PUBLIC KEY-... | <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... | [
"<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",
... | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1170-L1254 | train |
secure-systems-lab/securesystemslib | securesystemslib/keys.py | encrypt_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... | python | 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",
")",
":",
"# 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... | <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).
... | [
"<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... | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1260-L1326 | train |
secure-systems-lab/securesystemslib | securesystemslib/keys.py | decrypt_key | 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_... | python | 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",
")",
":",
"# 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... | <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.
... | [
"<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",
... | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1332-L1407 | train |
secure-systems-lab/securesystemslib | securesystemslib/keys.py | create_rsa_encrypted_pem | 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 ... | python | 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",
")",
":",
"# 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... | <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... | [
"<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",
... | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1413-L1474 | train |
secure-systems-lab/securesystemslib | securesystemslib/keys.py | is_pem_public | 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... | python | 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",
")",
":",
"# 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... | <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... | [
"<Purpose",
">",
"Checks",
"if",
"a",
"passed",
"PEM",
"formatted",
"string",
"is",
"a",
"PUBLIC",
"key",
"by",
"looking",
"for",
"the",
"following",
"pattern",
":"
] | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1479-L1525 | train |
secure-systems-lab/securesystemslib | securesystemslib/keys.py | is_pem_private | 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... | python | 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'",
")",
":",
"# 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... | <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... | [
"<Purpose",
">",
"Checks",
"if",
"a",
"passed",
"PEM",
"formatted",
"string",
"is",
"a",
"PRIVATE",
"key",
"by",
"looking",
"for",
"the",
"following",
"patterns",
":"
] | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1530-L1588 | train |
secure-systems-lab/securesystemslib | securesystemslib/keys.py | import_ecdsakey_from_private_pem | 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.... | python | 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",
")",
":",
"# Does 'pem' have the correct format?",
"# This check will ensure 'pem' conforms to",
"# 'securesystemslib.formats.ECDSARSA_SCHEMA'.",
"secur... | <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... | [
"<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",
... | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1637-L1735 | train |
secure-systems-lab/securesystemslib | securesystemslib/keys.py | import_ecdsakey_from_public_pem | 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': '... | python | 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'",
")",
":",
"# 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.",
... | <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,... | [
"<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... | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1741-L1830 | train |
secure-systems-lab/securesystemslib | securesystemslib/keys.py | import_ecdsakey_from_pem | 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... | python | 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'",
")",
":",
"# 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... | <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... | [
"<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... | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1836-L1908 | train |
boolangery/py-lua-parser | luaparser/builder.py | Builder.parse_func_body | 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(... | python | 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",
")",
":",
"self",
".",
"save",
"(",
")",
"self",
".",
"_expected",
"=",
"[",
"]",
"if",
"self",
".",
"next_is_rc",
"(",
"Tokens",
".",
"OPAR",
",",
"False",
")",
":",
"# do not render right hidden",
"self",
".",
"... | If success, return a tuple (args, body) | [
"If",
"success",
"return",
"a",
"tuple",
"(",
"args",
"body",
")"
] | 578f2bf75f6f84c4b52c2affba56a4ec569d7ce7 | https://github.com/boolangery/py-lua-parser/blob/578f2bf75f6f84c4b52c2affba56a4ec569d7ce7/luaparser/builder.py#L793-L815 | train |
HEPData/hepdata-converter | hepdata_converter/common.py | GetConcreteSubclassMixin.get_concrete_class | def get_concrete_class(cls, class_name):
"""This method provides easier access to all writers inheriting Writer class
:param class_name: name of the parser (name of the parser class which should be used)
:type class_name: str
:return: Writer subclass specified by parser_name
:rt... | python | def get_concrete_class(cls, class_name):
"""This method provides easier access to all writers inheriting Writer class
:param class_name: name of the parser (name of the parser class which should be used)
:type class_name: str
:return: Writer subclass specified by parser_name
:rt... | [
"def",
"get_concrete_class",
"(",
"cls",
",",
"class_name",
")",
":",
"def",
"recurrent_class_lookup",
"(",
"cls",
")",
":",
"for",
"cls",
"in",
"cls",
".",
"__subclasses__",
"(",
")",
":",
"if",
"lower",
"(",
"cls",
".",
"__name__",
")",
"==",
"lower",
... | This method provides easier access to all writers inheriting Writer class
:param class_name: name of the parser (name of the parser class which should be used)
:type class_name: str
:return: Writer subclass specified by parser_name
:rtype: Writer subclass
:raise ValueError: | [
"This",
"method",
"provides",
"easier",
"access",
"to",
"all",
"writers",
"inheriting",
"Writer",
"class"
] | 354271448980efba86f2f3d27b99d818e75fd90d | https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/common.py#L92-L115 | train |
indranilsinharoy/pyzos | pyzos/zos_obj_override/ilensdataeditor_methods.py | GetPupil | def GetPupil(self):
"""Retrieve pupil data
"""
pupil_data = _co.namedtuple('pupil_data', ['ZemaxApertureType',
'ApertureValue',
'entrancePupilDiameter',
'entrancePupil... | python | def GetPupil(self):
"""Retrieve pupil data
"""
pupil_data = _co.namedtuple('pupil_data', ['ZemaxApertureType',
'ApertureValue',
'entrancePupilDiameter',
'entrancePupil... | [
"def",
"GetPupil",
"(",
"self",
")",
":",
"pupil_data",
"=",
"_co",
".",
"namedtuple",
"(",
"'pupil_data'",
",",
"[",
"'ZemaxApertureType'",
",",
"'ApertureValue'",
",",
"'entrancePupilDiameter'",
",",
"'entrancePupilPosition'",
",",
"'exitPupilDiameter'",
",",
"'ex... | Retrieve pupil data | [
"Retrieve",
"pupil",
"data"
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos_obj_override/ilensdataeditor_methods.py#L21-L33 | train |
NetworkEng/fping.py | fping/fping.py | FastPing.ping | def ping(self, targets=list(), filename=str(), status=str()):
"""
Attempt to ping a list of hosts or networks (can be a single host)
:param targets: List - Name(s) or IP(s) of the host(s).
:param filename: String - name of the file containing hosts to ping
:param status: String -... | python | def ping(self, targets=list(), filename=str(), status=str()):
"""
Attempt to ping a list of hosts or networks (can be a single host)
:param targets: List - Name(s) or IP(s) of the host(s).
:param filename: String - name of the file containing hosts to ping
:param status: String -... | [
"def",
"ping",
"(",
"self",
",",
"targets",
"=",
"list",
"(",
")",
",",
"filename",
"=",
"str",
"(",
")",
",",
"status",
"=",
"str",
"(",
")",
")",
":",
"if",
"targets",
"and",
"filename",
":",
"raise",
"SyntaxError",
"(",
"\"You must specify only one ... | Attempt to ping a list of hosts or networks (can be a single host)
:param targets: List - Name(s) or IP(s) of the host(s).
:param filename: String - name of the file containing hosts to ping
:param status: String - if one of ['alive', 'dead', 'noip'] then only
return results that have th... | [
"Attempt",
"to",
"ping",
"a",
"list",
"of",
"hosts",
"or",
"networks",
"(",
"can",
"be",
"a",
"single",
"host",
")",
":",
"param",
"targets",
":",
"List",
"-",
"Name",
"(",
"s",
")",
"or",
"IP",
"(",
"s",
")",
"of",
"the",
"host",
"(",
"s",
")"... | 991507889561aa6eb9ee2ad821adf460883a9c5d | https://github.com/NetworkEng/fping.py/blob/991507889561aa6eb9ee2ad821adf460883a9c5d/fping/fping.py#L63-L196 | train |
NetworkEng/fping.py | fping/fping.py | FastPing.get_results | def get_results(cmd):
"""
def get_results(cmd: list) -> str:
return lines
Get the ping results using fping.
:param cmd: List - the fping command and its options
:return: String - raw string output containing csv fping results
including the newline characters
... | python | def get_results(cmd):
"""
def get_results(cmd: list) -> str:
return lines
Get the ping results using fping.
:param cmd: List - the fping command and its options
:return: String - raw string output containing csv fping results
including the newline characters
... | [
"def",
"get_results",
"(",
"cmd",
")",
":",
"try",
":",
"return",
"subprocess",
".",
"check_output",
"(",
"cmd",
")",
"except",
"subprocess",
".",
"CalledProcessError",
"as",
"e",
":",
"return",
"e",
".",
"output"
] | def get_results(cmd: list) -> str:
return lines
Get the ping results using fping.
:param cmd: List - the fping command and its options
:return: String - raw string output containing csv fping results
including the newline characters | [
"def",
"get_results",
"(",
"cmd",
":",
"list",
")",
"-",
">",
"str",
":",
"return",
"lines",
"Get",
"the",
"ping",
"results",
"using",
"fping",
".",
":",
"param",
"cmd",
":",
"List",
"-",
"the",
"fping",
"command",
"and",
"its",
"options",
":",
"retu... | 991507889561aa6eb9ee2ad821adf460883a9c5d | https://github.com/NetworkEng/fping.py/blob/991507889561aa6eb9ee2ad821adf460883a9c5d/fping/fping.py#L199-L211 | train |
NetworkEng/fping.py | fping/fping.py | FastPing.read_file | def read_file(filename):
"""
Reads the lines of a file into a list, and returns the list
:param filename: String - path and name of the file
:return: List - lines within the file
"""
lines = []
with open(filename) as f:
for line in f:
i... | python | def read_file(filename):
"""
Reads the lines of a file into a list, and returns the list
:param filename: String - path and name of the file
:return: List - lines within the file
"""
lines = []
with open(filename) as f:
for line in f:
i... | [
"def",
"read_file",
"(",
"filename",
")",
":",
"lines",
"=",
"[",
"]",
"with",
"open",
"(",
"filename",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"if",
"len",
"(",
"line",
".",
"strip",
"(",
")",
")",
"!=",
"0",
":",
"lines",
".",
"... | Reads the lines of a file into a list, and returns the list
:param filename: String - path and name of the file
:return: List - lines within the file | [
"Reads",
"the",
"lines",
"of",
"a",
"file",
"into",
"a",
"list",
"and",
"returns",
"the",
"list",
":",
"param",
"filename",
":",
"String",
"-",
"path",
"and",
"name",
"of",
"the",
"file",
":",
"return",
":",
"List",
"-",
"lines",
"within",
"the",
"fi... | 991507889561aa6eb9ee2ad821adf460883a9c5d | https://github.com/NetworkEng/fping.py/blob/991507889561aa6eb9ee2ad821adf460883a9c5d/fping/fping.py#L214-L225 | train |
HEPData/hepdata-converter | hepdata_converter/writers/root_writer.py | ROOT._prepare_outputs | def _prepare_outputs(self, data_out, outputs):
""" Open a ROOT file with option 'RECREATE' to create a new file (the file will
be overwritten if it already exists), and using the ZLIB compression algorithm
(with compression level 1) for better compatibility with older ROOT versions
(see ... | python | def _prepare_outputs(self, data_out, outputs):
""" Open a ROOT file with option 'RECREATE' to create a new file (the file will
be overwritten if it already exists), and using the ZLIB compression algorithm
(with compression level 1) for better compatibility with older ROOT versions
(see ... | [
"def",
"_prepare_outputs",
"(",
"self",
",",
"data_out",
",",
"outputs",
")",
":",
"compress",
"=",
"ROOTModule",
".",
"ROOT",
".",
"CompressionSettings",
"(",
"ROOTModule",
".",
"ROOT",
".",
"kZLIB",
",",
"1",
")",
"if",
"isinstance",
"(",
"data_out",
","... | Open a ROOT file with option 'RECREATE' to create a new file (the file will
be overwritten if it already exists), and using the ZLIB compression algorithm
(with compression level 1) for better compatibility with older ROOT versions
(see https://root.cern.ch/doc/v614/release-notes.html#important-... | [
"Open",
"a",
"ROOT",
"file",
"with",
"option",
"RECREATE",
"to",
"create",
"a",
"new",
"file",
"(",
"the",
"file",
"will",
"be",
"overwritten",
"if",
"it",
"already",
"exists",
")",
"and",
"using",
"the",
"ZLIB",
"compression",
"algorithm",
"(",
"with",
... | 354271448980efba86f2f3d27b99d818e75fd90d | https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/writers/root_writer.py#L405-L425 | train |
HEPData/hepdata-converter | hepdata_converter/writers/root_writer.py | ROOT.write | def write(self, data_in, data_out, *args, **kwargs):
"""
:param data_in:
:type data_in: hepconverter.parsers.ParsedData
:param data_out: filelike object
:type data_out: file
:param args:
:param kwargs:
"""
self._get_tables(data_in)
self.fi... | python | def write(self, data_in, data_out, *args, **kwargs):
"""
:param data_in:
:type data_in: hepconverter.parsers.ParsedData
:param data_out: filelike object
:type data_out: file
:param args:
:param kwargs:
"""
self._get_tables(data_in)
self.fi... | [
"def",
"write",
"(",
"self",
",",
"data_in",
",",
"data_out",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_get_tables",
"(",
"data_in",
")",
"self",
".",
"file_emulation",
"=",
"False",
"outputs",
"=",
"[",
"]",
"self",
".",
... | :param data_in:
:type data_in: hepconverter.parsers.ParsedData
:param data_out: filelike object
:type data_out: file
:param args:
:param kwargs: | [
":",
"param",
"data_in",
":",
":",
"type",
"data_in",
":",
"hepconverter",
".",
"parsers",
".",
"ParsedData",
":",
"param",
"data_out",
":",
"filelike",
"object",
":",
"type",
"data_out",
":",
"file",
":",
"param",
"args",
":",
":",
"param",
"kwargs",
":... | 354271448980efba86f2f3d27b99d818e75fd90d | https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/writers/root_writer.py#L427-L457 | train |
SciTools/biggus | biggus/_init.py | _pairwise | def _pairwise(iterable):
"""
itertools recipe
"s -> (s0,s1), (s1,s2), (s2, s3), ...
"""
a, b = itertools.tee(iterable)
next(b, None)
return zip(a, b) | python | def _pairwise(iterable):
"""
itertools recipe
"s -> (s0,s1), (s1,s2), (s2, s3), ...
"""
a, b = itertools.tee(iterable)
next(b, None)
return zip(a, b) | [
"def",
"_pairwise",
"(",
"iterable",
")",
":",
"a",
",",
"b",
"=",
"itertools",
".",
"tee",
"(",
"iterable",
")",
"next",
"(",
"b",
",",
"None",
")",
"return",
"zip",
"(",
"a",
",",
"b",
")"
] | itertools recipe
"s -> (s0,s1), (s1,s2), (s2, s3), ... | [
"itertools",
"recipe",
"s",
"-",
">",
"(",
"s0",
"s1",
")",
"(",
"s1",
"s2",
")",
"(",
"s2",
"s3",
")",
"..."
] | 0a76fbe7806dd6295081cd399bcb76135d834d25 | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L1577-L1585 | train |
SciTools/biggus | biggus/_init.py | _groups_of | def _groups_of(length, total_length):
"""
Return an iterator of tuples for slicing, in 'length' chunks.
Parameters
----------
length : int
Length of each chunk.
total_length : int
Length of the object we are slicing
Returns
-------
iterable of tuples
Values ... | python | def _groups_of(length, total_length):
"""
Return an iterator of tuples for slicing, in 'length' chunks.
Parameters
----------
length : int
Length of each chunk.
total_length : int
Length of the object we are slicing
Returns
-------
iterable of tuples
Values ... | [
"def",
"_groups_of",
"(",
"length",
",",
"total_length",
")",
":",
"indices",
"=",
"tuple",
"(",
"range",
"(",
"0",
",",
"total_length",
",",
"length",
")",
")",
"+",
"(",
"None",
",",
")",
"return",
"_pairwise",
"(",
"indices",
")"
] | Return an iterator of tuples for slicing, in 'length' chunks.
Parameters
----------
length : int
Length of each chunk.
total_length : int
Length of the object we are slicing
Returns
-------
iterable of tuples
Values defining a slice range resulting in length 'length... | [
"Return",
"an",
"iterator",
"of",
"tuples",
"for",
"slicing",
"in",
"length",
"chunks",
"."
] | 0a76fbe7806dd6295081cd399bcb76135d834d25 | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L1588-L1606 | train |
SciTools/biggus | biggus/_init.py | save | def save(sources, targets, masked=False):
"""
Save the numeric results of each source into its corresponding target.
Parameters
----------
sources: list
The list of source arrays for saving from; limited to length 1.
targets: list
The list of target arrays for saving to; limited... | python | def save(sources, targets, masked=False):
"""
Save the numeric results of each source into its corresponding target.
Parameters
----------
sources: list
The list of source arrays for saving from; limited to length 1.
targets: list
The list of target arrays for saving to; limited... | [
"def",
"save",
"(",
"sources",
",",
"targets",
",",
"masked",
"=",
"False",
")",
":",
"# TODO: Remove restriction",
"assert",
"len",
"(",
"sources",
")",
"==",
"1",
"and",
"len",
"(",
"targets",
")",
"==",
"1",
"array",
"=",
"sources",
"[",
"0",
"]",
... | Save the numeric results of each source into its corresponding target.
Parameters
----------
sources: list
The list of source arrays for saving from; limited to length 1.
targets: list
The list of target arrays for saving to; limited to length 1.
masked: boolean
Uses a maske... | [
"Save",
"the",
"numeric",
"results",
"of",
"each",
"source",
"into",
"its",
"corresponding",
"target",
"."
] | 0a76fbe7806dd6295081cd399bcb76135d834d25 | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L2163-L2196 | train |
SciTools/biggus | biggus/_init.py | count | def count(a, axis=None):
"""
Count the non-masked elements of the array along the given axis.
.. note:: Currently limited to operating on a single axis.
:param axis: Axis or axes along which the operation is performed.
The default (axis=None) is to perform the operation
... | python | def count(a, axis=None):
"""
Count the non-masked elements of the array along the given axis.
.. note:: Currently limited to operating on a single axis.
:param axis: Axis or axes along which the operation is performed.
The default (axis=None) is to perform the operation
... | [
"def",
"count",
"(",
"a",
",",
"axis",
"=",
"None",
")",
":",
"axes",
"=",
"_normalise_axis",
"(",
"axis",
",",
"a",
")",
"if",
"axes",
"is",
"None",
"or",
"len",
"(",
"axes",
")",
"!=",
"1",
":",
"msg",
"=",
"\"This operation is currently limited to a... | Count the non-masked elements of the array along the given axis.
.. note:: Currently limited to operating on a single axis.
:param axis: Axis or axes along which the operation is performed.
The default (axis=None) is to perform the operation
over all the dimensions of the inp... | [
"Count",
"the",
"non",
"-",
"masked",
"elements",
"of",
"the",
"array",
"along",
"the",
"given",
"axis",
"."
] | 0a76fbe7806dd6295081cd399bcb76135d834d25 | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L2700-L2724 | train |
SciTools/biggus | biggus/_init.py | min | def min(a, axis=None):
"""
Request the minimum of an Array over any number of axes.
.. note:: Currently limited to operating on a single axis.
Parameters
----------
a : Array object
The object whose minimum is to be found.
axis : None, or int, or iterable of ints
Axis or ax... | python | def min(a, axis=None):
"""
Request the minimum of an Array over any number of axes.
.. note:: Currently limited to operating on a single axis.
Parameters
----------
a : Array object
The object whose minimum is to be found.
axis : None, or int, or iterable of ints
Axis or ax... | [
"def",
"min",
"(",
"a",
",",
"axis",
"=",
"None",
")",
":",
"axes",
"=",
"_normalise_axis",
"(",
"axis",
",",
"a",
")",
"assert",
"axes",
"is",
"not",
"None",
"and",
"len",
"(",
"axes",
")",
"==",
"1",
"return",
"_Aggregation",
"(",
"a",
",",
"ax... | Request the minimum of an Array over any number of axes.
.. note:: Currently limited to operating on a single axis.
Parameters
----------
a : Array object
The object whose minimum is to be found.
axis : None, or int, or iterable of ints
Axis or axes along which the operation is per... | [
"Request",
"the",
"minimum",
"of",
"an",
"Array",
"over",
"any",
"number",
"of",
"axes",
"."
] | 0a76fbe7806dd6295081cd399bcb76135d834d25 | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L2728-L2754 | train |
SciTools/biggus | biggus/_init.py | max | def max(a, axis=None):
"""
Request the maximum of an Array over any number of axes.
.. note:: Currently limited to operating on a single axis.
Parameters
----------
a : Array object
The object whose maximum is to be found.
axis : None, or int, or iterable of ints
Axis or ax... | python | def max(a, axis=None):
"""
Request the maximum of an Array over any number of axes.
.. note:: Currently limited to operating on a single axis.
Parameters
----------
a : Array object
The object whose maximum is to be found.
axis : None, or int, or iterable of ints
Axis or ax... | [
"def",
"max",
"(",
"a",
",",
"axis",
"=",
"None",
")",
":",
"axes",
"=",
"_normalise_axis",
"(",
"axis",
",",
"a",
")",
"assert",
"axes",
"is",
"not",
"None",
"and",
"len",
"(",
"axes",
")",
"==",
"1",
"return",
"_Aggregation",
"(",
"a",
",",
"ax... | Request the maximum of an Array over any number of axes.
.. note:: Currently limited to operating on a single axis.
Parameters
----------
a : Array object
The object whose maximum is to be found.
axis : None, or int, or iterable of ints
Axis or axes along which the operation is per... | [
"Request",
"the",
"maximum",
"of",
"an",
"Array",
"over",
"any",
"number",
"of",
"axes",
"."
] | 0a76fbe7806dd6295081cd399bcb76135d834d25 | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L2758-L2784 | train |
SciTools/biggus | biggus/_init.py | sum | def sum(a, axis=None):
"""
Request the sum of an Array over any number of axes.
.. note:: Currently limited to operating on a single axis.
Parameters
----------
a : Array object
The object whose summation is to be found.
axis : None, or int, or iterable of ints
Axis or axes... | python | def sum(a, axis=None):
"""
Request the sum of an Array over any number of axes.
.. note:: Currently limited to operating on a single axis.
Parameters
----------
a : Array object
The object whose summation is to be found.
axis : None, or int, or iterable of ints
Axis or axes... | [
"def",
"sum",
"(",
"a",
",",
"axis",
"=",
"None",
")",
":",
"axes",
"=",
"_normalise_axis",
"(",
"axis",
",",
"a",
")",
"assert",
"axes",
"is",
"not",
"None",
"and",
"len",
"(",
"axes",
")",
"==",
"1",
"return",
"_Aggregation",
"(",
"a",
",",
"ax... | Request the sum of an Array over any number of axes.
.. note:: Currently limited to operating on a single axis.
Parameters
----------
a : Array object
The object whose summation is to be found.
axis : None, or int, or iterable of ints
Axis or axes along which the operation is perfo... | [
"Request",
"the",
"sum",
"of",
"an",
"Array",
"over",
"any",
"number",
"of",
"axes",
"."
] | 0a76fbe7806dd6295081cd399bcb76135d834d25 | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L2788-L2814 | train |
SciTools/biggus | biggus/_init.py | mean | def mean(a, axis=None, mdtol=1):
"""
Request the mean of an Array over any number of axes.
.. note:: Currently limited to operating on a single axis.
:param axis: Axis or axes along which the operation is performed.
The default (axis=None) is to perform the operation
... | python | def mean(a, axis=None, mdtol=1):
"""
Request the mean of an Array over any number of axes.
.. note:: Currently limited to operating on a single axis.
:param axis: Axis or axes along which the operation is performed.
The default (axis=None) is to perform the operation
... | [
"def",
"mean",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"mdtol",
"=",
"1",
")",
":",
"axes",
"=",
"_normalise_axis",
"(",
"axis",
",",
"a",
")",
"if",
"axes",
"is",
"None",
"or",
"len",
"(",
"axes",
")",
"!=",
"1",
":",
"msg",
"=",
"\"This oper... | Request the mean of an Array over any number of axes.
.. note:: Currently limited to operating on a single axis.
:param axis: Axis or axes along which the operation is performed.
The default (axis=None) is to perform the operation
over all the dimensions of the input array.
... | [
"Request",
"the",
"mean",
"of",
"an",
"Array",
"over",
"any",
"number",
"of",
"axes",
"."
] | 0a76fbe7806dd6295081cd399bcb76135d834d25 | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L2818-L2852 | train |
SciTools/biggus | biggus/_init.py | std | def std(a, axis=None, ddof=0):
"""
Request the standard deviation of an Array over any number of axes.
.. note:: Currently limited to operating on a single axis.
:param axis: Axis or axes along which the operation is performed.
The default (axis=None) is to perform the operation
... | python | def std(a, axis=None, ddof=0):
"""
Request the standard deviation of an Array over any number of axes.
.. note:: Currently limited to operating on a single axis.
:param axis: Axis or axes along which the operation is performed.
The default (axis=None) is to perform the operation
... | [
"def",
"std",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"ddof",
"=",
"0",
")",
":",
"axes",
"=",
"_normalise_axis",
"(",
"axis",
",",
"a",
")",
"if",
"axes",
"is",
"None",
"or",
"len",
"(",
"axes",
")",
"!=",
"1",
":",
"msg",
"=",
"\"This operat... | Request the standard deviation of an Array over any number of axes.
.. note:: Currently limited to operating on a single axis.
:param axis: Axis or axes along which the operation is performed.
The default (axis=None) is to perform the operation
over all the dimensions of the ... | [
"Request",
"the",
"standard",
"deviation",
"of",
"an",
"Array",
"over",
"any",
"number",
"of",
"axes",
"."
] | 0a76fbe7806dd6295081cd399bcb76135d834d25 | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L2856-L2884 | train |
SciTools/biggus | biggus/_init.py | var | def var(a, axis=None, ddof=0):
"""
Request the variance of an Array over any number of axes.
.. note:: Currently limited to operating on a single axis.
:param axis: Axis or axes along which the operation is performed.
The default (axis=None) is to perform the operation
... | python | def var(a, axis=None, ddof=0):
"""
Request the variance of an Array over any number of axes.
.. note:: Currently limited to operating on a single axis.
:param axis: Axis or axes along which the operation is performed.
The default (axis=None) is to perform the operation
... | [
"def",
"var",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"ddof",
"=",
"0",
")",
":",
"axes",
"=",
"_normalise_axis",
"(",
"axis",
",",
"a",
")",
"if",
"axes",
"is",
"None",
"or",
"len",
"(",
"axes",
")",
"!=",
"1",
":",
"msg",
"=",
"\"This operat... | Request the variance of an Array over any number of axes.
.. note:: Currently limited to operating on a single axis.
:param axis: Axis or axes along which the operation is performed.
The default (axis=None) is to perform the operation
over all the dimensions of the input arra... | [
"Request",
"the",
"variance",
"of",
"an",
"Array",
"over",
"any",
"number",
"of",
"axes",
"."
] | 0a76fbe7806dd6295081cd399bcb76135d834d25 | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L2888-L2916 | train |
SciTools/biggus | biggus/_init.py | _ufunc_wrapper | def _ufunc_wrapper(ufunc, name=None):
"""
A function to generate the top level biggus ufunc wrappers.
"""
if not isinstance(ufunc, np.ufunc):
raise TypeError('{} is not a ufunc'.format(ufunc))
ufunc_name = ufunc.__name__
# Get hold of the masked array equivalent, if it exists.
ma_u... | python | def _ufunc_wrapper(ufunc, name=None):
"""
A function to generate the top level biggus ufunc wrappers.
"""
if not isinstance(ufunc, np.ufunc):
raise TypeError('{} is not a ufunc'.format(ufunc))
ufunc_name = ufunc.__name__
# Get hold of the masked array equivalent, if it exists.
ma_u... | [
"def",
"_ufunc_wrapper",
"(",
"ufunc",
",",
"name",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"ufunc",
",",
"np",
".",
"ufunc",
")",
":",
"raise",
"TypeError",
"(",
"'{} is not a ufunc'",
".",
"format",
"(",
"ufunc",
")",
")",
"ufunc_name",
... | A function to generate the top level biggus ufunc wrappers. | [
"A",
"function",
"to",
"generate",
"the",
"top",
"level",
"biggus",
"ufunc",
"wrappers",
"."
] | 0a76fbe7806dd6295081cd399bcb76135d834d25 | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L3081-L3102 | train |
SciTools/biggus | biggus/_init.py | _sliced_shape | def _sliced_shape(shape, keys):
"""
Returns the shape that results from slicing an array of the given
shape by the given keys.
>>> _sliced_shape(shape=(52350, 70, 90, 180),
... keys=(np.newaxis, slice(None, 10), 3,
... slice(None), slice(2, 3)))
(1, 10, 90,... | python | def _sliced_shape(shape, keys):
"""
Returns the shape that results from slicing an array of the given
shape by the given keys.
>>> _sliced_shape(shape=(52350, 70, 90, 180),
... keys=(np.newaxis, slice(None, 10), 3,
... slice(None), slice(2, 3)))
(1, 10, 90,... | [
"def",
"_sliced_shape",
"(",
"shape",
",",
"keys",
")",
":",
"keys",
"=",
"_full_keys",
"(",
"keys",
",",
"len",
"(",
"shape",
")",
")",
"sliced_shape",
"=",
"[",
"]",
"shape_dim",
"=",
"-",
"1",
"for",
"key",
"in",
"keys",
":",
"shape_dim",
"+=",
... | Returns the shape that results from slicing an array of the given
shape by the given keys.
>>> _sliced_shape(shape=(52350, 70, 90, 180),
... keys=(np.newaxis, slice(None, 10), 3,
... slice(None), slice(2, 3)))
(1, 10, 90, 1) | [
"Returns",
"the",
"shape",
"that",
"results",
"from",
"slicing",
"an",
"array",
"of",
"the",
"given",
"shape",
"by",
"the",
"given",
"keys",
"."
] | 0a76fbe7806dd6295081cd399bcb76135d834d25 | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L3198-L3232 | train |
SciTools/biggus | biggus/_init.py | _full_keys | def _full_keys(keys, ndim):
"""
Given keys such as those passed to ``__getitem__`` for an
array of ndim, return a fully expanded tuple of keys.
In all instances, the result of this operation should follow:
array[keys] == array[_full_keys(keys, array.ndim)]
"""
if not isinstance(keys, ... | python | def _full_keys(keys, ndim):
"""
Given keys such as those passed to ``__getitem__`` for an
array of ndim, return a fully expanded tuple of keys.
In all instances, the result of this operation should follow:
array[keys] == array[_full_keys(keys, array.ndim)]
"""
if not isinstance(keys, ... | [
"def",
"_full_keys",
"(",
"keys",
",",
"ndim",
")",
":",
"if",
"not",
"isinstance",
"(",
"keys",
",",
"tuple",
")",
":",
"keys",
"=",
"(",
"keys",
",",
")",
"# Make keys mutable, and take a copy.",
"keys",
"=",
"list",
"(",
"keys",
")",
"# Count the number... | Given keys such as those passed to ``__getitem__`` for an
array of ndim, return a fully expanded tuple of keys.
In all instances, the result of this operation should follow:
array[keys] == array[_full_keys(keys, array.ndim)] | [
"Given",
"keys",
"such",
"as",
"those",
"passed",
"to",
"__getitem__",
"for",
"an",
"array",
"of",
"ndim",
"return",
"a",
"fully",
"expanded",
"tuple",
"of",
"keys",
"."
] | 0a76fbe7806dd6295081cd399bcb76135d834d25 | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L3235-L3285 | train |
SciTools/biggus | biggus/_init.py | ensure_array | def ensure_array(array):
"""
Assert that the given array is an Array subclass (or numpy array).
If the given array is a numpy.ndarray an appropriate NumpyArrayAdapter
instance is created, otherwise the passed array must be a subclass of
:class:`Array` else a TypeError will be raised.
"""
i... | python | def ensure_array(array):
"""
Assert that the given array is an Array subclass (or numpy array).
If the given array is a numpy.ndarray an appropriate NumpyArrayAdapter
instance is created, otherwise the passed array must be a subclass of
:class:`Array` else a TypeError will be raised.
"""
i... | [
"def",
"ensure_array",
"(",
"array",
")",
":",
"if",
"not",
"isinstance",
"(",
"array",
",",
"Array",
")",
":",
"if",
"isinstance",
"(",
"array",
",",
"np",
".",
"ndarray",
")",
":",
"array",
"=",
"NumpyArrayAdapter",
"(",
"array",
")",
"elif",
"np",
... | Assert that the given array is an Array subclass (or numpy array).
If the given array is a numpy.ndarray an appropriate NumpyArrayAdapter
instance is created, otherwise the passed array must be a subclass of
:class:`Array` else a TypeError will be raised. | [
"Assert",
"that",
"the",
"given",
"array",
"is",
"an",
"Array",
"subclass",
"(",
"or",
"numpy",
"array",
")",
"."
] | 0a76fbe7806dd6295081cd399bcb76135d834d25 | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L3289-L3306 | train |
SciTools/biggus | biggus/_init.py | size | def size(array):
"""
Return a human-readable description of the number of bytes required
to store the data of the given array.
For example::
>>> array.nbytes
14000000
>> biggus.size(array)
'13.35 MiB'
Parameters
----------
array : array-like object
... | python | def size(array):
"""
Return a human-readable description of the number of bytes required
to store the data of the given array.
For example::
>>> array.nbytes
14000000
>> biggus.size(array)
'13.35 MiB'
Parameters
----------
array : array-like object
... | [
"def",
"size",
"(",
"array",
")",
":",
"nbytes",
"=",
"array",
".",
"nbytes",
"if",
"nbytes",
"<",
"(",
"1",
"<<",
"10",
")",
":",
"size",
"=",
"'{} B'",
".",
"format",
"(",
"nbytes",
")",
"elif",
"nbytes",
"<",
"(",
"1",
"<<",
"20",
")",
":",
... | Return a human-readable description of the number of bytes required
to store the data of the given array.
For example::
>>> array.nbytes
14000000
>> biggus.size(array)
'13.35 MiB'
Parameters
----------
array : array-like object
The array object must provide... | [
"Return",
"a",
"human",
"-",
"readable",
"description",
"of",
"the",
"number",
"of",
"bytes",
"required",
"to",
"store",
"the",
"data",
"of",
"the",
"given",
"array",
"."
] | 0a76fbe7806dd6295081cd399bcb76135d834d25 | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L3310-L3344 | train |
SciTools/biggus | biggus/_init.py | Node.output | def output(self, chunk):
"""
Dispatch the given Chunk onto all the registered output queues.
If the chunk is None, it is silently ignored.
"""
if chunk is not None:
for queue in self.output_queues:
queue.put(chunk) | python | def output(self, chunk):
"""
Dispatch the given Chunk onto all the registered output queues.
If the chunk is None, it is silently ignored.
"""
if chunk is not None:
for queue in self.output_queues:
queue.put(chunk) | [
"def",
"output",
"(",
"self",
",",
"chunk",
")",
":",
"if",
"chunk",
"is",
"not",
"None",
":",
"for",
"queue",
"in",
"self",
".",
"output_queues",
":",
"queue",
".",
"put",
"(",
"chunk",
")"
] | Dispatch the given Chunk onto all the registered output queues.
If the chunk is None, it is silently ignored. | [
"Dispatch",
"the",
"given",
"Chunk",
"onto",
"all",
"the",
"registered",
"output",
"queues",
"."
] | 0a76fbe7806dd6295081cd399bcb76135d834d25 | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L115-L124 | train |
SciTools/biggus | biggus/_init.py | ProducerNode.run | def run(self):
"""
Emit the Chunk instances which cover the underlying Array.
The Array is divided into chunks with a size limit of
MAX_CHUNK_SIZE which are emitted into all registered output
queues.
"""
try:
chunk_index = self.chunk_index_gen(self.a... | python | def run(self):
"""
Emit the Chunk instances which cover the underlying Array.
The Array is divided into chunks with a size limit of
MAX_CHUNK_SIZE which are emitted into all registered output
queues.
"""
try:
chunk_index = self.chunk_index_gen(self.a... | [
"def",
"run",
"(",
"self",
")",
":",
"try",
":",
"chunk_index",
"=",
"self",
".",
"chunk_index_gen",
"(",
"self",
".",
"array",
".",
"shape",
",",
"self",
".",
"iteration_order",
")",
"for",
"key",
"in",
"chunk_index",
":",
"# Now we have the slices that des... | Emit the Chunk instances which cover the underlying Array.
The Array is divided into chunks with a size limit of
MAX_CHUNK_SIZE which are emitted into all registered output
queues. | [
"Emit",
"the",
"Chunk",
"instances",
"which",
"cover",
"the",
"underlying",
"Array",
"."
] | 0a76fbe7806dd6295081cd399bcb76135d834d25 | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L175-L204 | train |
SciTools/biggus | biggus/_init.py | ConsumerNode.add_input_nodes | def add_input_nodes(self, input_nodes):
"""
Set the given nodes as inputs for this node.
Creates a limited-size queue.Queue for each input node and
registers each queue as an output of its corresponding node.
"""
self.input_queues = [queue.Queue(maxsize=3) for _ in inpu... | python | def add_input_nodes(self, input_nodes):
"""
Set the given nodes as inputs for this node.
Creates a limited-size queue.Queue for each input node and
registers each queue as an output of its corresponding node.
"""
self.input_queues = [queue.Queue(maxsize=3) for _ in inpu... | [
"def",
"add_input_nodes",
"(",
"self",
",",
"input_nodes",
")",
":",
"self",
".",
"input_queues",
"=",
"[",
"queue",
".",
"Queue",
"(",
"maxsize",
"=",
"3",
")",
"for",
"_",
"in",
"input_nodes",
"]",
"for",
"input_node",
",",
"input_queue",
"in",
"zip",
... | Set the given nodes as inputs for this node.
Creates a limited-size queue.Queue for each input node and
registers each queue as an output of its corresponding node. | [
"Set",
"the",
"given",
"nodes",
"as",
"inputs",
"for",
"this",
"node",
"."
] | 0a76fbe7806dd6295081cd399bcb76135d834d25 | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L222-L232 | train |
SciTools/biggus | biggus/_init.py | ConsumerNode.run | def run(self):
"""
Process the input queues in lock-step, and push any results to
the registered output queues.
"""
try:
while True:
input_chunks = [input.get() for input in self.input_queues]
for input in self.input_queues:
... | python | def run(self):
"""
Process the input queues in lock-step, and push any results to
the registered output queues.
"""
try:
while True:
input_chunks = [input.get() for input in self.input_queues]
for input in self.input_queues:
... | [
"def",
"run",
"(",
"self",
")",
":",
"try",
":",
"while",
"True",
":",
"input_chunks",
"=",
"[",
"input",
".",
"get",
"(",
")",
"for",
"input",
"in",
"self",
".",
"input_queues",
"]",
"for",
"input",
"in",
"self",
".",
"input_queues",
":",
"input",
... | Process the input queues in lock-step, and push any results to
the registered output queues. | [
"Process",
"the",
"input",
"queues",
"in",
"lock",
"-",
"step",
"and",
"push",
"any",
"results",
"to",
"the",
"registered",
"output",
"queues",
"."
] | 0a76fbe7806dd6295081cd399bcb76135d834d25 | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L253-L278 | train |
SciTools/biggus | biggus/_init.py | NdarrayNode.process_chunks | def process_chunks(self, chunks):
"""
Store the incoming chunk at the corresponding position in the
result array.
"""
chunk, = chunks
if chunk.keys:
self.result[chunk.keys] = chunk.data
else:
self.result[...] = chunk.data | python | def process_chunks(self, chunks):
"""
Store the incoming chunk at the corresponding position in the
result array.
"""
chunk, = chunks
if chunk.keys:
self.result[chunk.keys] = chunk.data
else:
self.result[...] = chunk.data | [
"def",
"process_chunks",
"(",
"self",
",",
"chunks",
")",
":",
"chunk",
",",
"=",
"chunks",
"if",
"chunk",
".",
"keys",
":",
"self",
".",
"result",
"[",
"chunk",
".",
"keys",
"]",
"=",
"chunk",
".",
"data",
"else",
":",
"self",
".",
"result",
"[",
... | Store the incoming chunk at the corresponding position in the
result array. | [
"Store",
"the",
"incoming",
"chunk",
"at",
"the",
"corresponding",
"position",
"in",
"the",
"result",
"array",
"."
] | 0a76fbe7806dd6295081cd399bcb76135d834d25 | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L324-L334 | train |
SciTools/biggus | biggus/_init.py | _ArrayAdapter._cleanup_new_key | def _cleanup_new_key(self, key, size, axis):
"""
Return a key of type int, slice, or tuple that is guaranteed
to be valid for the given dimension size.
Raises IndexError/TypeError for invalid keys.
"""
if _is_scalar(key):
if key >= size or key < -size:
... | python | def _cleanup_new_key(self, key, size, axis):
"""
Return a key of type int, slice, or tuple that is guaranteed
to be valid for the given dimension size.
Raises IndexError/TypeError for invalid keys.
"""
if _is_scalar(key):
if key >= size or key < -size:
... | [
"def",
"_cleanup_new_key",
"(",
"self",
",",
"key",
",",
"size",
",",
"axis",
")",
":",
"if",
"_is_scalar",
"(",
"key",
")",
":",
"if",
"key",
">=",
"size",
"or",
"key",
"<",
"-",
"size",
":",
"msg",
"=",
"'index {0} is out of bounds for axis {1} with'",
... | Return a key of type int, slice, or tuple that is guaranteed
to be valid for the given dimension size.
Raises IndexError/TypeError for invalid keys. | [
"Return",
"a",
"key",
"of",
"type",
"int",
"slice",
"or",
"tuple",
"that",
"is",
"guaranteed",
"to",
"be",
"valid",
"for",
"the",
"given",
"dimension",
"size",
"."
] | 0a76fbe7806dd6295081cd399bcb76135d834d25 | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L1347-L1380 | train |
SciTools/biggus | biggus/_init.py | _ArrayAdapter._remap_new_key | def _remap_new_key(self, indices, new_key, axis):
"""
Return a key of type int, slice, or tuple that represents the
combination of new_key with the given indices.
Raises IndexError/TypeError for invalid keys.
"""
size = len(indices)
if _is_scalar(new_key):
... | python | def _remap_new_key(self, indices, new_key, axis):
"""
Return a key of type int, slice, or tuple that represents the
combination of new_key with the given indices.
Raises IndexError/TypeError for invalid keys.
"""
size = len(indices)
if _is_scalar(new_key):
... | [
"def",
"_remap_new_key",
"(",
"self",
",",
"indices",
",",
"new_key",
",",
"axis",
")",
":",
"size",
"=",
"len",
"(",
"indices",
")",
"if",
"_is_scalar",
"(",
"new_key",
")",
":",
"if",
"new_key",
">=",
"size",
"or",
"new_key",
"<",
"-",
"size",
":",... | Return a key of type int, slice, or tuple that represents the
combination of new_key with the given indices.
Raises IndexError/TypeError for invalid keys. | [
"Return",
"a",
"key",
"of",
"type",
"int",
"slice",
"or",
"tuple",
"that",
"represents",
"the",
"combination",
"of",
"new_key",
"with",
"the",
"given",
"indices",
"."
] | 0a76fbe7806dd6295081cd399bcb76135d834d25 | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L1382-L1421 | train |
SciTools/biggus | biggus/_init.py | TransposedArray._apply_axes_mapping | def _apply_axes_mapping(self, target, inverse=False):
"""
Apply the transposition to the target iterable.
Parameters
----------
target - iterable
The iterable to transpose. This would be suitable for things
such as a shape as well as a list of ``__getitem... | python | def _apply_axes_mapping(self, target, inverse=False):
"""
Apply the transposition to the target iterable.
Parameters
----------
target - iterable
The iterable to transpose. This would be suitable for things
such as a shape as well as a list of ``__getitem... | [
"def",
"_apply_axes_mapping",
"(",
"self",
",",
"target",
",",
"inverse",
"=",
"False",
")",
":",
"if",
"len",
"(",
"target",
")",
"!=",
"self",
".",
"ndim",
":",
"raise",
"ValueError",
"(",
"'The target iterable is of length {}, but '",
"'should be of length {}.'... | Apply the transposition to the target iterable.
Parameters
----------
target - iterable
The iterable to transpose. This would be suitable for things
such as a shape as well as a list of ``__getitem__`` keys.
inverse - bool
Whether to map old dimension... | [
"Apply",
"the",
"transposition",
"to",
"the",
"target",
"iterable",
"."
] | 0a76fbe7806dd6295081cd399bcb76135d834d25 | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L1635-L1667 | train |
SciTools/biggus | biggus/_init.py | _AggregationStreamsHandler.output_keys | def output_keys(self, source_keys):
"""
Given input chunk keys, compute what keys will be needed to put
the result into the result array.
As an example of where this gets used - when we aggregate on a
particular axis, the source keys may be ``(0:2, None:None)``, but for
... | python | def output_keys(self, source_keys):
"""
Given input chunk keys, compute what keys will be needed to put
the result into the result array.
As an example of where this gets used - when we aggregate on a
particular axis, the source keys may be ``(0:2, None:None)``, but for
... | [
"def",
"output_keys",
"(",
"self",
",",
"source_keys",
")",
":",
"keys",
"=",
"list",
"(",
"source_keys",
")",
"# Remove the aggregated axis from the keys.",
"del",
"keys",
"[",
"self",
".",
"axis",
"]",
"return",
"tuple",
"(",
"keys",
")"
] | Given input chunk keys, compute what keys will be needed to put
the result into the result array.
As an example of where this gets used - when we aggregate on a
particular axis, the source keys may be ``(0:2, None:None)``, but for
an aggregation on axis 0, they would result in target va... | [
"Given",
"input",
"chunk",
"keys",
"compute",
"what",
"keys",
"will",
"be",
"needed",
"to",
"put",
"the",
"result",
"into",
"the",
"result",
"array",
"."
] | 0a76fbe7806dd6295081cd399bcb76135d834d25 | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L2254-L2268 | train |
secure-systems-lab/securesystemslib | securesystemslib/_vendor/ed25519/ed25519.py | scalarmult_B | def scalarmult_B(e):
"""
Implements scalarmult(B, e) more efficiently.
"""
# scalarmult(B, l) is the identity
e = e % l
P = ident
for i in range(253):
if e & 1:
P = edwards_add(P, Bpow[i])
e = e // 2
assert e == 0, e
return P | python | def scalarmult_B(e):
"""
Implements scalarmult(B, e) more efficiently.
"""
# scalarmult(B, l) is the identity
e = e % l
P = ident
for i in range(253):
if e & 1:
P = edwards_add(P, Bpow[i])
e = e // 2
assert e == 0, e
return P | [
"def",
"scalarmult_B",
"(",
"e",
")",
":",
"# scalarmult(B, l) is the identity",
"e",
"=",
"e",
"%",
"l",
"P",
"=",
"ident",
"for",
"i",
"in",
"range",
"(",
"253",
")",
":",
"if",
"e",
"&",
"1",
":",
"P",
"=",
"edwards_add",
"(",
"P",
",",
"Bpow",
... | Implements scalarmult(B, e) more efficiently. | [
"Implements",
"scalarmult",
"(",
"B",
"e",
")",
"more",
"efficiently",
"."
] | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/_vendor/ed25519/ed25519.py#L181-L193 | train |
secure-systems-lab/securesystemslib | securesystemslib/_vendor/ed25519/ed25519.py | publickey_unsafe | def publickey_unsafe(sk):
"""
Not safe to use with secret keys or secret data.
See module docstring. This function should be used for testing only.
"""
h = H(sk)
a = 2 ** (b - 2) + sum(2 ** i * bit(h, i) for i in range(3, b - 2))
A = scalarmult_B(a)
return encodepoint(A) | python | def publickey_unsafe(sk):
"""
Not safe to use with secret keys or secret data.
See module docstring. This function should be used for testing only.
"""
h = H(sk)
a = 2 ** (b - 2) + sum(2 ** i * bit(h, i) for i in range(3, b - 2))
A = scalarmult_B(a)
return encodepoint(A) | [
"def",
"publickey_unsafe",
"(",
"sk",
")",
":",
"h",
"=",
"H",
"(",
"sk",
")",
"a",
"=",
"2",
"**",
"(",
"b",
"-",
"2",
")",
"+",
"sum",
"(",
"2",
"**",
"i",
"*",
"bit",
"(",
"h",
",",
"i",
")",
"for",
"i",
"in",
"range",
"(",
"3",
",",... | Not safe to use with secret keys or secret data.
See module docstring. This function should be used for testing only. | [
"Not",
"safe",
"to",
"use",
"with",
"secret",
"keys",
"or",
"secret",
"data",
"."
] | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/_vendor/ed25519/ed25519.py#L220-L229 | train |
secure-systems-lab/securesystemslib | securesystemslib/ed25519_keys.py | generate_public_and_private | def generate_public_and_private():
"""
<Purpose>
Generate a pair of ed25519 public and private keys with PyNaCl. The public
and private keys returned conform to
'securesystemslib.formats.ED25519PULIC_SCHEMA' and
'securesystemslib.formats.ED25519SEED_SCHEMA', respectively, and have the
form:
... | python | def generate_public_and_private():
"""
<Purpose>
Generate a pair of ed25519 public and private keys with PyNaCl. The public
and private keys returned conform to
'securesystemslib.formats.ED25519PULIC_SCHEMA' and
'securesystemslib.formats.ED25519SEED_SCHEMA', respectively, and have the
form:
... | [
"def",
"generate_public_and_private",
"(",
")",
":",
"# Generate ed25519's seed key by calling os.urandom(). The random bytes",
"# returned should be suitable for cryptographic use and is OS-specific.",
"# Raise 'NotImplementedError' if a randomness source is not found.",
"# ed25519 seed keys are f... | <Purpose>
Generate a pair of ed25519 public and private keys with PyNaCl. The public
and private keys returned conform to
'securesystemslib.formats.ED25519PULIC_SCHEMA' and
'securesystemslib.formats.ED25519SEED_SCHEMA', respectively, and have the
form:
'\xa2F\x99\xe0\x86\x80%\xc8\xee\x11\xb95T... | [
"<Purpose",
">",
"Generate",
"a",
"pair",
"of",
"ed25519",
"public",
"and",
"private",
"keys",
"with",
"PyNaCl",
".",
"The",
"public",
"and",
"private",
"keys",
"returned",
"conform",
"to",
"securesystemslib",
".",
"formats",
".",
"ED25519PULIC_SCHEMA",
"and",
... | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/ed25519_keys.py#L119-L177 | train |
secure-systems-lab/securesystemslib | securesystemslib/ed25519_keys.py | create_signature | def create_signature(public_key, private_key, data, scheme):
"""
<Purpose>
Return a (signature, scheme) tuple, where the signature scheme is 'ed25519'
and is always generated by PyNaCl (i.e., 'nacl'). The signature returned
conforms to 'securesystemslib.formats.ED25519SIGNATURE_SCHEMA', and has the
... | python | def create_signature(public_key, private_key, data, scheme):
"""
<Purpose>
Return a (signature, scheme) tuple, where the signature scheme is 'ed25519'
and is always generated by PyNaCl (i.e., 'nacl'). The signature returned
conforms to 'securesystemslib.formats.ED25519SIGNATURE_SCHEMA', and has the
... | [
"def",
"create_signature",
"(",
"public_key",
",",
"private_key",
",",
"data",
",",
"scheme",
")",
":",
"# Does 'public_key' have the correct format?",
"# This check will ensure 'public_key' conforms to",
"# 'securesystemslib.formats.ED25519PUBLIC_SCHEMA', which must have length 32",
"... | <Purpose>
Return a (signature, scheme) tuple, where the signature scheme is 'ed25519'
and is always generated by PyNaCl (i.e., 'nacl'). The signature returned
conforms to 'securesystemslib.formats.ED25519SIGNATURE_SCHEMA', and has the
form:
'\xae\xd7\x9f\xaf\x95{bP\x9e\xa8YO Z\x86\x9d...'
A s... | [
"<Purpose",
">",
"Return",
"a",
"(",
"signature",
"scheme",
")",
"tuple",
"where",
"the",
"signature",
"scheme",
"is",
"ed25519",
"and",
"is",
"always",
"generated",
"by",
"PyNaCl",
"(",
"i",
".",
"e",
".",
"nacl",
")",
".",
"The",
"signature",
"returned... | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/ed25519_keys.py#L183-L283 | train |
secure-systems-lab/securesystemslib | securesystemslib/ed25519_keys.py | verify_signature | def verify_signature(public_key, scheme, signature, data, use_pynacl=False):
"""
<Purpose>
Determine whether the private key corresponding to 'public_key' produced
'signature'. verify_signature() will use the public key, the 'scheme' and
'sig', and 'data' arguments to complete the verification.
>>... | python | def verify_signature(public_key, scheme, signature, data, use_pynacl=False):
"""
<Purpose>
Determine whether the private key corresponding to 'public_key' produced
'signature'. verify_signature() will use the public key, the 'scheme' and
'sig', and 'data' arguments to complete the verification.
>>... | [
"def",
"verify_signature",
"(",
"public_key",
",",
"scheme",
",",
"signature",
",",
"data",
",",
"use_pynacl",
"=",
"False",
")",
":",
"# Does 'public_key' have the correct format?",
"# This check will ensure 'public_key' conforms to",
"# 'securesystemslib.formats.ED25519PUBLIC_S... | <Purpose>
Determine whether the private key corresponding to 'public_key' produced
'signature'. verify_signature() will use the public key, the 'scheme' and
'sig', and 'data' arguments to complete the verification.
>>> public, private = generate_public_and_private()
>>> data = b'The quick brown fo... | [
"<Purpose",
">",
"Determine",
"whether",
"the",
"private",
"key",
"corresponding",
"to",
"public_key",
"produced",
"signature",
".",
"verify_signature",
"()",
"will",
"use",
"the",
"public",
"key",
"the",
"scheme",
"and",
"sig",
"and",
"data",
"arguments",
"to",... | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/ed25519_keys.py#L289-L404 | train |
indranilsinharoy/pyzos | pyzos/zos.py | _delete_file | def _delete_file(fileName, n=10):
"""Cleanly deletes a file in `n` attempts (if necessary)"""
status = False
count = 0
while not status and count < n:
try:
_os.remove(fileName)
except OSError:
count += 1
_time.sleep(0.2)
else:
statu... | python | def _delete_file(fileName, n=10):
"""Cleanly deletes a file in `n` attempts (if necessary)"""
status = False
count = 0
while not status and count < n:
try:
_os.remove(fileName)
except OSError:
count += 1
_time.sleep(0.2)
else:
statu... | [
"def",
"_delete_file",
"(",
"fileName",
",",
"n",
"=",
"10",
")",
":",
"status",
"=",
"False",
"count",
"=",
"0",
"while",
"not",
"status",
"and",
"count",
"<",
"n",
":",
"try",
":",
"_os",
".",
"remove",
"(",
"fileName",
")",
"except",
"OSError",
... | Cleanly deletes a file in `n` attempts (if necessary) | [
"Cleanly",
"deletes",
"a",
"file",
"in",
"n",
"attempts",
"(",
"if",
"necessary",
")"
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L53-L65 | train |
indranilsinharoy/pyzos | pyzos/zos.py | _PyZDDE.zDDEInit | def zDDEInit(self):
"""Initiates link with OpticStudio DDE server"""
self.pyver = _get_python_version()
# do this only one time or when there is no channel
if _PyZDDE.liveCh==0:
try:
_PyZDDE.server = _dde.CreateServer()
_PyZDDE.server.Create("Z... | python | def zDDEInit(self):
"""Initiates link with OpticStudio DDE server"""
self.pyver = _get_python_version()
# do this only one time or when there is no channel
if _PyZDDE.liveCh==0:
try:
_PyZDDE.server = _dde.CreateServer()
_PyZDDE.server.Create("Z... | [
"def",
"zDDEInit",
"(",
"self",
")",
":",
"self",
".",
"pyver",
"=",
"_get_python_version",
"(",
")",
"# do this only one time or when there is no channel",
"if",
"_PyZDDE",
".",
"liveCh",
"==",
"0",
":",
"try",
":",
"_PyZDDE",
".",
"server",
"=",
"_dde",
".",... | Initiates link with OpticStudio DDE server | [
"Initiates",
"link",
"with",
"OpticStudio",
"DDE",
"server"
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L80-L103 | train |
indranilsinharoy/pyzos | pyzos/zos.py | _PyZDDE.zDDEClose | def zDDEClose(self):
"""Close the DDE link with Zemax server"""
if _PyZDDE.server and not _PyZDDE.liveCh:
_PyZDDE.server.Shutdown(self.conversation)
_PyZDDE.server = 0
elif _PyZDDE.server and self.connection and _PyZDDE.liveCh == 1:
_PyZDDE.server.Shutdown(sel... | python | def zDDEClose(self):
"""Close the DDE link with Zemax server"""
if _PyZDDE.server and not _PyZDDE.liveCh:
_PyZDDE.server.Shutdown(self.conversation)
_PyZDDE.server = 0
elif _PyZDDE.server and self.connection and _PyZDDE.liveCh == 1:
_PyZDDE.server.Shutdown(sel... | [
"def",
"zDDEClose",
"(",
"self",
")",
":",
"if",
"_PyZDDE",
".",
"server",
"and",
"not",
"_PyZDDE",
".",
"liveCh",
":",
"_PyZDDE",
".",
"server",
".",
"Shutdown",
"(",
"self",
".",
"conversation",
")",
"_PyZDDE",
".",
"server",
"=",
"0",
"elif",
"_PyZD... | Close the DDE link with Zemax server | [
"Close",
"the",
"DDE",
"link",
"with",
"Zemax",
"server"
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L105-L121 | train |
indranilsinharoy/pyzos | pyzos/zos.py | _PyZDDE.setTimeout | def setTimeout(self, time):
"""Set global timeout value, in seconds, for all DDE calls"""
self.conversation.SetDDETimeout(round(time))
return self.conversation.GetDDETimeout() | python | def setTimeout(self, time):
"""Set global timeout value, in seconds, for all DDE calls"""
self.conversation.SetDDETimeout(round(time))
return self.conversation.GetDDETimeout() | [
"def",
"setTimeout",
"(",
"self",
",",
"time",
")",
":",
"self",
".",
"conversation",
".",
"SetDDETimeout",
"(",
"round",
"(",
"time",
")",
")",
"return",
"self",
".",
"conversation",
".",
"GetDDETimeout",
"(",
")"
] | Set global timeout value, in seconds, for all DDE calls | [
"Set",
"global",
"timeout",
"value",
"in",
"seconds",
"for",
"all",
"DDE",
"calls"
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L123-L126 | train |
indranilsinharoy/pyzos | pyzos/zos.py | _PyZDDE._sendDDEcommand | def _sendDDEcommand(self, cmd, timeout=None):
"""Send command to DDE client"""
reply = self.conversation.Request(cmd, timeout)
if self.pyver > 2:
reply = reply.decode('ascii').rstrip()
return reply | python | def _sendDDEcommand(self, cmd, timeout=None):
"""Send command to DDE client"""
reply = self.conversation.Request(cmd, timeout)
if self.pyver > 2:
reply = reply.decode('ascii').rstrip()
return reply | [
"def",
"_sendDDEcommand",
"(",
"self",
",",
"cmd",
",",
"timeout",
"=",
"None",
")",
":",
"reply",
"=",
"self",
".",
"conversation",
".",
"Request",
"(",
"cmd",
",",
"timeout",
")",
"if",
"self",
".",
"pyver",
">",
"2",
":",
"reply",
"=",
"reply",
... | Send command to DDE client | [
"Send",
"command",
"to",
"DDE",
"client"
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L128-L133 | train |
indranilsinharoy/pyzos | pyzos/zos.py | _PyZDDE.zGetUpdate | def zGetUpdate(self):
"""Update the lens"""
status,ret = -998, None
ret = self._sendDDEcommand("GetUpdate")
if ret != None:
status = int(ret) #Note: Zemax returns -1 if GetUpdate fails.
return status | python | def zGetUpdate(self):
"""Update the lens"""
status,ret = -998, None
ret = self._sendDDEcommand("GetUpdate")
if ret != None:
status = int(ret) #Note: Zemax returns -1 if GetUpdate fails.
return status | [
"def",
"zGetUpdate",
"(",
"self",
")",
":",
"status",
",",
"ret",
"=",
"-",
"998",
",",
"None",
"ret",
"=",
"self",
".",
"_sendDDEcommand",
"(",
"\"GetUpdate\"",
")",
"if",
"ret",
"!=",
"None",
":",
"status",
"=",
"int",
"(",
"ret",
")",
"#Note: Zema... | Update the lens | [
"Update",
"the",
"lens"
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L152-L158 | train |
indranilsinharoy/pyzos | pyzos/zos.py | _PyZDDE.zLoadFile | def zLoadFile(self, fileName, append=None):
"""Loads a zmx file into the DDE server"""
reply = None
if append:
cmd = "LoadFile,{},{}".format(fileName, append)
else:
cmd = "LoadFile,{}".format(fileName)
reply = self._sendDDEcommand(cmd)
if reply:
... | python | def zLoadFile(self, fileName, append=None):
"""Loads a zmx file into the DDE server"""
reply = None
if append:
cmd = "LoadFile,{},{}".format(fileName, append)
else:
cmd = "LoadFile,{}".format(fileName)
reply = self._sendDDEcommand(cmd)
if reply:
... | [
"def",
"zLoadFile",
"(",
"self",
",",
"fileName",
",",
"append",
"=",
"None",
")",
":",
"reply",
"=",
"None",
"if",
"append",
":",
"cmd",
"=",
"\"LoadFile,{},{}\"",
".",
"format",
"(",
"fileName",
",",
"append",
")",
"else",
":",
"cmd",
"=",
"\"LoadFil... | Loads a zmx file into the DDE server | [
"Loads",
"a",
"zmx",
"file",
"into",
"the",
"DDE",
"server"
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L164-L175 | train |
indranilsinharoy/pyzos | pyzos/zos.py | _PyZDDE.zPushLens | def zPushLens(self, update=None, timeout=None):
"""Copy lens in the Zemax DDE server into LDE"""
reply = None
if update == 1:
reply = self._sendDDEcommand('PushLens,1', timeout)
elif update == 0 or update is None:
reply = self._sendDDEcommand('PushLens,0', timeout... | python | def zPushLens(self, update=None, timeout=None):
"""Copy lens in the Zemax DDE server into LDE"""
reply = None
if update == 1:
reply = self._sendDDEcommand('PushLens,1', timeout)
elif update == 0 or update is None:
reply = self._sendDDEcommand('PushLens,0', timeout... | [
"def",
"zPushLens",
"(",
"self",
",",
"update",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"reply",
"=",
"None",
"if",
"update",
"==",
"1",
":",
"reply",
"=",
"self",
".",
"_sendDDEcommand",
"(",
"'PushLens,1'",
",",
"timeout",
")",
"elif",
... | Copy lens in the Zemax DDE server into LDE | [
"Copy",
"lens",
"in",
"the",
"Zemax",
"DDE",
"server",
"into",
"LDE"
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L177-L189 | train |
indranilsinharoy/pyzos | pyzos/zos.py | _PyZDDE.zSaveFile | def zSaveFile(self, fileName):
"""Saves the lens currently loaded in the server to a Zemax file """
cmd = "SaveFile,{}".format(fileName)
reply = self._sendDDEcommand(cmd)
return int(float(reply.rstrip())) | python | def zSaveFile(self, fileName):
"""Saves the lens currently loaded in the server to a Zemax file """
cmd = "SaveFile,{}".format(fileName)
reply = self._sendDDEcommand(cmd)
return int(float(reply.rstrip())) | [
"def",
"zSaveFile",
"(",
"self",
",",
"fileName",
")",
":",
"cmd",
"=",
"\"SaveFile,{}\"",
".",
"format",
"(",
"fileName",
")",
"reply",
"=",
"self",
".",
"_sendDDEcommand",
"(",
"cmd",
")",
"return",
"int",
"(",
"float",
"(",
"reply",
".",
"rstrip",
"... | Saves the lens currently loaded in the server to a Zemax file | [
"Saves",
"the",
"lens",
"currently",
"loaded",
"in",
"the",
"server",
"to",
"a",
"Zemax",
"file"
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L196-L200 | train |
indranilsinharoy/pyzos | pyzos/zos.py | OpticalSystem.zSyncWithUI | def zSyncWithUI(self):
"""Turn on sync-with-ui"""
if not OpticalSystem._dde_link:
OpticalSystem._dde_link = _get_new_dde_link()
if not self._sync_ui_file:
self._sync_ui_file = _get_sync_ui_filename()
self._sync_ui = True | python | def zSyncWithUI(self):
"""Turn on sync-with-ui"""
if not OpticalSystem._dde_link:
OpticalSystem._dde_link = _get_new_dde_link()
if not self._sync_ui_file:
self._sync_ui_file = _get_sync_ui_filename()
self._sync_ui = True | [
"def",
"zSyncWithUI",
"(",
"self",
")",
":",
"if",
"not",
"OpticalSystem",
".",
"_dde_link",
":",
"OpticalSystem",
".",
"_dde_link",
"=",
"_get_new_dde_link",
"(",
")",
"if",
"not",
"self",
".",
"_sync_ui_file",
":",
"self",
".",
"_sync_ui_file",
"=",
"_get_... | Turn on sync-with-ui | [
"Turn",
"on",
"sync",
"-",
"with",
"-",
"ui"
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L323-L329 | train |
indranilsinharoy/pyzos | pyzos/zos.py | OpticalSystem.zPushLens | def zPushLens(self, update=None):
"""Push lens in ZOS COM server to UI"""
self.SaveAs(self._sync_ui_file)
OpticalSystem._dde_link.zLoadFile(self._sync_ui_file)
OpticalSystem._dde_link.zPushLens(update) | python | def zPushLens(self, update=None):
"""Push lens in ZOS COM server to UI"""
self.SaveAs(self._sync_ui_file)
OpticalSystem._dde_link.zLoadFile(self._sync_ui_file)
OpticalSystem._dde_link.zPushLens(update) | [
"def",
"zPushLens",
"(",
"self",
",",
"update",
"=",
"None",
")",
":",
"self",
".",
"SaveAs",
"(",
"self",
".",
"_sync_ui_file",
")",
"OpticalSystem",
".",
"_dde_link",
".",
"zLoadFile",
"(",
"self",
".",
"_sync_ui_file",
")",
"OpticalSystem",
".",
"_dde_l... | Push lens in ZOS COM server to UI | [
"Push",
"lens",
"in",
"ZOS",
"COM",
"server",
"to",
"UI"
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L331-L335 | train |
indranilsinharoy/pyzos | pyzos/zos.py | OpticalSystem.zGetRefresh | def zGetRefresh(self):
"""Copy lens in UI to headless ZOS COM server"""
OpticalSystem._dde_link.zGetRefresh()
OpticalSystem._dde_link.zSaveFile(self._sync_ui_file)
self._iopticalsystem.LoadFile (self._sync_ui_file, False) | python | def zGetRefresh(self):
"""Copy lens in UI to headless ZOS COM server"""
OpticalSystem._dde_link.zGetRefresh()
OpticalSystem._dde_link.zSaveFile(self._sync_ui_file)
self._iopticalsystem.LoadFile (self._sync_ui_file, False) | [
"def",
"zGetRefresh",
"(",
"self",
")",
":",
"OpticalSystem",
".",
"_dde_link",
".",
"zGetRefresh",
"(",
")",
"OpticalSystem",
".",
"_dde_link",
".",
"zSaveFile",
"(",
"self",
".",
"_sync_ui_file",
")",
"self",
".",
"_iopticalsystem",
".",
"LoadFile",
"(",
"... | Copy lens in UI to headless ZOS COM server | [
"Copy",
"lens",
"in",
"UI",
"to",
"headless",
"ZOS",
"COM",
"server"
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L337-L341 | train |
indranilsinharoy/pyzos | pyzos/zos.py | OpticalSystem.SaveAs | def SaveAs(self, filename):
"""Saves the current system to the specified file.
@param filename: absolute path (string)
@return: None
@raise: ValueError if path (excluding the zemax file name) is not valid
All future calls to `Save()` will use the same file.
"""
... | python | def SaveAs(self, filename):
"""Saves the current system to the specified file.
@param filename: absolute path (string)
@return: None
@raise: ValueError if path (excluding the zemax file name) is not valid
All future calls to `Save()` will use the same file.
"""
... | [
"def",
"SaveAs",
"(",
"self",
",",
"filename",
")",
":",
"directory",
",",
"zfile",
"=",
"_os",
".",
"path",
".",
"split",
"(",
"filename",
")",
"if",
"zfile",
".",
"startswith",
"(",
"'pyzos_ui_sync_file'",
")",
":",
"self",
".",
"_iopticalsystem",
".",... | Saves the current system to the specified file.
@param filename: absolute path (string)
@return: None
@raise: ValueError if path (excluding the zemax file name) is not valid
All future calls to `Save()` will use the same file. | [
"Saves",
"the",
"current",
"system",
"to",
"the",
"specified",
"file",
"."
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L344-L361 | train |
indranilsinharoy/pyzos | pyzos/zos.py | OpticalSystem.Save | def Save(self):
"""Saves the current system"""
# This method is intercepted to allow ui_sync
if self._file_to_save_on_Save:
self._iopticalsystem.SaveAs(self._file_to_save_on_Save)
else:
self._iopticalsystem.Save() | python | def Save(self):
"""Saves the current system"""
# This method is intercepted to allow ui_sync
if self._file_to_save_on_Save:
self._iopticalsystem.SaveAs(self._file_to_save_on_Save)
else:
self._iopticalsystem.Save() | [
"def",
"Save",
"(",
"self",
")",
":",
"# This method is intercepted to allow ui_sync",
"if",
"self",
".",
"_file_to_save_on_Save",
":",
"self",
".",
"_iopticalsystem",
".",
"SaveAs",
"(",
"self",
".",
"_file_to_save_on_Save",
")",
"else",
":",
"self",
".",
"_iopti... | Saves the current system | [
"Saves",
"the",
"current",
"system"
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L363-L369 | train |
indranilsinharoy/pyzos | pyzos/zos.py | OpticalSystem.zGetSurfaceData | def zGetSurfaceData(self, surfNum):
"""Return surface data"""
if self.pMode == 0: # Sequential mode
surf_data = _co.namedtuple('surface_data', ['radius', 'thick', 'material', 'semidia',
'conic', 'comment'])
surf = self.pLDE... | python | def zGetSurfaceData(self, surfNum):
"""Return surface data"""
if self.pMode == 0: # Sequential mode
surf_data = _co.namedtuple('surface_data', ['radius', 'thick', 'material', 'semidia',
'conic', 'comment'])
surf = self.pLDE... | [
"def",
"zGetSurfaceData",
"(",
"self",
",",
"surfNum",
")",
":",
"if",
"self",
".",
"pMode",
"==",
"0",
":",
"# Sequential mode",
"surf_data",
"=",
"_co",
".",
"namedtuple",
"(",
"'surface_data'",
",",
"[",
"'radius'",
",",
"'thick'",
",",
"'material'",
",... | Return surface data | [
"Return",
"surface",
"data"
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L378-L387 | train |
indranilsinharoy/pyzos | pyzos/zos.py | OpticalSystem.zSetSurfaceData | def zSetSurfaceData(self, surfNum, radius=None, thick=None, material=None, semidia=None,
conic=None, comment=None):
"""Sets surface data"""
if self.pMode == 0: # Sequential mode
surf = self.pLDE.GetSurfaceAt(surfNum)
if radius is not None:
... | python | def zSetSurfaceData(self, surfNum, radius=None, thick=None, material=None, semidia=None,
conic=None, comment=None):
"""Sets surface data"""
if self.pMode == 0: # Sequential mode
surf = self.pLDE.GetSurfaceAt(surfNum)
if radius is not None:
... | [
"def",
"zSetSurfaceData",
"(",
"self",
",",
"surfNum",
",",
"radius",
"=",
"None",
",",
"thick",
"=",
"None",
",",
"material",
"=",
"None",
",",
"semidia",
"=",
"None",
",",
"conic",
"=",
"None",
",",
"comment",
"=",
"None",
")",
":",
"if",
"self",
... | Sets surface data | [
"Sets",
"surface",
"data"
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L396-L414 | train |
indranilsinharoy/pyzos | pyzos/zos.py | OpticalSystem.zSetDefaultMeritFunctionSEQ | def zSetDefaultMeritFunctionSEQ(self, ofType=0, ofData=0, ofRef=0, pupilInteg=0, rings=0,
arms=0, obscuration=0, grid=0, delVignetted=False, useGlass=False,
glassMin=0, glassMax=1000, glassEdge=0, useAir=False, airMin=0,
... | python | def zSetDefaultMeritFunctionSEQ(self, ofType=0, ofData=0, ofRef=0, pupilInteg=0, rings=0,
arms=0, obscuration=0, grid=0, delVignetted=False, useGlass=False,
glassMin=0, glassMax=1000, glassEdge=0, useAir=False, airMin=0,
... | [
"def",
"zSetDefaultMeritFunctionSEQ",
"(",
"self",
",",
"ofType",
"=",
"0",
",",
"ofData",
"=",
"0",
",",
"ofRef",
"=",
"0",
",",
"pupilInteg",
"=",
"0",
",",
"rings",
"=",
"0",
",",
"arms",
"=",
"0",
",",
"obscuration",
"=",
"0",
",",
"grid",
"=",... | Sets the default merit function for Sequential Merit Function Editor
Parameters
----------
ofType : integer
optimization function type (0=RMS, ...)
ofData : integer
optimization function data (0=Wavefront, 1=Spot Radius, ...)
ofRef : integer
... | [
"Sets",
"the",
"default",
"merit",
"function",
"for",
"Sequential",
"Merit",
"Function",
"Editor"
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L416-L499 | train |
secure-systems-lab/securesystemslib | securesystemslib/formats.py | datetime_to_unix_timestamp | def datetime_to_unix_timestamp(datetime_object):
"""
<Purpose>
Convert 'datetime_object' (in datetime.datetime()) format) to a Unix/POSIX
timestamp. For example, Python's time.time() returns a Unix timestamp, and
includes the number of microseconds. 'datetime_object' is converted to UTC.
>>> date... | python | def datetime_to_unix_timestamp(datetime_object):
"""
<Purpose>
Convert 'datetime_object' (in datetime.datetime()) format) to a Unix/POSIX
timestamp. For example, Python's time.time() returns a Unix timestamp, and
includes the number of microseconds. 'datetime_object' is converted to UTC.
>>> date... | [
"def",
"datetime_to_unix_timestamp",
"(",
"datetime_object",
")",
":",
"# Is 'datetime_object' a datetime.datetime() object?",
"# Raise 'securesystemslib.exceptions.FormatError' if not.",
"if",
"not",
"isinstance",
"(",
"datetime_object",
",",
"datetime",
".",
"datetime",
")",
":... | <Purpose>
Convert 'datetime_object' (in datetime.datetime()) format) to a Unix/POSIX
timestamp. For example, Python's time.time() returns a Unix timestamp, and
includes the number of microseconds. 'datetime_object' is converted to UTC.
>>> datetime_object = datetime.datetime(1985, 10, 26, 1, 22)
... | [
"<Purpose",
">",
"Convert",
"datetime_object",
"(",
"in",
"datetime",
".",
"datetime",
"()",
")",
"format",
")",
"to",
"a",
"Unix",
"/",
"POSIX",
"timestamp",
".",
"For",
"example",
"Python",
"s",
"time",
".",
"time",
"()",
"returns",
"a",
"Unix",
"times... | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/formats.py#L533-L568 | train |
secure-systems-lab/securesystemslib | securesystemslib/formats.py | unix_timestamp_to_datetime | def unix_timestamp_to_datetime(unix_timestamp):
"""
<Purpose>
Convert 'unix_timestamp' (i.e., POSIX time, in UNIX_TIMESTAMP_SCHEMA format)
to a datetime.datetime() object. 'unix_timestamp' is the number of seconds
since the epoch (January 1, 1970.)
>>> datetime_object = unix_timestamp_to_datetime(... | python | def unix_timestamp_to_datetime(unix_timestamp):
"""
<Purpose>
Convert 'unix_timestamp' (i.e., POSIX time, in UNIX_TIMESTAMP_SCHEMA format)
to a datetime.datetime() object. 'unix_timestamp' is the number of seconds
since the epoch (January 1, 1970.)
>>> datetime_object = unix_timestamp_to_datetime(... | [
"def",
"unix_timestamp_to_datetime",
"(",
"unix_timestamp",
")",
":",
"# Is 'unix_timestamp' properly formatted?",
"# Raise 'securesystemslib.exceptions.FormatError' if there is a mismatch.",
"securesystemslib",
".",
"formats",
".",
"UNIX_TIMESTAMP_SCHEMA",
".",
"check_match",
"(",
"... | <Purpose>
Convert 'unix_timestamp' (i.e., POSIX time, in UNIX_TIMESTAMP_SCHEMA format)
to a datetime.datetime() object. 'unix_timestamp' is the number of seconds
since the epoch (January 1, 1970.)
>>> datetime_object = unix_timestamp_to_datetime(1445455680)
>>> datetime_object
datetime.datetim... | [
"<Purpose",
">",
"Convert",
"unix_timestamp",
"(",
"i",
".",
"e",
".",
"POSIX",
"time",
"in",
"UNIX_TIMESTAMP_SCHEMA",
"format",
")",
"to",
"a",
"datetime",
".",
"datetime",
"()",
"object",
".",
"unix_timestamp",
"is",
"the",
"number",
"of",
"seconds",
"sinc... | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/formats.py#L573-L613 | train |
secure-systems-lab/securesystemslib | securesystemslib/formats.py | format_base64 | def format_base64(data):
"""
<Purpose>
Return the base64 encoding of 'data' with whitespace and '=' signs omitted.
<Arguments>
data:
Binary or buffer of data to convert.
<Exceptions>
securesystemslib.exceptions.FormatError, if the base64 encoding fails or the
argument is invalid.
<Sid... | python | def format_base64(data):
"""
<Purpose>
Return the base64 encoding of 'data' with whitespace and '=' signs omitted.
<Arguments>
data:
Binary or buffer of data to convert.
<Exceptions>
securesystemslib.exceptions.FormatError, if the base64 encoding fails or the
argument is invalid.
<Sid... | [
"def",
"format_base64",
"(",
"data",
")",
":",
"try",
":",
"return",
"binascii",
".",
"b2a_base64",
"(",
"data",
")",
".",
"decode",
"(",
"'utf-8'",
")",
".",
"rstrip",
"(",
"'=\\n '",
")",
"except",
"(",
"TypeError",
",",
"binascii",
".",
"Error",
")"... | <Purpose>
Return the base64 encoding of 'data' with whitespace and '=' signs omitted.
<Arguments>
data:
Binary or buffer of data to convert.
<Exceptions>
securesystemslib.exceptions.FormatError, if the base64 encoding fails or the
argument is invalid.
<Side Effects>
None.
<Returns>... | [
"<Purpose",
">",
"Return",
"the",
"base64",
"encoding",
"of",
"data",
"with",
"whitespace",
"and",
"=",
"signs",
"omitted",
"."
] | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/formats.py#L618-L643 | train |
secure-systems-lab/securesystemslib | securesystemslib/formats.py | parse_base64 | def parse_base64(base64_string):
"""
<Purpose>
Parse a base64 encoding with whitespace and '=' signs omitted.
<Arguments>
base64_string:
A string holding a base64 value.
<Exceptions>
securesystemslib.exceptions.FormatError, if 'base64_string' cannot be parsed
due to an invalid base64 enc... | python | def parse_base64(base64_string):
"""
<Purpose>
Parse a base64 encoding with whitespace and '=' signs omitted.
<Arguments>
base64_string:
A string holding a base64 value.
<Exceptions>
securesystemslib.exceptions.FormatError, if 'base64_string' cannot be parsed
due to an invalid base64 enc... | [
"def",
"parse_base64",
"(",
"base64_string",
")",
":",
"if",
"not",
"isinstance",
"(",
"base64_string",
",",
"six",
".",
"string_types",
")",
":",
"message",
"=",
"'Invalid argument: '",
"+",
"repr",
"(",
"base64_string",
")",
"raise",
"securesystemslib",
".",
... | <Purpose>
Parse a base64 encoding with whitespace and '=' signs omitted.
<Arguments>
base64_string:
A string holding a base64 value.
<Exceptions>
securesystemslib.exceptions.FormatError, if 'base64_string' cannot be parsed
due to an invalid base64 encoding.
<Side Effects>
None.
<Re... | [
"<Purpose",
">",
"Parse",
"a",
"base64",
"encoding",
"with",
"whitespace",
"and",
"=",
"signs",
"omitted",
"."
] | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/formats.py#L648-L683 | train |
secure-systems-lab/securesystemslib | securesystemslib/formats.py | encode_canonical | def encode_canonical(object, output_function=None):
"""
<Purpose>
Encode 'object' in canonical JSON form, as specified at
http://wiki.laptop.org/go/Canonical_JSON . It's a restricted
dialect of JSON in which keys are always lexically sorted,
there is no whitespace, floats aren't allowed, and only q... | python | def encode_canonical(object, output_function=None):
"""
<Purpose>
Encode 'object' in canonical JSON form, as specified at
http://wiki.laptop.org/go/Canonical_JSON . It's a restricted
dialect of JSON in which keys are always lexically sorted,
there is no whitespace, floats aren't allowed, and only q... | [
"def",
"encode_canonical",
"(",
"object",
",",
"output_function",
"=",
"None",
")",
":",
"result",
"=",
"None",
"# If 'output_function' is unset, treat it as",
"# appending to a list.",
"if",
"output_function",
"is",
"None",
":",
"result",
"=",
"[",
"]",
"output_funct... | <Purpose>
Encode 'object' in canonical JSON form, as specified at
http://wiki.laptop.org/go/Canonical_JSON . It's a restricted
dialect of JSON in which keys are always lexically sorted,
there is no whitespace, floats aren't allowed, and only quote
and backslash get escaped. The result is encoded i... | [
"<Purpose",
">",
"Encode",
"object",
"in",
"canonical",
"JSON",
"form",
"as",
"specified",
"at",
"http",
":",
"//",
"wiki",
".",
"laptop",
".",
"org",
"/",
"go",
"/",
"Canonical_JSON",
".",
"It",
"s",
"a",
"restricted",
"dialect",
"of",
"JSON",
"in",
"... | beb3109d5bb462e5a60eed88fb40ed1167bd354e | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/formats.py#L752-L820 | train |
HEPData/hepdata-converter | hepdata_converter/writers/array_writer.py | ArrayWriter.process_error_labels | def process_error_labels(value):
""" Process the error labels of a dependent variable 'value' to ensure uniqueness. """
observed_error_labels = {}
for error in value.get('errors', []):
label = error.get('label', 'error')
if label not in observed_error_labels:
... | python | def process_error_labels(value):
""" Process the error labels of a dependent variable 'value' to ensure uniqueness. """
observed_error_labels = {}
for error in value.get('errors', []):
label = error.get('label', 'error')
if label not in observed_error_labels:
... | [
"def",
"process_error_labels",
"(",
"value",
")",
":",
"observed_error_labels",
"=",
"{",
"}",
"for",
"error",
"in",
"value",
".",
"get",
"(",
"'errors'",
",",
"[",
"]",
")",
":",
"label",
"=",
"error",
".",
"get",
"(",
"'label'",
",",
"'error'",
")",
... | Process the error labels of a dependent variable 'value' to ensure uniqueness. | [
"Process",
"the",
"error",
"labels",
"of",
"a",
"dependent",
"variable",
"value",
"to",
"ensure",
"uniqueness",
"."
] | 354271448980efba86f2f3d27b99d818e75fd90d | https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/writers/array_writer.py#L140-L160 | train |
boolangery/py-lua-parser | luaparser/printers.py | raw | def raw(text):
"""Returns a raw string representation of text"""
new_string = ''
for char in text:
try:
new_string += escape_dict[char]
except KeyError:
new_string += char
return new_string | python | def raw(text):
"""Returns a raw string representation of text"""
new_string = ''
for char in text:
try:
new_string += escape_dict[char]
except KeyError:
new_string += char
return new_string | [
"def",
"raw",
"(",
"text",
")",
":",
"new_string",
"=",
"''",
"for",
"char",
"in",
"text",
":",
"try",
":",
"new_string",
"+=",
"escape_dict",
"[",
"char",
"]",
"except",
"KeyError",
":",
"new_string",
"+=",
"char",
"return",
"new_string"
] | Returns a raw string representation of text | [
"Returns",
"a",
"raw",
"string",
"representation",
"of",
"text"
] | 578f2bf75f6f84c4b52c2affba56a4ec569d7ce7 | https://github.com/boolangery/py-lua-parser/blob/578f2bf75f6f84c4b52c2affba56a4ec569d7ce7/luaparser/printers.py#L139-L147 | train |
indranilsinharoy/pyzos | pyzos/ddeclient.py | get_winfunc | def get_winfunc(libname, funcname, restype=None, argtypes=(), _libcache={}):
"""Retrieve a function from a library/DLL, and set the data types."""
if libname not in _libcache:
_libcache[libname] = windll.LoadLibrary(libname)
func = getattr(_libcache[libname], funcname)
func.argtypes = argtypes
... | python | def get_winfunc(libname, funcname, restype=None, argtypes=(), _libcache={}):
"""Retrieve a function from a library/DLL, and set the data types."""
if libname not in _libcache:
_libcache[libname] = windll.LoadLibrary(libname)
func = getattr(_libcache[libname], funcname)
func.argtypes = argtypes
... | [
"def",
"get_winfunc",
"(",
"libname",
",",
"funcname",
",",
"restype",
"=",
"None",
",",
"argtypes",
"=",
"(",
")",
",",
"_libcache",
"=",
"{",
"}",
")",
":",
"if",
"libname",
"not",
"in",
"_libcache",
":",
"_libcache",
"[",
"libname",
"]",
"=",
"win... | Retrieve a function from a library/DLL, and set the data types. | [
"Retrieve",
"a",
"function",
"from",
"a",
"library",
"/",
"DLL",
"and",
"set",
"the",
"data",
"types",
"."
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/ddeclient.py#L237-L244 | train |
indranilsinharoy/pyzos | pyzos/ddeclient.py | WinMSGLoop | def WinMSGLoop():
"""Run the main windows message loop."""
LPMSG = POINTER(MSG)
LRESULT = c_ulong
GetMessage = get_winfunc("user32", "GetMessageW", BOOL, (LPMSG, HWND, UINT, UINT))
TranslateMessage = get_winfunc("user32", "TranslateMessage", BOOL, (LPMSG,))
# restype = LRESULT
DispatchMessag... | python | def WinMSGLoop():
"""Run the main windows message loop."""
LPMSG = POINTER(MSG)
LRESULT = c_ulong
GetMessage = get_winfunc("user32", "GetMessageW", BOOL, (LPMSG, HWND, UINT, UINT))
TranslateMessage = get_winfunc("user32", "TranslateMessage", BOOL, (LPMSG,))
# restype = LRESULT
DispatchMessag... | [
"def",
"WinMSGLoop",
"(",
")",
":",
"LPMSG",
"=",
"POINTER",
"(",
"MSG",
")",
"LRESULT",
"=",
"c_ulong",
"GetMessage",
"=",
"get_winfunc",
"(",
"\"user32\"",
",",
"\"GetMessageW\"",
",",
"BOOL",
",",
"(",
"LPMSG",
",",
"HWND",
",",
"UINT",
",",
"UINT",
... | Run the main windows message loop. | [
"Run",
"the",
"main",
"windows",
"message",
"loop",
"."
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/ddeclient.py#L384-L397 | train |
indranilsinharoy/pyzos | pyzos/ddeclient.py | CreateConversation.ConnectTo | def ConnectTo(self, appName, data=None):
"""Exceptional error is handled in zdde Init() method, so the exception
must be re-raised"""
global number_of_apps_communicating
self.ddeServerName = appName
try:
self.ddec = DDEClient(self.ddeServerName, self.ddeClientName) # ... | python | def ConnectTo(self, appName, data=None):
"""Exceptional error is handled in zdde Init() method, so the exception
must be re-raised"""
global number_of_apps_communicating
self.ddeServerName = appName
try:
self.ddec = DDEClient(self.ddeServerName, self.ddeClientName) # ... | [
"def",
"ConnectTo",
"(",
"self",
",",
"appName",
",",
"data",
"=",
"None",
")",
":",
"global",
"number_of_apps_communicating",
"self",
".",
"ddeServerName",
"=",
"appName",
"try",
":",
"self",
".",
"ddec",
"=",
"DDEClient",
"(",
"self",
".",
"ddeServerName",... | Exceptional error is handled in zdde Init() method, so the exception
must be re-raised | [
"Exceptional",
"error",
"is",
"handled",
"in",
"zdde",
"Init",
"()",
"method",
"so",
"the",
"exception",
"must",
"be",
"re",
"-",
"raised"
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/ddeclient.py#L191-L201 | train |
indranilsinharoy/pyzos | pyzos/ddeclient.py | CreateConversation.Request | def Request(self, item, timeout=None):
"""Request DDE client
timeout in seconds
Note ... handle the exception within this function.
"""
if not timeout:
timeout = self.ddetimeout
try:
reply = self.ddec.request(item, int(timeout*1000)) # convert time... | python | def Request(self, item, timeout=None):
"""Request DDE client
timeout in seconds
Note ... handle the exception within this function.
"""
if not timeout:
timeout = self.ddetimeout
try:
reply = self.ddec.request(item, int(timeout*1000)) # convert time... | [
"def",
"Request",
"(",
"self",
",",
"item",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"not",
"timeout",
":",
"timeout",
"=",
"self",
".",
"ddetimeout",
"try",
":",
"reply",
"=",
"self",
".",
"ddec",
".",
"request",
"(",
"item",
",",
"int",
"(",
... | Request DDE client
timeout in seconds
Note ... handle the exception within this function. | [
"Request",
"DDE",
"client",
"timeout",
"in",
"seconds",
"Note",
"...",
"handle",
"the",
"exception",
"within",
"this",
"function",
"."
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/ddeclient.py#L204-L222 | train |
indranilsinharoy/pyzos | pyzos/ddeclient.py | DDEClient.advise | def advise(self, item, stop=False):
"""Request updates when DDE data changes."""
hszItem = DDE.CreateStringHandle(self._idInst, item, CP_WINUNICODE)
hDdeData = DDE.ClientTransaction(LPBYTE(), 0, self._hConv, hszItem, CF_TEXT, XTYP_ADVSTOP if stop else XTYP_ADVSTART, TIMEOUT_ASYNC, LPDWORD())
... | python | def advise(self, item, stop=False):
"""Request updates when DDE data changes."""
hszItem = DDE.CreateStringHandle(self._idInst, item, CP_WINUNICODE)
hDdeData = DDE.ClientTransaction(LPBYTE(), 0, self._hConv, hszItem, CF_TEXT, XTYP_ADVSTOP if stop else XTYP_ADVSTART, TIMEOUT_ASYNC, LPDWORD())
... | [
"def",
"advise",
"(",
"self",
",",
"item",
",",
"stop",
"=",
"False",
")",
":",
"hszItem",
"=",
"DDE",
".",
"CreateStringHandle",
"(",
"self",
".",
"_idInst",
",",
"item",
",",
"CP_WINUNICODE",
")",
"hDdeData",
"=",
"DDE",
".",
"ClientTransaction",
"(",
... | Request updates when DDE data changes. | [
"Request",
"updates",
"when",
"DDE",
"data",
"changes",
"."
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/ddeclient.py#L305-L312 | train |
indranilsinharoy/pyzos | pyzos/ddeclient.py | DDEClient.execute | def execute(self, command):
"""Execute a DDE command."""
pData = c_char_p(command)
cbData = DWORD(len(command) + 1)
hDdeData = DDE.ClientTransaction(pData, cbData, self._hConv, HSZ(), CF_TEXT, XTYP_EXECUTE, TIMEOUT_ASYNC, LPDWORD())
if not hDdeData:
raise DDEError("Un... | python | def execute(self, command):
"""Execute a DDE command."""
pData = c_char_p(command)
cbData = DWORD(len(command) + 1)
hDdeData = DDE.ClientTransaction(pData, cbData, self._hConv, HSZ(), CF_TEXT, XTYP_EXECUTE, TIMEOUT_ASYNC, LPDWORD())
if not hDdeData:
raise DDEError("Un... | [
"def",
"execute",
"(",
"self",
",",
"command",
")",
":",
"pData",
"=",
"c_char_p",
"(",
"command",
")",
"cbData",
"=",
"DWORD",
"(",
"len",
"(",
"command",
")",
"+",
"1",
")",
"hDdeData",
"=",
"DDE",
".",
"ClientTransaction",
"(",
"pData",
",",
"cbDa... | Execute a DDE command. | [
"Execute",
"a",
"DDE",
"command",
"."
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/ddeclient.py#L314-L321 | train |
indranilsinharoy/pyzos | pyzos/ddeclient.py | DDEClient.request | def request(self, item, timeout=5000):
"""Request data from DDE service."""
hszItem = DDE.CreateStringHandle(self._idInst, item, CP_WINUNICODE)
#hDdeData = DDE.ClientTransaction(LPBYTE(), 0, self._hConv, hszItem, CF_TEXT, XTYP_REQUEST, timeout, LPDWORD())
pdwResult = DWORD(0)
hDd... | python | def request(self, item, timeout=5000):
"""Request data from DDE service."""
hszItem = DDE.CreateStringHandle(self._idInst, item, CP_WINUNICODE)
#hDdeData = DDE.ClientTransaction(LPBYTE(), 0, self._hConv, hszItem, CF_TEXT, XTYP_REQUEST, timeout, LPDWORD())
pdwResult = DWORD(0)
hDd... | [
"def",
"request",
"(",
"self",
",",
"item",
",",
"timeout",
"=",
"5000",
")",
":",
"hszItem",
"=",
"DDE",
".",
"CreateStringHandle",
"(",
"self",
".",
"_idInst",
",",
"item",
",",
"CP_WINUNICODE",
")",
"#hDdeData = DDE.ClientTransaction(LPBYTE(), 0, self._hConv, h... | Request data from DDE service. | [
"Request",
"data",
"from",
"DDE",
"service",
"."
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/ddeclient.py#L323-L343 | train |
indranilsinharoy/pyzos | pyzos/ddeclient.py | DDEClient._callback | def _callback(self, wType, uFmt, hConv, hsz1, hsz2, hDdeData, dwData1, dwData2):
"""DdeCallback callback function for processing Dynamic Data Exchange (DDE)
transactions sent by DDEML in response to DDE events
Parameters
----------
wType : transaction type (UINT)
uFmt... | python | def _callback(self, wType, uFmt, hConv, hsz1, hsz2, hDdeData, dwData1, dwData2):
"""DdeCallback callback function for processing Dynamic Data Exchange (DDE)
transactions sent by DDEML in response to DDE events
Parameters
----------
wType : transaction type (UINT)
uFmt... | [
"def",
"_callback",
"(",
"self",
",",
"wType",
",",
"uFmt",
",",
"hConv",
",",
"hsz1",
",",
"hsz2",
",",
"hDdeData",
",",
"dwData1",
",",
"dwData2",
")",
":",
"if",
"wType",
"==",
"XTYP_ADVDATA",
":",
"# value of the data item has changed [hsz1 = topic; hsz2 = i... | DdeCallback callback function for processing Dynamic Data Exchange (DDE)
transactions sent by DDEML in response to DDE events
Parameters
----------
wType : transaction type (UINT)
uFmt : clipboard data format (UINT)
hConv : handle to conversation (HCONV)
... | [
"DdeCallback",
"callback",
"function",
"for",
"processing",
"Dynamic",
"Data",
"Exchange",
"(",
"DDE",
")",
"transactions",
"sent",
"by",
"DDEML",
"in",
"response",
"to",
"DDE",
"events"
] | da6bf3296b0154ccee44ad9a4286055ae031ecc7 | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/ddeclient.py#L349-L382 | train |
HEPData/hepdata-converter | hepdata_converter/parsers/yaml_parser.py | YAML.parse | def parse(self, data_in, *args, **kwargs):
"""
:param data_in: path to submission.yaml
:param args:
:param kwargs:
:raise ValueError:
"""
if not os.path.exists(data_in):
raise ValueError("File / Directory does not exist: %s" % data_in)
if os.p... | python | def parse(self, data_in, *args, **kwargs):
"""
:param data_in: path to submission.yaml
:param args:
:param kwargs:
:raise ValueError:
"""
if not os.path.exists(data_in):
raise ValueError("File / Directory does not exist: %s" % data_in)
if os.p... | [
"def",
"parse",
"(",
"self",
",",
"data_in",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"data_in",
")",
":",
"raise",
"ValueError",
"(",
"\"File / Directory does not exist: %s\"",
"%",
"data_i... | :param data_in: path to submission.yaml
:param args:
:param kwargs:
:raise ValueError: | [
":",
"param",
"data_in",
":",
"path",
"to",
"submission",
".",
"yaml",
":",
"param",
"args",
":",
":",
"param",
"kwargs",
":",
":",
"raise",
"ValueError",
":"
] | 354271448980efba86f2f3d27b99d818e75fd90d | https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/parsers/yaml_parser.py#L42-L109 | train |
jay-johnson/antinex-client | antinex_client/generate_ai_request.py | generate_ai_request | def generate_ai_request(
predict_rows,
req_dict=None,
req_file=ANTINEX_PUBLISH_REQUEST_FILE,
features=ANTINEX_FEATURES_TO_PROCESS,
ignore_features=ANTINEX_IGNORE_FEATURES,
sort_values=ANTINEX_SORT_VALUES,
ml_type=ANTINEX_ML_TYPE,
use_model_name=ANTINEX_USE... | python | def generate_ai_request(
predict_rows,
req_dict=None,
req_file=ANTINEX_PUBLISH_REQUEST_FILE,
features=ANTINEX_FEATURES_TO_PROCESS,
ignore_features=ANTINEX_IGNORE_FEATURES,
sort_values=ANTINEX_SORT_VALUES,
ml_type=ANTINEX_ML_TYPE,
use_model_name=ANTINEX_USE... | [
"def",
"generate_ai_request",
"(",
"predict_rows",
",",
"req_dict",
"=",
"None",
",",
"req_file",
"=",
"ANTINEX_PUBLISH_REQUEST_FILE",
",",
"features",
"=",
"ANTINEX_FEATURES_TO_PROCESS",
",",
"ignore_features",
"=",
"ANTINEX_IGNORE_FEATURES",
",",
"sort_values",
"=",
"... | generate_ai_request
:param predict_rows: list of predict rows to build into the request
:param req_dict: request dictionary to update - for long-running clients
:param req_file: file holding a request dict to update - one-off tests
:param features: features to process in the data
:param ignore_feat... | [
"generate_ai_request"
] | 850ba2a2fe21c836e071def618dcecc9caf5d59c | https://github.com/jay-johnson/antinex-client/blob/850ba2a2fe21c836e071def618dcecc9caf5d59c/antinex_client/generate_ai_request.py#L44-L256 | train |
jay-johnson/antinex-client | antinex_client/scripts/ai_get_job.py | get_ml_job | def get_ml_job():
"""get_ml_job
Get an ``MLJob`` by database id.
"""
parser = argparse.ArgumentParser(
description=("Python client get AI Job by ID"))
parser.add_argument(
"-u",
help="username",
required=False,
dest="user")
parser.add_argument(
... | python | def get_ml_job():
"""get_ml_job
Get an ``MLJob`` by database id.
"""
parser = argparse.ArgumentParser(
description=("Python client get AI Job by ID"))
parser.add_argument(
"-u",
help="username",
required=False,
dest="user")
parser.add_argument(
... | [
"def",
"get_ml_job",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"(",
"\"Python client get AI Job by ID\"",
")",
")",
"parser",
".",
"add_argument",
"(",
"\"-u\"",
",",
"help",
"=",
"\"username\"",
",",
"required",
... | get_ml_job
Get an ``MLJob`` by database id. | [
"get_ml_job"
] | 850ba2a2fe21c836e071def618dcecc9caf5d59c | https://github.com/jay-johnson/antinex-client/blob/850ba2a2fe21c836e071def618dcecc9caf5d59c/antinex_client/scripts/ai_get_job.py#L20-L251 | train |
praekeltfoundation/molo.commenting | molo/commenting/templatetags/molo_commenting_tags.py | get_molo_comments | def get_molo_comments(parser, token):
"""
Get a limited set of comments for a given object.
Defaults to a limit of 5. Setting the limit to -1 disables limiting.
Set the amount of comments to
usage:
{% get_molo_comments for object as variable_name %}
{% get_molo_comments for object ... | python | def get_molo_comments(parser, token):
"""
Get a limited set of comments for a given object.
Defaults to a limit of 5. Setting the limit to -1 disables limiting.
Set the amount of comments to
usage:
{% get_molo_comments for object as variable_name %}
{% get_molo_comments for object ... | [
"def",
"get_molo_comments",
"(",
"parser",
",",
"token",
")",
":",
"keywords",
"=",
"token",
".",
"contents",
".",
"split",
"(",
")",
"if",
"len",
"(",
"keywords",
")",
"!=",
"5",
"and",
"len",
"(",
"keywords",
")",
"!=",
"7",
"and",
"len",
"(",
"k... | Get a limited set of comments for a given object.
Defaults to a limit of 5. Setting the limit to -1 disables limiting.
Set the amount of comments to
usage:
{% get_molo_comments for object as variable_name %}
{% get_molo_comments for object as variable_name limit amount %}
{% get_mo... | [
"Get",
"a",
"limited",
"set",
"of",
"comments",
"for",
"a",
"given",
"object",
".",
"Defaults",
"to",
"a",
"limit",
"of",
"5",
".",
"Setting",
"the",
"limit",
"to",
"-",
"1",
"disables",
"limiting",
".",
"Set",
"the",
"amount",
"of",
"comments",
"to"
] | 94549bd75e4a5c5b3db43149e32d636330b3969c | https://github.com/praekeltfoundation/molo.commenting/blob/94549bd75e4a5c5b3db43149e32d636330b3969c/molo/commenting/templatetags/molo_commenting_tags.py#L13-L48 | train |
praekeltfoundation/molo.commenting | molo/commenting/templatetags/molo_commenting_tags.py | get_comments_content_object | def get_comments_content_object(parser, token):
"""
Get a limited set of comments for a given object.
Defaults to a limit of 5. Setting the limit to -1 disables limiting.
usage:
{% get_comments_content_object for form_object as variable_name %}
"""
keywords = token.contents.split()
... | python | def get_comments_content_object(parser, token):
"""
Get a limited set of comments for a given object.
Defaults to a limit of 5. Setting the limit to -1 disables limiting.
usage:
{% get_comments_content_object for form_object as variable_name %}
"""
keywords = token.contents.split()
... | [
"def",
"get_comments_content_object",
"(",
"parser",
",",
"token",
")",
":",
"keywords",
"=",
"token",
".",
"contents",
".",
"split",
"(",
")",
"if",
"len",
"(",
"keywords",
")",
"!=",
"5",
":",
"raise",
"template",
".",
"TemplateSyntaxError",
"(",
"\"'%s'... | Get a limited set of comments for a given object.
Defaults to a limit of 5. Setting the limit to -1 disables limiting.
usage:
{% get_comments_content_object for form_object as variable_name %} | [
"Get",
"a",
"limited",
"set",
"of",
"comments",
"for",
"a",
"given",
"object",
".",
"Defaults",
"to",
"a",
"limit",
"of",
"5",
".",
"Setting",
"the",
"limit",
"to",
"-",
"1",
"disables",
"limiting",
"."
] | 94549bd75e4a5c5b3db43149e32d636330b3969c | https://github.com/praekeltfoundation/molo.commenting/blob/94549bd75e4a5c5b3db43149e32d636330b3969c/molo/commenting/templatetags/molo_commenting_tags.py#L75-L95 | train |
praekeltfoundation/molo.commenting | molo/commenting/views.py | report | def report(request, comment_id):
"""
Flags a comment on GET.
Redirects to whatever is provided in request.REQUEST['next'].
"""
comment = get_object_or_404(
django_comments.get_model(), pk=comment_id, site__pk=settings.SITE_ID)
if comment.parent is not None:
messages.info(reques... | python | def report(request, comment_id):
"""
Flags a comment on GET.
Redirects to whatever is provided in request.REQUEST['next'].
"""
comment = get_object_or_404(
django_comments.get_model(), pk=comment_id, site__pk=settings.SITE_ID)
if comment.parent is not None:
messages.info(reques... | [
"def",
"report",
"(",
"request",
",",
"comment_id",
")",
":",
"comment",
"=",
"get_object_or_404",
"(",
"django_comments",
".",
"get_model",
"(",
")",
",",
"pk",
"=",
"comment_id",
",",
"site__pk",
"=",
"settings",
".",
"SITE_ID",
")",
"if",
"comment",
"."... | Flags a comment on GET.
Redirects to whatever is provided in request.REQUEST['next']. | [
"Flags",
"a",
"comment",
"on",
"GET",
"."
] | 94549bd75e4a5c5b3db43149e32d636330b3969c | https://github.com/praekeltfoundation/molo.commenting/blob/94549bd75e4a5c5b3db43149e32d636330b3969c/molo/commenting/views.py#L21-L37 | train |
praekeltfoundation/molo.commenting | molo/commenting/views.py | post_molo_comment | def post_molo_comment(request, next=None, using=None):
"""
Allows for posting of a Molo Comment, this allows comments to
be set with the "user_name" as "Anonymous"
"""
data = request.POST.copy()
if 'submit_anonymously' in data:
data['name'] = 'Anonymous'
# replace with our changed PO... | python | def post_molo_comment(request, next=None, using=None):
"""
Allows for posting of a Molo Comment, this allows comments to
be set with the "user_name" as "Anonymous"
"""
data = request.POST.copy()
if 'submit_anonymously' in data:
data['name'] = 'Anonymous'
# replace with our changed PO... | [
"def",
"post_molo_comment",
"(",
"request",
",",
"next",
"=",
"None",
",",
"using",
"=",
"None",
")",
":",
"data",
"=",
"request",
".",
"POST",
".",
"copy",
"(",
")",
"if",
"'submit_anonymously'",
"in",
"data",
":",
"data",
"[",
"'name'",
"]",
"=",
"... | Allows for posting of a Molo Comment, this allows comments to
be set with the "user_name" as "Anonymous" | [
"Allows",
"for",
"posting",
"of",
"a",
"Molo",
"Comment",
"this",
"allows",
"comments",
"to",
"be",
"set",
"with",
"the",
"user_name",
"as",
"Anonymous"
] | 94549bd75e4a5c5b3db43149e32d636330b3969c | https://github.com/praekeltfoundation/molo.commenting/blob/94549bd75e4a5c5b3db43149e32d636330b3969c/molo/commenting/views.py#L41-L55 | train |
jay-johnson/antinex-client | antinex_client/build_ai_client_from_env.py | build_ai_client_from_env | def build_ai_client_from_env(
verbose=ANTINEX_CLIENT_VERBOSE,
debug=ANTINEX_CLIENT_DEBUG,
ca_dir=None,
cert_file=None,
key_file=None):
"""build_ai_client_from_env
Use environment variables to build a client
:param verbose: verbose logging
:param debug: debug int... | python | def build_ai_client_from_env(
verbose=ANTINEX_CLIENT_VERBOSE,
debug=ANTINEX_CLIENT_DEBUG,
ca_dir=None,
cert_file=None,
key_file=None):
"""build_ai_client_from_env
Use environment variables to build a client
:param verbose: verbose logging
:param debug: debug int... | [
"def",
"build_ai_client_from_env",
"(",
"verbose",
"=",
"ANTINEX_CLIENT_VERBOSE",
",",
"debug",
"=",
"ANTINEX_CLIENT_DEBUG",
",",
"ca_dir",
"=",
"None",
",",
"cert_file",
"=",
"None",
",",
"key_file",
"=",
"None",
")",
":",
"if",
"not",
"ANTINEX_PUBLISH_ENABLED",
... | build_ai_client_from_env
Use environment variables to build a client
:param verbose: verbose logging
:param debug: debug internal client calls
:param ca_dir: optional path to CA bundle dir
:param cert_file: optional path to x509 ssl cert file
:param key_file: optional path to x509 ssl key file | [
"build_ai_client_from_env"
] | 850ba2a2fe21c836e071def618dcecc9caf5d59c | https://github.com/jay-johnson/antinex-client/blob/850ba2a2fe21c836e071def618dcecc9caf5d59c/antinex_client/build_ai_client_from_env.py#L19-L78 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.