repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
Yubico/python-pyhsm | pyhsm/ksm/yubikey_ksm.py | YHSM_KSMRequestHandler.decrypt_yubikey_otp | def decrypt_yubikey_otp(self, from_key):
"""
Try to decrypt a YubiKey OTP.
Returns a string starting with either 'OK' or 'ERR' :
'OK counter=ab12 low=dd34 high=2a use=0a'
'ERR Unknown public_id'
on YubiHSM errors (or bad OTP), only 'ERR' is returned.
"""
... | python | def decrypt_yubikey_otp(self, from_key):
"""
Try to decrypt a YubiKey OTP.
Returns a string starting with either 'OK' or 'ERR' :
'OK counter=ab12 low=dd34 high=2a use=0a'
'ERR Unknown public_id'
on YubiHSM errors (or bad OTP), only 'ERR' is returned.
"""
... | [
"def",
"decrypt_yubikey_otp",
"(",
"self",
",",
"from_key",
")",
":",
"if",
"not",
"re",
".",
"match",
"(",
"valid_input_from_key",
",",
"from_key",
")",
":",
"self",
".",
"log_error",
"(",
"\"IN: %s, Invalid OTP\"",
"%",
"(",
"from_key",
")",
")",
"if",
"... | Try to decrypt a YubiKey OTP.
Returns a string starting with either 'OK' or 'ERR' :
'OK counter=ab12 low=dd34 high=2a use=0a'
'ERR Unknown public_id'
on YubiHSM errors (or bad OTP), only 'ERR' is returned. | [
"Try",
"to",
"decrypt",
"a",
"YubiKey",
"OTP",
"."
] | b6e2744d1ea15c352a0fc1d6ebc5950026b71311 | https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/ksm/yubikey_ksm.py#L118-L162 | train |
Yubico/python-pyhsm | pyhsm/ksm/yubikey_ksm.py | YHSM_KSMRequestHandler.my_address_string | def my_address_string(self):
""" For logging client host without resolving. """
addr = getattr(self, 'client_address', ('', None))[0]
# If listed in proxy_ips, use the X-Forwarded-For header, if present.
if addr in self.proxy_ips:
return self.headers.getheader('x-forwarded-f... | python | def my_address_string(self):
""" For logging client host without resolving. """
addr = getattr(self, 'client_address', ('', None))[0]
# If listed in proxy_ips, use the X-Forwarded-For header, if present.
if addr in self.proxy_ips:
return self.headers.getheader('x-forwarded-f... | [
"def",
"my_address_string",
"(",
"self",
")",
":",
"addr",
"=",
"getattr",
"(",
"self",
",",
"'client_address'",
",",
"(",
"''",
",",
"None",
")",
")",
"[",
"0",
"]",
"# If listed in proxy_ips, use the X-Forwarded-For header, if present.",
"if",
"addr",
"in",
"s... | For logging client host without resolving. | [
"For",
"logging",
"client",
"host",
"without",
"resolving",
"."
] | b6e2744d1ea15c352a0fc1d6ebc5950026b71311 | https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/ksm/yubikey_ksm.py#L174-L181 | train |
Yubico/python-pyhsm | pyhsm/ksm/yubikey_ksm.py | SQLBackend.load_aead | def load_aead(self, public_id):
""" Loads AEAD from the specified database. """
connection = self.engine.connect()
trans = connection.begin()
try:
s = sqlalchemy.select([self.aead_table]).where(
(self.aead_table.c.public_id == public_id)
& sel... | python | def load_aead(self, public_id):
""" Loads AEAD from the specified database. """
connection = self.engine.connect()
trans = connection.begin()
try:
s = sqlalchemy.select([self.aead_table]).where(
(self.aead_table.c.public_id == public_id)
& sel... | [
"def",
"load_aead",
"(",
"self",
",",
"public_id",
")",
":",
"connection",
"=",
"self",
".",
"engine",
".",
"connect",
"(",
")",
"trans",
"=",
"connection",
".",
"begin",
"(",
")",
"try",
":",
"s",
"=",
"sqlalchemy",
".",
"select",
"(",
"[",
"self",
... | Loads AEAD from the specified database. | [
"Loads",
"AEAD",
"from",
"the",
"specified",
"database",
"."
] | b6e2744d1ea15c352a0fc1d6ebc5950026b71311 | https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/ksm/yubikey_ksm.py#L215-L236 | train |
Yubico/python-pyhsm | pyhsm/val/init_oath_token.py | generate_aead | def generate_aead(hsm, args):
""" Protect the oath-k in an AEAD. """
key = get_oath_k(args)
# Enabled flags 00010000 = YSM_HMAC_SHA1_GENERATE
flags = struct.pack("< I", 0x10000)
hsm.load_secret(key + flags)
nonce = hsm.get_nonce().nonce
aead = hsm.generate_aead(nonce, args.key_handle)
if... | python | def generate_aead(hsm, args):
""" Protect the oath-k in an AEAD. """
key = get_oath_k(args)
# Enabled flags 00010000 = YSM_HMAC_SHA1_GENERATE
flags = struct.pack("< I", 0x10000)
hsm.load_secret(key + flags)
nonce = hsm.get_nonce().nonce
aead = hsm.generate_aead(nonce, args.key_handle)
if... | [
"def",
"generate_aead",
"(",
"hsm",
",",
"args",
")",
":",
"key",
"=",
"get_oath_k",
"(",
"args",
")",
"# Enabled flags 00010000 = YSM_HMAC_SHA1_GENERATE",
"flags",
"=",
"struct",
".",
"pack",
"(",
"\"< I\"",
",",
"0x10000",
")",
"hsm",
".",
"load_secret",
"("... | Protect the oath-k in an AEAD. | [
"Protect",
"the",
"oath",
"-",
"k",
"in",
"an",
"AEAD",
"."
] | b6e2744d1ea15c352a0fc1d6ebc5950026b71311 | https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/val/init_oath_token.py#L105-L115 | train |
Yubico/python-pyhsm | pyhsm/val/init_oath_token.py | store_oath_entry | def store_oath_entry(args, nonce, aead, oath_c):
""" Store the AEAD in the database. """
data = {"key": args.uid,
"aead": aead.data.encode('hex'),
"nonce": nonce.encode('hex'),
"key_handle": args.key_handle,
"oath_C": oath_c,
"oath_T": None,
... | python | def store_oath_entry(args, nonce, aead, oath_c):
""" Store the AEAD in the database. """
data = {"key": args.uid,
"aead": aead.data.encode('hex'),
"nonce": nonce.encode('hex'),
"key_handle": args.key_handle,
"oath_C": oath_c,
"oath_T": None,
... | [
"def",
"store_oath_entry",
"(",
"args",
",",
"nonce",
",",
"aead",
",",
"oath_c",
")",
":",
"data",
"=",
"{",
"\"key\"",
":",
"args",
".",
"uid",
",",
"\"aead\"",
":",
"aead",
".",
"data",
".",
"encode",
"(",
"'hex'",
")",
",",
"\"nonce\"",
":",
"n... | Store the AEAD in the database. | [
"Store",
"the",
"AEAD",
"in",
"the",
"database",
"."
] | b6e2744d1ea15c352a0fc1d6ebc5950026b71311 | https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/val/init_oath_token.py#L185-L203 | train |
Yubico/python-pyhsm | pyhsm/val/init_oath_token.py | ValOathDb.add | def add(self, entry):
""" Add entry to database. """
c = self.conn.cursor()
c.execute("INSERT INTO oath (key, aead, nonce, key_handle, oath_C, oath_T) VALUES (?, ?, ?, ?, ?, ?)",
(entry.data["key"], \
entry.data["aead"], \
entry.dat... | python | def add(self, entry):
""" Add entry to database. """
c = self.conn.cursor()
c.execute("INSERT INTO oath (key, aead, nonce, key_handle, oath_C, oath_T) VALUES (?, ?, ?, ?, ?, ?)",
(entry.data["key"], \
entry.data["aead"], \
entry.dat... | [
"def",
"add",
"(",
"self",
",",
"entry",
")",
":",
"c",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"c",
".",
"execute",
"(",
"\"INSERT INTO oath (key, aead, nonce, key_handle, oath_C, oath_T) VALUES (?, ?, ?, ?, ?, ?)\"",
",",
"(",
"entry",
".",
"data",
... | Add entry to database. | [
"Add",
"entry",
"to",
"database",
"."
] | b6e2744d1ea15c352a0fc1d6ebc5950026b71311 | https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/val/init_oath_token.py#L161-L172 | train |
Yubico/python-pyhsm | pyhsm/val/init_oath_token.py | ValOathDb.delete | def delete(self, entry):
""" Delete entry from database. """
c = self.conn.cursor()
c.execute("DELETE FROM oath WHERE key = ?", (entry.data["key"],)) | python | def delete(self, entry):
""" Delete entry from database. """
c = self.conn.cursor()
c.execute("DELETE FROM oath WHERE key = ?", (entry.data["key"],)) | [
"def",
"delete",
"(",
"self",
",",
"entry",
")",
":",
"c",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"c",
".",
"execute",
"(",
"\"DELETE FROM oath WHERE key = ?\"",
",",
"(",
"entry",
".",
"data",
"[",
"\"key\"",
"]",
",",
")",
")"
] | Delete entry from database. | [
"Delete",
"entry",
"from",
"database",
"."
] | b6e2744d1ea15c352a0fc1d6ebc5950026b71311 | https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/val/init_oath_token.py#L174-L177 | train |
Yubico/python-pyhsm | pyhsm/aead_cmd.py | YHSM_AEAD_Cmd.parse_result | def parse_result(self, data):
"""
Returns a YHSM_GeneratedAEAD instance, or throws pyhsm.exception.YHSM_CommandFailed.
"""
# typedef struct {
# uint8_t nonce[YSM_AEAD_NONCE_SIZE]; // Nonce (publicId for Yubikey AEADs)
# uint32_t keyHandle; // Key handl... | python | def parse_result(self, data):
"""
Returns a YHSM_GeneratedAEAD instance, or throws pyhsm.exception.YHSM_CommandFailed.
"""
# typedef struct {
# uint8_t nonce[YSM_AEAD_NONCE_SIZE]; // Nonce (publicId for Yubikey AEADs)
# uint32_t keyHandle; // Key handl... | [
"def",
"parse_result",
"(",
"self",
",",
"data",
")",
":",
"# typedef struct {",
"# uint8_t nonce[YSM_AEAD_NONCE_SIZE]; // Nonce (publicId for Yubikey AEADs)",
"# uint32_t keyHandle; // Key handle",
"# YSM_STATUS status; // Status",
"# uint8_t numByte... | Returns a YHSM_GeneratedAEAD instance, or throws pyhsm.exception.YHSM_CommandFailed. | [
"Returns",
"a",
"YHSM_GeneratedAEAD",
"instance",
"or",
"throws",
"pyhsm",
".",
"exception",
".",
"YHSM_CommandFailed",
"."
] | b6e2744d1ea15c352a0fc1d6ebc5950026b71311 | https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/aead_cmd.py#L58-L84 | train |
Yubico/python-pyhsm | pyhsm/aead_cmd.py | YHSM_GeneratedAEAD.save | def save(self, filename):
"""
Store AEAD in a file.
@param filename: File to create/overwrite
@type filename: string
"""
aead_f = open(filename, "wb")
fmt = "< B I %is %is" % (pyhsm.defines.YSM_AEAD_NONCE_SIZE, len(self.data))
version = 1
packed =... | python | def save(self, filename):
"""
Store AEAD in a file.
@param filename: File to create/overwrite
@type filename: string
"""
aead_f = open(filename, "wb")
fmt = "< B I %is %is" % (pyhsm.defines.YSM_AEAD_NONCE_SIZE, len(self.data))
version = 1
packed =... | [
"def",
"save",
"(",
"self",
",",
"filename",
")",
":",
"aead_f",
"=",
"open",
"(",
"filename",
",",
"\"wb\"",
")",
"fmt",
"=",
"\"< B I %is %is\"",
"%",
"(",
"pyhsm",
".",
"defines",
".",
"YSM_AEAD_NONCE_SIZE",
",",
"len",
"(",
"self",
".",
"data",
")"... | Store AEAD in a file.
@param filename: File to create/overwrite
@type filename: string | [
"Store",
"AEAD",
"in",
"a",
"file",
"."
] | b6e2744d1ea15c352a0fc1d6ebc5950026b71311 | https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/aead_cmd.py#L214-L226 | train |
Yubico/python-pyhsm | pyhsm/aead_cmd.py | YHSM_GeneratedAEAD.load | def load(self, filename):
"""
Load AEAD from a file.
@param filename: File to read AEAD from
@type filename: string
"""
aead_f = open(filename, "rb")
buf = aead_f.read(1024)
if buf.startswith(YHSM_AEAD_CRLF_File_Marker):
buf = YHSM_AEAD_File_M... | python | def load(self, filename):
"""
Load AEAD from a file.
@param filename: File to read AEAD from
@type filename: string
"""
aead_f = open(filename, "rb")
buf = aead_f.read(1024)
if buf.startswith(YHSM_AEAD_CRLF_File_Marker):
buf = YHSM_AEAD_File_M... | [
"def",
"load",
"(",
"self",
",",
"filename",
")",
":",
"aead_f",
"=",
"open",
"(",
"filename",
",",
"\"rb\"",
")",
"buf",
"=",
"aead_f",
".",
"read",
"(",
"1024",
")",
"if",
"buf",
".",
"startswith",
"(",
"YHSM_AEAD_CRLF_File_Marker",
")",
":",
"buf",
... | Load AEAD from a file.
@param filename: File to read AEAD from
@type filename: string | [
"Load",
"AEAD",
"from",
"a",
"file",
"."
] | b6e2744d1ea15c352a0fc1d6ebc5950026b71311 | https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/aead_cmd.py#L228-L250 | train |
Yubico/python-pyhsm | pyhsm/aead_cmd.py | YHSM_YubiKeySecret.pack | def pack(self):
""" Return key and uid packed for sending in a command to the YubiHSM. """
# # 22-bytes Yubikey secrets block
# typedef struct {
# uint8_t key[KEY_SIZE]; // AES key
# uint8_t uid[UID_SIZE]; // Unique (secret) ID
# } YUBIKEY_SE... | python | def pack(self):
""" Return key and uid packed for sending in a command to the YubiHSM. """
# # 22-bytes Yubikey secrets block
# typedef struct {
# uint8_t key[KEY_SIZE]; // AES key
# uint8_t uid[UID_SIZE]; // Unique (secret) ID
# } YUBIKEY_SE... | [
"def",
"pack",
"(",
"self",
")",
":",
"# # 22-bytes Yubikey secrets block",
"# typedef struct {",
"# uint8_t key[KEY_SIZE]; // AES key",
"# uint8_t uid[UID_SIZE]; // Unique (secret) ID",
"# } YUBIKEY_SECRETS;",
"return",
"self",
".",
"key",
"+",
"self",
... | Return key and uid packed for sending in a command to the YubiHSM. | [
"Return",
"key",
"and",
"uid",
"packed",
"for",
"sending",
"in",
"a",
"command",
"to",
"the",
"YubiHSM",
"."
] | b6e2744d1ea15c352a0fc1d6ebc5950026b71311 | https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/aead_cmd.py#L258-L265 | train |
Yubico/python-pyhsm | pyhsm/val/validate_otp.py | validate_otp | def validate_otp(hsm, args):
"""
Validate an OTP.
"""
try:
res = pyhsm.yubikey.validate_otp(hsm, args.otp)
if args.verbose:
print "OK counter=%04x low=%04x high=%02x use=%02x" % \
(res.use_ctr, res.ts_low, res.ts_high, res.session_ctr)
return 0
exc... | python | def validate_otp(hsm, args):
"""
Validate an OTP.
"""
try:
res = pyhsm.yubikey.validate_otp(hsm, args.otp)
if args.verbose:
print "OK counter=%04x low=%04x high=%02x use=%02x" % \
(res.use_ctr, res.ts_low, res.ts_high, res.session_ctr)
return 0
exc... | [
"def",
"validate_otp",
"(",
"hsm",
",",
"args",
")",
":",
"try",
":",
"res",
"=",
"pyhsm",
".",
"yubikey",
".",
"validate_otp",
"(",
"hsm",
",",
"args",
".",
"otp",
")",
"if",
"args",
".",
"verbose",
":",
"print",
"\"OK counter=%04x low=%04x high=%02x use=... | Validate an OTP. | [
"Validate",
"an",
"OTP",
"."
] | b6e2744d1ea15c352a0fc1d6ebc5950026b71311 | https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/val/validate_otp.py#L61-L81 | train |
Yubico/python-pyhsm | pyhsm/oath_totp.py | search_for_oath_code | def search_for_oath_code(hsm, key_handle, nonce, aead, user_code, interval=30,
tolerance=0):
"""
Try to validate an OATH TOTP OTP generated by a token whose secret key is
available to the YubiHSM through the AEAD.
The parameter `aead' is either a string, or an instance of YHSM_... | python | def search_for_oath_code(hsm, key_handle, nonce, aead, user_code, interval=30,
tolerance=0):
"""
Try to validate an OATH TOTP OTP generated by a token whose secret key is
available to the YubiHSM through the AEAD.
The parameter `aead' is either a string, or an instance of YHSM_... | [
"def",
"search_for_oath_code",
"(",
"hsm",
",",
"key_handle",
",",
"nonce",
",",
"aead",
",",
"user_code",
",",
"interval",
"=",
"30",
",",
"tolerance",
"=",
"0",
")",
":",
"# timecounter is the lowest acceptable value based on tolerance",
"timecounter",
"=",
"timec... | Try to validate an OATH TOTP OTP generated by a token whose secret key is
available to the YubiHSM through the AEAD.
The parameter `aead' is either a string, or an instance of YHSM_GeneratedAEAD.
Returns timecounter value on successful auth, and None otherwise. | [
"Try",
"to",
"validate",
"an",
"OATH",
"TOTP",
"OTP",
"generated",
"by",
"a",
"token",
"whose",
"secret",
"key",
"is",
"available",
"to",
"the",
"YubiHSM",
"through",
"the",
"AEAD",
"."
] | b6e2744d1ea15c352a0fc1d6ebc5950026b71311 | https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/oath_totp.py#L21-L36 | train |
Yubico/python-pyhsm | pyhsm/oath_totp.py | timecode | def timecode(time_now, interval):
""" make integer and divide by time interval of valid OTP """
i = time.mktime(time_now.timetuple())
return int(i / interval) | python | def timecode(time_now, interval):
""" make integer and divide by time interval of valid OTP """
i = time.mktime(time_now.timetuple())
return int(i / interval) | [
"def",
"timecode",
"(",
"time_now",
",",
"interval",
")",
":",
"i",
"=",
"time",
".",
"mktime",
"(",
"time_now",
".",
"timetuple",
"(",
")",
")",
"return",
"int",
"(",
"i",
"/",
"interval",
")"
] | make integer and divide by time interval of valid OTP | [
"make",
"integer",
"and",
"divide",
"by",
"time",
"interval",
"of",
"valid",
"OTP"
] | b6e2744d1ea15c352a0fc1d6ebc5950026b71311 | https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/oath_totp.py#L39-L42 | train |
Yubico/python-pyhsm | pyhsm/soft_hsm.py | _xor_block | def _xor_block(a, b):
""" XOR two blocks of equal length. """
return ''.join([chr(ord(x) ^ ord(y)) for (x, y) in zip(a, b)]) | python | def _xor_block(a, b):
""" XOR two blocks of equal length. """
return ''.join([chr(ord(x) ^ ord(y)) for (x, y) in zip(a, b)]) | [
"def",
"_xor_block",
"(",
"a",
",",
"b",
")",
":",
"return",
"''",
".",
"join",
"(",
"[",
"chr",
"(",
"ord",
"(",
"x",
")",
"^",
"ord",
"(",
"y",
")",
")",
"for",
"(",
"x",
",",
"y",
")",
"in",
"zip",
"(",
"a",
",",
"b",
")",
"]",
")"
] | XOR two blocks of equal length. | [
"XOR",
"two",
"blocks",
"of",
"equal",
"length",
"."
] | b6e2744d1ea15c352a0fc1d6ebc5950026b71311 | https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/soft_hsm.py#L26-L28 | train |
Yubico/python-pyhsm | pyhsm/soft_hsm.py | crc16 | def crc16(data):
"""
Calculate an ISO13239 CRC checksum of the input buffer.
"""
m_crc = 0xffff
for this in data:
m_crc ^= ord(this)
for _ in range(8):
j = m_crc & 1
m_crc >>= 1
if j:
m_crc ^= 0x8408
return m_crc | python | def crc16(data):
"""
Calculate an ISO13239 CRC checksum of the input buffer.
"""
m_crc = 0xffff
for this in data:
m_crc ^= ord(this)
for _ in range(8):
j = m_crc & 1
m_crc >>= 1
if j:
m_crc ^= 0x8408
return m_crc | [
"def",
"crc16",
"(",
"data",
")",
":",
"m_crc",
"=",
"0xffff",
"for",
"this",
"in",
"data",
":",
"m_crc",
"^=",
"ord",
"(",
"this",
")",
"for",
"_",
"in",
"range",
"(",
"8",
")",
":",
"j",
"=",
"m_crc",
"&",
"1",
"m_crc",
">>=",
"1",
"if",
"j... | Calculate an ISO13239 CRC checksum of the input buffer. | [
"Calculate",
"an",
"ISO13239",
"CRC",
"checksum",
"of",
"the",
"input",
"buffer",
"."
] | b6e2744d1ea15c352a0fc1d6ebc5950026b71311 | https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/soft_hsm.py#L132-L144 | train |
Yubico/python-pyhsm | pyhsm/soft_hsm.py | _cbc_mac.finalize | def finalize(self, block):
"""
The final step of CBC-MAC encrypts before xor.
"""
t1 = self.mac_aes.encrypt(block)
t2 = _xor_block(self.mac, t1)
self.mac = t2 | python | def finalize(self, block):
"""
The final step of CBC-MAC encrypts before xor.
"""
t1 = self.mac_aes.encrypt(block)
t2 = _xor_block(self.mac, t1)
self.mac = t2 | [
"def",
"finalize",
"(",
"self",
",",
"block",
")",
":",
"t1",
"=",
"self",
".",
"mac_aes",
".",
"encrypt",
"(",
"block",
")",
"t2",
"=",
"_xor_block",
"(",
"self",
".",
"mac",
",",
"t1",
")",
"self",
".",
"mac",
"=",
"t2"
] | The final step of CBC-MAC encrypts before xor. | [
"The",
"final",
"step",
"of",
"CBC",
"-",
"MAC",
"encrypts",
"before",
"xor",
"."
] | b6e2744d1ea15c352a0fc1d6ebc5950026b71311 | https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/soft_hsm.py#L77-L83 | train |
Yubico/python-pyhsm | pyhsm/yubikey.py | validate_otp | def validate_otp(hsm, from_key):
"""
Try to validate an OTP from a YubiKey using the internal database
on the YubiHSM.
`from_key' is the modhex encoded string emitted when you press the
button on your YubiKey.
Will only return on succesfull validation. All failures will result
in an L{pyhs... | python | def validate_otp(hsm, from_key):
"""
Try to validate an OTP from a YubiKey using the internal database
on the YubiHSM.
`from_key' is the modhex encoded string emitted when you press the
button on your YubiKey.
Will only return on succesfull validation. All failures will result
in an L{pyhs... | [
"def",
"validate_otp",
"(",
"hsm",
",",
"from_key",
")",
":",
"public_id",
",",
"otp",
"=",
"split_id_otp",
"(",
"from_key",
")",
"return",
"hsm",
".",
"db_validate_yubikey_otp",
"(",
"modhex_decode",
"(",
"public_id",
")",
".",
"decode",
"(",
"'hex'",
")",
... | Try to validate an OTP from a YubiKey using the internal database
on the YubiHSM.
`from_key' is the modhex encoded string emitted when you press the
button on your YubiKey.
Will only return on succesfull validation. All failures will result
in an L{pyhsm.exception.YHSM_CommandFailed}.
@param ... | [
"Try",
"to",
"validate",
"an",
"OTP",
"from",
"a",
"YubiKey",
"using",
"the",
"internal",
"database",
"on",
"the",
"YubiHSM",
"."
] | b6e2744d1ea15c352a0fc1d6ebc5950026b71311 | https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/yubikey.py#L24-L48 | train |
Yubico/python-pyhsm | pyhsm/yubikey.py | validate_yubikey_with_aead | def validate_yubikey_with_aead(hsm, from_key, aead, key_handle):
"""
Try to validate an OTP from a YubiKey using the AEAD that can decrypt this YubiKey's
internal secret, using the key_handle for the AEAD.
`from_key' is the modhex encoded string emitted when you press the
button on your YubiKey.
... | python | def validate_yubikey_with_aead(hsm, from_key, aead, key_handle):
"""
Try to validate an OTP from a YubiKey using the AEAD that can decrypt this YubiKey's
internal secret, using the key_handle for the AEAD.
`from_key' is the modhex encoded string emitted when you press the
button on your YubiKey.
... | [
"def",
"validate_yubikey_with_aead",
"(",
"hsm",
",",
"from_key",
",",
"aead",
",",
"key_handle",
")",
":",
"from_key",
"=",
"pyhsm",
".",
"util",
".",
"input_validate_str",
"(",
"from_key",
",",
"'from_key'",
",",
"max_len",
"=",
"48",
")",
"nonce",
"=",
... | Try to validate an OTP from a YubiKey using the AEAD that can decrypt this YubiKey's
internal secret, using the key_handle for the AEAD.
`from_key' is the modhex encoded string emitted when you press the
button on your YubiKey.
Will only return on succesfull validation. All failures will result
in... | [
"Try",
"to",
"validate",
"an",
"OTP",
"from",
"a",
"YubiKey",
"using",
"the",
"AEAD",
"that",
"can",
"decrypt",
"this",
"YubiKey",
"s",
"internal",
"secret",
"using",
"the",
"key_handle",
"for",
"the",
"AEAD",
"."
] | b6e2744d1ea15c352a0fc1d6ebc5950026b71311 | https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/yubikey.py#L50-L90 | train |
Yubico/python-pyhsm | pyhsm/yubikey.py | split_id_otp | def split_id_otp(from_key):
"""
Separate public id from OTP given a YubiKey OTP as input.
@param from_key: The OTP from a YubiKey (in modhex)
@type from_key: string
@returns: public_id and OTP
@rtype: tuple of string
"""
if len(from_key) > 32:
public_id, otp = from_key[:-32], f... | python | def split_id_otp(from_key):
"""
Separate public id from OTP given a YubiKey OTP as input.
@param from_key: The OTP from a YubiKey (in modhex)
@type from_key: string
@returns: public_id and OTP
@rtype: tuple of string
"""
if len(from_key) > 32:
public_id, otp = from_key[:-32], f... | [
"def",
"split_id_otp",
"(",
"from_key",
")",
":",
"if",
"len",
"(",
"from_key",
")",
">",
"32",
":",
"public_id",
",",
"otp",
"=",
"from_key",
"[",
":",
"-",
"32",
"]",
",",
"from_key",
"[",
"-",
"32",
":",
"]",
"elif",
"len",
"(",
"from_key",
")... | Separate public id from OTP given a YubiKey OTP as input.
@param from_key: The OTP from a YubiKey (in modhex)
@type from_key: string
@returns: public_id and OTP
@rtype: tuple of string | [
"Separate",
"public",
"id",
"from",
"OTP",
"given",
"a",
"YubiKey",
"OTP",
"as",
"input",
"."
] | b6e2744d1ea15c352a0fc1d6ebc5950026b71311 | https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/yubikey.py#L118-L136 | train |
Yubico/python-pyhsm | pyhsm/tools/keystore_unlock.py | get_password | def get_password(hsm, args):
""" Get password of correct length for this YubiHSM version. """
expected_len = 32
name = 'HSM password'
if hsm.version.have_key_store_decrypt():
expected_len = 64
name = 'master key'
if args.stdin:
password = sys.stdin.readline()
while p... | python | def get_password(hsm, args):
""" Get password of correct length for this YubiHSM version. """
expected_len = 32
name = 'HSM password'
if hsm.version.have_key_store_decrypt():
expected_len = 64
name = 'master key'
if args.stdin:
password = sys.stdin.readline()
while p... | [
"def",
"get_password",
"(",
"hsm",
",",
"args",
")",
":",
"expected_len",
"=",
"32",
"name",
"=",
"'HSM password'",
"if",
"hsm",
".",
"version",
".",
"have_key_store_decrypt",
"(",
")",
":",
"expected_len",
"=",
"64",
"name",
"=",
"'master key'",
"if",
"ar... | Get password of correct length for this YubiHSM version. | [
"Get",
"password",
"of",
"correct",
"length",
"for",
"this",
"YubiHSM",
"version",
"."
] | b6e2744d1ea15c352a0fc1d6ebc5950026b71311 | https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/tools/keystore_unlock.py#L56-L82 | train |
Yubico/python-pyhsm | pyhsm/tools/keystore_unlock.py | get_otp | def get_otp(hsm, args):
""" Get OTP from YubiKey. """
if args.no_otp:
return None
if hsm.version.have_unlock():
if args.stdin:
otp = sys.stdin.readline()
while otp and otp[-1] == '\n':
otp = otp[:-1]
else:
otp = raw_input('Enter adm... | python | def get_otp(hsm, args):
""" Get OTP from YubiKey. """
if args.no_otp:
return None
if hsm.version.have_unlock():
if args.stdin:
otp = sys.stdin.readline()
while otp and otp[-1] == '\n':
otp = otp[:-1]
else:
otp = raw_input('Enter adm... | [
"def",
"get_otp",
"(",
"hsm",
",",
"args",
")",
":",
"if",
"args",
".",
"no_otp",
":",
"return",
"None",
"if",
"hsm",
".",
"version",
".",
"have_unlock",
"(",
")",
":",
"if",
"args",
".",
"stdin",
":",
"otp",
"=",
"sys",
".",
"stdin",
".",
"readl... | Get OTP from YubiKey. | [
"Get",
"OTP",
"from",
"YubiKey",
"."
] | b6e2744d1ea15c352a0fc1d6ebc5950026b71311 | https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/tools/keystore_unlock.py#L84-L100 | train |
ResidentMario/geoplot | geoplot/crs.py | Base.load | def load(self, df, centerings):
"""
A moderately mind-bendy meta-method which abstracts the internals of individual projections' load procedures.
Parameters
----------
proj : geoplot.crs object instance
A disguised reference to ``self``.
df : GeoDataFrame
... | python | def load(self, df, centerings):
"""
A moderately mind-bendy meta-method which abstracts the internals of individual projections' load procedures.
Parameters
----------
proj : geoplot.crs object instance
A disguised reference to ``self``.
df : GeoDataFrame
... | [
"def",
"load",
"(",
"self",
",",
"df",
",",
"centerings",
")",
":",
"centering_variables",
"=",
"dict",
"(",
")",
"if",
"not",
"df",
".",
"empty",
"and",
"df",
".",
"geometry",
".",
"notna",
"(",
")",
".",
"any",
"(",
")",
":",
"for",
"key",
",",... | A moderately mind-bendy meta-method which abstracts the internals of individual projections' load procedures.
Parameters
----------
proj : geoplot.crs object instance
A disguised reference to ``self``.
df : GeoDataFrame
The GeoDataFrame which has been passed as i... | [
"A",
"moderately",
"mind",
"-",
"bendy",
"meta",
"-",
"method",
"which",
"abstracts",
"the",
"internals",
"of",
"individual",
"projections",
"load",
"procedures",
"."
] | 942b474878187a87a95a27fbe41285dfdc1d20ca | https://github.com/ResidentMario/geoplot/blob/942b474878187a87a95a27fbe41285dfdc1d20ca/geoplot/crs.py#L26-L62 | train |
ResidentMario/geoplot | geoplot/crs.py | Filtering.load | def load(self, df, centerings):
"""Call `load` method with `centerings` filtered to keys in `self.filter_`."""
return super().load(
df,
{key: value
for key, value in centerings.items()
if key in self.filter_}
) | python | def load(self, df, centerings):
"""Call `load` method with `centerings` filtered to keys in `self.filter_`."""
return super().load(
df,
{key: value
for key, value in centerings.items()
if key in self.filter_}
) | [
"def",
"load",
"(",
"self",
",",
"df",
",",
"centerings",
")",
":",
"return",
"super",
"(",
")",
".",
"load",
"(",
"df",
",",
"{",
"key",
":",
"value",
"for",
"key",
",",
"value",
"in",
"centerings",
".",
"items",
"(",
")",
"if",
"key",
"in",
"... | Call `load` method with `centerings` filtered to keys in `self.filter_`. | [
"Call",
"load",
"method",
"with",
"centerings",
"filtered",
"to",
"keys",
"in",
"self",
".",
"filter_",
"."
] | 942b474878187a87a95a27fbe41285dfdc1d20ca | https://github.com/ResidentMario/geoplot/blob/942b474878187a87a95a27fbe41285dfdc1d20ca/geoplot/crs.py#L99-L106 | train |
ResidentMario/geoplot | geoplot/utils.py | gaussian_points | def gaussian_points(loc=(0, 0), scale=(10, 10), n=100):
"""
Generates and returns `n` normally distributed points centered at `loc` with `scale` x and y directionality.
"""
arr = np.random.normal(loc, scale, (n, 2))
return gpd.GeoSeries([shapely.geometry.Point(x, y) for (x, y) in arr]) | python | def gaussian_points(loc=(0, 0), scale=(10, 10), n=100):
"""
Generates and returns `n` normally distributed points centered at `loc` with `scale` x and y directionality.
"""
arr = np.random.normal(loc, scale, (n, 2))
return gpd.GeoSeries([shapely.geometry.Point(x, y) for (x, y) in arr]) | [
"def",
"gaussian_points",
"(",
"loc",
"=",
"(",
"0",
",",
"0",
")",
",",
"scale",
"=",
"(",
"10",
",",
"10",
")",
",",
"n",
"=",
"100",
")",
":",
"arr",
"=",
"np",
".",
"random",
".",
"normal",
"(",
"loc",
",",
"scale",
",",
"(",
"n",
",",
... | Generates and returns `n` normally distributed points centered at `loc` with `scale` x and y directionality. | [
"Generates",
"and",
"returns",
"n",
"normally",
"distributed",
"points",
"centered",
"at",
"loc",
"with",
"scale",
"x",
"and",
"y",
"directionality",
"."
] | 942b474878187a87a95a27fbe41285dfdc1d20ca | https://github.com/ResidentMario/geoplot/blob/942b474878187a87a95a27fbe41285dfdc1d20ca/geoplot/utils.py#L14-L20 | train |
ResidentMario/geoplot | geoplot/utils.py | classify_clusters | def classify_clusters(points, n=10):
"""
Return an array of K-Means cluster classes for an array of `shapely.geometry.Point` objects.
"""
arr = [[p.x, p.y] for p in points.values]
clf = KMeans(n_clusters=n)
clf.fit(arr)
classes = clf.predict(arr)
return classes | python | def classify_clusters(points, n=10):
"""
Return an array of K-Means cluster classes for an array of `shapely.geometry.Point` objects.
"""
arr = [[p.x, p.y] for p in points.values]
clf = KMeans(n_clusters=n)
clf.fit(arr)
classes = clf.predict(arr)
return classes | [
"def",
"classify_clusters",
"(",
"points",
",",
"n",
"=",
"10",
")",
":",
"arr",
"=",
"[",
"[",
"p",
".",
"x",
",",
"p",
".",
"y",
"]",
"for",
"p",
"in",
"points",
".",
"values",
"]",
"clf",
"=",
"KMeans",
"(",
"n_clusters",
"=",
"n",
")",
"c... | Return an array of K-Means cluster classes for an array of `shapely.geometry.Point` objects. | [
"Return",
"an",
"array",
"of",
"K",
"-",
"Means",
"cluster",
"classes",
"for",
"an",
"array",
"of",
"shapely",
".",
"geometry",
".",
"Point",
"objects",
"."
] | 942b474878187a87a95a27fbe41285dfdc1d20ca | https://github.com/ResidentMario/geoplot/blob/942b474878187a87a95a27fbe41285dfdc1d20ca/geoplot/utils.py#L23-L31 | train |
ResidentMario/geoplot | geoplot/utils.py | gaussian_polygons | def gaussian_polygons(points, n=10):
"""
Returns an array of approximately `n` `shapely.geometry.Polygon` objects for an array of `shapely.geometry.Point`
objects.
"""
gdf = gpd.GeoDataFrame(data={'cluster_number': classify_clusters(points, n=n)}, geometry=points)
polygons = []
for i in rang... | python | def gaussian_polygons(points, n=10):
"""
Returns an array of approximately `n` `shapely.geometry.Polygon` objects for an array of `shapely.geometry.Point`
objects.
"""
gdf = gpd.GeoDataFrame(data={'cluster_number': classify_clusters(points, n=n)}, geometry=points)
polygons = []
for i in rang... | [
"def",
"gaussian_polygons",
"(",
"points",
",",
"n",
"=",
"10",
")",
":",
"gdf",
"=",
"gpd",
".",
"GeoDataFrame",
"(",
"data",
"=",
"{",
"'cluster_number'",
":",
"classify_clusters",
"(",
"points",
",",
"n",
"=",
"n",
")",
"}",
",",
"geometry",
"=",
... | Returns an array of approximately `n` `shapely.geometry.Polygon` objects for an array of `shapely.geometry.Point`
objects. | [
"Returns",
"an",
"array",
"of",
"approximately",
"n",
"shapely",
".",
"geometry",
".",
"Polygon",
"objects",
"for",
"an",
"array",
"of",
"shapely",
".",
"geometry",
".",
"Point",
"objects",
"."
] | 942b474878187a87a95a27fbe41285dfdc1d20ca | https://github.com/ResidentMario/geoplot/blob/942b474878187a87a95a27fbe41285dfdc1d20ca/geoplot/utils.py#L34-L46 | train |
ResidentMario/geoplot | geoplot/utils.py | gaussian_multi_polygons | def gaussian_multi_polygons(points, n=10):
"""
Returns an array of approximately `n` `shapely.geometry.MultiPolygon` objects for an array of
`shapely.geometry.Point` objects.
"""
polygons = gaussian_polygons(points, n*2)
# Randomly stitch them together.
polygon_pairs = [shapely.geometry.Mult... | python | def gaussian_multi_polygons(points, n=10):
"""
Returns an array of approximately `n` `shapely.geometry.MultiPolygon` objects for an array of
`shapely.geometry.Point` objects.
"""
polygons = gaussian_polygons(points, n*2)
# Randomly stitch them together.
polygon_pairs = [shapely.geometry.Mult... | [
"def",
"gaussian_multi_polygons",
"(",
"points",
",",
"n",
"=",
"10",
")",
":",
"polygons",
"=",
"gaussian_polygons",
"(",
"points",
",",
"n",
"*",
"2",
")",
"# Randomly stitch them together.",
"polygon_pairs",
"=",
"[",
"shapely",
".",
"geometry",
".",
"Multi... | Returns an array of approximately `n` `shapely.geometry.MultiPolygon` objects for an array of
`shapely.geometry.Point` objects. | [
"Returns",
"an",
"array",
"of",
"approximately",
"n",
"shapely",
".",
"geometry",
".",
"MultiPolygon",
"objects",
"for",
"an",
"array",
"of",
"shapely",
".",
"geometry",
".",
"Point",
"objects",
"."
] | 942b474878187a87a95a27fbe41285dfdc1d20ca | https://github.com/ResidentMario/geoplot/blob/942b474878187a87a95a27fbe41285dfdc1d20ca/geoplot/utils.py#L49-L57 | train |
ResidentMario/geoplot | geoplot/utils.py | uniform_random_global_points | def uniform_random_global_points(n=100):
"""
Returns an array of `n` uniformally distributed `shapely.geometry.Point` objects. Points are coordinates
distributed equivalently across the Earth's surface.
"""
xs = np.random.uniform(-180, 180, n)
ys = np.random.uniform(-90, 90, n)
return [shape... | python | def uniform_random_global_points(n=100):
"""
Returns an array of `n` uniformally distributed `shapely.geometry.Point` objects. Points are coordinates
distributed equivalently across the Earth's surface.
"""
xs = np.random.uniform(-180, 180, n)
ys = np.random.uniform(-90, 90, n)
return [shape... | [
"def",
"uniform_random_global_points",
"(",
"n",
"=",
"100",
")",
":",
"xs",
"=",
"np",
".",
"random",
".",
"uniform",
"(",
"-",
"180",
",",
"180",
",",
"n",
")",
"ys",
"=",
"np",
".",
"random",
".",
"uniform",
"(",
"-",
"90",
",",
"90",
",",
"... | Returns an array of `n` uniformally distributed `shapely.geometry.Point` objects. Points are coordinates
distributed equivalently across the Earth's surface. | [
"Returns",
"an",
"array",
"of",
"n",
"uniformally",
"distributed",
"shapely",
".",
"geometry",
".",
"Point",
"objects",
".",
"Points",
"are",
"coordinates",
"distributed",
"equivalently",
"across",
"the",
"Earth",
"s",
"surface",
"."
] | 942b474878187a87a95a27fbe41285dfdc1d20ca | https://github.com/ResidentMario/geoplot/blob/942b474878187a87a95a27fbe41285dfdc1d20ca/geoplot/utils.py#L60-L67 | train |
ResidentMario/geoplot | geoplot/utils.py | uniform_random_global_network | def uniform_random_global_network(loc=2000, scale=250, n=100):
"""
Returns an array of `n` uniformally randomly distributed `shapely.geometry.Point` objects.
"""
arr = (np.random.normal(loc, scale, n)).astype(int)
return pd.DataFrame(data={'mock_variable': arr,
'from': ... | python | def uniform_random_global_network(loc=2000, scale=250, n=100):
"""
Returns an array of `n` uniformally randomly distributed `shapely.geometry.Point` objects.
"""
arr = (np.random.normal(loc, scale, n)).astype(int)
return pd.DataFrame(data={'mock_variable': arr,
'from': ... | [
"def",
"uniform_random_global_network",
"(",
"loc",
"=",
"2000",
",",
"scale",
"=",
"250",
",",
"n",
"=",
"100",
")",
":",
"arr",
"=",
"(",
"np",
".",
"random",
".",
"normal",
"(",
"loc",
",",
"scale",
",",
"n",
")",
")",
".",
"astype",
"(",
"int... | Returns an array of `n` uniformally randomly distributed `shapely.geometry.Point` objects. | [
"Returns",
"an",
"array",
"of",
"n",
"uniformally",
"randomly",
"distributed",
"shapely",
".",
"geometry",
".",
"Point",
"objects",
"."
] | 942b474878187a87a95a27fbe41285dfdc1d20ca | https://github.com/ResidentMario/geoplot/blob/942b474878187a87a95a27fbe41285dfdc1d20ca/geoplot/utils.py#L70-L77 | train |
ResidentMario/geoplot | geoplot/quad.py | subpartition | def subpartition(quadtree, nmin, nmax):
"""
Recursive core of the ``QuadTree.partition`` method. Just five lines of code, amazingly.
Parameters
----------
quadtree : QuadTree object instance
The QuadTree object instance being partitioned.
nmin : int
The splitting threshold. If t... | python | def subpartition(quadtree, nmin, nmax):
"""
Recursive core of the ``QuadTree.partition`` method. Just five lines of code, amazingly.
Parameters
----------
quadtree : QuadTree object instance
The QuadTree object instance being partitioned.
nmin : int
The splitting threshold. If t... | [
"def",
"subpartition",
"(",
"quadtree",
",",
"nmin",
",",
"nmax",
")",
":",
"subtrees",
"=",
"quadtree",
".",
"split",
"(",
")",
"if",
"quadtree",
".",
"n",
">",
"nmax",
":",
"return",
"[",
"q",
".",
"partition",
"(",
"nmin",
",",
"nmax",
")",
"for... | Recursive core of the ``QuadTree.partition`` method. Just five lines of code, amazingly.
Parameters
----------
quadtree : QuadTree object instance
The QuadTree object instance being partitioned.
nmin : int
The splitting threshold. If this is not met this method will return a listing con... | [
"Recursive",
"core",
"of",
"the",
"QuadTree",
".",
"partition",
"method",
".",
"Just",
"five",
"lines",
"of",
"code",
"amazingly",
"."
] | 942b474878187a87a95a27fbe41285dfdc1d20ca | https://github.com/ResidentMario/geoplot/blob/942b474878187a87a95a27fbe41285dfdc1d20ca/geoplot/quad.py#L116-L138 | train |
ResidentMario/geoplot | geoplot/quad.py | QuadTree.split | def split(self):
"""
Splits the current QuadTree instance four ways through the midpoint.
Returns
-------
A list of four "sub" QuadTree instances, corresponding with the first, second, third, and fourth quartiles,
respectively.
"""
# TODO: Investigate why... | python | def split(self):
"""
Splits the current QuadTree instance four ways through the midpoint.
Returns
-------
A list of four "sub" QuadTree instances, corresponding with the first, second, third, and fourth quartiles,
respectively.
"""
# TODO: Investigate why... | [
"def",
"split",
"(",
"self",
")",
":",
"# TODO: Investigate why a small number of entries are lost every time this method is run.",
"min_x",
",",
"max_x",
",",
"min_y",
",",
"max_y",
"=",
"self",
".",
"bounds",
"mid_x",
",",
"mid_y",
"=",
"(",
"min_x",
"+",
"max_x",... | Splits the current QuadTree instance four ways through the midpoint.
Returns
-------
A list of four "sub" QuadTree instances, corresponding with the first, second, third, and fourth quartiles,
respectively. | [
"Splits",
"the",
"current",
"QuadTree",
"instance",
"four",
"ways",
"through",
"the",
"midpoint",
"."
] | 942b474878187a87a95a27fbe41285dfdc1d20ca | https://github.com/ResidentMario/geoplot/blob/942b474878187a87a95a27fbe41285dfdc1d20ca/geoplot/quad.py#L71-L88 | train |
ResidentMario/geoplot | geoplot/quad.py | QuadTree.partition | def partition(self, nmin, nmax):
"""
This method call decomposes a QuadTree instances into a list of sub- QuadTree instances which are the
smallest possible geospatial "buckets", given the current splitting rules, containing at least ``thresh``
points.
Parameters
-------... | python | def partition(self, nmin, nmax):
"""
This method call decomposes a QuadTree instances into a list of sub- QuadTree instances which are the
smallest possible geospatial "buckets", given the current splitting rules, containing at least ``thresh``
points.
Parameters
-------... | [
"def",
"partition",
"(",
"self",
",",
"nmin",
",",
"nmax",
")",
":",
"if",
"self",
".",
"n",
"<",
"nmin",
":",
"return",
"[",
"self",
"]",
"else",
":",
"ret",
"=",
"subpartition",
"(",
"self",
",",
"nmin",
",",
"nmax",
")",
"return",
"flatten",
"... | This method call decomposes a QuadTree instances into a list of sub- QuadTree instances which are the
smallest possible geospatial "buckets", given the current splitting rules, containing at least ``thresh``
points.
Parameters
----------
thresh : int
The minimum numb... | [
"This",
"method",
"call",
"decomposes",
"a",
"QuadTree",
"instances",
"into",
"a",
"list",
"of",
"sub",
"-",
"QuadTree",
"instances",
"which",
"are",
"the",
"smallest",
"possible",
"geospatial",
"buckets",
"given",
"the",
"current",
"splitting",
"rules",
"contai... | 942b474878187a87a95a27fbe41285dfdc1d20ca | https://github.com/ResidentMario/geoplot/blob/942b474878187a87a95a27fbe41285dfdc1d20ca/geoplot/quad.py#L90-L113 | train |
ResidentMario/geoplot | docs/examples/nyc-parking-tickets.py | plot_state_to_ax | def plot_state_to_ax(state, ax):
"""Reusable plotting wrapper."""
gplt.choropleth(tickets.set_index('id').loc[:, [state, 'geometry']],
hue=state,
projection=gcrs.AlbersEqualArea(), cmap='Blues',
linewidth=0.0, ax=ax)
gplt.polyplot(boroughs, project... | python | def plot_state_to_ax(state, ax):
"""Reusable plotting wrapper."""
gplt.choropleth(tickets.set_index('id').loc[:, [state, 'geometry']],
hue=state,
projection=gcrs.AlbersEqualArea(), cmap='Blues',
linewidth=0.0, ax=ax)
gplt.polyplot(boroughs, project... | [
"def",
"plot_state_to_ax",
"(",
"state",
",",
"ax",
")",
":",
"gplt",
".",
"choropleth",
"(",
"tickets",
".",
"set_index",
"(",
"'id'",
")",
".",
"loc",
"[",
":",
",",
"[",
"state",
",",
"'geometry'",
"]",
"]",
",",
"hue",
"=",
"state",
",",
"proje... | Reusable plotting wrapper. | [
"Reusable",
"plotting",
"wrapper",
"."
] | 942b474878187a87a95a27fbe41285dfdc1d20ca | https://github.com/ResidentMario/geoplot/blob/942b474878187a87a95a27fbe41285dfdc1d20ca/docs/examples/nyc-parking-tickets.py#L19-L25 | train |
ResidentMario/geoplot | geoplot/geoplot.py | polyplot | def polyplot(df, projection=None,
extent=None,
figsize=(8, 6), ax=None,
edgecolor='black',
facecolor='None', **kwargs):
"""
Trivial polygonal plot.
Parameters
----------
df : GeoDataFrame
The data being plotted.
projection : geoplot.cr... | python | def polyplot(df, projection=None,
extent=None,
figsize=(8, 6), ax=None,
edgecolor='black',
facecolor='None', **kwargs):
"""
Trivial polygonal plot.
Parameters
----------
df : GeoDataFrame
The data being plotted.
projection : geoplot.cr... | [
"def",
"polyplot",
"(",
"df",
",",
"projection",
"=",
"None",
",",
"extent",
"=",
"None",
",",
"figsize",
"=",
"(",
"8",
",",
"6",
")",
",",
"ax",
"=",
"None",
",",
"edgecolor",
"=",
"'black'",
",",
"facecolor",
"=",
"'None'",
",",
"*",
"*",
"kwa... | Trivial polygonal plot.
Parameters
----------
df : GeoDataFrame
The data being plotted.
projection : geoplot.crs object instance, optional
A geographic projection. For more information refer to `the tutorial page on projections
<https://nbviewer.jupyter.org/github/ResidentMario/... | [
"Trivial",
"polygonal",
"plot",
"."
] | 942b474878187a87a95a27fbe41285dfdc1d20ca | https://github.com/ResidentMario/geoplot/blob/942b474878187a87a95a27fbe41285dfdc1d20ca/geoplot/geoplot.py#L346-L462 | train |
ResidentMario/geoplot | geoplot/geoplot.py | choropleth | def choropleth(df, projection=None,
hue=None,
scheme=None, k=5, cmap='Set1', categorical=False, vmin=None, vmax=None,
legend=False, legend_kwargs=None, legend_labels=None,
extent=None,
figsize=(8, 6), ax=None,
**kwargs):
"""
... | python | def choropleth(df, projection=None,
hue=None,
scheme=None, k=5, cmap='Set1', categorical=False, vmin=None, vmax=None,
legend=False, legend_kwargs=None, legend_labels=None,
extent=None,
figsize=(8, 6), ax=None,
**kwargs):
"""
... | [
"def",
"choropleth",
"(",
"df",
",",
"projection",
"=",
"None",
",",
"hue",
"=",
"None",
",",
"scheme",
"=",
"None",
",",
"k",
"=",
"5",
",",
"cmap",
"=",
"'Set1'",
",",
"categorical",
"=",
"False",
",",
"vmin",
"=",
"None",
",",
"vmax",
"=",
"No... | Area aggregation plot.
Parameters
----------
df : GeoDataFrame
The data being plotted.
projection : geoplot.crs object instance, optional
A geographic projection. For more information refer to `the tutorial page on projections
<https://nbviewer.jupyter.org/github/ResidentMario/g... | [
"Area",
"aggregation",
"plot",
"."
] | 942b474878187a87a95a27fbe41285dfdc1d20ca | https://github.com/ResidentMario/geoplot/blob/942b474878187a87a95a27fbe41285dfdc1d20ca/geoplot/geoplot.py#L465-L687 | train |
ResidentMario/geoplot | geoplot/geoplot.py | _get_envelopes_min_maxes | def _get_envelopes_min_maxes(envelopes):
"""
Returns the extrema of the inputted polygonal envelopes. Used for setting chart extent where appropriate. Note
tha the ``Quadtree.bounds`` object property serves a similar role.
Parameters
----------
envelopes : GeoSeries
The envelopes of the... | python | def _get_envelopes_min_maxes(envelopes):
"""
Returns the extrema of the inputted polygonal envelopes. Used for setting chart extent where appropriate. Note
tha the ``Quadtree.bounds`` object property serves a similar role.
Parameters
----------
envelopes : GeoSeries
The envelopes of the... | [
"def",
"_get_envelopes_min_maxes",
"(",
"envelopes",
")",
":",
"xmin",
"=",
"np",
".",
"min",
"(",
"envelopes",
".",
"map",
"(",
"lambda",
"linearring",
":",
"np",
".",
"min",
"(",
"[",
"linearring",
".",
"coords",
"[",
"1",
"]",
"[",
"0",
"]",
",",
... | Returns the extrema of the inputted polygonal envelopes. Used for setting chart extent where appropriate. Note
tha the ``Quadtree.bounds`` object property serves a similar role.
Parameters
----------
envelopes : GeoSeries
The envelopes of the given geometries, as would be returned by e.g. ``dat... | [
"Returns",
"the",
"extrema",
"of",
"the",
"inputted",
"polygonal",
"envelopes",
".",
"Used",
"for",
"setting",
"chart",
"extent",
"where",
"appropriate",
".",
"Note",
"tha",
"the",
"Quadtree",
".",
"bounds",
"object",
"property",
"serves",
"a",
"similar",
"rol... | 942b474878187a87a95a27fbe41285dfdc1d20ca | https://github.com/ResidentMario/geoplot/blob/942b474878187a87a95a27fbe41285dfdc1d20ca/geoplot/geoplot.py#L2192-L2224 | train |
ResidentMario/geoplot | geoplot/geoplot.py | _get_envelopes_centroid | def _get_envelopes_centroid(envelopes):
"""
Returns the centroid of an inputted geometry column. Not currently in use, as this is now handled by this
library's CRS wrapper directly. Light wrapper over ``_get_envelopes_min_maxes``.
Parameters
----------
envelopes : GeoSeries
The envelope... | python | def _get_envelopes_centroid(envelopes):
"""
Returns the centroid of an inputted geometry column. Not currently in use, as this is now handled by this
library's CRS wrapper directly. Light wrapper over ``_get_envelopes_min_maxes``.
Parameters
----------
envelopes : GeoSeries
The envelope... | [
"def",
"_get_envelopes_centroid",
"(",
"envelopes",
")",
":",
"xmin",
",",
"xmax",
",",
"ymin",
",",
"ymax",
"=",
"_get_envelopes_min_maxes",
"(",
"envelopes",
")",
"return",
"np",
".",
"mean",
"(",
"xmin",
",",
"xmax",
")",
",",
"np",
".",
"mean",
"(",
... | Returns the centroid of an inputted geometry column. Not currently in use, as this is now handled by this
library's CRS wrapper directly. Light wrapper over ``_get_envelopes_min_maxes``.
Parameters
----------
envelopes : GeoSeries
The envelopes of the given geometries, as would be returned by e... | [
"Returns",
"the",
"centroid",
"of",
"an",
"inputted",
"geometry",
"column",
".",
"Not",
"currently",
"in",
"use",
"as",
"this",
"is",
"now",
"handled",
"by",
"this",
"library",
"s",
"CRS",
"wrapper",
"directly",
".",
"Light",
"wrapper",
"over",
"_get_envelop... | 942b474878187a87a95a27fbe41285dfdc1d20ca | https://github.com/ResidentMario/geoplot/blob/942b474878187a87a95a27fbe41285dfdc1d20ca/geoplot/geoplot.py#L2227-L2243 | train |
ResidentMario/geoplot | geoplot/geoplot.py | _set_extent | def _set_extent(ax, projection, extent, extrema):
"""
Sets the plot extent.
Parameters
----------
ax : cartopy.GeoAxesSubplot instance
The axis whose boundaries are being tweaked.
projection : None or geoplot.crs instance
The projection, if one is being used.
extent : None o... | python | def _set_extent(ax, projection, extent, extrema):
"""
Sets the plot extent.
Parameters
----------
ax : cartopy.GeoAxesSubplot instance
The axis whose boundaries are being tweaked.
projection : None or geoplot.crs instance
The projection, if one is being used.
extent : None o... | [
"def",
"_set_extent",
"(",
"ax",
",",
"projection",
",",
"extent",
",",
"extrema",
")",
":",
"if",
"extent",
":",
"xmin",
",",
"xmax",
",",
"ymin",
",",
"ymax",
"=",
"extent",
"xmin",
",",
"xmax",
",",
"ymin",
",",
"ymax",
"=",
"max",
"(",
"xmin",
... | Sets the plot extent.
Parameters
----------
ax : cartopy.GeoAxesSubplot instance
The axis whose boundaries are being tweaked.
projection : None or geoplot.crs instance
The projection, if one is being used.
extent : None or (xmin, xmax, ymin, ymax) tuple
A copy of the ``exten... | [
"Sets",
"the",
"plot",
"extent",
"."
] | 942b474878187a87a95a27fbe41285dfdc1d20ca | https://github.com/ResidentMario/geoplot/blob/942b474878187a87a95a27fbe41285dfdc1d20ca/geoplot/geoplot.py#L2246-L2285 | train |
ResidentMario/geoplot | geoplot/geoplot.py | _lay_out_axes | def _lay_out_axes(ax, projection):
"""
``cartopy`` enables a a transparent background patch and an "outline" patch by default. This short method simply
hides these extraneous visual features. If the plot is a pure ``matplotlib`` one, it does the same thing by
removing the axis altogether.
Parameter... | python | def _lay_out_axes(ax, projection):
"""
``cartopy`` enables a a transparent background patch and an "outline" patch by default. This short method simply
hides these extraneous visual features. If the plot is a pure ``matplotlib`` one, it does the same thing by
removing the axis altogether.
Parameter... | [
"def",
"_lay_out_axes",
"(",
"ax",
",",
"projection",
")",
":",
"if",
"projection",
"is",
"not",
"None",
":",
"try",
":",
"ax",
".",
"background_patch",
".",
"set_visible",
"(",
"False",
")",
"ax",
".",
"outline_patch",
".",
"set_visible",
"(",
"False",
... | ``cartopy`` enables a a transparent background patch and an "outline" patch by default. This short method simply
hides these extraneous visual features. If the plot is a pure ``matplotlib`` one, it does the same thing by
removing the axis altogether.
Parameters
----------
ax : matplotlib.Axes insta... | [
"cartopy",
"enables",
"a",
"a",
"transparent",
"background",
"patch",
"and",
"an",
"outline",
"patch",
"by",
"default",
".",
"This",
"short",
"method",
"simply",
"hides",
"these",
"extraneous",
"visual",
"features",
".",
"If",
"the",
"plot",
"is",
"a",
"pure... | 942b474878187a87a95a27fbe41285dfdc1d20ca | https://github.com/ResidentMario/geoplot/blob/942b474878187a87a95a27fbe41285dfdc1d20ca/geoplot/geoplot.py#L2288-L2312 | train |
ResidentMario/geoplot | geoplot/geoplot.py | _continuous_colormap | def _continuous_colormap(hue, cmap, vmin, vmax):
"""
Creates a continuous colormap.
Parameters
----------
hue : iterable
The data column whose entries are being discretely colorized. Note that although top-level plotter ``hue``
parameters ingest many argument signatures, not just it... | python | def _continuous_colormap(hue, cmap, vmin, vmax):
"""
Creates a continuous colormap.
Parameters
----------
hue : iterable
The data column whose entries are being discretely colorized. Note that although top-level plotter ``hue``
parameters ingest many argument signatures, not just it... | [
"def",
"_continuous_colormap",
"(",
"hue",
",",
"cmap",
",",
"vmin",
",",
"vmax",
")",
":",
"mn",
"=",
"min",
"(",
"hue",
")",
"if",
"vmin",
"is",
"None",
"else",
"vmin",
"mx",
"=",
"max",
"(",
"hue",
")",
"if",
"vmax",
"is",
"None",
"else",
"vma... | Creates a continuous colormap.
Parameters
----------
hue : iterable
The data column whose entries are being discretely colorized. Note that although top-level plotter ``hue``
parameters ingest many argument signatures, not just iterables, they are all preprocessed to standardized
it... | [
"Creates",
"a",
"continuous",
"colormap",
"."
] | 942b474878187a87a95a27fbe41285dfdc1d20ca | https://github.com/ResidentMario/geoplot/blob/942b474878187a87a95a27fbe41285dfdc1d20ca/geoplot/geoplot.py#L2345-L2374 | train |
ResidentMario/geoplot | geoplot/geoplot.py | _discrete_colorize | def _discrete_colorize(categorical, hue, scheme, k, cmap, vmin, vmax):
"""
Creates a discrete colormap, either using an already-categorical data variable or by bucketing a non-categorical
ordinal one. If a scheme is provided we compute a distribution for the given data. If one is not provided we
assume ... | python | def _discrete_colorize(categorical, hue, scheme, k, cmap, vmin, vmax):
"""
Creates a discrete colormap, either using an already-categorical data variable or by bucketing a non-categorical
ordinal one. If a scheme is provided we compute a distribution for the given data. If one is not provided we
assume ... | [
"def",
"_discrete_colorize",
"(",
"categorical",
",",
"hue",
",",
"scheme",
",",
"k",
",",
"cmap",
",",
"vmin",
",",
"vmax",
")",
":",
"if",
"not",
"categorical",
":",
"binning",
"=",
"_mapclassify_choro",
"(",
"hue",
",",
"scheme",
",",
"k",
"=",
"k",... | Creates a discrete colormap, either using an already-categorical data variable or by bucketing a non-categorical
ordinal one. If a scheme is provided we compute a distribution for the given data. If one is not provided we
assume that the input data is categorical.
This code makes extensive use of ``geopand... | [
"Creates",
"a",
"discrete",
"colormap",
"either",
"using",
"an",
"already",
"-",
"categorical",
"data",
"variable",
"or",
"by",
"bucketing",
"a",
"non",
"-",
"categorical",
"ordinal",
"one",
".",
"If",
"a",
"scheme",
"is",
"provided",
"we",
"compute",
"a",
... | 942b474878187a87a95a27fbe41285dfdc1d20ca | https://github.com/ResidentMario/geoplot/blob/942b474878187a87a95a27fbe41285dfdc1d20ca/geoplot/geoplot.py#L2377-L2428 | train |
ResidentMario/geoplot | geoplot/geoplot.py | _norm_cmap | def _norm_cmap(values, cmap, normalize, cm, vmin=None, vmax=None):
"""
Normalize and set colormap. Taken from geopandas@0.2.1 codebase, removed in geopandas@0.3.0.
"""
mn = min(values) if vmin is None else vmin
mx = max(values) if vmax is None else vmax
norm = normalize(vmin=mn, vmax=mx)
n_... | python | def _norm_cmap(values, cmap, normalize, cm, vmin=None, vmax=None):
"""
Normalize and set colormap. Taken from geopandas@0.2.1 codebase, removed in geopandas@0.3.0.
"""
mn = min(values) if vmin is None else vmin
mx = max(values) if vmax is None else vmax
norm = normalize(vmin=mn, vmax=mx)
n_... | [
"def",
"_norm_cmap",
"(",
"values",
",",
"cmap",
",",
"normalize",
",",
"cm",
",",
"vmin",
"=",
"None",
",",
"vmax",
"=",
"None",
")",
":",
"mn",
"=",
"min",
"(",
"values",
")",
"if",
"vmin",
"is",
"None",
"else",
"vmin",
"mx",
"=",
"max",
"(",
... | Normalize and set colormap. Taken from geopandas@0.2.1 codebase, removed in geopandas@0.3.0. | [
"Normalize",
"and",
"set",
"colormap",
".",
"Taken",
"from",
"geopandas"
] | 942b474878187a87a95a27fbe41285dfdc1d20ca | https://github.com/ResidentMario/geoplot/blob/942b474878187a87a95a27fbe41285dfdc1d20ca/geoplot/geoplot.py#L2733-L2742 | train |
tmux-python/libtmux | libtmux/common.py | get_version | def get_version():
"""
Return tmux version.
If tmux is built from git master, the version returned will be the latest
version appended with -master, e.g. ``2.4-master``.
If using OpenBSD's base system tmux, the version will have ``-openbsd``
appended to the latest version, e.g. ``2.4-openbsd``... | python | def get_version():
"""
Return tmux version.
If tmux is built from git master, the version returned will be the latest
version appended with -master, e.g. ``2.4-master``.
If using OpenBSD's base system tmux, the version will have ``-openbsd``
appended to the latest version, e.g. ``2.4-openbsd``... | [
"def",
"get_version",
"(",
")",
":",
"proc",
"=",
"tmux_cmd",
"(",
"'-V'",
")",
"if",
"proc",
".",
"stderr",
":",
"if",
"proc",
".",
"stderr",
"[",
"0",
"]",
"==",
"'tmux: unknown option -- V'",
":",
"if",
"sys",
".",
"platform",
".",
"startswith",
"("... | Return tmux version.
If tmux is built from git master, the version returned will be the latest
version appended with -master, e.g. ``2.4-master``.
If using OpenBSD's base system tmux, the version will have ``-openbsd``
appended to the latest version, e.g. ``2.4-openbsd``.
Returns
-------
... | [
"Return",
"tmux",
"version",
"."
] | 8eb2f8bbea3a025c1567b1516653414dbc24e1fc | https://github.com/tmux-python/libtmux/blob/8eb2f8bbea3a025c1567b1516653414dbc24e1fc/libtmux/common.py#L442-L476 | train |
tmux-python/libtmux | libtmux/common.py | has_minimum_version | def has_minimum_version(raises=True):
"""
Return if tmux meets version requirement. Version >1.8 or above.
Parameters
----------
raises : bool
raise exception if below minimum version requirement
Returns
-------
bool
True if tmux meets minimum required version.
Rai... | python | def has_minimum_version(raises=True):
"""
Return if tmux meets version requirement. Version >1.8 or above.
Parameters
----------
raises : bool
raise exception if below minimum version requirement
Returns
-------
bool
True if tmux meets minimum required version.
Rai... | [
"def",
"has_minimum_version",
"(",
"raises",
"=",
"True",
")",
":",
"if",
"get_version",
"(",
")",
"<",
"LooseVersion",
"(",
"TMUX_MIN_VERSION",
")",
":",
"if",
"raises",
":",
"raise",
"exc",
".",
"VersionTooLow",
"(",
"'libtmux only supports tmux %s and greater. ... | Return if tmux meets version requirement. Version >1.8 or above.
Parameters
----------
raises : bool
raise exception if below minimum version requirement
Returns
-------
bool
True if tmux meets minimum required version.
Raises
------
libtmux.exc.VersionTooLow
... | [
"Return",
"if",
"tmux",
"meets",
"version",
"requirement",
".",
"Version",
">",
"1",
".",
"8",
"or",
"above",
"."
] | 8eb2f8bbea3a025c1567b1516653414dbc24e1fc | https://github.com/tmux-python/libtmux/blob/8eb2f8bbea3a025c1567b1516653414dbc24e1fc/libtmux/common.py#L564-L603 | train |
tmux-python/libtmux | libtmux/common.py | session_check_name | def session_check_name(session_name):
"""
Raises exception session name invalid, modeled after tmux function.
tmux(1) session names may not be empty, or include periods or colons.
These delimiters are reserved for noting session, window and pane.
Parameters
----------
session_name : str
... | python | def session_check_name(session_name):
"""
Raises exception session name invalid, modeled after tmux function.
tmux(1) session names may not be empty, or include periods or colons.
These delimiters are reserved for noting session, window and pane.
Parameters
----------
session_name : str
... | [
"def",
"session_check_name",
"(",
"session_name",
")",
":",
"if",
"not",
"session_name",
"or",
"len",
"(",
"session_name",
")",
"==",
"0",
":",
"raise",
"exc",
".",
"BadSessionName",
"(",
"\"tmux session names may not be empty.\"",
")",
"elif",
"'.'",
"in",
"ses... | Raises exception session name invalid, modeled after tmux function.
tmux(1) session names may not be empty, or include periods or colons.
These delimiters are reserved for noting session, window and pane.
Parameters
----------
session_name : str
Name of session.
Raises
------
... | [
"Raises",
"exception",
"session",
"name",
"invalid",
"modeled",
"after",
"tmux",
"function",
"."
] | 8eb2f8bbea3a025c1567b1516653414dbc24e1fc | https://github.com/tmux-python/libtmux/blob/8eb2f8bbea3a025c1567b1516653414dbc24e1fc/libtmux/common.py#L606-L632 | train |
tmux-python/libtmux | libtmux/common.py | handle_option_error | def handle_option_error(error):
"""Raises exception if error in option command found.
Purpose: As of tmux 2.4, there are now 3 different types of option errors:
- unknown option
- invalid option
- ambiguous option
Before 2.4, unknown option was the user.
All errors raised will have the b... | python | def handle_option_error(error):
"""Raises exception if error in option command found.
Purpose: As of tmux 2.4, there are now 3 different types of option errors:
- unknown option
- invalid option
- ambiguous option
Before 2.4, unknown option was the user.
All errors raised will have the b... | [
"def",
"handle_option_error",
"(",
"error",
")",
":",
"if",
"'unknown option'",
"in",
"error",
":",
"raise",
"exc",
".",
"UnknownOption",
"(",
"error",
")",
"elif",
"'invalid option'",
"in",
"error",
":",
"raise",
"exc",
".",
"InvalidOption",
"(",
"error",
"... | Raises exception if error in option command found.
Purpose: As of tmux 2.4, there are now 3 different types of option errors:
- unknown option
- invalid option
- ambiguous option
Before 2.4, unknown option was the user.
All errors raised will have the base error of :exc:`exc.OptionError`. So... | [
"Raises",
"exception",
"if",
"error",
"in",
"option",
"command",
"found",
"."
] | 8eb2f8bbea3a025c1567b1516653414dbc24e1fc | https://github.com/tmux-python/libtmux/blob/8eb2f8bbea3a025c1567b1516653414dbc24e1fc/libtmux/common.py#L635-L666 | train |
tmux-python/libtmux | libtmux/common.py | TmuxRelationalObject.where | def where(self, attrs, first=False):
"""
Return objects matching child objects properties.
Parameters
----------
attrs : dict
tmux properties to match values of
Returns
-------
list
"""
# from https://github.com/serkanyersen/... | python | def where(self, attrs, first=False):
"""
Return objects matching child objects properties.
Parameters
----------
attrs : dict
tmux properties to match values of
Returns
-------
list
"""
# from https://github.com/serkanyersen/... | [
"def",
"where",
"(",
"self",
",",
"attrs",
",",
"first",
"=",
"False",
")",
":",
"# from https://github.com/serkanyersen/underscore.py",
"def",
"by",
"(",
"val",
",",
"*",
"args",
")",
":",
"for",
"key",
",",
"value",
"in",
"attrs",
".",
"items",
"(",
")... | Return objects matching child objects properties.
Parameters
----------
attrs : dict
tmux properties to match values of
Returns
-------
list | [
"Return",
"objects",
"matching",
"child",
"objects",
"properties",
"."
] | 8eb2f8bbea3a025c1567b1516653414dbc24e1fc | https://github.com/tmux-python/libtmux/blob/8eb2f8bbea3a025c1567b1516653414dbc24e1fc/libtmux/common.py#L324-L351 | train |
tmux-python/libtmux | libtmux/common.py | TmuxRelationalObject.get_by_id | def get_by_id(self, id):
"""
Return object based on ``child_id_attribute``.
Parameters
----------
val : str
Returns
-------
object
Notes
-----
Based on `.get()`_ from `backbone.js`_.
.. _backbone.js: http://backbonejs.or... | python | def get_by_id(self, id):
"""
Return object based on ``child_id_attribute``.
Parameters
----------
val : str
Returns
-------
object
Notes
-----
Based on `.get()`_ from `backbone.js`_.
.. _backbone.js: http://backbonejs.or... | [
"def",
"get_by_id",
"(",
"self",
",",
"id",
")",
":",
"for",
"child",
"in",
"self",
".",
"children",
":",
"if",
"child",
"[",
"self",
".",
"child_id_attribute",
"]",
"==",
"id",
":",
"return",
"child",
"else",
":",
"continue",
"return",
"None"
] | Return object based on ``child_id_attribute``.
Parameters
----------
val : str
Returns
-------
object
Notes
-----
Based on `.get()`_ from `backbone.js`_.
.. _backbone.js: http://backbonejs.org/
.. _.get(): http://backbonejs.org/... | [
"Return",
"object",
"based",
"on",
"child_id_attribute",
"."
] | 8eb2f8bbea3a025c1567b1516653414dbc24e1fc | https://github.com/tmux-python/libtmux/blob/8eb2f8bbea3a025c1567b1516653414dbc24e1fc/libtmux/common.py#L353-L378 | train |
tmux-python/libtmux | libtmux/window.py | Window.select_window | def select_window(self):
"""
Select window. Return ``self``.
To select a window object asynchrously. If a ``window`` object exists
and is no longer longer the current window, ``w.select_window()``
will make ``w`` the current window.
Returns
-------
:clas... | python | def select_window(self):
"""
Select window. Return ``self``.
To select a window object asynchrously. If a ``window`` object exists
and is no longer longer the current window, ``w.select_window()``
will make ``w`` the current window.
Returns
-------
:clas... | [
"def",
"select_window",
"(",
"self",
")",
":",
"target",
"=",
"(",
"'%s:%s'",
"%",
"(",
"self",
".",
"get",
"(",
"'session_id'",
")",
",",
"self",
".",
"index",
")",
",",
")",
"return",
"self",
".",
"session",
".",
"select_window",
"(",
"target",
")"... | Select window. Return ``self``.
To select a window object asynchrously. If a ``window`` object exists
and is no longer longer the current window, ``w.select_window()``
will make ``w`` the current window.
Returns
-------
:class:`Window` | [
"Select",
"window",
".",
"Return",
"self",
"."
] | 8eb2f8bbea3a025c1567b1516653414dbc24e1fc | https://github.com/tmux-python/libtmux/blob/8eb2f8bbea3a025c1567b1516653414dbc24e1fc/libtmux/window.py#L341-L354 | train |
tmux-python/libtmux | libtmux/server.py | Server.cmd | def cmd(self, *args, **kwargs):
"""
Execute tmux command and return output.
Returns
-------
:class:`common.tmux_cmd`
Notes
-----
.. versionchanged:: 0.8
Renamed from ``.tmux`` to ``.cmd``.
"""
args = list(args)
if se... | python | def cmd(self, *args, **kwargs):
"""
Execute tmux command and return output.
Returns
-------
:class:`common.tmux_cmd`
Notes
-----
.. versionchanged:: 0.8
Renamed from ``.tmux`` to ``.cmd``.
"""
args = list(args)
if se... | [
"def",
"cmd",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"list",
"(",
"args",
")",
"if",
"self",
".",
"socket_name",
":",
"args",
".",
"insert",
"(",
"0",
",",
"'-L{0}'",
".",
"format",
"(",
"self",
".",
"soc... | Execute tmux command and return output.
Returns
-------
:class:`common.tmux_cmd`
Notes
-----
.. versionchanged:: 0.8
Renamed from ``.tmux`` to ``.cmd``. | [
"Execute",
"tmux",
"command",
"and",
"return",
"output",
"."
] | 8eb2f8bbea3a025c1567b1516653414dbc24e1fc | https://github.com/tmux-python/libtmux/blob/8eb2f8bbea3a025c1567b1516653414dbc24e1fc/libtmux/server.py#L99-L129 | train |
tmux-python/libtmux | libtmux/session.py | Session.switch_client | def switch_client(self):
"""
Switch client to this session.
Raises
------
:exc:`exc.LibTmuxException`
"""
proc = self.cmd('switch-client', '-t%s' % self.id)
if proc.stderr:
raise exc.LibTmuxException(proc.stderr) | python | def switch_client(self):
"""
Switch client to this session.
Raises
------
:exc:`exc.LibTmuxException`
"""
proc = self.cmd('switch-client', '-t%s' % self.id)
if proc.stderr:
raise exc.LibTmuxException(proc.stderr) | [
"def",
"switch_client",
"(",
"self",
")",
":",
"proc",
"=",
"self",
".",
"cmd",
"(",
"'switch-client'",
",",
"'-t%s'",
"%",
"self",
".",
"id",
")",
"if",
"proc",
".",
"stderr",
":",
"raise",
"exc",
".",
"LibTmuxException",
"(",
"proc",
".",
"stderr",
... | Switch client to this session.
Raises
------
:exc:`exc.LibTmuxException` | [
"Switch",
"client",
"to",
"this",
"session",
"."
] | 8eb2f8bbea3a025c1567b1516653414dbc24e1fc | https://github.com/tmux-python/libtmux/blob/8eb2f8bbea3a025c1567b1516653414dbc24e1fc/libtmux/session.py#L122-L134 | train |
Yubico/yubikey-manager | ykman/cli/opgp.py | openpgp | def openpgp(ctx):
"""
Manage OpenPGP Application.
Examples:
\b
Set the retries for PIN, Reset Code and Admin PIN to 10:
$ ykman openpgp set-retries 10 10 10
\b
Require touch to use the authentication key:
$ ykman openpgp touch aut on
"""
try:
ctx.obj['contr... | python | def openpgp(ctx):
"""
Manage OpenPGP Application.
Examples:
\b
Set the retries for PIN, Reset Code and Admin PIN to 10:
$ ykman openpgp set-retries 10 10 10
\b
Require touch to use the authentication key:
$ ykman openpgp touch aut on
"""
try:
ctx.obj['contr... | [
"def",
"openpgp",
"(",
"ctx",
")",
":",
"try",
":",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"=",
"OpgpController",
"(",
"ctx",
".",
"obj",
"[",
"'dev'",
"]",
".",
"driver",
")",
"except",
"APDUError",
"as",
"e",
":",
"if",
"e",
".",
"sw",
"=... | Manage OpenPGP Application.
Examples:
\b
Set the retries for PIN, Reset Code and Admin PIN to 10:
$ ykman openpgp set-retries 10 10 10
\b
Require touch to use the authentication key:
$ ykman openpgp touch aut on | [
"Manage",
"OpenPGP",
"Application",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/opgp.py#L83-L104 | train |
Yubico/yubikey-manager | ykman/cli/opgp.py | info | def info(ctx):
"""
Display status of OpenPGP application.
"""
controller = ctx.obj['controller']
click.echo('OpenPGP version: %d.%d.%d' % controller.version)
retries = controller.get_remaining_pin_tries()
click.echo('PIN tries remaining: {}'.format(retries.pin))
click.echo('Reset code tr... | python | def info(ctx):
"""
Display status of OpenPGP application.
"""
controller = ctx.obj['controller']
click.echo('OpenPGP version: %d.%d.%d' % controller.version)
retries = controller.get_remaining_pin_tries()
click.echo('PIN tries remaining: {}'.format(retries.pin))
click.echo('Reset code tr... | [
"def",
"info",
"(",
"ctx",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"click",
".",
"echo",
"(",
"'OpenPGP version: %d.%d.%d'",
"%",
"controller",
".",
"version",
")",
"retries",
"=",
"controller",
".",
"get_remaining_pin_tries",... | Display status of OpenPGP application. | [
"Display",
"status",
"of",
"OpenPGP",
"application",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/opgp.py#L109-L129 | train |
Yubico/yubikey-manager | ykman/cli/opgp.py | reset | def reset(ctx):
"""
Reset OpenPGP application.
This action will wipe all OpenPGP data, and set all PINs to their default
values.
"""
click.echo("Resetting OpenPGP data, don't remove your YubiKey...")
ctx.obj['controller'].reset()
click.echo('Success! All data has been cleared and defaul... | python | def reset(ctx):
"""
Reset OpenPGP application.
This action will wipe all OpenPGP data, and set all PINs to their default
values.
"""
click.echo("Resetting OpenPGP data, don't remove your YubiKey...")
ctx.obj['controller'].reset()
click.echo('Success! All data has been cleared and defaul... | [
"def",
"reset",
"(",
"ctx",
")",
":",
"click",
".",
"echo",
"(",
"\"Resetting OpenPGP data, don't remove your YubiKey...\"",
")",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
".",
"reset",
"(",
")",
"click",
".",
"echo",
"(",
"'Success! All data has been cleared a... | Reset OpenPGP application.
This action will wipe all OpenPGP data, and set all PINs to their default
values. | [
"Reset",
"OpenPGP",
"application",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/opgp.py#L137-L147 | train |
Yubico/yubikey-manager | ykman/cli/opgp.py | touch | def touch(ctx, key, policy, admin_pin, force):
"""
Manage touch policy for OpenPGP keys.
\b
KEY Key slot to set (sig, enc or aut).
POLICY Touch policy to set (on, off or fixed).
"""
controller = ctx.obj['controller']
old_policy = controller.get_touch(key)
if old_policy == TOUC... | python | def touch(ctx, key, policy, admin_pin, force):
"""
Manage touch policy for OpenPGP keys.
\b
KEY Key slot to set (sig, enc or aut).
POLICY Touch policy to set (on, off or fixed).
"""
controller = ctx.obj['controller']
old_policy = controller.get_touch(key)
if old_policy == TOUC... | [
"def",
"touch",
"(",
"ctx",
",",
"key",
",",
"policy",
",",
"admin_pin",
",",
"force",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"old_policy",
"=",
"controller",
".",
"get_touch",
"(",
"key",
")",
"if",
"old_policy",
"==... | Manage touch policy for OpenPGP keys.
\b
KEY Key slot to set (sig, enc or aut).
POLICY Touch policy to set (on, off or fixed). | [
"Manage",
"touch",
"policy",
"for",
"OpenPGP",
"keys",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/opgp.py#L165-L183 | train |
Yubico/yubikey-manager | ykman/cli/opgp.py | set_pin_retries | def set_pin_retries(ctx, pw_attempts, admin_pin, force):
"""
Manage pin-retries.
Sets the number of attempts available before locking for each PIN.
PW_ATTEMPTS should be three integer values corresponding to the number of
attempts for the PIN, Reset Code, and Admin PIN, respectively.
"""
c... | python | def set_pin_retries(ctx, pw_attempts, admin_pin, force):
"""
Manage pin-retries.
Sets the number of attempts available before locking for each PIN.
PW_ATTEMPTS should be three integer values corresponding to the number of
attempts for the PIN, Reset Code, and Admin PIN, respectively.
"""
c... | [
"def",
"set_pin_retries",
"(",
"ctx",
",",
"pw_attempts",
",",
"admin_pin",
",",
"force",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"resets_pins",
"=",
"controller",
".",
"version",
"<",
"(",
"4",
",",
"0",
",",
"0",
")"... | Manage pin-retries.
Sets the number of attempts available before locking for each PIN.
PW_ATTEMPTS should be three integer values corresponding to the number of
attempts for the PIN, Reset Code, and Admin PIN, respectively. | [
"Manage",
"pin",
"-",
"retries",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/opgp.py#L192-L212 | train |
Yubico/yubikey-manager | ykman/cli/piv.py | piv | def piv(ctx):
"""
Manage PIV Application.
Examples:
\b
Generate an ECC P-256 private key and a self-signed certificate in
slot 9a:
$ ykman piv generate-key --algorithm ECCP256 9a pubkey.pem
$ ykman piv generate-certificate --subject "yubico" 9a pubkey.pem
\b
Change t... | python | def piv(ctx):
"""
Manage PIV Application.
Examples:
\b
Generate an ECC P-256 private key and a self-signed certificate in
slot 9a:
$ ykman piv generate-key --algorithm ECCP256 9a pubkey.pem
$ ykman piv generate-certificate --subject "yubico" 9a pubkey.pem
\b
Change t... | [
"def",
"piv",
"(",
"ctx",
")",
":",
"try",
":",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"=",
"PivController",
"(",
"ctx",
".",
"obj",
"[",
"'dev'",
"]",
".",
"driver",
")",
"except",
"APDUError",
"as",
"e",
":",
"if",
"e",
".",
"sw",
"==",
... | Manage PIV Application.
Examples:
\b
Generate an ECC P-256 private key and a self-signed certificate in
slot 9a:
$ ykman piv generate-key --algorithm ECCP256 9a pubkey.pem
$ ykman piv generate-certificate --subject "yubico" 9a pubkey.pem
\b
Change the PIN from 123456 to 6543... | [
"Manage",
"PIV",
"Application",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/piv.py#L95-L120 | train |
Yubico/yubikey-manager | ykman/cli/piv.py | info | def info(ctx):
"""
Display status of PIV application.
"""
controller = ctx.obj['controller']
click.echo('PIV version: %d.%d.%d' % controller.version)
# Largest possible number of PIN tries to get back is 15
tries = controller.get_pin_tries()
tries = '15 or more.' if tries == 15 else tri... | python | def info(ctx):
"""
Display status of PIV application.
"""
controller = ctx.obj['controller']
click.echo('PIV version: %d.%d.%d' % controller.version)
# Largest possible number of PIN tries to get back is 15
tries = controller.get_pin_tries()
tries = '15 or more.' if tries == 15 else tri... | [
"def",
"info",
"(",
"ctx",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"click",
".",
"echo",
"(",
"'PIV version: %d.%d.%d'",
"%",
"controller",
".",
"version",
")",
"# Largest possible number of PIN tries to get back is 15",
"tries",
... | Display status of PIV application. | [
"Display",
"status",
"of",
"PIV",
"application",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/piv.py#L125-L195 | train |
Yubico/yubikey-manager | ykman/cli/piv.py | reset | def reset(ctx):
"""
Reset all PIV data.
This action will wipe all data and restore factory settings for
the PIV application on your YubiKey.
"""
click.echo('Resetting PIV data...')
ctx.obj['controller'].reset()
click.echo(
'Success! All PIV data have been cleared from your Yubi... | python | def reset(ctx):
"""
Reset all PIV data.
This action will wipe all data and restore factory settings for
the PIV application on your YubiKey.
"""
click.echo('Resetting PIV data...')
ctx.obj['controller'].reset()
click.echo(
'Success! All PIV data have been cleared from your Yubi... | [
"def",
"reset",
"(",
"ctx",
")",
":",
"click",
".",
"echo",
"(",
"'Resetting PIV data...'",
")",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
".",
"reset",
"(",
")",
"click",
".",
"echo",
"(",
"'Success! All PIV data have been cleared from your YubiKey.'",
")",
... | Reset all PIV data.
This action will wipe all data and restore factory settings for
the PIV application on your YubiKey. | [
"Reset",
"all",
"PIV",
"data",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/piv.py#L203-L219 | train |
Yubico/yubikey-manager | ykman/cli/piv.py | generate_key | def generate_key(
ctx, slot, public_key_output, management_key, pin, algorithm,
format, pin_policy, touch_policy):
"""
Generate an asymmetric key pair.
The private key is generated on the YubiKey, and written to one of the
slots.
\b
SLOT PIV slot where private key should be ... | python | def generate_key(
ctx, slot, public_key_output, management_key, pin, algorithm,
format, pin_policy, touch_policy):
"""
Generate an asymmetric key pair.
The private key is generated on the YubiKey, and written to one of the
slots.
\b
SLOT PIV slot where private key should be ... | [
"def",
"generate_key",
"(",
"ctx",
",",
"slot",
",",
"public_key_output",
",",
"management_key",
",",
"pin",
",",
"algorithm",
",",
"format",
",",
"pin_policy",
",",
"touch_policy",
")",
":",
"dev",
"=",
"ctx",
".",
"obj",
"[",
"'dev'",
"]",
"controller",
... | Generate an asymmetric key pair.
The private key is generated on the YubiKey, and written to one of the
slots.
\b
SLOT PIV slot where private key should be stored.
PUBLIC-KEY File containing the generated public key. Use '-' to use stdout. | [
"Generate",
"an",
"asymmetric",
"key",
"pair",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/piv.py#L237-L279 | train |
Yubico/yubikey-manager | ykman/cli/piv.py | import_certificate | def import_certificate(
ctx, slot, management_key, pin, cert, password, verify):
"""
Import a X.509 certificate.
Write a certificate to one of the slots on the YubiKey.
\b
SLOT PIV slot to import the certificate to.
CERTIFICATE File containing the certificate. Use '-' to... | python | def import_certificate(
ctx, slot, management_key, pin, cert, password, verify):
"""
Import a X.509 certificate.
Write a certificate to one of the slots on the YubiKey.
\b
SLOT PIV slot to import the certificate to.
CERTIFICATE File containing the certificate. Use '-' to... | [
"def",
"import_certificate",
"(",
"ctx",
",",
"slot",
",",
"management_key",
",",
"pin",
",",
"cert",
",",
"password",
",",
"verify",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"_ensure_authenticated",
"(",
"ctx",
",",
"contr... | Import a X.509 certificate.
Write a certificate to one of the slots on the YubiKey.
\b
SLOT PIV slot to import the certificate to.
CERTIFICATE File containing the certificate. Use '-' to use stdin. | [
"Import",
"a",
"X",
".",
"509",
"certificate",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/piv.py#L293-L353 | train |
Yubico/yubikey-manager | ykman/cli/piv.py | import_key | def import_key(
ctx, slot, management_key, pin, private_key,
pin_policy, touch_policy, password):
"""
Import a private key.
Write a private key to one of the slots on the YubiKey.
\b
SLOT PIV slot to import the private key to.
PRIVATE-KEY File containing the private key.... | python | def import_key(
ctx, slot, management_key, pin, private_key,
pin_policy, touch_policy, password):
"""
Import a private key.
Write a private key to one of the slots on the YubiKey.
\b
SLOT PIV slot to import the private key to.
PRIVATE-KEY File containing the private key.... | [
"def",
"import_key",
"(",
"ctx",
",",
"slot",
",",
"management_key",
",",
"pin",
",",
"private_key",
",",
"pin_policy",
",",
"touch_policy",
",",
"password",
")",
":",
"dev",
"=",
"ctx",
".",
"obj",
"[",
"'dev'",
"]",
"controller",
"=",
"ctx",
".",
"ob... | Import a private key.
Write a private key to one of the slots on the YubiKey.
\b
SLOT PIV slot to import the private key to.
PRIVATE-KEY File containing the private key. Use '-' to use stdin. | [
"Import",
"a",
"private",
"key",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/piv.py#L366-L416 | train |
Yubico/yubikey-manager | ykman/cli/piv.py | export_certificate | def export_certificate(ctx, slot, format, certificate):
"""
Export a X.509 certificate.
Reads a certificate from one of the slots on the YubiKey.
\b
SLOT PIV slot to read certificate from.
CERTIFICATE File to write certificate to. Use '-' to use stdout.
"""
controller = ctx.obj[... | python | def export_certificate(ctx, slot, format, certificate):
"""
Export a X.509 certificate.
Reads a certificate from one of the slots on the YubiKey.
\b
SLOT PIV slot to read certificate from.
CERTIFICATE File to write certificate to. Use '-' to use stdout.
"""
controller = ctx.obj[... | [
"def",
"export_certificate",
"(",
"ctx",
",",
"slot",
",",
"format",
",",
"certificate",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"try",
":",
"cert",
"=",
"controller",
".",
"read_certificate",
"(",
"slot",
")",
"except",
... | Export a X.509 certificate.
Reads a certificate from one of the slots on the YubiKey.
\b
SLOT PIV slot to read certificate from.
CERTIFICATE File to write certificate to. Use '-' to use stdout. | [
"Export",
"a",
"X",
".",
"509",
"certificate",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/piv.py#L449-L468 | train |
Yubico/yubikey-manager | ykman/cli/piv.py | set_chuid | def set_chuid(ctx, management_key, pin):
"""
Generate and set a CHUID on the YubiKey.
"""
controller = ctx.obj['controller']
_ensure_authenticated(ctx, controller, pin, management_key)
controller.update_chuid() | python | def set_chuid(ctx, management_key, pin):
"""
Generate and set a CHUID on the YubiKey.
"""
controller = ctx.obj['controller']
_ensure_authenticated(ctx, controller, pin, management_key)
controller.update_chuid() | [
"def",
"set_chuid",
"(",
"ctx",
",",
"management_key",
",",
"pin",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"_ensure_authenticated",
"(",
"ctx",
",",
"controller",
",",
"pin",
",",
"management_key",
")",
"controller",
".",
... | Generate and set a CHUID on the YubiKey. | [
"Generate",
"and",
"set",
"a",
"CHUID",
"on",
"the",
"YubiKey",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/piv.py#L475-L481 | train |
Yubico/yubikey-manager | ykman/cli/piv.py | set_ccc | def set_ccc(ctx, management_key, pin):
"""
Generate and set a CCC on the YubiKey.
"""
controller = ctx.obj['controller']
_ensure_authenticated(ctx, controller, pin, management_key)
controller.update_ccc() | python | def set_ccc(ctx, management_key, pin):
"""
Generate and set a CCC on the YubiKey.
"""
controller = ctx.obj['controller']
_ensure_authenticated(ctx, controller, pin, management_key)
controller.update_ccc() | [
"def",
"set_ccc",
"(",
"ctx",
",",
"management_key",
",",
"pin",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"_ensure_authenticated",
"(",
"ctx",
",",
"controller",
",",
"pin",
",",
"management_key",
")",
"controller",
".",
"u... | Generate and set a CCC on the YubiKey. | [
"Generate",
"and",
"set",
"a",
"CCC",
"on",
"the",
"YubiKey",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/piv.py#L488-L494 | train |
Yubico/yubikey-manager | ykman/cli/piv.py | generate_certificate | def generate_certificate(
ctx, slot, management_key, pin, public_key, subject, valid_days):
"""
Generate a self-signed X.509 certificate.
A self-signed certificate is generated and written to one of the slots on
the YubiKey. A private key need to exist in the slot.
\b
SLOT P... | python | def generate_certificate(
ctx, slot, management_key, pin, public_key, subject, valid_days):
"""
Generate a self-signed X.509 certificate.
A self-signed certificate is generated and written to one of the slots on
the YubiKey. A private key need to exist in the slot.
\b
SLOT P... | [
"def",
"generate_certificate",
"(",
"ctx",
",",
"slot",
",",
"management_key",
",",
"pin",
",",
"public_key",
",",
"subject",
",",
"valid_days",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"_ensure_authenticated",
"(",
"ctx",
",... | Generate a self-signed X.509 certificate.
A self-signed certificate is generated and written to one of the slots on
the YubiKey. A private key need to exist in the slot.
\b
SLOT PIV slot where private key is stored.
PUBLIC-KEY File containing a public key. Use '-' to use stdin. | [
"Generate",
"a",
"self",
"-",
"signed",
"X",
".",
"509",
"certificate",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/piv.py#L542-L573 | train |
Yubico/yubikey-manager | ykman/cli/piv.py | change_pin | def change_pin(ctx, pin, new_pin):
"""
Change the PIN code.
The PIN must be between 6 and 8 characters long, and supports any type of
alphanumeric characters. For cross-platform compatibility,
numeric digits are recommended.
"""
controller = ctx.obj['controller']
if not pin:
p... | python | def change_pin(ctx, pin, new_pin):
"""
Change the PIN code.
The PIN must be between 6 and 8 characters long, and supports any type of
alphanumeric characters. For cross-platform compatibility,
numeric digits are recommended.
"""
controller = ctx.obj['controller']
if not pin:
p... | [
"def",
"change_pin",
"(",
"ctx",
",",
"pin",
",",
"new_pin",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"if",
"not",
"pin",
":",
"pin",
"=",
"_prompt_pin",
"(",
"ctx",
",",
"prompt",
"=",
"'Enter your current PIN'",
")",
... | Change the PIN code.
The PIN must be between 6 and 8 characters long, and supports any type of
alphanumeric characters. For cross-platform compatibility,
numeric digits are recommended. | [
"Change",
"the",
"PIN",
"code",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/piv.py#L635-L670 | train |
Yubico/yubikey-manager | ykman/cli/piv.py | change_puk | def change_puk(ctx, puk, new_puk):
"""
Change the PUK code.
If the PIN is lost or blocked it can be reset using a PUK.
The PUK must be between 6 and 8 characters long, and supports any type of
alphanumeric characters.
"""
controller = ctx.obj['controller']
if not puk:
puk = _pro... | python | def change_puk(ctx, puk, new_puk):
"""
Change the PUK code.
If the PIN is lost or blocked it can be reset using a PUK.
The PUK must be between 6 and 8 characters long, and supports any type of
alphanumeric characters.
"""
controller = ctx.obj['controller']
if not puk:
puk = _pro... | [
"def",
"change_puk",
"(",
"ctx",
",",
"puk",
",",
"new_puk",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"if",
"not",
"puk",
":",
"puk",
"=",
"_prompt_pin",
"(",
"ctx",
",",
"prompt",
"=",
"'Enter your current PUK'",
")",
... | Change the PUK code.
If the PIN is lost or blocked it can be reset using a PUK.
The PUK must be between 6 and 8 characters long, and supports any type of
alphanumeric characters. | [
"Change",
"the",
"PUK",
"code",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/piv.py#L677-L711 | train |
Yubico/yubikey-manager | ykman/cli/piv.py | change_management_key | def change_management_key(
ctx, management_key, pin, new_management_key, touch, protect, generate,
force):
"""
Change the management key.
Management functionality is guarded by a 24 byte management key.
This key is required for administrative tasks, such as generating key pairs.
A r... | python | def change_management_key(
ctx, management_key, pin, new_management_key, touch, protect, generate,
force):
"""
Change the management key.
Management functionality is guarded by a 24 byte management key.
This key is required for administrative tasks, such as generating key pairs.
A r... | [
"def",
"change_management_key",
"(",
"ctx",
",",
"management_key",
",",
"pin",
",",
"new_management_key",
",",
"touch",
",",
"protect",
",",
"generate",
",",
"force",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"pin_verified",
"... | Change the management key.
Management functionality is guarded by a 24 byte management key.
This key is required for administrative tasks, such as generating key pairs.
A random key may be generated and stored on the YubiKey, protected by PIN. | [
"Change",
"the",
"management",
"key",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/piv.py#L735-L802 | train |
Yubico/yubikey-manager | ykman/cli/piv.py | unblock_pin | def unblock_pin(ctx, puk, new_pin):
"""
Unblock the PIN.
Reset the PIN using the PUK code.
"""
controller = ctx.obj['controller']
if not puk:
puk = click.prompt(
'Enter PUK', default='', show_default=False,
hide_input=True, err=True)
if not new_pin:
n... | python | def unblock_pin(ctx, puk, new_pin):
"""
Unblock the PIN.
Reset the PIN using the PUK code.
"""
controller = ctx.obj['controller']
if not puk:
puk = click.prompt(
'Enter PUK', default='', show_default=False,
hide_input=True, err=True)
if not new_pin:
n... | [
"def",
"unblock_pin",
"(",
"ctx",
",",
"puk",
",",
"new_pin",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"if",
"not",
"puk",
":",
"puk",
"=",
"click",
".",
"prompt",
"(",
"'Enter PUK'",
",",
"default",
"=",
"''",
",",
... | Unblock the PIN.
Reset the PIN using the PUK code. | [
"Unblock",
"the",
"PIN",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/piv.py#L809-L824 | train |
Yubico/yubikey-manager | ykman/cli/piv.py | read_object | def read_object(ctx, pin, object_id):
"""
Read arbitrary PIV object.
Read PIV object by providing the object id.
\b
OBJECT-ID Id of PIV object in HEX.
"""
controller = ctx.obj['controller']
def do_read_object(retry=True):
try:
click.echo(controller.get_data(... | python | def read_object(ctx, pin, object_id):
"""
Read arbitrary PIV object.
Read PIV object by providing the object id.
\b
OBJECT-ID Id of PIV object in HEX.
"""
controller = ctx.obj['controller']
def do_read_object(retry=True):
try:
click.echo(controller.get_data(... | [
"def",
"read_object",
"(",
"ctx",
",",
"pin",
",",
"object_id",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"def",
"do_read_object",
"(",
"retry",
"=",
"True",
")",
":",
"try",
":",
"click",
".",
"echo",
"(",
"controller",... | Read arbitrary PIV object.
Read PIV object by providing the object id.
\b
OBJECT-ID Id of PIV object in HEX. | [
"Read",
"arbitrary",
"PIV",
"object",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/piv.py#L833-L857 | train |
Yubico/yubikey-manager | ykman/cli/piv.py | write_object | def write_object(ctx, pin, management_key, object_id, data):
"""
Write an arbitrary PIV object.
Write a PIV object by providing the object id.
Yubico writable PIV objects are available in
the range 5f0000 - 5fffff.
\b
OBJECT-ID Id of PIV object in HEX.
DATA File contai... | python | def write_object(ctx, pin, management_key, object_id, data):
"""
Write an arbitrary PIV object.
Write a PIV object by providing the object id.
Yubico writable PIV objects are available in
the range 5f0000 - 5fffff.
\b
OBJECT-ID Id of PIV object in HEX.
DATA File contai... | [
"def",
"write_object",
"(",
"ctx",
",",
"pin",
",",
"management_key",
",",
"object_id",
",",
"data",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"_ensure_authenticated",
"(",
"ctx",
",",
"controller",
",",
"pin",
",",
"managem... | Write an arbitrary PIV object.
Write a PIV object by providing the object id.
Yubico writable PIV objects are available in
the range 5f0000 - 5fffff.
\b
OBJECT-ID Id of PIV object in HEX.
DATA File containing the data to be written. Use '-' to use stdin. | [
"Write",
"an",
"arbitrary",
"PIV",
"object",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/piv.py#L869-L894 | train |
Yubico/yubikey-manager | ykman/cli/fido.py | fido | def fido(ctx):
"""
Manage FIDO applications.
Examples:
\b
Reset the FIDO (FIDO2 and U2F) applications:
$ ykman fido reset
\b
Change the FIDO2 PIN from 123456 to 654321:
$ ykman fido set-pin --pin 123456 --new-pin 654321
"""
dev = ctx.obj['dev']
if dev.is_fips:... | python | def fido(ctx):
"""
Manage FIDO applications.
Examples:
\b
Reset the FIDO (FIDO2 and U2F) applications:
$ ykman fido reset
\b
Change the FIDO2 PIN from 123456 to 654321:
$ ykman fido set-pin --pin 123456 --new-pin 654321
"""
dev = ctx.obj['dev']
if dev.is_fips:... | [
"def",
"fido",
"(",
"ctx",
")",
":",
"dev",
"=",
"ctx",
".",
"obj",
"[",
"'dev'",
"]",
"if",
"dev",
".",
"is_fips",
":",
"try",
":",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"=",
"FipsU2fController",
"(",
"dev",
".",
"driver",
")",
"except",
... | Manage FIDO applications.
Examples:
\b
Reset the FIDO (FIDO2 and U2F) applications:
$ ykman fido reset
\b
Change the FIDO2 PIN from 123456 to 654321:
$ ykman fido set-pin --pin 123456 --new-pin 654321 | [
"Manage",
"FIDO",
"applications",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/fido.py#L51-L78 | train |
Yubico/yubikey-manager | ykman/cli/fido.py | info | def info(ctx):
"""
Display status of FIDO2 application.
"""
controller = ctx.obj['controller']
if controller.is_fips:
click.echo('FIPS Approved Mode: {}'.format(
'Yes' if controller.is_in_fips_mode else 'No'))
else:
if controller.has_pin:
try:
... | python | def info(ctx):
"""
Display status of FIDO2 application.
"""
controller = ctx.obj['controller']
if controller.is_fips:
click.echo('FIPS Approved Mode: {}'.format(
'Yes' if controller.is_in_fips_mode else 'No'))
else:
if controller.has_pin:
try:
... | [
"def",
"info",
"(",
"ctx",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"if",
"controller",
".",
"is_fips",
":",
"click",
".",
"echo",
"(",
"'FIPS Approved Mode: {}'",
".",
"format",
"(",
"'Yes'",
"if",
"controller",
".",
"is... | Display status of FIDO2 application. | [
"Display",
"status",
"of",
"FIDO2",
"application",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/fido.py#L83-L102 | train |
Yubico/yubikey-manager | ykman/cli/fido.py | reset | def reset(ctx, force):
"""
Reset all FIDO applications.
This action will wipe all FIDO credentials, including FIDO U2F credentials,
on the YubiKey and remove the PIN code.
The reset must be triggered immediately after the YubiKey is
inserted, and requires a touch on the YubiKey.
"""
n... | python | def reset(ctx, force):
"""
Reset all FIDO applications.
This action will wipe all FIDO credentials, including FIDO U2F credentials,
on the YubiKey and remove the PIN code.
The reset must be triggered immediately after the YubiKey is
inserted, and requires a touch on the YubiKey.
"""
n... | [
"def",
"reset",
"(",
"ctx",
",",
"force",
")",
":",
"n_keys",
"=",
"len",
"(",
"list",
"(",
"get_descriptors",
"(",
")",
")",
")",
"if",
"n_keys",
">",
"1",
":",
"ctx",
".",
"fail",
"(",
"'Only one YubiKey can be connected to perform a reset.'",
")",
"if",... | Reset all FIDO applications.
This action will wipe all FIDO credentials, including FIDO U2F credentials,
on the YubiKey and remove the PIN code.
The reset must be triggered immediately after the YubiKey is
inserted, and requires a touch on the YubiKey. | [
"Reset",
"all",
"FIDO",
"applications",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/fido.py#L210-L302 | train |
Yubico/yubikey-manager | ykman/cli/fido.py | unlock | def unlock(ctx, pin):
"""
Verify U2F PIN for YubiKey FIPS.
Unlock the YubiKey FIPS and allow U2F registration.
"""
controller = ctx.obj['controller']
if not controller.is_fips:
ctx.fail('This is not a YubiKey FIPS, and therefore'
' does not support a U2F PIN.')
if... | python | def unlock(ctx, pin):
"""
Verify U2F PIN for YubiKey FIPS.
Unlock the YubiKey FIPS and allow U2F registration.
"""
controller = ctx.obj['controller']
if not controller.is_fips:
ctx.fail('This is not a YubiKey FIPS, and therefore'
' does not support a U2F PIN.')
if... | [
"def",
"unlock",
"(",
"ctx",
",",
"pin",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"if",
"not",
"controller",
".",
"is_fips",
":",
"ctx",
".",
"fail",
"(",
"'This is not a YubiKey FIPS, and therefore'",
"' does not support a U2F P... | Verify U2F PIN for YubiKey FIPS.
Unlock the YubiKey FIPS and allow U2F registration. | [
"Verify",
"U2F",
"PIN",
"for",
"YubiKey",
"FIPS",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/fido.py#L308-L335 | train |
Yubico/yubikey-manager | ykman/piv.py | PivController.get_pin_tries | def get_pin_tries(self):
"""
Returns the number of PIN retries left,
0 PIN authentication blocked. Note that 15 is the highest
value that will be returned even if remaining tries is higher.
"""
# Verify without PIN gives number of tries left.
_, sw = self.send_cmd... | python | def get_pin_tries(self):
"""
Returns the number of PIN retries left,
0 PIN authentication blocked. Note that 15 is the highest
value that will be returned even if remaining tries is higher.
"""
# Verify without PIN gives number of tries left.
_, sw = self.send_cmd... | [
"def",
"get_pin_tries",
"(",
"self",
")",
":",
"# Verify without PIN gives number of tries left.",
"_",
",",
"sw",
"=",
"self",
".",
"send_cmd",
"(",
"INS",
".",
"VERIFY",
",",
"0",
",",
"PIN",
",",
"check",
"=",
"None",
")",
"return",
"tries_left",
"(",
"... | Returns the number of PIN retries left,
0 PIN authentication blocked. Note that 15 is the highest
value that will be returned even if remaining tries is higher. | [
"Returns",
"the",
"number",
"of",
"PIN",
"retries",
"left",
"0",
"PIN",
"authentication",
"blocked",
".",
"Note",
"that",
"15",
"is",
"the",
"highest",
"value",
"that",
"will",
"be",
"returned",
"even",
"if",
"remaining",
"tries",
"is",
"higher",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/piv.py#L778-L786 | train |
Yubico/yubikey-manager | ykman/cli/__main__.py | cli | def cli(ctx, device, log_level, log_file, reader):
"""
Configure your YubiKey via the command line.
Examples:
\b
List connected YubiKeys, only output serial number:
$ ykman list --serials
\b
Show information about YubiKey with serial number 0123456:
$ ykman --device 012345... | python | def cli(ctx, device, log_level, log_file, reader):
"""
Configure your YubiKey via the command line.
Examples:
\b
List connected YubiKeys, only output serial number:
$ ykman list --serials
\b
Show information about YubiKey with serial number 0123456:
$ ykman --device 012345... | [
"def",
"cli",
"(",
"ctx",
",",
"device",
",",
"log_level",
",",
"log_file",
",",
"reader",
")",
":",
"ctx",
".",
"obj",
"=",
"YkmanContextObject",
"(",
")",
"if",
"log_level",
":",
"ykman",
".",
"logging_setup",
".",
"setup",
"(",
"log_level",
",",
"lo... | Configure your YubiKey via the command line.
Examples:
\b
List connected YubiKeys, only output serial number:
$ ykman list --serials
\b
Show information about YubiKey with serial number 0123456:
$ ykman --device 0123456 info | [
"Configure",
"your",
"YubiKey",
"via",
"the",
"command",
"line",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/__main__.py#L154-L191 | train |
Yubico/yubikey-manager | ykman/cli/__main__.py | list_keys | def list_keys(ctx, serials, readers):
"""
List connected YubiKeys.
"""
if readers:
for reader in list_readers():
click.echo(reader.name)
ctx.exit()
all_descriptors = get_descriptors()
descriptors = [d for d in all_descriptors if d.key_type != YUBIKEY.SKY]
skys = ... | python | def list_keys(ctx, serials, readers):
"""
List connected YubiKeys.
"""
if readers:
for reader in list_readers():
click.echo(reader.name)
ctx.exit()
all_descriptors = get_descriptors()
descriptors = [d for d in all_descriptors if d.key_type != YUBIKEY.SKY]
skys = ... | [
"def",
"list_keys",
"(",
"ctx",
",",
"serials",
",",
"readers",
")",
":",
"if",
"readers",
":",
"for",
"reader",
"in",
"list_readers",
"(",
")",
":",
"click",
".",
"echo",
"(",
"reader",
".",
"name",
")",
"ctx",
".",
"exit",
"(",
")",
"all_descriptor... | List connected YubiKeys. | [
"List",
"connected",
"YubiKeys",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/__main__.py#L200-L241 | train |
Yubico/yubikey-manager | ykman/cli/otp.py | otp | def otp(ctx, access_code):
"""
Manage OTP Application.
The YubiKey provides two keyboard-based slots which can each be configured
with a credential. Several credential types are supported.
A slot configuration may be write-protected with an access code. This
prevents the configuration to be ov... | python | def otp(ctx, access_code):
"""
Manage OTP Application.
The YubiKey provides two keyboard-based slots which can each be configured
with a credential. Several credential types are supported.
A slot configuration may be write-protected with an access code. This
prevents the configuration to be ov... | [
"def",
"otp",
"(",
"ctx",
",",
"access_code",
")",
":",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"=",
"OtpController",
"(",
"ctx",
".",
"obj",
"[",
"'dev'",
"]",
".",
"driver",
")",
"if",
"access_code",
"is",
"not",
"None",
":",
"if",
"access_cod... | Manage OTP Application.
The YubiKey provides two keyboard-based slots which can each be configured
with a credential. Several credential types are supported.
A slot configuration may be write-protected with an access code. This
prevents the configuration to be overwritten without the access code
p... | [
"Manage",
"OTP",
"Application",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/otp.py#L98-L140 | train |
Yubico/yubikey-manager | ykman/cli/otp.py | info | def info(ctx):
"""
Display status of YubiKey Slots.
"""
dev = ctx.obj['dev']
controller = ctx.obj['controller']
slot1, slot2 = controller.slot_status
click.echo('Slot 1: {}'.format(slot1 and 'programmed' or 'empty'))
click.echo('Slot 2: {}'.format(slot2 and 'programmed' or 'empty'))
... | python | def info(ctx):
"""
Display status of YubiKey Slots.
"""
dev = ctx.obj['dev']
controller = ctx.obj['controller']
slot1, slot2 = controller.slot_status
click.echo('Slot 1: {}'.format(slot1 and 'programmed' or 'empty'))
click.echo('Slot 2: {}'.format(slot2 and 'programmed' or 'empty'))
... | [
"def",
"info",
"(",
"ctx",
")",
":",
"dev",
"=",
"ctx",
".",
"obj",
"[",
"'dev'",
"]",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"slot1",
",",
"slot2",
"=",
"controller",
".",
"slot_status",
"click",
".",
"echo",
"(",
"'Slot 1: ... | Display status of YubiKey Slots. | [
"Display",
"status",
"of",
"YubiKey",
"Slots",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/otp.py#L145-L158 | train |
Yubico/yubikey-manager | ykman/cli/otp.py | swap | def swap(ctx):
"""
Swaps the two slot configurations.
"""
controller = ctx.obj['controller']
click.echo('Swapping slots...')
try:
controller.swap_slots()
except YkpersError as e:
_failed_to_write_msg(ctx, e) | python | def swap(ctx):
"""
Swaps the two slot configurations.
"""
controller = ctx.obj['controller']
click.echo('Swapping slots...')
try:
controller.swap_slots()
except YkpersError as e:
_failed_to_write_msg(ctx, e) | [
"def",
"swap",
"(",
"ctx",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"click",
".",
"echo",
"(",
"'Swapping slots...'",
")",
"try",
":",
"controller",
".",
"swap_slots",
"(",
")",
"except",
"YkpersError",
"as",
"e",
":",
... | Swaps the two slot configurations. | [
"Swaps",
"the",
"two",
"slot",
"configurations",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/otp.py#L165-L174 | train |
Yubico/yubikey-manager | ykman/cli/otp.py | ndef | def ndef(ctx, slot, prefix):
"""
Select slot configuration to use for NDEF.
The default prefix will be used if no prefix is specified.
"""
dev = ctx.obj['dev']
controller = ctx.obj['controller']
if not dev.config.nfc_supported:
ctx.fail('NFC interface not available.')
if not co... | python | def ndef(ctx, slot, prefix):
"""
Select slot configuration to use for NDEF.
The default prefix will be used if no prefix is specified.
"""
dev = ctx.obj['dev']
controller = ctx.obj['controller']
if not dev.config.nfc_supported:
ctx.fail('NFC interface not available.')
if not co... | [
"def",
"ndef",
"(",
"ctx",
",",
"slot",
",",
"prefix",
")",
":",
"dev",
"=",
"ctx",
".",
"obj",
"[",
"'dev'",
"]",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"if",
"not",
"dev",
".",
"config",
".",
"nfc_supported",
":",
"ctx",
... | Select slot configuration to use for NDEF.
The default prefix will be used if no prefix is specified. | [
"Select",
"slot",
"configuration",
"to",
"use",
"for",
"NDEF",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/otp.py#L182-L202 | train |
Yubico/yubikey-manager | ykman/cli/otp.py | delete | def delete(ctx, slot, force):
"""
Deletes the configuration of a slot.
"""
controller = ctx.obj['controller']
if not force and not controller.slot_status[slot - 1]:
ctx.fail('Not possible to delete an empty slot.')
force or click.confirm(
'Do you really want to delete'
' ... | python | def delete(ctx, slot, force):
"""
Deletes the configuration of a slot.
"""
controller = ctx.obj['controller']
if not force and not controller.slot_status[slot - 1]:
ctx.fail('Not possible to delete an empty slot.')
force or click.confirm(
'Do you really want to delete'
' ... | [
"def",
"delete",
"(",
"ctx",
",",
"slot",
",",
"force",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"if",
"not",
"force",
"and",
"not",
"controller",
".",
"slot_status",
"[",
"slot",
"-",
"1",
"]",
":",
"ctx",
".",
"fa... | Deletes the configuration of a slot. | [
"Deletes",
"the",
"configuration",
"of",
"a",
"slot",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/otp.py#L209-L223 | train |
Yubico/yubikey-manager | ykman/cli/otp.py | yubiotp | def yubiotp(ctx, slot, public_id, private_id, key, no_enter, force,
serial_public_id, generate_private_id,
generate_key):
"""
Program a Yubico OTP credential.
"""
dev = ctx.obj['dev']
controller = ctx.obj['controller']
if public_id and serial_public_id:
ctx.fai... | python | def yubiotp(ctx, slot, public_id, private_id, key, no_enter, force,
serial_public_id, generate_private_id,
generate_key):
"""
Program a Yubico OTP credential.
"""
dev = ctx.obj['dev']
controller = ctx.obj['controller']
if public_id and serial_public_id:
ctx.fai... | [
"def",
"yubiotp",
"(",
"ctx",
",",
"slot",
",",
"public_id",
",",
"private_id",
",",
"key",
",",
"no_enter",
",",
"force",
",",
"serial_public_id",
",",
"generate_private_id",
",",
"generate_key",
")",
":",
"dev",
"=",
"ctx",
".",
"obj",
"[",
"'dev'",
"]... | Program a Yubico OTP credential. | [
"Program",
"a",
"Yubico",
"OTP",
"credential",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/otp.py#L247-L321 | train |
Yubico/yubikey-manager | ykman/cli/otp.py | static | def static(
ctx, slot, password, generate, length,
keyboard_layout, no_enter, force):
"""
Configure a static password.
To avoid problems with different keyboard layouts, the following characters
are allowed by default: cbdefghijklnrtuv
Use the --keyboard-layout option to allow more... | python | def static(
ctx, slot, password, generate, length,
keyboard_layout, no_enter, force):
"""
Configure a static password.
To avoid problems with different keyboard layouts, the following characters
are allowed by default: cbdefghijklnrtuv
Use the --keyboard-layout option to allow more... | [
"def",
"static",
"(",
"ctx",
",",
"slot",
",",
"password",
",",
"generate",
",",
"length",
",",
"keyboard_layout",
",",
"no_enter",
",",
"force",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"keyboard_layout",
"=",
"KEYBOARD_LA... | Configure a static password.
To avoid problems with different keyboard layouts, the following characters
are allowed by default: cbdefghijklnrtuv
Use the --keyboard-layout option to allow more characters based on
preferred keyboard layout. | [
"Configure",
"a",
"static",
"password",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/otp.py#L341-L373 | train |
Yubico/yubikey-manager | ykman/cli/otp.py | chalresp | def chalresp(ctx, slot, key, totp, touch, force, generate):
"""
Program a challenge-response credential.
If KEY is not given, an interactive prompt will ask for it.
"""
controller = ctx.obj['controller']
if key:
if generate:
ctx.fail('Invalid options: --generate conflicts w... | python | def chalresp(ctx, slot, key, totp, touch, force, generate):
"""
Program a challenge-response credential.
If KEY is not given, an interactive prompt will ask for it.
"""
controller = ctx.obj['controller']
if key:
if generate:
ctx.fail('Invalid options: --generate conflicts w... | [
"def",
"chalresp",
"(",
"ctx",
",",
"slot",
",",
"key",
",",
"totp",
",",
"touch",
",",
"force",
",",
"generate",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"if",
"key",
":",
"if",
"generate",
":",
"ctx",
".",
"fail",... | Program a challenge-response credential.
If KEY is not given, an interactive prompt will ask for it. | [
"Program",
"a",
"challenge",
"-",
"response",
"credential",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/otp.py#L390-L432 | train |
Yubico/yubikey-manager | ykman/cli/otp.py | calculate | def calculate(ctx, slot, challenge, totp, digits):
"""
Perform a challenge-response operation.
Send a challenge (in hex) to a YubiKey slot with a challenge-response
credential, and read the response. Supports output as a OATH-TOTP code.
"""
controller = ctx.obj['controller']
if not challeng... | python | def calculate(ctx, slot, challenge, totp, digits):
"""
Perform a challenge-response operation.
Send a challenge (in hex) to a YubiKey slot with a challenge-response
credential, and read the response. Supports output as a OATH-TOTP code.
"""
controller = ctx.obj['controller']
if not challeng... | [
"def",
"calculate",
"(",
"ctx",
",",
"slot",
",",
"challenge",
",",
"totp",
",",
"digits",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"if",
"not",
"challenge",
"and",
"not",
"totp",
":",
"ctx",
".",
"fail",
"(",
"'No ch... | Perform a challenge-response operation.
Send a challenge (in hex) to a YubiKey slot with a challenge-response
credential, and read the response. Supports output as a OATH-TOTP code. | [
"Perform",
"a",
"challenge",
"-",
"response",
"operation",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/otp.py#L445-L488 | train |
Yubico/yubikey-manager | ykman/cli/otp.py | hotp | def hotp(ctx, slot, key, digits, counter, no_enter, force):
"""
Program an HMAC-SHA1 OATH-HOTP credential.
"""
controller = ctx.obj['controller']
if not key:
while True:
key = click.prompt('Enter a secret key (base32)', err=True)
try:
key = parse_b32_... | python | def hotp(ctx, slot, key, digits, counter, no_enter, force):
"""
Program an HMAC-SHA1 OATH-HOTP credential.
"""
controller = ctx.obj['controller']
if not key:
while True:
key = click.prompt('Enter a secret key (base32)', err=True)
try:
key = parse_b32_... | [
"def",
"hotp",
"(",
"ctx",
",",
"slot",
",",
"key",
",",
"digits",
",",
"counter",
",",
"no_enter",
",",
"force",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"if",
"not",
"key",
":",
"while",
"True",
":",
"key",
"=",
... | Program an HMAC-SHA1 OATH-HOTP credential. | [
"Program",
"an",
"HMAC",
"-",
"SHA1",
"OATH",
"-",
"HOTP",
"credential",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/otp.py#L502-L524 | train |
Yubico/yubikey-manager | ykman/cli/otp.py | settings | def settings(ctx, slot, new_access_code, delete_access_code, enter, pacing,
force):
"""
Update the settings for a slot.
Change the settings for a slot without changing the stored secret.
All settings not specified will be written with default values.
"""
controller = ctx.obj['contr... | python | def settings(ctx, slot, new_access_code, delete_access_code, enter, pacing,
force):
"""
Update the settings for a slot.
Change the settings for a slot without changing the stored secret.
All settings not specified will be written with default values.
"""
controller = ctx.obj['contr... | [
"def",
"settings",
"(",
"ctx",
",",
"slot",
",",
"new_access_code",
",",
"delete_access_code",
",",
"enter",
",",
"pacing",
",",
"force",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"if",
"(",
"new_access_code",
"is",
"not",
... | Update the settings for a slot.
Change the settings for a slot without changing the stored secret.
All settings not specified will be written with default values. | [
"Update",
"the",
"settings",
"for",
"a",
"slot",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/otp.py#L545-L597 | train |
Yubico/yubikey-manager | ykman/util.py | parse_private_key | def parse_private_key(data, password):
"""
Identifies, decrypts and returns a cryptography private key object.
"""
# PEM
if is_pem(data):
if b'ENCRYPTED' in data:
if password is None:
raise TypeError('No password provided for encrypted key.')
try:
... | python | def parse_private_key(data, password):
"""
Identifies, decrypts and returns a cryptography private key object.
"""
# PEM
if is_pem(data):
if b'ENCRYPTED' in data:
if password is None:
raise TypeError('No password provided for encrypted key.')
try:
... | [
"def",
"parse_private_key",
"(",
"data",
",",
"password",
")",
":",
"# PEM",
"if",
"is_pem",
"(",
"data",
")",
":",
"if",
"b'ENCRYPTED'",
"in",
"data",
":",
"if",
"password",
"is",
"None",
":",
"raise",
"TypeError",
"(",
"'No password provided for encrypted ke... | Identifies, decrypts and returns a cryptography private key object. | [
"Identifies",
"decrypts",
"and",
"returns",
"a",
"cryptography",
"private",
"key",
"object",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/util.py#L419-L456 | train |
Yubico/yubikey-manager | ykman/util.py | parse_certificates | def parse_certificates(data, password):
"""
Identifies, decrypts and returns list of cryptography x509 certificates.
"""
# PEM
if is_pem(data):
certs = []
for cert in data.split(PEM_IDENTIFIER):
try:
certs.append(
x509.load_pem_x509_ce... | python | def parse_certificates(data, password):
"""
Identifies, decrypts and returns list of cryptography x509 certificates.
"""
# PEM
if is_pem(data):
certs = []
for cert in data.split(PEM_IDENTIFIER):
try:
certs.append(
x509.load_pem_x509_ce... | [
"def",
"parse_certificates",
"(",
"data",
",",
"password",
")",
":",
"# PEM",
"if",
"is_pem",
"(",
"data",
")",
":",
"certs",
"=",
"[",
"]",
"for",
"cert",
"in",
"data",
".",
"split",
"(",
"PEM_IDENTIFIER",
")",
":",
"try",
":",
"certs",
".",
"append... | Identifies, decrypts and returns list of cryptography x509 certificates. | [
"Identifies",
"decrypts",
"and",
"returns",
"list",
"of",
"cryptography",
"x509",
"certificates",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/util.py#L459-L494 | train |
Yubico/yubikey-manager | ykman/util.py | get_leaf_certificates | def get_leaf_certificates(certs):
"""
Extracts the leaf certificates from a list of certificates. Leaf
certificates are ones whose subject does not appear as issuer among the
others.
"""
issuers = [cert.issuer.get_attributes_for_oid(x509.NameOID.COMMON_NAME)
for cert in certs]
... | python | def get_leaf_certificates(certs):
"""
Extracts the leaf certificates from a list of certificates. Leaf
certificates are ones whose subject does not appear as issuer among the
others.
"""
issuers = [cert.issuer.get_attributes_for_oid(x509.NameOID.COMMON_NAME)
for cert in certs]
... | [
"def",
"get_leaf_certificates",
"(",
"certs",
")",
":",
"issuers",
"=",
"[",
"cert",
".",
"issuer",
".",
"get_attributes_for_oid",
"(",
"x509",
".",
"NameOID",
".",
"COMMON_NAME",
")",
"for",
"cert",
"in",
"certs",
"]",
"leafs",
"=",
"[",
"cert",
"for",
... | Extracts the leaf certificates from a list of certificates. Leaf
certificates are ones whose subject does not appear as issuer among the
others. | [
"Extracts",
"the",
"leaf",
"certificates",
"from",
"a",
"list",
"of",
"certificates",
".",
"Leaf",
"certificates",
"are",
"ones",
"whose",
"subject",
"does",
"not",
"appear",
"as",
"issuer",
"among",
"the",
"others",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/util.py#L497-L508 | train |
Yubico/yubikey-manager | ykman/cli/config.py | set_lock_code | def set_lock_code(ctx, lock_code, new_lock_code, clear, generate, force):
"""
Set or change the configuration lock code.
A lock code may be used to protect the application configuration.
The lock code must be a 32 characters (16 bytes) hex value.
"""
dev = ctx.obj['dev']
def prompt_new_lo... | python | def set_lock_code(ctx, lock_code, new_lock_code, clear, generate, force):
"""
Set or change the configuration lock code.
A lock code may be used to protect the application configuration.
The lock code must be a 32 characters (16 bytes) hex value.
"""
dev = ctx.obj['dev']
def prompt_new_lo... | [
"def",
"set_lock_code",
"(",
"ctx",
",",
"lock_code",
",",
"new_lock_code",
",",
"clear",
",",
"generate",
",",
"force",
")",
":",
"dev",
"=",
"ctx",
".",
"obj",
"[",
"'dev'",
"]",
"def",
"prompt_new_lock_code",
"(",
")",
":",
"return",
"prompt_lock_code",... | Set or change the configuration lock code.
A lock code may be used to protect the application configuration.
The lock code must be a 32 characters (16 bytes) hex value. | [
"Set",
"or",
"change",
"the",
"configuration",
"lock",
"code",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/config.py#L101-L179 | train |
Yubico/yubikey-manager | ykman/cli/config.py | nfc | def nfc(ctx, enable, disable, enable_all, disable_all, list, lock_code, force):
"""
Enable or disable applications over NFC.
"""
if not (list or enable_all or enable or disable_all or disable):
ctx.fail('No configuration options chosen.')
if enable_all:
enable = APPLICATION.__membe... | python | def nfc(ctx, enable, disable, enable_all, disable_all, list, lock_code, force):
"""
Enable or disable applications over NFC.
"""
if not (list or enable_all or enable or disable_all or disable):
ctx.fail('No configuration options chosen.')
if enable_all:
enable = APPLICATION.__membe... | [
"def",
"nfc",
"(",
"ctx",
",",
"enable",
",",
"disable",
",",
"enable_all",
",",
"disable_all",
",",
"list",
",",
"lock_code",
",",
"force",
")",
":",
"if",
"not",
"(",
"list",
"or",
"enable_all",
"or",
"enable",
"or",
"disable_all",
"or",
"disable",
"... | Enable or disable applications over NFC. | [
"Enable",
"or",
"disable",
"applications",
"over",
"NFC",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/config.py#L332-L401 | train |
Yubico/yubikey-manager | ykman/cli/info.py | info | def info(ctx, check_fips):
"""
Show general information.
Displays information about the attached YubiKey such as serial number,
firmware version, applications, etc.
"""
dev = ctx.obj['dev']
if dev.is_fips and check_fips:
fips_status = get_overall_fips_status(dev.serial, dev.config)... | python | def info(ctx, check_fips):
"""
Show general information.
Displays information about the attached YubiKey such as serial number,
firmware version, applications, etc.
"""
dev = ctx.obj['dev']
if dev.is_fips and check_fips:
fips_status = get_overall_fips_status(dev.serial, dev.config)... | [
"def",
"info",
"(",
"ctx",
",",
"check_fips",
")",
":",
"dev",
"=",
"ctx",
".",
"obj",
"[",
"'dev'",
"]",
"if",
"dev",
".",
"is_fips",
"and",
"check_fips",
":",
"fips_status",
"=",
"get_overall_fips_status",
"(",
"dev",
".",
"serial",
",",
"dev",
".",
... | Show general information.
Displays information about the attached YubiKey such as serial number,
firmware version, applications, etc. | [
"Show",
"general",
"information",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/info.py#L130-L175 | train |
Yubico/yubikey-manager | ykman/cli/oath.py | oath | def oath(ctx, password):
"""
Manage OATH Application.
Examples:
\b
Generate codes for credentials starting with 'yubi':
$ ykman oath code yubi
\b
Add a touch credential with the secret key f5up4ub3dw and the name yubico:
$ ykman oath add yubico f5up4ub3dw --touch
\b
... | python | def oath(ctx, password):
"""
Manage OATH Application.
Examples:
\b
Generate codes for credentials starting with 'yubi':
$ ykman oath code yubi
\b
Add a touch credential with the secret key f5up4ub3dw and the name yubico:
$ ykman oath add yubico f5up4ub3dw --touch
\b
... | [
"def",
"oath",
"(",
"ctx",
",",
"password",
")",
":",
"try",
":",
"controller",
"=",
"OathController",
"(",
"ctx",
".",
"obj",
"[",
"'dev'",
"]",
".",
"driver",
")",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"=",
"controller",
"ctx",
".",
"obj",
... | Manage OATH Application.
Examples:
\b
Generate codes for credentials starting with 'yubi':
$ ykman oath code yubi
\b
Add a touch credential with the secret key f5up4ub3dw and the name yubico:
$ ykman oath add yubico f5up4ub3dw --touch
\b
Set a password for the OATH appl... | [
"Manage",
"OATH",
"Application",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/oath.py#L87-L115 | train |
Yubico/yubikey-manager | ykman/cli/oath.py | info | def info(ctx):
"""
Display status of OATH application.
"""
controller = ctx.obj['controller']
version = controller.version
click.echo(
'OATH version: {}.{}.{}'.format(version[0], version[1], version[2]))
click.echo('Password protection ' +
('enabled' if controller.lock... | python | def info(ctx):
"""
Display status of OATH application.
"""
controller = ctx.obj['controller']
version = controller.version
click.echo(
'OATH version: {}.{}.{}'.format(version[0], version[1], version[2]))
click.echo('Password protection ' +
('enabled' if controller.lock... | [
"def",
"info",
"(",
"ctx",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"version",
"=",
"controller",
".",
"version",
"click",
".",
"echo",
"(",
"'OATH version: {}.{}.{}'",
".",
"format",
"(",
"version",
"[",
"0",
"]",
",",
... | Display status of OATH application. | [
"Display",
"status",
"of",
"OATH",
"application",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/oath.py#L120-L137 | train |
Yubico/yubikey-manager | ykman/cli/oath.py | reset | def reset(ctx):
"""
Reset all OATH data.
This action will wipe all credentials and reset factory settings for
the OATH application on the YubiKey.
"""
controller = ctx.obj['controller']
click.echo('Resetting OATH data...')
old_id = controller.id
controller.reset()
settings = c... | python | def reset(ctx):
"""
Reset all OATH data.
This action will wipe all credentials and reset factory settings for
the OATH application on the YubiKey.
"""
controller = ctx.obj['controller']
click.echo('Resetting OATH data...')
old_id = controller.id
controller.reset()
settings = c... | [
"def",
"reset",
"(",
"ctx",
")",
":",
"controller",
"=",
"ctx",
".",
"obj",
"[",
"'controller'",
"]",
"click",
".",
"echo",
"(",
"'Resetting OATH data...'",
")",
"old_id",
"=",
"controller",
".",
"id",
"controller",
".",
"reset",
"(",
")",
"settings",
"=... | Reset all OATH data.
This action will wipe all credentials and reset factory settings for
the OATH application on the YubiKey. | [
"Reset",
"all",
"OATH",
"data",
"."
] | 3ac27bc59ae76a59db9d09a530494add2edbbabf | https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/oath.py#L145-L165 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.