repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
HEPData/hepdata-converter | hepdata_converter/__init__.py | convert | def convert(input, output=None, options={}):
"""Converts a supported ``input_format`` (*oldhepdata*, *yaml*)
to a supported ``output_format`` (*csv*, *root*, *yaml*, *yoda*).
:param input: location of input file for *oldhepdata* format or input directory for *yaml* format
:param output: location of out... | python | def convert(input, output=None, options={}):
"""Converts a supported ``input_format`` (*oldhepdata*, *yaml*)
to a supported ``output_format`` (*csv*, *root*, *yaml*, *yoda*).
:param input: location of input file for *oldhepdata* format or input directory for *yaml* format
:param output: location of out... | [
"def",
"convert",
"(",
"input",
",",
"output",
"=",
"None",
",",
"options",
"=",
"{",
"}",
")",
":",
"if",
"'input_format'",
"not",
"in",
"options",
"and",
"'output_format'",
"not",
"in",
"options",
":",
"raise",
"ValueError",
"(",
"\"no input_format and out... | Converts a supported ``input_format`` (*oldhepdata*, *yaml*)
to a supported ``output_format`` (*csv*, *root*, *yaml*, *yoda*).
:param input: location of input file for *oldhepdata* format or input directory for *yaml* format
:param output: location of output directory to which converted files will be writt... | [
"Converts",
"a",
"supported",
"input_format",
"(",
"*",
"oldhepdata",
"*",
"*",
"yaml",
"*",
")",
"to",
"a",
"supported",
"output_format",
"(",
"*",
"csv",
"*",
"*",
"root",
"*",
"*",
"yaml",
"*",
"*",
"yoda",
"*",
")",
"."
] | train | https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/__init__.py#L9-L43 |
HEPData/hepdata-converter | hepdata_converter/writers/csv_writer.py | CSV._write_packed_data | def _write_packed_data(self, data_out, table):
"""This is kind of legacy function - this functionality may be useful for some people, so even though
now the default of writing CSV is writing unpacked data (divided by independent variable) this method is
still available and accessible if ```pack`... | python | def _write_packed_data(self, data_out, table):
"""This is kind of legacy function - this functionality may be useful for some people, so even though
now the default of writing CSV is writing unpacked data (divided by independent variable) this method is
still available and accessible if ```pack`... | [
"def",
"_write_packed_data",
"(",
"self",
",",
"data_out",
",",
"table",
")",
":",
"headers",
"=",
"[",
"]",
"data",
"=",
"[",
"]",
"qualifiers_marks",
"=",
"[",
"]",
"qualifiers",
"=",
"{",
"}",
"self",
".",
"_extract_independent_variables",
"(",
"table",... | This is kind of legacy function - this functionality may be useful for some people, so even though
now the default of writing CSV is writing unpacked data (divided by independent variable) this method is
still available and accessible if ```pack``` flag is specified in Writer's options
:param o... | [
"This",
"is",
"kind",
"of",
"legacy",
"function",
"-",
"this",
"functionality",
"may",
"be",
"useful",
"for",
"some",
"people",
"so",
"even",
"though",
"now",
"the",
"default",
"of",
"writing",
"CSV",
"is",
"writing",
"unpacked",
"data",
"(",
"divided",
"b... | train | https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/writers/csv_writer.py#L82-L102 |
secure-systems-lab/securesystemslib | securesystemslib/hash.py | digest | def digest(algorithm=DEFAULT_HASH_ALGORITHM, hash_library=DEFAULT_HASH_LIBRARY):
"""
<Purpose>
Provide the caller with the ability to create digest objects without having
to worry about crypto library availability or which library to use. The
caller also has the option of specifying which hash algorith... | python | def digest(algorithm=DEFAULT_HASH_ALGORITHM, hash_library=DEFAULT_HASH_LIBRARY):
"""
<Purpose>
Provide the caller with the ability to create digest objects without having
to worry about crypto library availability or which library to use. The
caller also has the option of specifying which hash algorith... | [
"def",
"digest",
"(",
"algorithm",
"=",
"DEFAULT_HASH_ALGORITHM",
",",
"hash_library",
"=",
"DEFAULT_HASH_LIBRARY",
")",
":",
"# Are the arguments properly formatted? If not, raise",
"# 'securesystemslib.exceptions.FormatError'.",
"securesystemslib",
".",
"formats",
".",
"NAME_S... | <Purpose>
Provide the caller with the ability to create digest objects without having
to worry about crypto library availability or which library to use. The
caller also has the option of specifying which hash algorithm and/or
library to use.
# Creation of a digest object using defaults or by spec... | [
"<Purpose",
">",
"Provide",
"the",
"caller",
"with",
"the",
"ability",
"to",
"create",
"digest",
"objects",
"without",
"having",
"to",
"worry",
"about",
"crypto",
"library",
"availability",
"or",
"which",
"library",
"to",
"use",
".",
"The",
"caller",
"also",
... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/hash.py#L50-L122 |
secure-systems-lab/securesystemslib | securesystemslib/hash.py | digest_fileobject | def digest_fileobject(file_object, algorithm=DEFAULT_HASH_ALGORITHM,
hash_library=DEFAULT_HASH_LIBRARY, normalize_line_endings=False):
"""
<Purpose>
Generate a digest object given a file object. The new digest object
is updated with the contents of 'file_object' prior to returning the
object to the... | python | def digest_fileobject(file_object, algorithm=DEFAULT_HASH_ALGORITHM,
hash_library=DEFAULT_HASH_LIBRARY, normalize_line_endings=False):
"""
<Purpose>
Generate a digest object given a file object. The new digest object
is updated with the contents of 'file_object' prior to returning the
object to the... | [
"def",
"digest_fileobject",
"(",
"file_object",
",",
"algorithm",
"=",
"DEFAULT_HASH_ALGORITHM",
",",
"hash_library",
"=",
"DEFAULT_HASH_LIBRARY",
",",
"normalize_line_endings",
"=",
"False",
")",
":",
"# Are the arguments properly formatted? If not, raise",
"# 'securesystemsl... | <Purpose>
Generate a digest object given a file object. The new digest object
is updated with the contents of 'file_object' prior to returning the
object to the caller.
<Arguments>
file_object:
File object whose contents will be used as the data
to update the hash of a digest object to b... | [
"<Purpose",
">",
"Generate",
"a",
"digest",
"object",
"given",
"a",
"file",
"object",
".",
"The",
"new",
"digest",
"object",
"is",
"updated",
"with",
"the",
"contents",
"of",
"file_object",
"prior",
"to",
"returning",
"the",
"object",
"to",
"the",
"caller",
... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/hash.py#L128-L217 |
secure-systems-lab/securesystemslib | securesystemslib/hash.py | digest_filename | def digest_filename(filename, algorithm=DEFAULT_HASH_ALGORITHM,
hash_library=DEFAULT_HASH_LIBRARY, normalize_line_endings=False):
"""
<Purpose>
Generate a digest object, update its hash using a file object
specified by filename, and then return it to the caller.
<Arguments>
filename:
The fi... | python | def digest_filename(filename, algorithm=DEFAULT_HASH_ALGORITHM,
hash_library=DEFAULT_HASH_LIBRARY, normalize_line_endings=False):
"""
<Purpose>
Generate a digest object, update its hash using a file object
specified by filename, and then return it to the caller.
<Arguments>
filename:
The fi... | [
"def",
"digest_filename",
"(",
"filename",
",",
"algorithm",
"=",
"DEFAULT_HASH_ALGORITHM",
",",
"hash_library",
"=",
"DEFAULT_HASH_LIBRARY",
",",
"normalize_line_endings",
"=",
"False",
")",
":",
"# Are the arguments properly formatted? If not, raise",
"# 'securesystemslib.ex... | <Purpose>
Generate a digest object, update its hash using a file object
specified by filename, and then return it to the caller.
<Arguments>
filename:
The filename belonging to the file object to be used.
algorithm:
The hash algorithm (e.g., 'md5', 'sha1', 'sha256').
hash_library:
... | [
"<Purpose",
">",
"Generate",
"a",
"digest",
"object",
"update",
"its",
"hash",
"using",
"a",
"file",
"object",
"specified",
"by",
"filename",
"and",
"then",
"return",
"it",
"to",
"the",
"caller",
"."
] | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/hash.py#L223-L276 |
boolangery/py-lua-parser | luaparser/ast.py | get_token_stream | def get_token_stream(source: str) -> CommonTokenStream:
""" Get the antlr token stream.
"""
lexer = LuaLexer(InputStream(source))
stream = CommonTokenStream(lexer)
return stream | python | def get_token_stream(source: str) -> CommonTokenStream:
""" Get the antlr token stream.
"""
lexer = LuaLexer(InputStream(source))
stream = CommonTokenStream(lexer)
return stream | [
"def",
"get_token_stream",
"(",
"source",
":",
"str",
")",
"->",
"CommonTokenStream",
":",
"lexer",
"=",
"LuaLexer",
"(",
"InputStream",
"(",
"source",
")",
")",
"stream",
"=",
"CommonTokenStream",
"(",
"lexer",
")",
"return",
"stream"
] | Get the antlr token stream. | [
"Get",
"the",
"antlr",
"token",
"stream",
"."
] | train | https://github.com/boolangery/py-lua-parser/blob/578f2bf75f6f84c4b52c2affba56a4ec569d7ce7/luaparser/ast.py#L18-L23 |
PokeDevs/pokedex.py | pokedex/pokedex.py | Pokedex.get_evolution_stone | def get_evolution_stone(self, slug):
"""
Returns a Evolution Stone object containing the details about the
evolution stone.
"""
endpoint = '/evolution-stone/' + slug
return self.make_request(self.BASE_URL + endpoint) | python | def get_evolution_stone(self, slug):
"""
Returns a Evolution Stone object containing the details about the
evolution stone.
"""
endpoint = '/evolution-stone/' + slug
return self.make_request(self.BASE_URL + endpoint) | [
"def",
"get_evolution_stone",
"(",
"self",
",",
"slug",
")",
":",
"endpoint",
"=",
"'/evolution-stone/'",
"+",
"slug",
"return",
"self",
".",
"make_request",
"(",
"self",
".",
"BASE_URL",
"+",
"endpoint",
")"
] | Returns a Evolution Stone object containing the details about the
evolution stone. | [
"Returns",
"a",
"Evolution",
"Stone",
"object",
"containing",
"the",
"details",
"about",
"the",
"evolution",
"stone",
"."
] | train | https://github.com/PokeDevs/pokedex.py/blob/dc1280f34176b0ecea633a87ab9e7eed02c1d32b/pokedex/pokedex.py#L66-L72 |
PokeDevs/pokedex.py | pokedex/pokedex.py | Pokedex.get_league | def get_league(self, slug):
"""
Returns a Pokemon League object containing the details about the
league.
"""
endpoint = '/league/' + slug
return self.make_request(self.BASE_URL + endpoint) | python | def get_league(self, slug):
"""
Returns a Pokemon League object containing the details about the
league.
"""
endpoint = '/league/' + slug
return self.make_request(self.BASE_URL + endpoint) | [
"def",
"get_league",
"(",
"self",
",",
"slug",
")",
":",
"endpoint",
"=",
"'/league/'",
"+",
"slug",
"return",
"self",
".",
"make_request",
"(",
"self",
".",
"BASE_URL",
"+",
"endpoint",
")"
] | Returns a Pokemon League object containing the details about the
league. | [
"Returns",
"a",
"Pokemon",
"League",
"object",
"containing",
"the",
"details",
"about",
"the",
"league",
"."
] | train | https://github.com/PokeDevs/pokedex.py/blob/dc1280f34176b0ecea633a87ab9e7eed02c1d32b/pokedex/pokedex.py#L82-L88 |
PokeDevs/pokedex.py | pokedex/pokedex.py | Pokedex.get_pokemon_by_name | def get_pokemon_by_name(self, name):
"""
Returns an array of Pokemon objects containing all the forms of the
Pokemon specified the name of the Pokemon.
"""
endpoint = '/pokemon/' + str(name)
return self.make_request(self.BASE_URL + endpoint) | python | def get_pokemon_by_name(self, name):
"""
Returns an array of Pokemon objects containing all the forms of the
Pokemon specified the name of the Pokemon.
"""
endpoint = '/pokemon/' + str(name)
return self.make_request(self.BASE_URL + endpoint) | [
"def",
"get_pokemon_by_name",
"(",
"self",
",",
"name",
")",
":",
"endpoint",
"=",
"'/pokemon/'",
"+",
"str",
"(",
"name",
")",
"return",
"self",
".",
"make_request",
"(",
"self",
".",
"BASE_URL",
"+",
"endpoint",
")"
] | Returns an array of Pokemon objects containing all the forms of the
Pokemon specified the name of the Pokemon. | [
"Returns",
"an",
"array",
"of",
"Pokemon",
"objects",
"containing",
"all",
"the",
"forms",
"of",
"the",
"Pokemon",
"specified",
"the",
"name",
"of",
"the",
"Pokemon",
"."
] | train | https://github.com/PokeDevs/pokedex.py/blob/dc1280f34176b0ecea633a87ab9e7eed02c1d32b/pokedex/pokedex.py#L91-L97 |
PokeDevs/pokedex.py | pokedex/pokedex.py | Pokedex.get_pokemon_by_number | def get_pokemon_by_number(self, number):
"""
Returns an array of Pokemon objects containing all the forms of the
Pokemon specified the Pokedex number.
"""
endpoint = '/pokemon/' + str(number)
return self.make_request(self.BASE_URL + endpoint) | python | def get_pokemon_by_number(self, number):
"""
Returns an array of Pokemon objects containing all the forms of the
Pokemon specified the Pokedex number.
"""
endpoint = '/pokemon/' + str(number)
return self.make_request(self.BASE_URL + endpoint) | [
"def",
"get_pokemon_by_number",
"(",
"self",
",",
"number",
")",
":",
"endpoint",
"=",
"'/pokemon/'",
"+",
"str",
"(",
"number",
")",
"return",
"self",
".",
"make_request",
"(",
"self",
".",
"BASE_URL",
"+",
"endpoint",
")"
] | Returns an array of Pokemon objects containing all the forms of the
Pokemon specified the Pokedex number. | [
"Returns",
"an",
"array",
"of",
"Pokemon",
"objects",
"containing",
"all",
"the",
"forms",
"of",
"the",
"Pokemon",
"specified",
"the",
"Pokedex",
"number",
"."
] | train | https://github.com/PokeDevs/pokedex.py/blob/dc1280f34176b0ecea633a87ab9e7eed02c1d32b/pokedex/pokedex.py#L99-L105 |
secure-systems-lab/securesystemslib | securesystemslib/pyca_crypto_keys.py | generate_rsa_public_and_private | def generate_rsa_public_and_private(bits=_DEFAULT_RSA_KEY_BITS):
"""
<Purpose>
Generate public and private RSA keys with modulus length 'bits'. The
public and private keys returned conform to
'securesystemslib.formats.PEMRSA_SCHEMA' and have the form:
'-----BEGIN RSA PUBLIC KEY----- ...'
or
... | python | def generate_rsa_public_and_private(bits=_DEFAULT_RSA_KEY_BITS):
"""
<Purpose>
Generate public and private RSA keys with modulus length 'bits'. The
public and private keys returned conform to
'securesystemslib.formats.PEMRSA_SCHEMA' and have the form:
'-----BEGIN RSA PUBLIC KEY----- ...'
or
... | [
"def",
"generate_rsa_public_and_private",
"(",
"bits",
"=",
"_DEFAULT_RSA_KEY_BITS",
")",
":",
"# Does 'bits' have the correct format?",
"# This check will ensure 'bits' conforms to",
"# 'securesystemslib.formats.RSAKEYBITS_SCHEMA'. 'bits' must be an integer",
"# object, with a minimum value ... | <Purpose>
Generate public and private RSA keys with modulus length 'bits'. The
public and private keys returned conform to
'securesystemslib.formats.PEMRSA_SCHEMA' and have the form:
'-----BEGIN RSA PUBLIC KEY----- ...'
or
'-----BEGIN RSA PRIVATE KEY----- ...'
The public and private key... | [
"<Purpose",
">",
"Generate",
"public",
"and",
"private",
"RSA",
"keys",
"with",
"modulus",
"length",
"bits",
".",
"The",
"public",
"and",
"private",
"keys",
"returned",
"conform",
"to",
"securesystemslib",
".",
"formats",
".",
"PEMRSA_SCHEMA",
"and",
"have",
"... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/pyca_crypto_keys.py#L160-L229 |
secure-systems-lab/securesystemslib | securesystemslib/pyca_crypto_keys.py | create_rsa_signature | def create_rsa_signature(private_key, data, scheme='rsassa-pss-sha256'):
"""
<Purpose>
Generate a 'scheme' signature. The signature, and the signature scheme
used, is returned as a (signature, scheme) tuple.
The signing process will use 'private_key' to generate the signature of
'data'.
RFC34... | python | def create_rsa_signature(private_key, data, scheme='rsassa-pss-sha256'):
"""
<Purpose>
Generate a 'scheme' signature. The signature, and the signature scheme
used, is returned as a (signature, scheme) tuple.
The signing process will use 'private_key' to generate the signature of
'data'.
RFC34... | [
"def",
"create_rsa_signature",
"(",
"private_key",
",",
"data",
",",
"scheme",
"=",
"'rsassa-pss-sha256'",
")",
":",
"# Does the arguments have the correct format?",
"# If not, raise 'securesystemslib.exceptions.FormatError' if any of the",
"# checks fail.",
"securesystemslib",
".",
... | <Purpose>
Generate a 'scheme' signature. The signature, and the signature scheme
used, is returned as a (signature, scheme) tuple.
The signing process will use 'private_key' to generate the signature of
'data'.
RFC3447 - RSASSA-PSS
http://www.ietf.org/rfc/rfc3447.txt
>>> public, private ... | [
"<Purpose",
">",
"Generate",
"a",
"scheme",
"signature",
".",
"The",
"signature",
"and",
"the",
"signature",
"scheme",
"used",
"is",
"returned",
"as",
"a",
"(",
"signature",
"scheme",
")",
"tuple",
"."
] | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/pyca_crypto_keys.py#L235-L354 |
secure-systems-lab/securesystemslib | securesystemslib/pyca_crypto_keys.py | verify_rsa_signature | def verify_rsa_signature(signature, signature_scheme, public_key, data):
"""
<Purpose>
Determine whether the corresponding private key of 'public_key' produced
'signature'. verify_signature() will use the public key, signature scheme,
and 'data' to complete the verification.
>>> public, private = ... | python | def verify_rsa_signature(signature, signature_scheme, public_key, data):
"""
<Purpose>
Determine whether the corresponding private key of 'public_key' produced
'signature'. verify_signature() will use the public key, signature scheme,
and 'data' to complete the verification.
>>> public, private = ... | [
"def",
"verify_rsa_signature",
"(",
"signature",
",",
"signature_scheme",
",",
"public_key",
",",
"data",
")",
":",
"# Does 'public_key' have the correct format?",
"# This check will ensure 'public_key' conforms to",
"# 'securesystemslib.formats.PEMRSA_SCHEMA'. Raise",
"# 'securesyste... | <Purpose>
Determine whether the corresponding private key of 'public_key' produced
'signature'. verify_signature() will use the public key, signature scheme,
and 'data' to complete the verification.
>>> public, private = generate_rsa_public_and_private(2048)
>>> data = b'The quick brown fox jumps ... | [
"<Purpose",
">",
"Determine",
"whether",
"the",
"corresponding",
"private",
"key",
"of",
"public_key",
"produced",
"signature",
".",
"verify_signature",
"()",
"will",
"use",
"the",
"public",
"key",
"signature",
"scheme",
"and",
"data",
"to",
"complete",
"the",
"... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/pyca_crypto_keys.py#L360-L452 |
secure-systems-lab/securesystemslib | securesystemslib/pyca_crypto_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",
")",
":",
"# This check will ensure 'private_key' has the appropriate number",
"# of objects and object types, and that all dict keys are properly named.",
"# Raise 'securesystemslib.exceptions.FormatError' if the check fa... | <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",
... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/pyca_crypto_keys.py#L455-L522 |
secure-systems-lab/securesystemslib | securesystemslib/pyca_crypto_keys.py | create_rsa_public_and_private_from_pem | def create_rsa_public_and_private_from_pem(pem, passphrase=None):
"""
<Purpose>
Generate public and private RSA keys from an optionally encrypted PEM. The
public and private keys returned conform to
'securesystemslib.formats.PEMRSA_SCHEMA' and have the form:
'-----BEGIN RSA PUBLIC KEY----- ... ---... | python | def create_rsa_public_and_private_from_pem(pem, passphrase=None):
"""
<Purpose>
Generate public and private RSA keys from an optionally encrypted PEM. The
public and private keys returned conform to
'securesystemslib.formats.PEMRSA_SCHEMA' and have the form:
'-----BEGIN RSA PUBLIC KEY----- ... ---... | [
"def",
"create_rsa_public_and_private_from_pem",
"(",
"pem",
",",
"passphrase",
"=",
"None",
")",
":",
"# Does 'encryped_pem' have the correct format?",
"# This check will ensure 'pem' has the appropriate number",
"# of objects and object types, and that all dict keys are properly named.",
... | <Purpose>
Generate public and private RSA keys from an optionally encrypted PEM. The
public and private keys returned conform to
'securesystemslib.formats.PEMRSA_SCHEMA' and have the form:
'-----BEGIN RSA PUBLIC KEY----- ... -----END RSA PUBLIC KEY-----'
and
'-----BEGIN RSA PRIVATE KEY----- ... | [
"<Purpose",
">",
"Generate",
"public",
"and",
"private",
"RSA",
"keys",
"from",
"an",
"optionally",
"encrypted",
"PEM",
".",
"The",
"public",
"and",
"private",
"keys",
"returned",
"conform",
"to",
"securesystemslib",
".",
"formats",
".",
"PEMRSA_SCHEMA",
"and",
... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/pyca_crypto_keys.py#L528-L643 |
secure-systems-lab/securesystemslib | securesystemslib/pyca_crypto_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 TUF... | 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 TUF... | [
"def",
"encrypt_key",
"(",
"key_object",
",",
"password",
")",
":",
"# Do the arguments have the correct format?",
"# Ensure the arguments have the appropriate number of objects and object",
"# types, and that all dict keys are properly named.",
"# Raise 'securesystemslib.exceptions.FormatErro... | <Purpose>
Return a string containing 'key_object' in encrypted form. Encrypted
strings may be safely saved to a file. The corresponding decrypt_key()
function can be applied to the encrypted string to restore the original key
object. 'key_object' is a TUF key (e.g., RSAKEY_SCHEMA,
ED25519KEY_SCHEM... | [
"<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... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/pyca_crypto_keys.py#L649-L739 |
secure-systems-lab/securesystemslib | securesystemslib/pyca_crypto_keys.py | decrypt_key | def decrypt_key(encrypted_key, password):
"""
<Purpose>
Return a string containing 'encrypted_key' in non-encrypted form.
The decrypt_key() function can be applied to the encrypted string to restore
the original key object, a TUF key (e.g., RSAKEY_SCHEMA, ED25519KEY_SCHEMA).
This function calls the ... | python | def decrypt_key(encrypted_key, password):
"""
<Purpose>
Return a string containing 'encrypted_key' in non-encrypted form.
The decrypt_key() function can be applied to the encrypted string to restore
the original key object, a TUF key (e.g., RSAKEY_SCHEMA, ED25519KEY_SCHEMA).
This function calls the ... | [
"def",
"decrypt_key",
"(",
"encrypted_key",
",",
"password",
")",
":",
"# Do the arguments have the correct format?",
"# Ensure the arguments have the appropriate number of objects and object",
"# types, and that all dict keys are properly named.",
"# Raise 'securesystemslib.exceptions.FormatE... | <Purpose>
Return a string containing 'encrypted_key' in non-encrypted form.
The decrypt_key() function can be applied to the encrypted string to restore
the original key object, a TUF key (e.g., RSAKEY_SCHEMA, ED25519KEY_SCHEMA).
This function calls the appropriate cryptography module (i.e.,
pyca_cr... | [
"<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",
... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/pyca_crypto_keys.py#L745-L827 |
secure-systems-lab/securesystemslib | securesystemslib/pyca_crypto_keys.py | _generate_derived_key | def _generate_derived_key(password, salt=None, iterations=None):
"""
Generate a derived key by feeding 'password' to the Password-Based Key
Derivation Function (PBKDF2). pyca/cryptography's PBKDF2 implementation is
used in this module. 'salt' may be specified so that a previous derived key
may be regenerate... | python | def _generate_derived_key(password, salt=None, iterations=None):
"""
Generate a derived key by feeding 'password' to the Password-Based Key
Derivation Function (PBKDF2). pyca/cryptography's PBKDF2 implementation is
used in this module. 'salt' may be specified so that a previous derived key
may be regenerate... | [
"def",
"_generate_derived_key",
"(",
"password",
",",
"salt",
"=",
"None",
",",
"iterations",
"=",
"None",
")",
":",
"# Use pyca/cryptography's default backend (e.g., openSSL, CommonCrypto, etc.)",
"# The default backend is not fixed and can be changed by pyca/cryptography",
"# over ... | Generate a derived key by feeding 'password' to the Password-Based Key
Derivation Function (PBKDF2). pyca/cryptography's PBKDF2 implementation is
used in this module. 'salt' may be specified so that a previous derived key
may be regenerated, otherwise '_SALT_SIZE' is used by default. 'iterations'
is the numb... | [
"Generate",
"a",
"derived",
"key",
"by",
"feeding",
"password",
"to",
"the",
"Password",
"-",
"Based",
"Key",
"Derivation",
"Function",
"(",
"PBKDF2",
")",
".",
"pyca",
"/",
"cryptography",
"s",
"PBKDF2",
"implementation",
"is",
"used",
"in",
"this",
"module... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/pyca_crypto_keys.py#L833-L864 |
secure-systems-lab/securesystemslib | securesystemslib/pyca_crypto_keys.py | _encrypt | def _encrypt(key_data, derived_key_information):
"""
Encrypt 'key_data' using the Advanced Encryption Standard (AES-256) algorithm.
'derived_key_information' should contain a key strengthened by PBKDF2. The
key size is 256 bits and AES's mode of operation is set to CTR (CounTeR Mode).
The HMAC of the ciphert... | python | def _encrypt(key_data, derived_key_information):
"""
Encrypt 'key_data' using the Advanced Encryption Standard (AES-256) algorithm.
'derived_key_information' should contain a key strengthened by PBKDF2. The
key size is 256 bits and AES's mode of operation is set to CTR (CounTeR Mode).
The HMAC of the ciphert... | [
"def",
"_encrypt",
"(",
"key_data",
",",
"derived_key_information",
")",
":",
"# Generate a random Initialization Vector (IV). Follow the provably secure",
"# encrypt-then-MAC approach, which affords the ability to verify ciphertext",
"# without needing to decrypt it and preventing an attacker ... | Encrypt 'key_data' using the Advanced Encryption Standard (AES-256) algorithm.
'derived_key_information' should contain a key strengthened by PBKDF2. The
key size is 256 bits and AES's mode of operation is set to CTR (CounTeR Mode).
The HMAC of the ciphertext is generated to ensure the ciphertext has not been
... | [
"Encrypt",
"key_data",
"using",
"the",
"Advanced",
"Encryption",
"Standard",
"(",
"AES",
"-",
"256",
")",
"algorithm",
".",
"derived_key_information",
"should",
"contain",
"a",
"key",
"strengthened",
"by",
"PBKDF2",
".",
"The",
"key",
"size",
"is",
"256",
"bit... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/pyca_crypto_keys.py#L870-L939 |
secure-systems-lab/securesystemslib | securesystemslib/pyca_crypto_keys.py | _decrypt | def _decrypt(file_contents, password):
"""
The corresponding decryption routine for _encrypt().
'securesystemslib.exceptions.CryptoError' raised if the decryption fails.
"""
# Extract the salt, iterations, hmac, initialization vector, and ciphertext
# from 'file_contents'. These five values are delimited... | python | def _decrypt(file_contents, password):
"""
The corresponding decryption routine for _encrypt().
'securesystemslib.exceptions.CryptoError' raised if the decryption fails.
"""
# Extract the salt, iterations, hmac, initialization vector, and ciphertext
# from 'file_contents'. These five values are delimited... | [
"def",
"_decrypt",
"(",
"file_contents",
",",
"password",
")",
":",
"# Extract the salt, iterations, hmac, initialization vector, and ciphertext",
"# from 'file_contents'. These five values are delimited by",
"# '_ENCRYPTION_DELIMITER'. This delimiter is arbitrarily chosen and should",
"# no... | The corresponding decryption routine for _encrypt().
'securesystemslib.exceptions.CryptoError' raised if the decryption fails. | [
"The",
"corresponding",
"decryption",
"routine",
"for",
"_encrypt",
"()",
"."
] | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/pyca_crypto_keys.py#L945-L999 |
Tristramg/mumoro | virtualenv.py | create_environment | def create_environment(home_dir, site_packages=True, clear=False,
unzip_setuptools=False, use_distribute=False):
"""
Creates a new environment in ``home_dir``.
If ``site_packages`` is true (the default) then the global
``site-packages/`` directory will be on the path.
If ``c... | python | def create_environment(home_dir, site_packages=True, clear=False,
unzip_setuptools=False, use_distribute=False):
"""
Creates a new environment in ``home_dir``.
If ``site_packages`` is true (the default) then the global
``site-packages/`` directory will be on the path.
If ``c... | [
"def",
"create_environment",
"(",
"home_dir",
",",
"site_packages",
"=",
"True",
",",
"clear",
"=",
"False",
",",
"unzip_setuptools",
"=",
"False",
",",
"use_distribute",
"=",
"False",
")",
":",
"home_dir",
",",
"lib_dir",
",",
"inc_dir",
",",
"bin_dir",
"="... | Creates a new environment in ``home_dir``.
If ``site_packages`` is true (the default) then the global
``site-packages/`` directory will be on the path.
If ``clear`` is true (default False) then the environment will
first be cleared. | [
"Creates",
"a",
"new",
"environment",
"in",
"home_dir",
"."
] | train | https://github.com/Tristramg/mumoro/blob/e37d6ddb72fd23fb485c80fd8a5cda520ca08187/virtualenv.py#L594-L620 |
Tristramg/mumoro | virtualenv.py | path_locations | def path_locations(home_dir):
"""Return the path locations for the environment (where libraries are,
where scripts go, etc)"""
# XXX: We'd use distutils.sysconfig.get_python_inc/lib but its
# prefix arg is broken: http://bugs.python.org/issue3386
if sys.platform == 'win32':
# Windows has lot... | python | def path_locations(home_dir):
"""Return the path locations for the environment (where libraries are,
where scripts go, etc)"""
# XXX: We'd use distutils.sysconfig.get_python_inc/lib but its
# prefix arg is broken: http://bugs.python.org/issue3386
if sys.platform == 'win32':
# Windows has lot... | [
"def",
"path_locations",
"(",
"home_dir",
")",
":",
"# XXX: We'd use distutils.sysconfig.get_python_inc/lib but its",
"# prefix arg is broken: http://bugs.python.org/issue3386",
"if",
"sys",
".",
"platform",
"==",
"'win32'",
":",
"# Windows has lots of problems with executables with sp... | Return the path locations for the environment (where libraries are,
where scripts go, etc) | [
"Return",
"the",
"path",
"locations",
"for",
"the",
"environment",
"(",
"where",
"libraries",
"are",
"where",
"scripts",
"go",
"etc",
")"
] | train | https://github.com/Tristramg/mumoro/blob/e37d6ddb72fd23fb485c80fd8a5cda520ca08187/virtualenv.py#L622-L652 |
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"
] | train | https://github.com/Tristramg/mumoro/blob/e37d6ddb72fd23fb485c80fd8a5cda520ca08187/virtualenv.py#L654-L857 |
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... | train | https://github.com/Tristramg/mumoro/blob/e37d6ddb72fd23fb485c80fd8a5cda520ca08187/virtualenv.py#L885-L899 |
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"
] | train | https://github.com/Tristramg/mumoro/blob/e37d6ddb72fd23fb485c80fd8a5cda520ca08187/virtualenv.py#L901-L914 |
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",
"."
] | train | https://github.com/Tristramg/mumoro/blob/e37d6ddb72fd23fb485c80fd8a5cda520ca08187/virtualenv.py#L919-L930 |
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",... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L127-L230 |
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... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L236-L315 |
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",... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L321-L394 |
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",
":"
] | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L400-L490 |
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... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L496-L582 |
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",
"."
] | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L586-L606 |
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",
":",
"...",
"}",
"."
] | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L612-L738 |
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",... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L744-L882 |
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... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L888-L991 |
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"... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L997-L1081 |
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",
... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1170-L1254 |
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... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1260-L1326 |
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",
... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1332-L1407 |
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",
... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1413-L1474 |
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",
":"
] | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1479-L1525 |
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",
":"
] | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1530-L1588 |
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",
... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1637-L1735 |
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... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1741-L1830 |
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... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L1836-L1908 |
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",
")"
] | train | https://github.com/boolangery/py-lua-parser/blob/578f2bf75f6f84c4b52c2affba56a4ec569d7ce7/luaparser/builder.py#L793-L815 |
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"
] | train | https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/common.py#L92-L115 |
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"
] | train | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos_obj_override/ilensdataeditor_methods.py#L21-L33 |
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",
")"... | train | https://github.com/NetworkEng/fping.py/blob/991507889561aa6eb9ee2ad821adf460883a9c5d/fping/fping.py#L63-L196 |
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... | train | https://github.com/NetworkEng/fping.py/blob/991507889561aa6eb9ee2ad821adf460883a9c5d/fping/fping.py#L199-L211 |
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... | train | https://github.com/NetworkEng/fping.py/blob/991507889561aa6eb9ee2ad821adf460883a9c5d/fping/fping.py#L214-L225 |
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",
... | train | https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/writers/root_writer.py#L405-L425 |
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",
":... | train | https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/writers/root_writer.py#L427-L457 |
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",
")",
"..."
] | train | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L1577-L1585 |
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",
"."
] | train | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L1588-L1606 |
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",
"."
] | train | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L2163-L2196 |
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",
"."
] | train | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L2700-L2724 |
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",
"."
] | train | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L2728-L2754 |
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",
"."
] | train | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L2758-L2784 |
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",
"."
] | train | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L2788-L2814 |
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",
"."
] | train | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L2818-L2852 |
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",
"."
] | train | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L2856-L2884 |
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",
"."
] | train | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L2888-L2916 |
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",
"."
] | train | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L3081-L3102 |
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",
"."
] | train | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L3198-L3232 |
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",
"."
] | train | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L3235-L3285 |
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",
")",
"."
] | train | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L3289-L3306 |
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",
"."
] | train | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L3310-L3344 |
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",
"."
] | train | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L115-L124 |
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",
"."
] | train | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L175-L204 |
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",
"."
] | train | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L222-L232 |
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",
"."
] | train | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L253-L278 |
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",
"."
] | train | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L324-L334 |
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",
"."
] | train | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L1347-L1380 |
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",
"."
] | train | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L1382-L1421 |
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",
"."
] | train | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L1635-L1667 |
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",
"."
] | train | https://github.com/SciTools/biggus/blob/0a76fbe7806dd6295081cd399bcb76135d834d25/biggus/_init.py#L2254-L2268 |
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",
"."
] | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/_vendor/ed25519/ed25519.py#L181-L193 |
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",
"."
] | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/_vendor/ed25519/ed25519.py#L220-L229 |
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",
... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/ed25519_keys.py#L119-L177 |
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... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/ed25519_keys.py#L183-L283 |
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",... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/ed25519_keys.py#L289-L404 |
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",
")"
] | train | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L53-L65 |
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"
] | train | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L80-L103 |
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"
] | train | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L105-L121 |
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"
] | train | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L123-L126 |
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"
] | train | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L128-L133 |
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"
] | train | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L152-L158 |
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"
] | train | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L164-L175 |
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"
] | train | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L177-L189 |
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"
] | train | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L196-L200 |
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"
] | train | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L323-L329 |
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"
] | train | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L331-L335 |
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"
] | train | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L337-L341 |
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",
"."
] | train | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L344-L361 |
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"
] | train | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L363-L369 |
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"
] | train | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L378-L387 |
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"
] | train | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L396-L414 |
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"
] | train | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L416-L499 |
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... | train | https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/formats.py#L533-L568 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.