id int32 0 252k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
15,400 | postlund/pyatv | pyatv/dmap/__init__.py | DmapRemoteControl.set_position | def set_position(self, pos):
"""Seek in the current playing media."""
time_in_ms = int(pos)*1000
return self.apple_tv.set_property('dacp.playingtime', time_in_ms) | python | def set_position(self, pos):
"""Seek in the current playing media."""
time_in_ms = int(pos)*1000
return self.apple_tv.set_property('dacp.playingtime', time_in_ms) | [
"def",
"set_position",
"(",
"self",
",",
"pos",
")",
":",
"time_in_ms",
"=",
"int",
"(",
"pos",
")",
"*",
"1000",
"return",
"self",
".",
"apple_tv",
".",
"set_property",
"(",
"'dacp.playingtime'",
",",
"time_in_ms",
")"
] | Seek in the current playing media. | [
"Seek",
"in",
"the",
"current",
"playing",
"media",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/dmap/__init__.py#L185-L188 |
15,401 | postlund/pyatv | examples/device_auth.py | authenticate_with_device | async def authenticate_with_device(atv):
"""Perform device authentication and print credentials."""
credentials = await atv.airplay.generate_credentials()
await atv.airplay.load_credentials(credentials)
try:
await atv.airplay.start_authentication()
pin = input('PIN Code: ')
awai... | python | async def authenticate_with_device(atv):
"""Perform device authentication and print credentials."""
credentials = await atv.airplay.generate_credentials()
await atv.airplay.load_credentials(credentials)
try:
await atv.airplay.start_authentication()
pin = input('PIN Code: ')
awai... | [
"async",
"def",
"authenticate_with_device",
"(",
"atv",
")",
":",
"credentials",
"=",
"await",
"atv",
".",
"airplay",
".",
"generate_credentials",
"(",
")",
"await",
"atv",
".",
"airplay",
".",
"load_credentials",
"(",
"credentials",
")",
"try",
":",
"await",
... | Perform device authentication and print credentials. | [
"Perform",
"device",
"authentication",
"and",
"print",
"credentials",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/examples/device_auth.py#L7-L19 |
15,402 | postlund/pyatv | pyatv/mrp/chacha20.py | Chacha20Cipher.encrypt | def encrypt(self, data, nounce=None):
"""Encrypt data with counter or specified nounce."""
if nounce is None:
nounce = self._out_counter.to_bytes(length=8, byteorder='little')
self._out_counter += 1
return self._enc_out.seal(b'\x00\x00\x00\x00' + nounce, data, bytes()) | python | def encrypt(self, data, nounce=None):
"""Encrypt data with counter or specified nounce."""
if nounce is None:
nounce = self._out_counter.to_bytes(length=8, byteorder='little')
self._out_counter += 1
return self._enc_out.seal(b'\x00\x00\x00\x00' + nounce, data, bytes()) | [
"def",
"encrypt",
"(",
"self",
",",
"data",
",",
"nounce",
"=",
"None",
")",
":",
"if",
"nounce",
"is",
"None",
":",
"nounce",
"=",
"self",
".",
"_out_counter",
".",
"to_bytes",
"(",
"length",
"=",
"8",
",",
"byteorder",
"=",
"'little'",
")",
"self",... | Encrypt data with counter or specified nounce. | [
"Encrypt",
"data",
"with",
"counter",
"or",
"specified",
"nounce",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/chacha20.py#L15-L21 |
15,403 | postlund/pyatv | pyatv/mrp/chacha20.py | Chacha20Cipher.decrypt | def decrypt(self, data, nounce=None):
"""Decrypt data with counter or specified nounce."""
if nounce is None:
nounce = self._in_counter.to_bytes(length=8, byteorder='little')
self._in_counter += 1
decrypted = self._enc_in.open(
b'\x00\x00\x00\x00' + nounce, d... | python | def decrypt(self, data, nounce=None):
"""Decrypt data with counter or specified nounce."""
if nounce is None:
nounce = self._in_counter.to_bytes(length=8, byteorder='little')
self._in_counter += 1
decrypted = self._enc_in.open(
b'\x00\x00\x00\x00' + nounce, d... | [
"def",
"decrypt",
"(",
"self",
",",
"data",
",",
"nounce",
"=",
"None",
")",
":",
"if",
"nounce",
"is",
"None",
":",
"nounce",
"=",
"self",
".",
"_in_counter",
".",
"to_bytes",
"(",
"length",
"=",
"8",
",",
"byteorder",
"=",
"'little'",
")",
"self",
... | Decrypt data with counter or specified nounce. | [
"Decrypt",
"data",
"with",
"counter",
"or",
"specified",
"nounce",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/chacha20.py#L23-L35 |
15,404 | postlund/pyatv | pyatv/helpers.py | auto_connect | def auto_connect(handler, timeout=5, not_found=None, event_loop=None):
"""Short method for connecting to a device.
This is a convenience method that create an event loop, auto discovers
devices, picks the first device found, connects to it and passes it to a
user provided handler. An optional error han... | python | def auto_connect(handler, timeout=5, not_found=None, event_loop=None):
"""Short method for connecting to a device.
This is a convenience method that create an event loop, auto discovers
devices, picks the first device found, connects to it and passes it to a
user provided handler. An optional error han... | [
"def",
"auto_connect",
"(",
"handler",
",",
"timeout",
"=",
"5",
",",
"not_found",
"=",
"None",
",",
"event_loop",
"=",
"None",
")",
":",
"# A coroutine is used so we can connect to the device while being inside",
"# the event loop",
"async",
"def",
"_handle",
"(",
"l... | Short method for connecting to a device.
This is a convenience method that create an event loop, auto discovers
devices, picks the first device found, connects to it and passes it to a
user provided handler. An optional error handler can be provided that is
called when no device was found. Very inflexi... | [
"Short",
"method",
"for",
"connecting",
"to",
"a",
"device",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/helpers.py#L7-L37 |
15,405 | postlund/pyatv | pyatv/dmap/daap.py | DaapRequester.login | async def login(self):
"""Login to Apple TV using specified login id."""
# Do not use session.get_data(...) in login as that would end up in
# an infinte loop.
def _login_request():
return self.http.get_data(
self._mkurl('login?[AUTH]&hasFP=1',
... | python | async def login(self):
"""Login to Apple TV using specified login id."""
# Do not use session.get_data(...) in login as that would end up in
# an infinte loop.
def _login_request():
return self.http.get_data(
self._mkurl('login?[AUTH]&hasFP=1',
... | [
"async",
"def",
"login",
"(",
"self",
")",
":",
"# Do not use session.get_data(...) in login as that would end up in",
"# an infinte loop.",
"def",
"_login_request",
"(",
")",
":",
"return",
"self",
".",
"http",
".",
"get_data",
"(",
"self",
".",
"_mkurl",
"(",
"'lo... | Login to Apple TV using specified login id. | [
"Login",
"to",
"Apple",
"TV",
"using",
"specified",
"login",
"id",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/dmap/daap.py#L41-L55 |
15,406 | postlund/pyatv | pyatv/dmap/daap.py | DaapRequester.get | async def get(self, cmd, daap_data=True, timeout=None, **args):
"""Perform a DAAP GET command."""
def _get_request():
return self.http.get_data(
self._mkurl(cmd, *args),
headers=_DMAP_HEADERS,
timeout=timeout)
await self._assure_logged... | python | async def get(self, cmd, daap_data=True, timeout=None, **args):
"""Perform a DAAP GET command."""
def _get_request():
return self.http.get_data(
self._mkurl(cmd, *args),
headers=_DMAP_HEADERS,
timeout=timeout)
await self._assure_logged... | [
"async",
"def",
"get",
"(",
"self",
",",
"cmd",
",",
"daap_data",
"=",
"True",
",",
"timeout",
"=",
"None",
",",
"*",
"*",
"args",
")",
":",
"def",
"_get_request",
"(",
")",
":",
"return",
"self",
".",
"http",
".",
"get_data",
"(",
"self",
".",
"... | Perform a DAAP GET command. | [
"Perform",
"a",
"DAAP",
"GET",
"command",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/dmap/daap.py#L57-L66 |
15,407 | postlund/pyatv | pyatv/dmap/daap.py | DaapRequester.get_url | def get_url(self, cmd, **args):
"""Expand the request URL for a request."""
return self.http.base_url + self._mkurl(cmd, *args) | python | def get_url(self, cmd, **args):
"""Expand the request URL for a request."""
return self.http.base_url + self._mkurl(cmd, *args) | [
"def",
"get_url",
"(",
"self",
",",
"cmd",
",",
"*",
"*",
"args",
")",
":",
"return",
"self",
".",
"http",
".",
"base_url",
"+",
"self",
".",
"_mkurl",
"(",
"cmd",
",",
"*",
"args",
")"
] | Expand the request URL for a request. | [
"Expand",
"the",
"request",
"URL",
"for",
"a",
"request",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/dmap/daap.py#L68-L70 |
15,408 | postlund/pyatv | pyatv/dmap/daap.py | DaapRequester.post | async def post(self, cmd, data=None, timeout=None, **args):
"""Perform DAAP POST command with optional data."""
def _post_request():
headers = copy(_DMAP_HEADERS)
headers['Content-Type'] = 'application/x-www-form-urlencoded'
return self.http.post_data(
... | python | async def post(self, cmd, data=None, timeout=None, **args):
"""Perform DAAP POST command with optional data."""
def _post_request():
headers = copy(_DMAP_HEADERS)
headers['Content-Type'] = 'application/x-www-form-urlencoded'
return self.http.post_data(
... | [
"async",
"def",
"post",
"(",
"self",
",",
"cmd",
",",
"data",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"*",
"*",
"args",
")",
":",
"def",
"_post_request",
"(",
")",
":",
"headers",
"=",
"copy",
"(",
"_DMAP_HEADERS",
")",
"headers",
"[",
"'Con... | Perform DAAP POST command with optional data. | [
"Perform",
"DAAP",
"POST",
"command",
"with",
"optional",
"data",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/dmap/daap.py#L72-L84 |
15,409 | postlund/pyatv | pyatv/mrp/__init__.py | MrpRemoteControl.set_repeat | def set_repeat(self, repeat_mode):
"""Change repeat mode."""
# TODO: extract to convert module
if int(repeat_mode) == const.REPEAT_STATE_OFF:
state = 1
elif int(repeat_mode) == const.REPEAT_STATE_ALL:
state = 2
elif int(repeat_mode) == const.REPEAT_STATE_T... | python | def set_repeat(self, repeat_mode):
"""Change repeat mode."""
# TODO: extract to convert module
if int(repeat_mode) == const.REPEAT_STATE_OFF:
state = 1
elif int(repeat_mode) == const.REPEAT_STATE_ALL:
state = 2
elif int(repeat_mode) == const.REPEAT_STATE_T... | [
"def",
"set_repeat",
"(",
"self",
",",
"repeat_mode",
")",
":",
"# TODO: extract to convert module",
"if",
"int",
"(",
"repeat_mode",
")",
"==",
"const",
".",
"REPEAT_STATE_OFF",
":",
"state",
"=",
"1",
"elif",
"int",
"(",
"repeat_mode",
")",
"==",
"const",
... | Change repeat mode. | [
"Change",
"repeat",
"mode",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/__init__.py#L116-L128 |
15,410 | postlund/pyatv | pyatv/mrp/__init__.py | MrpPlaying.genre | def genre(self):
"""Genre of the currently playing song."""
if self._metadata:
from pyatv.mrp.protobuf import ContentItem_pb2
transaction = ContentItem_pb2.ContentItem()
transaction.ParseFromString(self._metadata) | python | def genre(self):
"""Genre of the currently playing song."""
if self._metadata:
from pyatv.mrp.protobuf import ContentItem_pb2
transaction = ContentItem_pb2.ContentItem()
transaction.ParseFromString(self._metadata) | [
"def",
"genre",
"(",
"self",
")",
":",
"if",
"self",
".",
"_metadata",
":",
"from",
"pyatv",
".",
"mrp",
".",
"protobuf",
"import",
"ContentItem_pb2",
"transaction",
"=",
"ContentItem_pb2",
".",
"ContentItem",
"(",
")",
"transaction",
".",
"ParseFromString",
... | Genre of the currently playing song. | [
"Genre",
"of",
"the",
"currently",
"playing",
"song",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/__init__.py#L172-L177 |
15,411 | postlund/pyatv | pyatv/mrp/__init__.py | MrpPlaying.total_time | def total_time(self):
"""Total play time in seconds."""
now_playing = self._setstate.nowPlayingInfo
if now_playing.HasField('duration'):
return int(now_playing.duration)
return None | python | def total_time(self):
"""Total play time in seconds."""
now_playing = self._setstate.nowPlayingInfo
if now_playing.HasField('duration'):
return int(now_playing.duration)
return None | [
"def",
"total_time",
"(",
"self",
")",
":",
"now_playing",
"=",
"self",
".",
"_setstate",
".",
"nowPlayingInfo",
"if",
"now_playing",
".",
"HasField",
"(",
"'duration'",
")",
":",
"return",
"int",
"(",
"now_playing",
".",
"duration",
")",
"return",
"None"
] | Total play time in seconds. | [
"Total",
"play",
"time",
"in",
"seconds",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/__init__.py#L181-L187 |
15,412 | postlund/pyatv | pyatv/mrp/__init__.py | MrpPlaying.shuffle | def shuffle(self):
"""If shuffle is enabled or not."""
info = self._get_command_info(CommandInfo_pb2.ChangeShuffleMode)
return None if info is None else info.shuffleMode | python | def shuffle(self):
"""If shuffle is enabled or not."""
info = self._get_command_info(CommandInfo_pb2.ChangeShuffleMode)
return None if info is None else info.shuffleMode | [
"def",
"shuffle",
"(",
"self",
")",
":",
"info",
"=",
"self",
".",
"_get_command_info",
"(",
"CommandInfo_pb2",
".",
"ChangeShuffleMode",
")",
"return",
"None",
"if",
"info",
"is",
"None",
"else",
"info",
".",
"shuffleMode"
] | If shuffle is enabled or not. | [
"If",
"shuffle",
"is",
"enabled",
"or",
"not",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/__init__.py#L205-L208 |
15,413 | postlund/pyatv | pyatv/mrp/__init__.py | MrpPlaying.repeat | def repeat(self):
"""Repeat mode."""
info = self._get_command_info(CommandInfo_pb2.ChangeRepeatMode)
return None if info is None else info.repeatMode | python | def repeat(self):
"""Repeat mode."""
info = self._get_command_info(CommandInfo_pb2.ChangeRepeatMode)
return None if info is None else info.repeatMode | [
"def",
"repeat",
"(",
"self",
")",
":",
"info",
"=",
"self",
".",
"_get_command_info",
"(",
"CommandInfo_pb2",
".",
"ChangeRepeatMode",
")",
"return",
"None",
"if",
"info",
"is",
"None",
"else",
"info",
".",
"repeatMode"
] | Repeat mode. | [
"Repeat",
"mode",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/__init__.py#L211-L214 |
15,414 | postlund/pyatv | pyatv/mrp/__init__.py | MrpMetadata.playing | async def playing(self):
"""Return what is currently playing."""
# TODO: This is hack-ish
if self._setstate is None:
await self.protocol.start()
# No SET_STATE_MESSAGE received yet, use default
if self._setstate is None:
return MrpPlaying(protobuf.SetStat... | python | async def playing(self):
"""Return what is currently playing."""
# TODO: This is hack-ish
if self._setstate is None:
await self.protocol.start()
# No SET_STATE_MESSAGE received yet, use default
if self._setstate is None:
return MrpPlaying(protobuf.SetStat... | [
"async",
"def",
"playing",
"(",
"self",
")",
":",
"# TODO: This is hack-ish",
"if",
"self",
".",
"_setstate",
"is",
"None",
":",
"await",
"self",
".",
"protocol",
".",
"start",
"(",
")",
"# No SET_STATE_MESSAGE received yet, use default",
"if",
"self",
".",
"_se... | Return what is currently playing. | [
"Return",
"what",
"is",
"currently",
"playing",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/__init__.py#L250-L260 |
15,415 | postlund/pyatv | pyatv/mrp/__init__.py | MrpPairingHandler.stop | async def stop(self, **kwargs):
"""Stop pairing process."""
if not self._pin_code:
raise Exception('no pin given') # TODO: new exception
self.service.device_credentials = \
await self.pairing_procedure.finish_pairing(self._pin_code) | python | async def stop(self, **kwargs):
"""Stop pairing process."""
if not self._pin_code:
raise Exception('no pin given') # TODO: new exception
self.service.device_credentials = \
await self.pairing_procedure.finish_pairing(self._pin_code) | [
"async",
"def",
"stop",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"_pin_code",
":",
"raise",
"Exception",
"(",
"'no pin given'",
")",
"# TODO: new exception",
"self",
".",
"service",
".",
"device_credentials",
"=",
"await",
... | Stop pairing process. | [
"Stop",
"pairing",
"process",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/__init__.py#L324-L330 |
15,416 | postlund/pyatv | pyatv/mrp/tlv8.py | read_tlv | def read_tlv(data):
"""Parse TLV8 bytes into a dict.
If value is larger than 255 bytes, it is split up in multiple chunks. So
the same tag might occurr several times.
"""
def _parse(data, pos, size, result=None):
if result is None:
result = {}
if pos >= size:
... | python | def read_tlv(data):
"""Parse TLV8 bytes into a dict.
If value is larger than 255 bytes, it is split up in multiple chunks. So
the same tag might occurr several times.
"""
def _parse(data, pos, size, result=None):
if result is None:
result = {}
if pos >= size:
... | [
"def",
"read_tlv",
"(",
"data",
")",
":",
"def",
"_parse",
"(",
"data",
",",
"pos",
",",
"size",
",",
"result",
"=",
"None",
")",
":",
"if",
"result",
"is",
"None",
":",
"result",
"=",
"{",
"}",
"if",
"pos",
">=",
"size",
":",
"return",
"result",... | Parse TLV8 bytes into a dict.
If value is larger than 255 bytes, it is split up in multiple chunks. So
the same tag might occurr several times. | [
"Parse",
"TLV8",
"bytes",
"into",
"a",
"dict",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/tlv8.py#L19-L41 |
15,417 | postlund/pyatv | pyatv/mrp/tlv8.py | write_tlv | def write_tlv(data):
"""Convert a dict to TLV8 bytes."""
tlv = b''
for key, value in data.items():
tag = bytes([int(key)])
length = len(value)
pos = 0
# A tag with length > 255 is added multiple times and concatenated into
# one buffer when reading the TLV again.
... | python | def write_tlv(data):
"""Convert a dict to TLV8 bytes."""
tlv = b''
for key, value in data.items():
tag = bytes([int(key)])
length = len(value)
pos = 0
# A tag with length > 255 is added multiple times and concatenated into
# one buffer when reading the TLV again.
... | [
"def",
"write_tlv",
"(",
"data",
")",
":",
"tlv",
"=",
"b''",
"for",
"key",
",",
"value",
"in",
"data",
".",
"items",
"(",
")",
":",
"tag",
"=",
"bytes",
"(",
"[",
"int",
"(",
"key",
")",
"]",
")",
"length",
"=",
"len",
"(",
"value",
")",
"po... | Convert a dict to TLV8 bytes. | [
"Convert",
"a",
"dict",
"to",
"TLV8",
"bytes",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/tlv8.py#L44-L61 |
15,418 | tommikaikkonen/prettyprinter | prettyprinter/prettyprinter.py | comment | def comment(value, comment_text):
"""Annotates a value or a Doc with a comment.
When printed by prettyprinter, the comment will be
rendered next to the value or Doc.
"""
if isinstance(value, Doc):
return comment_doc(value, comment_text)
return comment_value(value, comment_text) | python | def comment(value, comment_text):
"""Annotates a value or a Doc with a comment.
When printed by prettyprinter, the comment will be
rendered next to the value or Doc.
"""
if isinstance(value, Doc):
return comment_doc(value, comment_text)
return comment_value(value, comment_text) | [
"def",
"comment",
"(",
"value",
",",
"comment_text",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"Doc",
")",
":",
"return",
"comment_doc",
"(",
"value",
",",
"comment_text",
")",
"return",
"comment_value",
"(",
"value",
",",
"comment_text",
")"
] | Annotates a value or a Doc with a comment.
When printed by prettyprinter, the comment will be
rendered next to the value or Doc. | [
"Annotates",
"a",
"value",
"or",
"a",
"Doc",
"with",
"a",
"comment",
"."
] | 6b405884b8085eaf867e81c02b7b662b463ac5a0 | https://github.com/tommikaikkonen/prettyprinter/blob/6b405884b8085eaf867e81c02b7b662b463ac5a0/prettyprinter/prettyprinter.py#L156-L164 |
15,419 | tommikaikkonen/prettyprinter | prettyprinter/prettyprinter.py | register_pretty | def register_pretty(type=None, predicate=None):
"""Returns a decorator that registers the decorated function
as the pretty printer for instances of ``type``.
:param type: the type to register the pretty printer for, or a ``str``
to indicate the module and name, e.g.: ``'collections.Counter... | python | def register_pretty(type=None, predicate=None):
"""Returns a decorator that registers the decorated function
as the pretty printer for instances of ``type``.
:param type: the type to register the pretty printer for, or a ``str``
to indicate the module and name, e.g.: ``'collections.Counter... | [
"def",
"register_pretty",
"(",
"type",
"=",
"None",
",",
"predicate",
"=",
"None",
")",
":",
"if",
"type",
"is",
"None",
"and",
"predicate",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"You must provide either the 'type' or 'predicate' argument.\"",
")",
"if"... | Returns a decorator that registers the decorated function
as the pretty printer for instances of ``type``.
:param type: the type to register the pretty printer for, or a ``str``
to indicate the module and name, e.g.: ``'collections.Counter'``.
:param predicate: a predicate function that ta... | [
"Returns",
"a",
"decorator",
"that",
"registers",
"the",
"decorated",
"function",
"as",
"the",
"pretty",
"printer",
"for",
"instances",
"of",
"type",
"."
] | 6b405884b8085eaf867e81c02b7b662b463ac5a0 | https://github.com/tommikaikkonen/prettyprinter/blob/6b405884b8085eaf867e81c02b7b662b463ac5a0/prettyprinter/prettyprinter.py#L462-L544 |
15,420 | tommikaikkonen/prettyprinter | prettyprinter/prettyprinter.py | commentdoc | def commentdoc(text):
"""Returns a Doc representing a comment `text`. `text` is
treated as words, and any whitespace may be used to break
the comment to multiple lines."""
if not text:
raise ValueError(
'Expected non-empty comment str, got {}'.format(repr(text))
)
commen... | python | def commentdoc(text):
"""Returns a Doc representing a comment `text`. `text` is
treated as words, and any whitespace may be used to break
the comment to multiple lines."""
if not text:
raise ValueError(
'Expected non-empty comment str, got {}'.format(repr(text))
)
commen... | [
"def",
"commentdoc",
"(",
"text",
")",
":",
"if",
"not",
"text",
":",
"raise",
"ValueError",
"(",
"'Expected non-empty comment str, got {}'",
".",
"format",
"(",
"repr",
"(",
"text",
")",
")",
")",
"commentlines",
"=",
"[",
"]",
"for",
"line",
"in",
"text"... | Returns a Doc representing a comment `text`. `text` is
treated as words, and any whitespace may be used to break
the comment to multiple lines. | [
"Returns",
"a",
"Doc",
"representing",
"a",
"comment",
"text",
".",
"text",
"is",
"treated",
"as",
"words",
"and",
"any",
"whitespace",
"may",
"be",
"used",
"to",
"break",
"the",
"comment",
"to",
"multiple",
"lines",
"."
] | 6b405884b8085eaf867e81c02b7b662b463ac5a0 | https://github.com/tommikaikkonen/prettyprinter/blob/6b405884b8085eaf867e81c02b7b662b463ac5a0/prettyprinter/prettyprinter.py#L599-L654 |
15,421 | tommikaikkonen/prettyprinter | prettyprinter/prettyprinter.py | build_fncall | def build_fncall(
ctx,
fndoc,
argdocs=(),
kwargdocs=(),
hug_sole_arg=False,
trailing_comment=None,
):
"""Builds a doc that looks like a function call,
from docs that represent the function, arguments
and keyword arguments.
If ``hug_sole_arg`` is True, and the represented
fun... | python | def build_fncall(
ctx,
fndoc,
argdocs=(),
kwargdocs=(),
hug_sole_arg=False,
trailing_comment=None,
):
"""Builds a doc that looks like a function call,
from docs that represent the function, arguments
and keyword arguments.
If ``hug_sole_arg`` is True, and the represented
fun... | [
"def",
"build_fncall",
"(",
"ctx",
",",
"fndoc",
",",
"argdocs",
"=",
"(",
")",
",",
"kwargdocs",
"=",
"(",
")",
",",
"hug_sole_arg",
"=",
"False",
",",
"trailing_comment",
"=",
"None",
",",
")",
":",
"if",
"callable",
"(",
"fndoc",
")",
":",
"fndoc"... | Builds a doc that looks like a function call,
from docs that represent the function, arguments
and keyword arguments.
If ``hug_sole_arg`` is True, and the represented
functional call is done with a single non-keyword
argument, the function call parentheses will hug
the sole argument doc without... | [
"Builds",
"a",
"doc",
"that",
"looks",
"like",
"a",
"function",
"call",
"from",
"docs",
"that",
"represent",
"the",
"function",
"arguments",
"and",
"keyword",
"arguments",
"."
] | 6b405884b8085eaf867e81c02b7b662b463ac5a0 | https://github.com/tommikaikkonen/prettyprinter/blob/6b405884b8085eaf867e81c02b7b662b463ac5a0/prettyprinter/prettyprinter.py#L849-L1003 |
15,422 | tommikaikkonen/prettyprinter | prettyprinter/prettyprinter.py | PrettyContext.assoc | def assoc(self, key, value):
"""
Return a modified PrettyContext with ``key`` set to ``value``
"""
return self._replace(user_ctx={
**self.user_ctx,
key: value,
}) | python | def assoc(self, key, value):
"""
Return a modified PrettyContext with ``key`` set to ``value``
"""
return self._replace(user_ctx={
**self.user_ctx,
key: value,
}) | [
"def",
"assoc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"return",
"self",
".",
"_replace",
"(",
"user_ctx",
"=",
"{",
"*",
"*",
"self",
".",
"user_ctx",
",",
"key",
":",
"value",
",",
"}",
")"
] | Return a modified PrettyContext with ``key`` set to ``value`` | [
"Return",
"a",
"modified",
"PrettyContext",
"with",
"key",
"set",
"to",
"value"
] | 6b405884b8085eaf867e81c02b7b662b463ac5a0 | https://github.com/tommikaikkonen/prettyprinter/blob/6b405884b8085eaf867e81c02b7b662b463ac5a0/prettyprinter/prettyprinter.py#L297-L304 |
15,423 | tommikaikkonen/prettyprinter | prettyprinter/doc.py | align | def align(doc):
"""Aligns each new line in ``doc`` with the first new line.
"""
validate_doc(doc)
def evaluator(indent, column, page_width, ribbon_width):
return Nest(column - indent, doc)
return contextual(evaluator) | python | def align(doc):
"""Aligns each new line in ``doc`` with the first new line.
"""
validate_doc(doc)
def evaluator(indent, column, page_width, ribbon_width):
return Nest(column - indent, doc)
return contextual(evaluator) | [
"def",
"align",
"(",
"doc",
")",
":",
"validate_doc",
"(",
"doc",
")",
"def",
"evaluator",
"(",
"indent",
",",
"column",
",",
"page_width",
",",
"ribbon_width",
")",
":",
"return",
"Nest",
"(",
"column",
"-",
"indent",
",",
"doc",
")",
"return",
"conte... | Aligns each new line in ``doc`` with the first new line. | [
"Aligns",
"each",
"new",
"line",
"in",
"doc",
"with",
"the",
"first",
"new",
"line",
"."
] | 6b405884b8085eaf867e81c02b7b662b463ac5a0 | https://github.com/tommikaikkonen/prettyprinter/blob/6b405884b8085eaf867e81c02b7b662b463ac5a0/prettyprinter/doc.py#L57-L64 |
15,424 | tommikaikkonen/prettyprinter | prettyprinter/layout.py | smart_fitting_predicate | def smart_fitting_predicate(
page_width,
ribbon_frac,
min_nesting_level,
max_width,
triplestack
):
"""
Lookahead until the last doc at the current indentation level.
Pretty, but not as fast.
"""
chars_left = max_width
while chars_left >= 0:
if not triplestack:
... | python | def smart_fitting_predicate(
page_width,
ribbon_frac,
min_nesting_level,
max_width,
triplestack
):
"""
Lookahead until the last doc at the current indentation level.
Pretty, but not as fast.
"""
chars_left = max_width
while chars_left >= 0:
if not triplestack:
... | [
"def",
"smart_fitting_predicate",
"(",
"page_width",
",",
"ribbon_frac",
",",
"min_nesting_level",
",",
"max_width",
",",
"triplestack",
")",
":",
"chars_left",
"=",
"max_width",
"while",
"chars_left",
">=",
"0",
":",
"if",
"not",
"triplestack",
":",
"return",
"... | Lookahead until the last doc at the current indentation level.
Pretty, but not as fast. | [
"Lookahead",
"until",
"the",
"last",
"doc",
"at",
"the",
"current",
"indentation",
"level",
".",
"Pretty",
"but",
"not",
"as",
"fast",
"."
] | 6b405884b8085eaf867e81c02b7b662b463ac5a0 | https://github.com/tommikaikkonen/prettyprinter/blob/6b405884b8085eaf867e81c02b7b662b463ac5a0/prettyprinter/layout.py#L124-L208 |
15,425 | tommikaikkonen/prettyprinter | prettyprinter/color.py | set_default_style | def set_default_style(style):
"""Sets default global style to be used by ``prettyprinter.cpprint``.
:param style: the style to set, either subclass of
``pygments.styles.Style`` or one of ``'dark'``, ``'light'``
"""
global default_style
if style == 'dark':
style = default_d... | python | def set_default_style(style):
"""Sets default global style to be used by ``prettyprinter.cpprint``.
:param style: the style to set, either subclass of
``pygments.styles.Style`` or one of ``'dark'``, ``'light'``
"""
global default_style
if style == 'dark':
style = default_d... | [
"def",
"set_default_style",
"(",
"style",
")",
":",
"global",
"default_style",
"if",
"style",
"==",
"'dark'",
":",
"style",
"=",
"default_dark_style",
"elif",
"style",
"==",
"'light'",
":",
"style",
"=",
"default_light_style",
"if",
"not",
"issubclass",
"(",
"... | Sets default global style to be used by ``prettyprinter.cpprint``.
:param style: the style to set, either subclass of
``pygments.styles.Style`` or one of ``'dark'``, ``'light'`` | [
"Sets",
"default",
"global",
"style",
"to",
"be",
"used",
"by",
"prettyprinter",
".",
"cpprint",
"."
] | 6b405884b8085eaf867e81c02b7b662b463ac5a0 | https://github.com/tommikaikkonen/prettyprinter/blob/6b405884b8085eaf867e81c02b7b662b463ac5a0/prettyprinter/color.py#L134-L151 |
15,426 | tommikaikkonen/prettyprinter | prettyprinter/utils.py | intersperse | def intersperse(x, ys):
"""
Returns an iterable where ``x`` is inserted between
each element of ``ys``
:type ys: Iterable
"""
it = iter(ys)
try:
y = next(it)
except StopIteration:
return
yield y
for y in it:
yield x
yield y | python | def intersperse(x, ys):
"""
Returns an iterable where ``x`` is inserted between
each element of ``ys``
:type ys: Iterable
"""
it = iter(ys)
try:
y = next(it)
except StopIteration:
return
yield y
for y in it:
yield x
yield y | [
"def",
"intersperse",
"(",
"x",
",",
"ys",
")",
":",
"it",
"=",
"iter",
"(",
"ys",
")",
"try",
":",
"y",
"=",
"next",
"(",
"it",
")",
"except",
"StopIteration",
":",
"return",
"yield",
"y",
"for",
"y",
"in",
"it",
":",
"yield",
"x",
"yield",
"y... | Returns an iterable where ``x`` is inserted between
each element of ``ys``
:type ys: Iterable | [
"Returns",
"an",
"iterable",
"where",
"x",
"is",
"inserted",
"between",
"each",
"element",
"of",
"ys"
] | 6b405884b8085eaf867e81c02b7b662b463ac5a0 | https://github.com/tommikaikkonen/prettyprinter/blob/6b405884b8085eaf867e81c02b7b662b463ac5a0/prettyprinter/utils.py#L5-L23 |
15,427 | tommikaikkonen/prettyprinter | prettyprinter/__init__.py | pprint | def pprint(
object,
stream=_UNSET_SENTINEL,
indent=_UNSET_SENTINEL,
width=_UNSET_SENTINEL,
depth=_UNSET_SENTINEL,
*,
compact=False,
ribbon_width=_UNSET_SENTINEL,
max_seq_len=_UNSET_SENTINEL,
sort_dict_keys=_UNSET_SENTINEL,
end='\n'
):
"""Pretty print a Python value ``obje... | python | def pprint(
object,
stream=_UNSET_SENTINEL,
indent=_UNSET_SENTINEL,
width=_UNSET_SENTINEL,
depth=_UNSET_SENTINEL,
*,
compact=False,
ribbon_width=_UNSET_SENTINEL,
max_seq_len=_UNSET_SENTINEL,
sort_dict_keys=_UNSET_SENTINEL,
end='\n'
):
"""Pretty print a Python value ``obje... | [
"def",
"pprint",
"(",
"object",
",",
"stream",
"=",
"_UNSET_SENTINEL",
",",
"indent",
"=",
"_UNSET_SENTINEL",
",",
"width",
"=",
"_UNSET_SENTINEL",
",",
"depth",
"=",
"_UNSET_SENTINEL",
",",
"*",
",",
"compact",
"=",
"False",
",",
"ribbon_width",
"=",
"_UNSE... | Pretty print a Python value ``object`` to ``stream``,
which defaults to ``sys.stdout``. The output will not be colored.
:param indent: number of spaces to add for each level of nesting.
:param stream: the output stream, defaults to ``sys.stdout``
:param width: a soft maximum allowed number of columns i... | [
"Pretty",
"print",
"a",
"Python",
"value",
"object",
"to",
"stream",
"which",
"defaults",
"to",
"sys",
".",
"stdout",
".",
"The",
"output",
"will",
"not",
"be",
"colored",
"."
] | 6b405884b8085eaf867e81c02b7b662b463ac5a0 | https://github.com/tommikaikkonen/prettyprinter/blob/6b405884b8085eaf867e81c02b7b662b463ac5a0/prettyprinter/__init__.py#L142-L195 |
15,428 | tommikaikkonen/prettyprinter | prettyprinter/__init__.py | cpprint | def cpprint(
object,
stream=_UNSET_SENTINEL,
indent=_UNSET_SENTINEL,
width=_UNSET_SENTINEL,
depth=_UNSET_SENTINEL,
*,
compact=False,
ribbon_width=_UNSET_SENTINEL,
max_seq_len=_UNSET_SENTINEL,
sort_dict_keys=_UNSET_SENTINEL,
style=None,
end='\n'
):
"""Pretty print a Py... | python | def cpprint(
object,
stream=_UNSET_SENTINEL,
indent=_UNSET_SENTINEL,
width=_UNSET_SENTINEL,
depth=_UNSET_SENTINEL,
*,
compact=False,
ribbon_width=_UNSET_SENTINEL,
max_seq_len=_UNSET_SENTINEL,
sort_dict_keys=_UNSET_SENTINEL,
style=None,
end='\n'
):
"""Pretty print a Py... | [
"def",
"cpprint",
"(",
"object",
",",
"stream",
"=",
"_UNSET_SENTINEL",
",",
"indent",
"=",
"_UNSET_SENTINEL",
",",
"width",
"=",
"_UNSET_SENTINEL",
",",
"depth",
"=",
"_UNSET_SENTINEL",
",",
"*",
",",
"compact",
"=",
"False",
",",
"ribbon_width",
"=",
"_UNS... | Pretty print a Python value ``object`` to ``stream``,
which defaults to sys.stdout. The output will be colored and
syntax highlighted.
:param indent: number of spaces to add for each level of nesting.
:param stream: the output stream, defaults to sys.stdout
:param width: a soft maximum allowed numb... | [
"Pretty",
"print",
"a",
"Python",
"value",
"object",
"to",
"stream",
"which",
"defaults",
"to",
"sys",
".",
"stdout",
".",
"The",
"output",
"will",
"be",
"colored",
"and",
"syntax",
"highlighted",
"."
] | 6b405884b8085eaf867e81c02b7b662b463ac5a0 | https://github.com/tommikaikkonen/prettyprinter/blob/6b405884b8085eaf867e81c02b7b662b463ac5a0/prettyprinter/__init__.py#L198-L257 |
15,429 | tommikaikkonen/prettyprinter | prettyprinter/__init__.py | install_extras | def install_extras(
include=ALL_EXTRAS,
*,
exclude=EMPTY_SET,
raise_on_error=False,
warn_on_error=True
):
"""Installs extras.
Installing an extra means registering pretty printers for objects from third
party libraries and/or enabling integrations with other python programs.
- ``'a... | python | def install_extras(
include=ALL_EXTRAS,
*,
exclude=EMPTY_SET,
raise_on_error=False,
warn_on_error=True
):
"""Installs extras.
Installing an extra means registering pretty printers for objects from third
party libraries and/or enabling integrations with other python programs.
- ``'a... | [
"def",
"install_extras",
"(",
"include",
"=",
"ALL_EXTRAS",
",",
"*",
",",
"exclude",
"=",
"EMPTY_SET",
",",
"raise_on_error",
"=",
"False",
",",
"warn_on_error",
"=",
"True",
")",
":",
"# noqa",
"include",
"=",
"set",
"(",
"include",
")",
"exclude",
"=",
... | Installs extras.
Installing an extra means registering pretty printers for objects from third
party libraries and/or enabling integrations with other python programs.
- ``'attrs'`` - automatically pretty prints classes created using the ``attrs`` package.
- ``'dataclasses'`` - automatically pretty pri... | [
"Installs",
"extras",
"."
] | 6b405884b8085eaf867e81c02b7b662b463ac5a0 | https://github.com/tommikaikkonen/prettyprinter/blob/6b405884b8085eaf867e81c02b7b662b463ac5a0/prettyprinter/__init__.py#L273-L341 |
15,430 | tommikaikkonen/prettyprinter | prettyprinter/__init__.py | set_default_config | def set_default_config(
*,
style=_UNSET_SENTINEL,
max_seq_len=_UNSET_SENTINEL,
width=_UNSET_SENTINEL,
ribbon_width=_UNSET_SENTINEL,
depth=_UNSET_SENTINEL,
sort_dict_keys=_UNSET_SENTINEL
):
"""
Sets the default configuration values used when calling
`pprint`, `cpprint`, or `pforma... | python | def set_default_config(
*,
style=_UNSET_SENTINEL,
max_seq_len=_UNSET_SENTINEL,
width=_UNSET_SENTINEL,
ribbon_width=_UNSET_SENTINEL,
depth=_UNSET_SENTINEL,
sort_dict_keys=_UNSET_SENTINEL
):
"""
Sets the default configuration values used when calling
`pprint`, `cpprint`, or `pforma... | [
"def",
"set_default_config",
"(",
"*",
",",
"style",
"=",
"_UNSET_SENTINEL",
",",
"max_seq_len",
"=",
"_UNSET_SENTINEL",
",",
"width",
"=",
"_UNSET_SENTINEL",
",",
"ribbon_width",
"=",
"_UNSET_SENTINEL",
",",
"depth",
"=",
"_UNSET_SENTINEL",
",",
"sort_dict_keys",
... | Sets the default configuration values used when calling
`pprint`, `cpprint`, or `pformat`, if those values weren't
explicitly provided. Only overrides the values provided in
the keyword arguments. | [
"Sets",
"the",
"default",
"configuration",
"values",
"used",
"when",
"calling",
"pprint",
"cpprint",
"or",
"pformat",
"if",
"those",
"values",
"weren",
"t",
"explicitly",
"provided",
".",
"Only",
"overrides",
"the",
"values",
"provided",
"in",
"the",
"keyword",
... | 6b405884b8085eaf867e81c02b7b662b463ac5a0 | https://github.com/tommikaikkonen/prettyprinter/blob/6b405884b8085eaf867e81c02b7b662b463ac5a0/prettyprinter/__init__.py#L344-L382 |
15,431 | bcdev/jpy | setup.py | package_maven | def package_maven():
""" Run maven package lifecycle """
if not os.getenv('JAVA_HOME'):
# make sure Maven uses the same JDK which we have used to compile
# and link the C-code
os.environ['JAVA_HOME'] = jdk_home_dir
mvn_goal = 'package'
log.info("Executing Maven goal '" + mvn_goa... | python | def package_maven():
""" Run maven package lifecycle """
if not os.getenv('JAVA_HOME'):
# make sure Maven uses the same JDK which we have used to compile
# and link the C-code
os.environ['JAVA_HOME'] = jdk_home_dir
mvn_goal = 'package'
log.info("Executing Maven goal '" + mvn_goa... | [
"def",
"package_maven",
"(",
")",
":",
"if",
"not",
"os",
".",
"getenv",
"(",
"'JAVA_HOME'",
")",
":",
"# make sure Maven uses the same JDK which we have used to compile",
"# and link the C-code",
"os",
".",
"environ",
"[",
"'JAVA_HOME'",
"]",
"=",
"jdk_home_dir",
"mv... | Run maven package lifecycle | [
"Run",
"maven",
"package",
"lifecycle"
] | ae813df536807fb839650a0b359aa90f8344dd79 | https://github.com/bcdev/jpy/blob/ae813df536807fb839650a0b359aa90f8344dd79/setup.py#L153-L184 |
15,432 | bcdev/jpy | setup.py | _write_jpy_config | def _write_jpy_config(target_dir=None, install_dir=None):
"""
Write out a well-formed jpyconfig.properties file for easier Java
integration in a given location.
"""
if not target_dir:
target_dir = _build_dir()
args = [sys.executable,
os.path.join(target_dir, 'jpyutil.py'... | python | def _write_jpy_config(target_dir=None, install_dir=None):
"""
Write out a well-formed jpyconfig.properties file for easier Java
integration in a given location.
"""
if not target_dir:
target_dir = _build_dir()
args = [sys.executable,
os.path.join(target_dir, 'jpyutil.py'... | [
"def",
"_write_jpy_config",
"(",
"target_dir",
"=",
"None",
",",
"install_dir",
"=",
"None",
")",
":",
"if",
"not",
"target_dir",
":",
"target_dir",
"=",
"_build_dir",
"(",
")",
"args",
"=",
"[",
"sys",
".",
"executable",
",",
"os",
".",
"path",
".",
"... | Write out a well-formed jpyconfig.properties file for easier Java
integration in a given location. | [
"Write",
"out",
"a",
"well",
"-",
"formed",
"jpyconfig",
".",
"properties",
"file",
"for",
"easier",
"Java",
"integration",
"in",
"a",
"given",
"location",
"."
] | ae813df536807fb839650a0b359aa90f8344dd79 | https://github.com/bcdev/jpy/blob/ae813df536807fb839650a0b359aa90f8344dd79/setup.py#L216-L236 |
15,433 | bcdev/jpy | jpyutil.py | _get_module_path | def _get_module_path(name, fail=False, install_path=None):
""" Find the path to the jpy jni modules. """
import imp
module = imp.find_module(name)
if not module and fail:
raise RuntimeError("can't find module '" + name + "'")
path = module[1]
if not path and fail:
raise RuntimeE... | python | def _get_module_path(name, fail=False, install_path=None):
""" Find the path to the jpy jni modules. """
import imp
module = imp.find_module(name)
if not module and fail:
raise RuntimeError("can't find module '" + name + "'")
path = module[1]
if not path and fail:
raise RuntimeE... | [
"def",
"_get_module_path",
"(",
"name",
",",
"fail",
"=",
"False",
",",
"install_path",
"=",
"None",
")",
":",
"import",
"imp",
"module",
"=",
"imp",
".",
"find_module",
"(",
"name",
")",
"if",
"not",
"module",
"and",
"fail",
":",
"raise",
"RuntimeError"... | Find the path to the jpy jni modules. | [
"Find",
"the",
"path",
"to",
"the",
"jpy",
"jni",
"modules",
"."
] | ae813df536807fb839650a0b359aa90f8344dd79 | https://github.com/bcdev/jpy/blob/ae813df536807fb839650a0b359aa90f8344dd79/jpyutil.py#L99-L113 |
15,434 | bcdev/jpy | jpyutil.py | init_jvm | def init_jvm(java_home=None,
jvm_dll=None,
jvm_maxmem=None,
jvm_classpath=None,
jvm_properties=None,
jvm_options=None,
config_file=None,
config=None):
"""
Creates a configured Java virtual machine which will be used by jp... | python | def init_jvm(java_home=None,
jvm_dll=None,
jvm_maxmem=None,
jvm_classpath=None,
jvm_properties=None,
jvm_options=None,
config_file=None,
config=None):
"""
Creates a configured Java virtual machine which will be used by jp... | [
"def",
"init_jvm",
"(",
"java_home",
"=",
"None",
",",
"jvm_dll",
"=",
"None",
",",
"jvm_maxmem",
"=",
"None",
",",
"jvm_classpath",
"=",
"None",
",",
"jvm_properties",
"=",
"None",
",",
"jvm_options",
"=",
"None",
",",
"config_file",
"=",
"None",
",",
"... | Creates a configured Java virtual machine which will be used by jpy.
:param java_home: The Java JRE or JDK home directory used to search JVM shared library, if 'jvm_dll' is omitted.
:param jvm_dll: The JVM shared library file. My be inferred from 'java_home'.
:param jvm_maxmem: The JVM maximum heap space, ... | [
"Creates",
"a",
"configured",
"Java",
"virtual",
"machine",
"which",
"will",
"be",
"used",
"by",
"jpy",
"."
] | ae813df536807fb839650a0b359aa90f8344dd79 | https://github.com/bcdev/jpy/blob/ae813df536807fb839650a0b359aa90f8344dd79/jpyutil.py#L411-L459 |
15,435 | KeepSafe/android-resource-remover | android_clean_app.py | run_lint_command | def run_lint_command():
"""
Run lint command in the shell and save results to lint-result.xml
"""
lint, app_dir, lint_result, ignore_layouts = parse_args()
if not lint_result:
if not distutils.spawn.find_executable(lint):
raise Exception(
'`%s` executable could no... | python | def run_lint_command():
"""
Run lint command in the shell and save results to lint-result.xml
"""
lint, app_dir, lint_result, ignore_layouts = parse_args()
if not lint_result:
if not distutils.spawn.find_executable(lint):
raise Exception(
'`%s` executable could no... | [
"def",
"run_lint_command",
"(",
")",
":",
"lint",
",",
"app_dir",
",",
"lint_result",
",",
"ignore_layouts",
"=",
"parse_args",
"(",
")",
"if",
"not",
"lint_result",
":",
"if",
"not",
"distutils",
".",
"spawn",
".",
"find_executable",
"(",
"lint",
")",
":"... | Run lint command in the shell and save results to lint-result.xml | [
"Run",
"lint",
"command",
"in",
"the",
"shell",
"and",
"save",
"results",
"to",
"lint",
"-",
"result",
".",
"xml"
] | f2b4fb5a6822da79c9b166e3250ca6bdc6ee06e8 | https://github.com/KeepSafe/android-resource-remover/blob/f2b4fb5a6822da79c9b166e3250ca6bdc6ee06e8/android_clean_app.py#L87-L105 |
15,436 | KeepSafe/android-resource-remover | android_clean_app.py | parse_lint_result | def parse_lint_result(lint_result_path, manifest_path):
"""
Parse lint-result.xml and create Issue for every problem found except unused strings referenced in AndroidManifest
"""
unused_string_pattern = re.compile('The resource `R\.string\.([^`]+)` appears to be unused')
mainfest_string_refs = get_m... | python | def parse_lint_result(lint_result_path, manifest_path):
"""
Parse lint-result.xml and create Issue for every problem found except unused strings referenced in AndroidManifest
"""
unused_string_pattern = re.compile('The resource `R\.string\.([^`]+)` appears to be unused')
mainfest_string_refs = get_m... | [
"def",
"parse_lint_result",
"(",
"lint_result_path",
",",
"manifest_path",
")",
":",
"unused_string_pattern",
"=",
"re",
".",
"compile",
"(",
"'The resource `R\\.string\\.([^`]+)` appears to be unused'",
")",
"mainfest_string_refs",
"=",
"get_manifest_string_refs",
"(",
"mani... | Parse lint-result.xml and create Issue for every problem found except unused strings referenced in AndroidManifest | [
"Parse",
"lint",
"-",
"result",
".",
"xml",
"and",
"create",
"Issue",
"for",
"every",
"problem",
"found",
"except",
"unused",
"strings",
"referenced",
"in",
"AndroidManifest"
] | f2b4fb5a6822da79c9b166e3250ca6bdc6ee06e8 | https://github.com/KeepSafe/android-resource-remover/blob/f2b4fb5a6822da79c9b166e3250ca6bdc6ee06e8/android_clean_app.py#L138-L163 |
15,437 | KeepSafe/android-resource-remover | android_clean_app.py | remove_resource_file | def remove_resource_file(issue, filepath, ignore_layouts):
"""
Delete a file from the filesystem
"""
if os.path.exists(filepath) and (ignore_layouts is False or issue.elements[0][0] != 'layout'):
print('removing resource: {0}'.format(filepath))
os.remove(os.path.abspath(filepath)) | python | def remove_resource_file(issue, filepath, ignore_layouts):
"""
Delete a file from the filesystem
"""
if os.path.exists(filepath) and (ignore_layouts is False or issue.elements[0][0] != 'layout'):
print('removing resource: {0}'.format(filepath))
os.remove(os.path.abspath(filepath)) | [
"def",
"remove_resource_file",
"(",
"issue",
",",
"filepath",
",",
"ignore_layouts",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"filepath",
")",
"and",
"(",
"ignore_layouts",
"is",
"False",
"or",
"issue",
".",
"elements",
"[",
"0",
"]",
"[",
... | Delete a file from the filesystem | [
"Delete",
"a",
"file",
"from",
"the",
"filesystem"
] | f2b4fb5a6822da79c9b166e3250ca6bdc6ee06e8 | https://github.com/KeepSafe/android-resource-remover/blob/f2b4fb5a6822da79c9b166e3250ca6bdc6ee06e8/android_clean_app.py#L166-L172 |
15,438 | KeepSafe/android-resource-remover | android_clean_app.py | remove_resource_value | def remove_resource_value(issue, filepath):
"""
Read an xml file and remove an element which is unused, then save the file back to the filesystem
"""
if os.path.exists(filepath):
for element in issue.elements:
print('removing {0} from resource {1}'.format(element, filepath))
... | python | def remove_resource_value(issue, filepath):
"""
Read an xml file and remove an element which is unused, then save the file back to the filesystem
"""
if os.path.exists(filepath):
for element in issue.elements:
print('removing {0} from resource {1}'.format(element, filepath))
... | [
"def",
"remove_resource_value",
"(",
"issue",
",",
"filepath",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"filepath",
")",
":",
"for",
"element",
"in",
"issue",
".",
"elements",
":",
"print",
"(",
"'removing {0} from resource {1}'",
".",
"format"... | Read an xml file and remove an element which is unused, then save the file back to the filesystem | [
"Read",
"an",
"xml",
"file",
"and",
"remove",
"an",
"element",
"which",
"is",
"unused",
"then",
"save",
"the",
"file",
"back",
"to",
"the",
"filesystem"
] | f2b4fb5a6822da79c9b166e3250ca6bdc6ee06e8 | https://github.com/KeepSafe/android-resource-remover/blob/f2b4fb5a6822da79c9b166e3250ca6bdc6ee06e8/android_clean_app.py#L175-L189 |
15,439 | KeepSafe/android-resource-remover | android_clean_app.py | remove_unused_resources | def remove_unused_resources(issues, app_dir, ignore_layouts):
"""
Remove the file or the value inside the file depending if the whole file is unused or not.
"""
for issue in issues:
filepath = os.path.join(app_dir, issue.filepath)
if issue.remove_file:
remove_resource_file(is... | python | def remove_unused_resources(issues, app_dir, ignore_layouts):
"""
Remove the file or the value inside the file depending if the whole file is unused or not.
"""
for issue in issues:
filepath = os.path.join(app_dir, issue.filepath)
if issue.remove_file:
remove_resource_file(is... | [
"def",
"remove_unused_resources",
"(",
"issues",
",",
"app_dir",
",",
"ignore_layouts",
")",
":",
"for",
"issue",
"in",
"issues",
":",
"filepath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"app_dir",
",",
"issue",
".",
"filepath",
")",
"if",
"issue",
"."... | Remove the file or the value inside the file depending if the whole file is unused or not. | [
"Remove",
"the",
"file",
"or",
"the",
"value",
"inside",
"the",
"file",
"depending",
"if",
"the",
"whole",
"file",
"is",
"unused",
"or",
"not",
"."
] | f2b4fb5a6822da79c9b166e3250ca6bdc6ee06e8 | https://github.com/KeepSafe/android-resource-remover/blob/f2b4fb5a6822da79c9b166e3250ca6bdc6ee06e8/android_clean_app.py#L192-L201 |
15,440 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/caches/__init__.py | _encryption_context_hash | def _encryption_context_hash(hasher, encryption_context):
"""Generates the expected hash for the provided encryption context.
:param hasher: Existing hasher to use
:type hasher: cryptography.hazmat.primitives.hashes.Hash
:param dict encryption_context: Encryption context to hash
:returns: Complete ... | python | def _encryption_context_hash(hasher, encryption_context):
"""Generates the expected hash for the provided encryption context.
:param hasher: Existing hasher to use
:type hasher: cryptography.hazmat.primitives.hashes.Hash
:param dict encryption_context: Encryption context to hash
:returns: Complete ... | [
"def",
"_encryption_context_hash",
"(",
"hasher",
",",
"encryption_context",
")",
":",
"serialized_encryption_context",
"=",
"serialize_encryption_context",
"(",
"encryption_context",
")",
"hasher",
".",
"update",
"(",
"serialized_encryption_context",
")",
"return",
"hasher... | Generates the expected hash for the provided encryption context.
:param hasher: Existing hasher to use
:type hasher: cryptography.hazmat.primitives.hashes.Hash
:param dict encryption_context: Encryption context to hash
:returns: Complete hash
:rtype: bytes | [
"Generates",
"the",
"expected",
"hash",
"for",
"the",
"provided",
"encryption",
"context",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/caches/__init__.py#L51-L62 |
15,441 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/caches/__init__.py | build_encryption_materials_cache_key | def build_encryption_materials_cache_key(partition, request):
"""Generates a cache key for an encrypt request.
:param bytes partition: Partition name for which to generate key
:param request: Request for which to generate key
:type request: aws_encryption_sdk.materials_managers.EncryptionMaterialsReque... | python | def build_encryption_materials_cache_key(partition, request):
"""Generates a cache key for an encrypt request.
:param bytes partition: Partition name for which to generate key
:param request: Request for which to generate key
:type request: aws_encryption_sdk.materials_managers.EncryptionMaterialsReque... | [
"def",
"build_encryption_materials_cache_key",
"(",
"partition",
",",
"request",
")",
":",
"if",
"request",
".",
"algorithm",
"is",
"None",
":",
"_algorithm_info",
"=",
"b\"\\x00\"",
"else",
":",
"_algorithm_info",
"=",
"b\"\\x01\"",
"+",
"request",
".",
"algorith... | Generates a cache key for an encrypt request.
:param bytes partition: Partition name for which to generate key
:param request: Request for which to generate key
:type request: aws_encryption_sdk.materials_managers.EncryptionMaterialsRequest
:returns: cache key
:rtype: bytes | [
"Generates",
"a",
"cache",
"key",
"for",
"an",
"encrypt",
"request",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/caches/__init__.py#L65-L86 |
15,442 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/caches/__init__.py | _encrypted_data_keys_hash | def _encrypted_data_keys_hash(hasher, encrypted_data_keys):
"""Generates the expected hash for the provided encrypted data keys.
:param hasher: Existing hasher to use
:type hasher: cryptography.hazmat.primitives.hashes.Hash
:param iterable encrypted_data_keys: Encrypted data keys to hash
:returns: ... | python | def _encrypted_data_keys_hash(hasher, encrypted_data_keys):
"""Generates the expected hash for the provided encrypted data keys.
:param hasher: Existing hasher to use
:type hasher: cryptography.hazmat.primitives.hashes.Hash
:param iterable encrypted_data_keys: Encrypted data keys to hash
:returns: ... | [
"def",
"_encrypted_data_keys_hash",
"(",
"hasher",
",",
"encrypted_data_keys",
")",
":",
"hashed_keys",
"=",
"[",
"]",
"for",
"edk",
"in",
"encrypted_data_keys",
":",
"serialized_edk",
"=",
"serialize_encrypted_data_key",
"(",
"edk",
")",
"_hasher",
"=",
"hasher",
... | Generates the expected hash for the provided encrypted data keys.
:param hasher: Existing hasher to use
:type hasher: cryptography.hazmat.primitives.hashes.Hash
:param iterable encrypted_data_keys: Encrypted data keys to hash
:returns: Concatenated, sorted, list of all hashes
:rtype: bytes | [
"Generates",
"the",
"expected",
"hash",
"for",
"the",
"provided",
"encrypted",
"data",
"keys",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/caches/__init__.py#L89-L104 |
15,443 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/caches/__init__.py | build_decryption_materials_cache_key | def build_decryption_materials_cache_key(partition, request):
"""Generates a cache key for a decrypt request.
:param bytes partition: Partition name for which to generate key
:param request: Request for which to generate key
:type request: aws_encryption_sdk.materials_managers.DecryptionMaterialsReques... | python | def build_decryption_materials_cache_key(partition, request):
"""Generates a cache key for a decrypt request.
:param bytes partition: Partition name for which to generate key
:param request: Request for which to generate key
:type request: aws_encryption_sdk.materials_managers.DecryptionMaterialsReques... | [
"def",
"build_decryption_materials_cache_key",
"(",
"partition",
",",
"request",
")",
":",
"hasher",
"=",
"_new_cache_key_hasher",
"(",
")",
"_partition_hash",
"=",
"_partition_name_hash",
"(",
"hasher",
"=",
"hasher",
".",
"copy",
"(",
")",
",",
"partition_name",
... | Generates a cache key for a decrypt request.
:param bytes partition: Partition name for which to generate key
:param request: Request for which to generate key
:type request: aws_encryption_sdk.materials_managers.DecryptionMaterialsRequest
:returns: cache key
:rtype: bytes | [
"Generates",
"a",
"cache",
"key",
"for",
"a",
"decrypt",
"request",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/caches/__init__.py#L111-L131 |
15,444 | aws/aws-encryption-sdk-python | examples/src/basic_file_encryption_with_raw_key_provider.py | cycle_file | def cycle_file(source_plaintext_filename):
"""Encrypts and then decrypts a file under a custom static master key provider.
:param str source_plaintext_filename: Filename of file to encrypt
"""
# Create a static random master key provider
key_id = os.urandom(8)
master_key_provider = StaticRandom... | python | def cycle_file(source_plaintext_filename):
"""Encrypts and then decrypts a file under a custom static master key provider.
:param str source_plaintext_filename: Filename of file to encrypt
"""
# Create a static random master key provider
key_id = os.urandom(8)
master_key_provider = StaticRandom... | [
"def",
"cycle_file",
"(",
"source_plaintext_filename",
")",
":",
"# Create a static random master key provider",
"key_id",
"=",
"os",
".",
"urandom",
"(",
"8",
")",
"master_key_provider",
"=",
"StaticRandomMasterKeyProvider",
"(",
")",
"master_key_provider",
".",
"add_mas... | Encrypts and then decrypts a file under a custom static master key provider.
:param str source_plaintext_filename: Filename of file to encrypt | [
"Encrypts",
"and",
"then",
"decrypts",
"a",
"file",
"under",
"a",
"custom",
"static",
"master",
"key",
"provider",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/examples/src/basic_file_encryption_with_raw_key_provider.py#L51-L88 |
15,445 | aws/aws-encryption-sdk-python | examples/src/basic_file_encryption_with_raw_key_provider.py | StaticRandomMasterKeyProvider._get_raw_key | def _get_raw_key(self, key_id):
"""Returns a static, randomly-generated symmetric key for the specified key ID.
:param str key_id: Key ID
:returns: Wrapping key that contains the specified static key
:rtype: :class:`aws_encryption_sdk.internal.crypto.WrappingKey`
"""
try... | python | def _get_raw_key(self, key_id):
"""Returns a static, randomly-generated symmetric key for the specified key ID.
:param str key_id: Key ID
:returns: Wrapping key that contains the specified static key
:rtype: :class:`aws_encryption_sdk.internal.crypto.WrappingKey`
"""
try... | [
"def",
"_get_raw_key",
"(",
"self",
",",
"key_id",
")",
":",
"try",
":",
"static_key",
"=",
"self",
".",
"_static_keys",
"[",
"key_id",
"]",
"except",
"KeyError",
":",
"static_key",
"=",
"os",
".",
"urandom",
"(",
"32",
")",
"self",
".",
"_static_keys",
... | Returns a static, randomly-generated symmetric key for the specified key ID.
:param str key_id: Key ID
:returns: Wrapping key that contains the specified static key
:rtype: :class:`aws_encryption_sdk.internal.crypto.WrappingKey` | [
"Returns",
"a",
"static",
"randomly",
"-",
"generated",
"symmetric",
"key",
"for",
"the",
"specified",
"key",
"ID",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/examples/src/basic_file_encryption_with_raw_key_provider.py#L32-L48 |
15,446 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/streaming_client.py | _EncryptionStream.stream_length | def stream_length(self):
"""Returns the length of the source stream, determining it if not already known."""
if self._stream_length is None:
try:
current_position = self.source_stream.tell()
self.source_stream.seek(0, 2)
self._stream_length = s... | python | def stream_length(self):
"""Returns the length of the source stream, determining it if not already known."""
if self._stream_length is None:
try:
current_position = self.source_stream.tell()
self.source_stream.seek(0, 2)
self._stream_length = s... | [
"def",
"stream_length",
"(",
"self",
")",
":",
"if",
"self",
".",
"_stream_length",
"is",
"None",
":",
"try",
":",
"current_position",
"=",
"self",
".",
"source_stream",
".",
"tell",
"(",
")",
"self",
".",
"source_stream",
".",
"seek",
"(",
"0",
",",
"... | Returns the length of the source stream, determining it if not already known. | [
"Returns",
"the",
"length",
"of",
"the",
"source",
"stream",
"determining",
"it",
"if",
"not",
"already",
"known",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/streaming_client.py#L173-L184 |
15,447 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/streaming_client.py | _EncryptionStream.read | def read(self, b=-1):
"""Returns either the requested number of bytes or the entire stream.
:param int b: Number of bytes to read
:returns: Processed (encrypted or decrypted) bytes from source stream
:rtype: bytes
"""
# Any negative value for b is interpreted as a full r... | python | def read(self, b=-1):
"""Returns either the requested number of bytes or the entire stream.
:param int b: Number of bytes to read
:returns: Processed (encrypted or decrypted) bytes from source stream
:rtype: bytes
"""
# Any negative value for b is interpreted as a full r... | [
"def",
"read",
"(",
"self",
",",
"b",
"=",
"-",
"1",
")",
":",
"# Any negative value for b is interpreted as a full read",
"# None is also accepted for legacy compatibility",
"if",
"b",
"is",
"None",
"or",
"b",
"<",
"0",
":",
"b",
"=",
"-",
"1",
"_LOGGER",
".",
... | Returns either the requested number of bytes or the entire stream.
:param int b: Number of bytes to read
:returns: Processed (encrypted or decrypted) bytes from source stream
:rtype: bytes | [
"Returns",
"either",
"the",
"requested",
"number",
"of",
"bytes",
"or",
"the",
"entire",
"stream",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/streaming_client.py#L220-L254 |
15,448 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/streaming_client.py | _EncryptionStream.readline | def readline(self):
"""Read a chunk of the output"""
_LOGGER.info("reading line")
line = self.read(self.line_length)
if len(line) < self.line_length:
_LOGGER.info("all lines read")
return line | python | def readline(self):
"""Read a chunk of the output"""
_LOGGER.info("reading line")
line = self.read(self.line_length)
if len(line) < self.line_length:
_LOGGER.info("all lines read")
return line | [
"def",
"readline",
"(",
"self",
")",
":",
"_LOGGER",
".",
"info",
"(",
"\"reading line\"",
")",
"line",
"=",
"self",
".",
"read",
"(",
"self",
".",
"line_length",
")",
"if",
"len",
"(",
"line",
")",
"<",
"self",
".",
"line_length",
":",
"_LOGGER",
".... | Read a chunk of the output | [
"Read",
"a",
"chunk",
"of",
"the",
"output"
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/streaming_client.py#L276-L282 |
15,449 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/streaming_client.py | _EncryptionStream.next | def next(self):
"""Provides hook for Python2 iterator functionality."""
_LOGGER.debug("reading next")
if self.closed:
_LOGGER.debug("stream is closed")
raise StopIteration()
line = self.readline()
if not line:
_LOGGER.debug("nothing more to re... | python | def next(self):
"""Provides hook for Python2 iterator functionality."""
_LOGGER.debug("reading next")
if self.closed:
_LOGGER.debug("stream is closed")
raise StopIteration()
line = self.readline()
if not line:
_LOGGER.debug("nothing more to re... | [
"def",
"next",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"reading next\"",
")",
"if",
"self",
".",
"closed",
":",
"_LOGGER",
".",
"debug",
"(",
"\"stream is closed\"",
")",
"raise",
"StopIteration",
"(",
")",
"line",
"=",
"self",
".",
"readl... | Provides hook for Python2 iterator functionality. | [
"Provides",
"hook",
"for",
"Python2",
"iterator",
"functionality",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/streaming_client.py#L292-L304 |
15,450 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/streaming_client.py | StreamEncryptor.ciphertext_length | def ciphertext_length(self):
"""Returns the length of the resulting ciphertext message in bytes.
:rtype: int
"""
return aws_encryption_sdk.internal.formatting.ciphertext_length(
header=self.header, plaintext_length=self.stream_length
) | python | def ciphertext_length(self):
"""Returns the length of the resulting ciphertext message in bytes.
:rtype: int
"""
return aws_encryption_sdk.internal.formatting.ciphertext_length(
header=self.header, plaintext_length=self.stream_length
) | [
"def",
"ciphertext_length",
"(",
"self",
")",
":",
"return",
"aws_encryption_sdk",
".",
"internal",
".",
"formatting",
".",
"ciphertext_length",
"(",
"header",
"=",
"self",
".",
"header",
",",
"plaintext_length",
"=",
"self",
".",
"stream_length",
")"
] | Returns the length of the resulting ciphertext message in bytes.
:rtype: int | [
"Returns",
"the",
"length",
"of",
"the",
"resulting",
"ciphertext",
"message",
"in",
"bytes",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/streaming_client.py#L409-L416 |
15,451 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/streaming_client.py | StreamEncryptor._write_header | def _write_header(self):
"""Builds the message header and writes it to the output stream."""
self.output_buffer += serialize_header(header=self._header, signer=self.signer)
self.output_buffer += serialize_header_auth(
algorithm=self._encryption_materials.algorithm,
header... | python | def _write_header(self):
"""Builds the message header and writes it to the output stream."""
self.output_buffer += serialize_header(header=self._header, signer=self.signer)
self.output_buffer += serialize_header_auth(
algorithm=self._encryption_materials.algorithm,
header... | [
"def",
"_write_header",
"(",
"self",
")",
":",
"self",
".",
"output_buffer",
"+=",
"serialize_header",
"(",
"header",
"=",
"self",
".",
"_header",
",",
"signer",
"=",
"self",
".",
"signer",
")",
"self",
".",
"output_buffer",
"+=",
"serialize_header_auth",
"(... | Builds the message header and writes it to the output stream. | [
"Builds",
"the",
"message",
"header",
"and",
"writes",
"it",
"to",
"the",
"output",
"stream",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/streaming_client.py#L484-L492 |
15,452 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/streaming_client.py | StreamEncryptor._read_bytes_to_non_framed_body | def _read_bytes_to_non_framed_body(self, b):
"""Reads the requested number of bytes from source to a streaming non-framed message body.
:param int b: Number of bytes to read
:returns: Encrypted bytes from source stream
:rtype: bytes
"""
_LOGGER.debug("Reading %d bytes", ... | python | def _read_bytes_to_non_framed_body(self, b):
"""Reads the requested number of bytes from source to a streaming non-framed message body.
:param int b: Number of bytes to read
:returns: Encrypted bytes from source stream
:rtype: bytes
"""
_LOGGER.debug("Reading %d bytes", ... | [
"def",
"_read_bytes_to_non_framed_body",
"(",
"self",
",",
"b",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Reading %d bytes\"",
",",
"b",
")",
"plaintext",
"=",
"self",
".",
"__unframed_plaintext_cache",
".",
"read",
"(",
"b",
")",
"plaintext_length",
"=",
"le... | Reads the requested number of bytes from source to a streaming non-framed message body.
:param int b: Number of bytes to read
:returns: Encrypted bytes from source stream
:rtype: bytes | [
"Reads",
"the",
"requested",
"number",
"of",
"bytes",
"from",
"source",
"to",
"a",
"streaming",
"non",
"-",
"framed",
"message",
"body",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/streaming_client.py#L529-L562 |
15,453 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/streaming_client.py | StreamEncryptor._read_bytes_to_framed_body | def _read_bytes_to_framed_body(self, b):
"""Reads the requested number of bytes from source to a streaming framed message body.
:param int b: Number of bytes to read
:returns: Bytes read from source stream, encrypted, and serialized
:rtype: bytes
"""
_LOGGER.debug("colle... | python | def _read_bytes_to_framed_body(self, b):
"""Reads the requested number of bytes from source to a streaming framed message body.
:param int b: Number of bytes to read
:returns: Bytes read from source stream, encrypted, and serialized
:rtype: bytes
"""
_LOGGER.debug("colle... | [
"def",
"_read_bytes_to_framed_body",
"(",
"self",
",",
"b",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"collecting %d bytes\"",
",",
"b",
")",
"_b",
"=",
"b",
"if",
"b",
">",
"0",
":",
"_frames_to_read",
"=",
"math",
".",
"ceil",
"(",
"b",
"/",
"float",... | Reads the requested number of bytes from source to a streaming framed message body.
:param int b: Number of bytes to read
:returns: Bytes read from source stream, encrypted, and serialized
:rtype: bytes | [
"Reads",
"the",
"requested",
"number",
"of",
"bytes",
"from",
"source",
"to",
"a",
"streaming",
"framed",
"message",
"body",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/streaming_client.py#L564-L627 |
15,454 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/streaming_client.py | StreamDecryptor._read_header | def _read_header(self):
"""Reads the message header from the input stream.
:returns: tuple containing deserialized header and header_auth objects
:rtype: tuple of aws_encryption_sdk.structures.MessageHeader
and aws_encryption_sdk.internal.structures.MessageHeaderAuthentication
... | python | def _read_header(self):
"""Reads the message header from the input stream.
:returns: tuple containing deserialized header and header_auth objects
:rtype: tuple of aws_encryption_sdk.structures.MessageHeader
and aws_encryption_sdk.internal.structures.MessageHeaderAuthentication
... | [
"def",
"_read_header",
"(",
"self",
")",
":",
"header",
",",
"raw_header",
"=",
"deserialize_header",
"(",
"self",
".",
"source_stream",
")",
"self",
".",
"__unframed_bytes_read",
"+=",
"len",
"(",
"raw_header",
")",
"if",
"(",
"self",
".",
"config",
".",
... | Reads the message header from the input stream.
:returns: tuple containing deserialized header and header_auth objects
:rtype: tuple of aws_encryption_sdk.structures.MessageHeader
and aws_encryption_sdk.internal.structures.MessageHeaderAuthentication
:raises CustomMaximumValueExceed... | [
"Reads",
"the",
"message",
"header",
"from",
"the",
"input",
"stream",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/streaming_client.py#L738-L782 |
15,455 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/streaming_client.py | StreamDecryptor._read_bytes_from_non_framed_body | def _read_bytes_from_non_framed_body(self, b):
"""Reads the requested number of bytes from a streaming non-framed message body.
:param int b: Number of bytes to read
:returns: Decrypted bytes from source stream
:rtype: bytes
"""
_LOGGER.debug("starting non-framed body re... | python | def _read_bytes_from_non_framed_body(self, b):
"""Reads the requested number of bytes from a streaming non-framed message body.
:param int b: Number of bytes to read
:returns: Decrypted bytes from source stream
:rtype: bytes
"""
_LOGGER.debug("starting non-framed body re... | [
"def",
"_read_bytes_from_non_framed_body",
"(",
"self",
",",
"b",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"starting non-framed body read\"",
")",
"# Always read the entire message for non-framed message bodies.",
"bytes_to_read",
"=",
"self",
".",
"body_length",
"_LOGGER",
... | Reads the requested number of bytes from a streaming non-framed message body.
:param int b: Number of bytes to read
:returns: Decrypted bytes from source stream
:rtype: bytes | [
"Reads",
"the",
"requested",
"number",
"of",
"bytes",
"from",
"a",
"streaming",
"non",
"-",
"framed",
"message",
"body",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/streaming_client.py#L814-L857 |
15,456 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/streaming_client.py | StreamDecryptor._read_bytes_from_framed_body | def _read_bytes_from_framed_body(self, b):
"""Reads the requested number of bytes from a streaming framed message body.
:param int b: Number of bytes to read
:returns: Bytes read from source stream and decrypted
:rtype: bytes
"""
plaintext = b""
final_frame = Fal... | python | def _read_bytes_from_framed_body(self, b):
"""Reads the requested number of bytes from a streaming framed message body.
:param int b: Number of bytes to read
:returns: Bytes read from source stream and decrypted
:rtype: bytes
"""
plaintext = b""
final_frame = Fal... | [
"def",
"_read_bytes_from_framed_body",
"(",
"self",
",",
"b",
")",
":",
"plaintext",
"=",
"b\"\"",
"final_frame",
"=",
"False",
"_LOGGER",
".",
"debug",
"(",
"\"collecting %d bytes\"",
",",
"b",
")",
"while",
"len",
"(",
"plaintext",
")",
"<",
"b",
"and",
... | Reads the requested number of bytes from a streaming framed message body.
:param int b: Number of bytes to read
:returns: Bytes read from source stream and decrypted
:rtype: bytes | [
"Reads",
"the",
"requested",
"number",
"of",
"bytes",
"from",
"a",
"streaming",
"framed",
"message",
"body",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/streaming_client.py#L859-L899 |
15,457 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/streaming_client.py | StreamDecryptor.close | def close(self):
"""Closes out the stream."""
_LOGGER.debug("Closing stream")
if not hasattr(self, "footer"):
raise SerializationError("Footer not read")
super(StreamDecryptor, self).close() | python | def close(self):
"""Closes out the stream."""
_LOGGER.debug("Closing stream")
if not hasattr(self, "footer"):
raise SerializationError("Footer not read")
super(StreamDecryptor, self).close() | [
"def",
"close",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Closing stream\"",
")",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"footer\"",
")",
":",
"raise",
"SerializationError",
"(",
"\"Footer not read\"",
")",
"super",
"(",
"StreamDecryptor",
... | Closes out the stream. | [
"Closes",
"out",
"the",
"stream",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/streaming_client.py#L923-L928 |
15,458 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/key_providers/kms.py | _region_from_key_id | def _region_from_key_id(key_id, default_region=None):
"""Determine the target region from a key ID, falling back to a default region if provided.
:param str key_id: AWS KMS key ID
:param str default_region: Region to use if no region found in key_id
:returns: region name
:rtype: str
:raises Unk... | python | def _region_from_key_id(key_id, default_region=None):
"""Determine the target region from a key ID, falling back to a default region if provided.
:param str key_id: AWS KMS key ID
:param str default_region: Region to use if no region found in key_id
:returns: region name
:rtype: str
:raises Unk... | [
"def",
"_region_from_key_id",
"(",
"key_id",
",",
"default_region",
"=",
"None",
")",
":",
"try",
":",
"region_name",
"=",
"key_id",
".",
"split",
"(",
"\":\"",
",",
"4",
")",
"[",
"3",
"]",
"except",
"IndexError",
":",
"if",
"default_region",
"is",
"Non... | Determine the target region from a key ID, falling back to a default region if provided.
:param str key_id: AWS KMS key ID
:param str default_region: Region to use if no region found in key_id
:returns: region name
:rtype: str
:raises UnknownRegionError: if no region found in key_id and no default_... | [
"Determine",
"the",
"target",
"region",
"from",
"a",
"key",
"ID",
"falling",
"back",
"to",
"a",
"default",
"region",
"if",
"provided",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/key_providers/kms.py#L35-L52 |
15,459 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/key_providers/kms.py | KMSMasterKeyProvider._process_config | def _process_config(self):
"""Traverses the config and adds master keys and regional clients as needed."""
self._user_agent_adding_config = botocore.config.Config(user_agent_extra=USER_AGENT_SUFFIX)
if self.config.region_names:
self.add_regional_clients_from_list(self.config.region_... | python | def _process_config(self):
"""Traverses the config and adds master keys and regional clients as needed."""
self._user_agent_adding_config = botocore.config.Config(user_agent_extra=USER_AGENT_SUFFIX)
if self.config.region_names:
self.add_regional_clients_from_list(self.config.region_... | [
"def",
"_process_config",
"(",
"self",
")",
":",
"self",
".",
"_user_agent_adding_config",
"=",
"botocore",
".",
"config",
".",
"Config",
"(",
"user_agent_extra",
"=",
"USER_AGENT_SUFFIX",
")",
"if",
"self",
".",
"config",
".",
"region_names",
":",
"self",
"."... | Traverses the config and adds master keys and regional clients as needed. | [
"Traverses",
"the",
"config",
"and",
"adds",
"master",
"keys",
"and",
"regional",
"clients",
"as",
"needed",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/key_providers/kms.py#L115-L128 |
15,460 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/key_providers/kms.py | KMSMasterKeyProvider._wrap_client | def _wrap_client(self, region_name, method, *args, **kwargs):
"""Proxies all calls to a kms clients methods and removes misbehaving clients
:param str region_name: AWS Region ID (ex: us-east-1)
:param callable method: a method on the KMS client to proxy
:param tuple args: list of argume... | python | def _wrap_client(self, region_name, method, *args, **kwargs):
"""Proxies all calls to a kms clients methods and removes misbehaving clients
:param str region_name: AWS Region ID (ex: us-east-1)
:param callable method: a method on the KMS client to proxy
:param tuple args: list of argume... | [
"def",
"_wrap_client",
"(",
"self",
",",
"region_name",
",",
"method",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"method",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"except",
"botocore",
".",
"exceptions",
".",
... | Proxies all calls to a kms clients methods and removes misbehaving clients
:param str region_name: AWS Region ID (ex: us-east-1)
:param callable method: a method on the KMS client to proxy
:param tuple args: list of arguments to pass to the provided ``method``
:param dict kwargs: dicton... | [
"Proxies",
"all",
"calls",
"to",
"a",
"kms",
"clients",
"methods",
"and",
"removes",
"misbehaving",
"clients"
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/key_providers/kms.py#L130-L145 |
15,461 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/key_providers/kms.py | KMSMasterKeyProvider._register_client | def _register_client(self, client, region_name):
"""Uses functools.partial to wrap all methods on a client with the self._wrap_client method
:param botocore.client.BaseClient client: the client to proxy
:param str region_name: AWS Region ID (ex: us-east-1)
"""
for item in client... | python | def _register_client(self, client, region_name):
"""Uses functools.partial to wrap all methods on a client with the self._wrap_client method
:param botocore.client.BaseClient client: the client to proxy
:param str region_name: AWS Region ID (ex: us-east-1)
"""
for item in client... | [
"def",
"_register_client",
"(",
"self",
",",
"client",
",",
"region_name",
")",
":",
"for",
"item",
"in",
"client",
".",
"meta",
".",
"method_to_api_mapping",
":",
"method",
"=",
"getattr",
"(",
"client",
",",
"item",
")",
"wrapped_method",
"=",
"functools",... | Uses functools.partial to wrap all methods on a client with the self._wrap_client method
:param botocore.client.BaseClient client: the client to proxy
:param str region_name: AWS Region ID (ex: us-east-1) | [
"Uses",
"functools",
".",
"partial",
"to",
"wrap",
"all",
"methods",
"on",
"a",
"client",
"with",
"the",
"self",
".",
"_wrap_client",
"method"
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/key_providers/kms.py#L147-L156 |
15,462 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/key_providers/kms.py | KMSMasterKeyProvider.add_regional_client | def add_regional_client(self, region_name):
"""Adds a regional client for the specified region if it does not already exist.
:param str region_name: AWS Region ID (ex: us-east-1)
"""
if region_name not in self._regional_clients:
session = boto3.session.Session(region_name=re... | python | def add_regional_client(self, region_name):
"""Adds a regional client for the specified region if it does not already exist.
:param str region_name: AWS Region ID (ex: us-east-1)
"""
if region_name not in self._regional_clients:
session = boto3.session.Session(region_name=re... | [
"def",
"add_regional_client",
"(",
"self",
",",
"region_name",
")",
":",
"if",
"region_name",
"not",
"in",
"self",
".",
"_regional_clients",
":",
"session",
"=",
"boto3",
".",
"session",
".",
"Session",
"(",
"region_name",
"=",
"region_name",
",",
"botocore_se... | Adds a regional client for the specified region if it does not already exist.
:param str region_name: AWS Region ID (ex: us-east-1) | [
"Adds",
"a",
"regional",
"client",
"for",
"the",
"specified",
"region",
"if",
"it",
"does",
"not",
"already",
"exist",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/key_providers/kms.py#L158-L167 |
15,463 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/key_providers/kms.py | KMSMasterKeyProvider._client | def _client(self, key_id):
"""Returns a Boto3 KMS client for the appropriate region.
:param str key_id: KMS CMK ID
"""
region_name = _region_from_key_id(key_id, self.default_region)
self.add_regional_client(region_name)
return self._regional_clients[region_name] | python | def _client(self, key_id):
"""Returns a Boto3 KMS client for the appropriate region.
:param str key_id: KMS CMK ID
"""
region_name = _region_from_key_id(key_id, self.default_region)
self.add_regional_client(region_name)
return self._regional_clients[region_name] | [
"def",
"_client",
"(",
"self",
",",
"key_id",
")",
":",
"region_name",
"=",
"_region_from_key_id",
"(",
"key_id",
",",
"self",
".",
"default_region",
")",
"self",
".",
"add_regional_client",
"(",
"region_name",
")",
"return",
"self",
".",
"_regional_clients",
... | Returns a Boto3 KMS client for the appropriate region.
:param str key_id: KMS CMK ID | [
"Returns",
"a",
"Boto3",
"KMS",
"client",
"for",
"the",
"appropriate",
"region",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/key_providers/kms.py#L177-L184 |
15,464 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/key_providers/kms.py | KMSMasterKeyProvider._new_master_key | def _new_master_key(self, key_id):
"""Returns a KMSMasterKey for the specified key_id.
:param bytes key_id: KMS CMK ID
:returns: KMS Master Key based on key_id
:rtype: aws_encryption_sdk.key_providers.kms.KMSMasterKey
:raises InvalidKeyIdError: if key_id is not a valid KMS CMK I... | python | def _new_master_key(self, key_id):
"""Returns a KMSMasterKey for the specified key_id.
:param bytes key_id: KMS CMK ID
:returns: KMS Master Key based on key_id
:rtype: aws_encryption_sdk.key_providers.kms.KMSMasterKey
:raises InvalidKeyIdError: if key_id is not a valid KMS CMK I... | [
"def",
"_new_master_key",
"(",
"self",
",",
"key_id",
")",
":",
"_key_id",
"=",
"to_str",
"(",
"key_id",
")",
"# KMS client requires str, not bytes",
"return",
"KMSMasterKey",
"(",
"config",
"=",
"KMSMasterKeyConfig",
"(",
"key_id",
"=",
"key_id",
",",
"client",
... | Returns a KMSMasterKey for the specified key_id.
:param bytes key_id: KMS CMK ID
:returns: KMS Master Key based on key_id
:rtype: aws_encryption_sdk.key_providers.kms.KMSMasterKey
:raises InvalidKeyIdError: if key_id is not a valid KMS CMK ID to which this key provider has access | [
"Returns",
"a",
"KMSMasterKey",
"for",
"the",
"specified",
"key_id",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/key_providers/kms.py#L186-L195 |
15,465 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/key_providers/kms.py | KMSMasterKey._generate_data_key | def _generate_data_key(self, algorithm, encryption_context=None):
"""Generates data key and returns plaintext and ciphertext of key.
:param algorithm: Algorithm on which to base data key
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:param dict encryption_context: Encryption... | python | def _generate_data_key(self, algorithm, encryption_context=None):
"""Generates data key and returns plaintext and ciphertext of key.
:param algorithm: Algorithm on which to base data key
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:param dict encryption_context: Encryption... | [
"def",
"_generate_data_key",
"(",
"self",
",",
"algorithm",
",",
"encryption_context",
"=",
"None",
")",
":",
"kms_params",
"=",
"{",
"\"KeyId\"",
":",
"self",
".",
"_key_id",
",",
"\"NumberOfBytes\"",
":",
"algorithm",
".",
"kdf_input_len",
"}",
"if",
"encryp... | Generates data key and returns plaintext and ciphertext of key.
:param algorithm: Algorithm on which to base data key
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:param dict encryption_context: Encryption context to pass to KMS
:returns: Generated data key
:rtype: ... | [
"Generates",
"data",
"key",
"and",
"returns",
"plaintext",
"and",
"ciphertext",
"of",
"key",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/key_providers/kms.py#L244-L272 |
15,466 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/key_providers/kms.py | KMSMasterKey._encrypt_data_key | def _encrypt_data_key(self, data_key, algorithm, encryption_context=None):
"""Encrypts a data key and returns the ciphertext.
:param data_key: Unencrypted data key
:type data_key: :class:`aws_encryption_sdk.structures.RawDataKey`
or :class:`aws_encryption_sdk.structures.DataKey`
... | python | def _encrypt_data_key(self, data_key, algorithm, encryption_context=None):
"""Encrypts a data key and returns the ciphertext.
:param data_key: Unencrypted data key
:type data_key: :class:`aws_encryption_sdk.structures.RawDataKey`
or :class:`aws_encryption_sdk.structures.DataKey`
... | [
"def",
"_encrypt_data_key",
"(",
"self",
",",
"data_key",
",",
"algorithm",
",",
"encryption_context",
"=",
"None",
")",
":",
"kms_params",
"=",
"{",
"\"KeyId\"",
":",
"self",
".",
"_key_id",
",",
"\"Plaintext\"",
":",
"data_key",
".",
"data_key",
"}",
"if",... | Encrypts a data key and returns the ciphertext.
:param data_key: Unencrypted data key
:type data_key: :class:`aws_encryption_sdk.structures.RawDataKey`
or :class:`aws_encryption_sdk.structures.DataKey`
:param algorithm: Placeholder to maintain API compatibility with parent
:... | [
"Encrypts",
"a",
"data",
"key",
"and",
"returns",
"the",
"ciphertext",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/key_providers/kms.py#L274-L302 |
15,467 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/formatting/serialize.py | serialize_encrypted_data_key | def serialize_encrypted_data_key(encrypted_data_key):
"""Serializes an encrypted data key.
.. versionadded:: 1.3.0
:param encrypted_data_key: Encrypted data key to serialize
:type encrypted_data_key: aws_encryption_sdk.structures.EncryptedDataKey
:returns: Serialized encrypted data key
:rtype:... | python | def serialize_encrypted_data_key(encrypted_data_key):
"""Serializes an encrypted data key.
.. versionadded:: 1.3.0
:param encrypted_data_key: Encrypted data key to serialize
:type encrypted_data_key: aws_encryption_sdk.structures.EncryptedDataKey
:returns: Serialized encrypted data key
:rtype:... | [
"def",
"serialize_encrypted_data_key",
"(",
"encrypted_data_key",
")",
":",
"encrypted_data_key_format",
"=",
"(",
"\">\"",
"# big endian",
"\"H\"",
"# key provider ID length",
"\"{provider_id_len}s\"",
"# key provider ID",
"\"H\"",
"# key info length",
"\"{provider_info_len}s\"",
... | Serializes an encrypted data key.
.. versionadded:: 1.3.0
:param encrypted_data_key: Encrypted data key to serialize
:type encrypted_data_key: aws_encryption_sdk.structures.EncryptedDataKey
:returns: Serialized encrypted data key
:rtype: bytes | [
"Serializes",
"an",
"encrypted",
"data",
"key",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/serialize.py#L29-L60 |
15,468 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/formatting/serialize.py | serialize_header | def serialize_header(header, signer=None):
"""Serializes a header object.
:param header: Header to serialize
:type header: aws_encryption_sdk.structures.MessageHeader
:param signer: Cryptographic signer object (optional)
:type signer: aws_encryption_sdk.internal.crypto.Signer
:returns: Serializ... | python | def serialize_header(header, signer=None):
"""Serializes a header object.
:param header: Header to serialize
:type header: aws_encryption_sdk.structures.MessageHeader
:param signer: Cryptographic signer object (optional)
:type signer: aws_encryption_sdk.internal.crypto.Signer
:returns: Serializ... | [
"def",
"serialize_header",
"(",
"header",
",",
"signer",
"=",
"None",
")",
":",
"ec_serialized",
"=",
"aws_encryption_sdk",
".",
"internal",
".",
"formatting",
".",
"encryption_context",
".",
"serialize_encryption_context",
"(",
"header",
".",
"encryption_context",
... | Serializes a header object.
:param header: Header to serialize
:type header: aws_encryption_sdk.structures.MessageHeader
:param signer: Cryptographic signer object (optional)
:type signer: aws_encryption_sdk.internal.crypto.Signer
:returns: Serialized header
:rtype: bytes | [
"Serializes",
"a",
"header",
"object",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/serialize.py#L63-L118 |
15,469 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/formatting/serialize.py | serialize_header_auth | def serialize_header_auth(algorithm, header, data_encryption_key, signer=None):
"""Creates serialized header authentication data.
:param algorithm: Algorithm to use for encryption
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:param bytes header: Serialized message header
:param bytes d... | python | def serialize_header_auth(algorithm, header, data_encryption_key, signer=None):
"""Creates serialized header authentication data.
:param algorithm: Algorithm to use for encryption
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:param bytes header: Serialized message header
:param bytes d... | [
"def",
"serialize_header_auth",
"(",
"algorithm",
",",
"header",
",",
"data_encryption_key",
",",
"signer",
"=",
"None",
")",
":",
"header_auth",
"=",
"encrypt",
"(",
"algorithm",
"=",
"algorithm",
",",
"key",
"=",
"data_encryption_key",
",",
"plaintext",
"=",
... | Creates serialized header authentication data.
:param algorithm: Algorithm to use for encryption
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:param bytes header: Serialized message header
:param bytes data_encryption_key: Data key with which to encrypt message
:param signer: Cryptogra... | [
"Creates",
"serialized",
"header",
"authentication",
"data",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/serialize.py#L121-L147 |
15,470 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/formatting/serialize.py | serialize_non_framed_open | def serialize_non_framed_open(algorithm, iv, plaintext_length, signer=None):
"""Serializes the opening block for a non-framed message body.
:param algorithm: Algorithm to use for encryption
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:param bytes iv: IV value used to encrypt body
:par... | python | def serialize_non_framed_open(algorithm, iv, plaintext_length, signer=None):
"""Serializes the opening block for a non-framed message body.
:param algorithm: Algorithm to use for encryption
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:param bytes iv: IV value used to encrypt body
:par... | [
"def",
"serialize_non_framed_open",
"(",
"algorithm",
",",
"iv",
",",
"plaintext_length",
",",
"signer",
"=",
"None",
")",
":",
"body_start_format",
"=",
"(",
"\">\"",
"\"{iv_length}s\"",
"\"Q\"",
")",
".",
"format",
"(",
"iv_length",
"=",
"algorithm",
".",
"i... | Serializes the opening block for a non-framed message body.
:param algorithm: Algorithm to use for encryption
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:param bytes iv: IV value used to encrypt body
:param int plaintext_length: Length of plaintext (and thus ciphertext) in body
:para... | [
"Serializes",
"the",
"opening",
"block",
"for",
"a",
"non",
"-",
"framed",
"message",
"body",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/serialize.py#L150-L166 |
15,471 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/formatting/serialize.py | serialize_non_framed_close | def serialize_non_framed_close(tag, signer=None):
"""Serializes the closing block for a non-framed message body.
:param bytes tag: Auth tag value from body encryptor
:param signer: Cryptographic signer object (optional)
:type signer: aws_encryption_sdk.internal.crypto.Signer
:returns: Serialized bo... | python | def serialize_non_framed_close(tag, signer=None):
"""Serializes the closing block for a non-framed message body.
:param bytes tag: Auth tag value from body encryptor
:param signer: Cryptographic signer object (optional)
:type signer: aws_encryption_sdk.internal.crypto.Signer
:returns: Serialized bo... | [
"def",
"serialize_non_framed_close",
"(",
"tag",
",",
"signer",
"=",
"None",
")",
":",
"body_close",
"=",
"struct",
".",
"pack",
"(",
"\"{auth_len}s\"",
".",
"format",
"(",
"auth_len",
"=",
"len",
"(",
"tag",
")",
")",
",",
"tag",
")",
"if",
"signer",
... | Serializes the closing block for a non-framed message body.
:param bytes tag: Auth tag value from body encryptor
:param signer: Cryptographic signer object (optional)
:type signer: aws_encryption_sdk.internal.crypto.Signer
:returns: Serialized body close block
:rtype: bytes | [
"Serializes",
"the",
"closing",
"block",
"for",
"a",
"non",
"-",
"framed",
"message",
"body",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/serialize.py#L169-L181 |
15,472 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/formatting/serialize.py | serialize_frame | def serialize_frame(
algorithm, plaintext, message_id, data_encryption_key, frame_length, sequence_number, is_final_frame, signer=None
):
"""Receives a message plaintext, breaks off a frame, encrypts and serializes
the frame, and returns the encrypted frame and the remaining plaintext.
:param algorithm... | python | def serialize_frame(
algorithm, plaintext, message_id, data_encryption_key, frame_length, sequence_number, is_final_frame, signer=None
):
"""Receives a message plaintext, breaks off a frame, encrypts and serializes
the frame, and returns the encrypted frame and the remaining plaintext.
:param algorithm... | [
"def",
"serialize_frame",
"(",
"algorithm",
",",
"plaintext",
",",
"message_id",
",",
"data_encryption_key",
",",
"frame_length",
",",
"sequence_number",
",",
"is_final_frame",
",",
"signer",
"=",
"None",
")",
":",
"if",
"sequence_number",
"<",
"1",
":",
"raise"... | Receives a message plaintext, breaks off a frame, encrypts and serializes
the frame, and returns the encrypted frame and the remaining plaintext.
:param algorithm: Algorithm to use for encryption
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:param bytes plaintext: Source plaintext to encry... | [
"Receives",
"a",
"message",
"plaintext",
"breaks",
"off",
"a",
"frame",
"encrypts",
"and",
"serializes",
"the",
"frame",
"and",
"returns",
"the",
"encrypted",
"frame",
"and",
"the",
"remaining",
"plaintext",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/serialize.py#L184-L252 |
15,473 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/formatting/serialize.py | serialize_footer | def serialize_footer(signer):
"""Uses the signer object which has been used to sign the message to generate
the signature, then serializes that signature.
:param signer: Cryptographic signer object
:type signer: aws_encryption_sdk.internal.crypto.Signer
:returns: Serialized footer
:rtype: bytes... | python | def serialize_footer(signer):
"""Uses the signer object which has been used to sign the message to generate
the signature, then serializes that signature.
:param signer: Cryptographic signer object
:type signer: aws_encryption_sdk.internal.crypto.Signer
:returns: Serialized footer
:rtype: bytes... | [
"def",
"serialize_footer",
"(",
"signer",
")",
":",
"footer",
"=",
"b\"\"",
"if",
"signer",
"is",
"not",
"None",
":",
"signature",
"=",
"signer",
".",
"finalize",
"(",
")",
"footer",
"=",
"struct",
".",
"pack",
"(",
"\">H{sig_len}s\"",
".",
"format",
"("... | Uses the signer object which has been used to sign the message to generate
the signature, then serializes that signature.
:param signer: Cryptographic signer object
:type signer: aws_encryption_sdk.internal.crypto.Signer
:returns: Serialized footer
:rtype: bytes | [
"Uses",
"the",
"signer",
"object",
"which",
"has",
"been",
"used",
"to",
"sign",
"the",
"message",
"to",
"generate",
"the",
"signature",
"then",
"serializes",
"that",
"signature",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/serialize.py#L255-L268 |
15,474 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/formatting/serialize.py | serialize_raw_master_key_prefix | def serialize_raw_master_key_prefix(raw_master_key):
"""Produces the prefix that a RawMasterKey will always use for the
key_info value of keys which require additional information.
:param raw_master_key: RawMasterKey for which to produce a prefix
:type raw_master_key: aws_encryption_sdk.key_providers.r... | python | def serialize_raw_master_key_prefix(raw_master_key):
"""Produces the prefix that a RawMasterKey will always use for the
key_info value of keys which require additional information.
:param raw_master_key: RawMasterKey for which to produce a prefix
:type raw_master_key: aws_encryption_sdk.key_providers.r... | [
"def",
"serialize_raw_master_key_prefix",
"(",
"raw_master_key",
")",
":",
"if",
"raw_master_key",
".",
"config",
".",
"wrapping_key",
".",
"wrapping_algorithm",
".",
"encryption_type",
"is",
"EncryptionType",
".",
"ASYMMETRIC",
":",
"return",
"to_bytes",
"(",
"raw_ma... | Produces the prefix that a RawMasterKey will always use for the
key_info value of keys which require additional information.
:param raw_master_key: RawMasterKey for which to produce a prefix
:type raw_master_key: aws_encryption_sdk.key_providers.raw.RawMasterKey
:returns: Serialized key_info prefix
... | [
"Produces",
"the",
"prefix",
"that",
"a",
"RawMasterKey",
"will",
"always",
"use",
"for",
"the",
"key_info",
"value",
"of",
"keys",
"which",
"require",
"additional",
"information",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/serialize.py#L271-L288 |
15,475 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/formatting/serialize.py | serialize_wrapped_key | def serialize_wrapped_key(key_provider, wrapping_algorithm, wrapping_key_id, encrypted_wrapped_key):
"""Serializes EncryptedData into a Wrapped EncryptedDataKey.
:param key_provider: Info for Wrapping MasterKey
:type key_provider: aws_encryption_sdk.structures.MasterKeyInfo
:param wrapping_algorithm: W... | python | def serialize_wrapped_key(key_provider, wrapping_algorithm, wrapping_key_id, encrypted_wrapped_key):
"""Serializes EncryptedData into a Wrapped EncryptedDataKey.
:param key_provider: Info for Wrapping MasterKey
:type key_provider: aws_encryption_sdk.structures.MasterKeyInfo
:param wrapping_algorithm: W... | [
"def",
"serialize_wrapped_key",
"(",
"key_provider",
",",
"wrapping_algorithm",
",",
"wrapping_key_id",
",",
"encrypted_wrapped_key",
")",
":",
"if",
"encrypted_wrapped_key",
".",
"iv",
"is",
"None",
":",
"key_info",
"=",
"wrapping_key_id",
"key_ciphertext",
"=",
"enc... | Serializes EncryptedData into a Wrapped EncryptedDataKey.
:param key_provider: Info for Wrapping MasterKey
:type key_provider: aws_encryption_sdk.structures.MasterKeyInfo
:param wrapping_algorithm: Wrapping Algorithm with which to wrap plaintext_data_key
:type wrapping_algorithm: aws_encryption_sdk.ide... | [
"Serializes",
"EncryptedData",
"into",
"a",
"Wrapped",
"EncryptedDataKey",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/serialize.py#L291-L321 |
15,476 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/formatting/encryption_context.py | assemble_content_aad | def assemble_content_aad(message_id, aad_content_string, seq_num, length):
"""Assembles the Body AAD string for a message body structure.
:param message_id: Message ID
:type message_id: str
:param aad_content_string: ContentAADString object for frame type
:type aad_content_string: aws_encryption_sd... | python | def assemble_content_aad(message_id, aad_content_string, seq_num, length):
"""Assembles the Body AAD string for a message body structure.
:param message_id: Message ID
:type message_id: str
:param aad_content_string: ContentAADString object for frame type
:type aad_content_string: aws_encryption_sd... | [
"def",
"assemble_content_aad",
"(",
"message_id",
",",
"aad_content_string",
",",
"seq_num",
",",
"length",
")",
":",
"if",
"not",
"isinstance",
"(",
"aad_content_string",
",",
"aws_encryption_sdk",
".",
"identifiers",
".",
"ContentAADString",
")",
":",
"raise",
"... | Assembles the Body AAD string for a message body structure.
:param message_id: Message ID
:type message_id: str
:param aad_content_string: ContentAADString object for frame type
:type aad_content_string: aws_encryption_sdk.identifiers.ContentAADString
:param seq_num: Sequence number of frame
:t... | [
"Assembles",
"the",
"Body",
"AAD",
"string",
"for",
"a",
"message",
"body",
"structure",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/encryption_context.py#L29-L47 |
15,477 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/formatting/encryption_context.py | serialize_encryption_context | def serialize_encryption_context(encryption_context):
"""Serializes the contents of a dictionary into a byte string.
:param dict encryption_context: Dictionary of encrytion context keys/values.
:returns: Serialized encryption context
:rtype: bytes
"""
if not encryption_context:
return b... | python | def serialize_encryption_context(encryption_context):
"""Serializes the contents of a dictionary into a byte string.
:param dict encryption_context: Dictionary of encrytion context keys/values.
:returns: Serialized encryption context
:rtype: bytes
"""
if not encryption_context:
return b... | [
"def",
"serialize_encryption_context",
"(",
"encryption_context",
")",
":",
"if",
"not",
"encryption_context",
":",
"return",
"bytes",
"(",
")",
"serialized_context",
"=",
"bytearray",
"(",
")",
"dict_size",
"=",
"len",
"(",
"encryption_context",
")",
"if",
"dict_... | Serializes the contents of a dictionary into a byte string.
:param dict encryption_context: Dictionary of encrytion context keys/values.
:returns: Serialized encryption context
:rtype: bytes | [
"Serializes",
"the",
"contents",
"of",
"a",
"dictionary",
"into",
"a",
"byte",
"string",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/encryption_context.py#L50-L96 |
15,478 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/formatting/encryption_context.py | read_short | def read_short(source, offset):
"""Reads a number from a byte array.
:param bytes source: Source byte string
:param int offset: Point in byte string to start reading
:returns: Read number and offset at point after read data
:rtype: tuple of ints
:raises: SerializationError if unable to unpack
... | python | def read_short(source, offset):
"""Reads a number from a byte array.
:param bytes source: Source byte string
:param int offset: Point in byte string to start reading
:returns: Read number and offset at point after read data
:rtype: tuple of ints
:raises: SerializationError if unable to unpack
... | [
"def",
"read_short",
"(",
"source",
",",
"offset",
")",
":",
"try",
":",
"(",
"short",
",",
")",
"=",
"struct",
".",
"unpack_from",
"(",
"\">H\"",
",",
"source",
",",
"offset",
")",
"return",
"short",
",",
"offset",
"+",
"struct",
".",
"calcsize",
"(... | Reads a number from a byte array.
:param bytes source: Source byte string
:param int offset: Point in byte string to start reading
:returns: Read number and offset at point after read data
:rtype: tuple of ints
:raises: SerializationError if unable to unpack | [
"Reads",
"a",
"number",
"from",
"a",
"byte",
"array",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/encryption_context.py#L99-L112 |
15,479 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/formatting/encryption_context.py | read_string | def read_string(source, offset, length):
"""Reads a string from a byte string.
:param bytes source: Source byte string
:param int offset: Point in byte string to start reading
:param int length: Length of string to read
:returns: Read string and offset at point after read data
:rtype: tuple of ... | python | def read_string(source, offset, length):
"""Reads a string from a byte string.
:param bytes source: Source byte string
:param int offset: Point in byte string to start reading
:param int length: Length of string to read
:returns: Read string and offset at point after read data
:rtype: tuple of ... | [
"def",
"read_string",
"(",
"source",
",",
"offset",
",",
"length",
")",
":",
"end",
"=",
"offset",
"+",
"length",
"try",
":",
"return",
"(",
"codecs",
".",
"decode",
"(",
"source",
"[",
"offset",
":",
"end",
"]",
",",
"aws_encryption_sdk",
".",
"intern... | Reads a string from a byte string.
:param bytes source: Source byte string
:param int offset: Point in byte string to start reading
:param int length: Length of string to read
:returns: Read string and offset at point after read data
:rtype: tuple of str and int
:raises SerializationError: if u... | [
"Reads",
"a",
"string",
"from",
"a",
"byte",
"string",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/encryption_context.py#L115-L129 |
15,480 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/formatting/encryption_context.py | deserialize_encryption_context | def deserialize_encryption_context(serialized_encryption_context):
"""Deserializes the contents of a byte string into a dictionary.
:param bytes serialized_encryption_context: Source byte string containing serialized dictionary
:returns: Deserialized encryption context
:rtype: dict
:raises Serializ... | python | def deserialize_encryption_context(serialized_encryption_context):
"""Deserializes the contents of a byte string into a dictionary.
:param bytes serialized_encryption_context: Source byte string containing serialized dictionary
:returns: Deserialized encryption context
:rtype: dict
:raises Serializ... | [
"def",
"deserialize_encryption_context",
"(",
"serialized_encryption_context",
")",
":",
"if",
"len",
"(",
"serialized_encryption_context",
")",
">",
"aws_encryption_sdk",
".",
"internal",
".",
"defaults",
".",
"MAX_BYTE_ARRAY_SIZE",
":",
"raise",
"SerializationError",
"(... | Deserializes the contents of a byte string into a dictionary.
:param bytes serialized_encryption_context: Source byte string containing serialized dictionary
:returns: Deserialized encryption context
:rtype: dict
:raises SerializationError: if serialized encryption context is too large
:raises Seri... | [
"Deserializes",
"the",
"contents",
"of",
"a",
"byte",
"string",
"into",
"a",
"dictionary",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/encryption_context.py#L132-L170 |
15,481 | aws/aws-encryption-sdk-python | decrypt_oracle/src/aws_encryption_sdk_decrypt_oracle/key_providers/null.py | NullMasterKey.owns_data_key | def owns_data_key(self, data_key: DataKey) -> bool:
"""Determine whether the data key is owned by a ``null`` or ``zero`` provider.
:param data_key: Data key to evaluate
:type data_key: :class:`aws_encryption_sdk.structures.DataKey`,
:class:`aws_encryption_sdk.structures.RawDataKey`,... | python | def owns_data_key(self, data_key: DataKey) -> bool:
"""Determine whether the data key is owned by a ``null`` or ``zero`` provider.
:param data_key: Data key to evaluate
:type data_key: :class:`aws_encryption_sdk.structures.DataKey`,
:class:`aws_encryption_sdk.structures.RawDataKey`,... | [
"def",
"owns_data_key",
"(",
"self",
",",
"data_key",
":",
"DataKey",
")",
"->",
"bool",
":",
"return",
"data_key",
".",
"key_provider",
".",
"provider_id",
"in",
"self",
".",
"_allowed_provider_ids"
] | Determine whether the data key is owned by a ``null`` or ``zero`` provider.
:param data_key: Data key to evaluate
:type data_key: :class:`aws_encryption_sdk.structures.DataKey`,
:class:`aws_encryption_sdk.structures.RawDataKey`,
or :class:`aws_encryption_sdk.structures.Encrypted... | [
"Determine",
"whether",
"the",
"data",
"key",
"is",
"owned",
"by",
"a",
"null",
"or",
"zero",
"provider",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/decrypt_oracle/src/aws_encryption_sdk_decrypt_oracle/key_providers/null.py#L46-L56 |
15,482 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/crypto/iv.py | frame_iv | def frame_iv(algorithm, sequence_number):
"""Builds the deterministic IV for a body frame.
:param algorithm: Algorithm for which to build IV
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:param int sequence_number: Frame sequence number
:returns: Generated IV
:rtype: bytes
:rais... | python | def frame_iv(algorithm, sequence_number):
"""Builds the deterministic IV for a body frame.
:param algorithm: Algorithm for which to build IV
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:param int sequence_number: Frame sequence number
:returns: Generated IV
:rtype: bytes
:rais... | [
"def",
"frame_iv",
"(",
"algorithm",
",",
"sequence_number",
")",
":",
"if",
"sequence_number",
"<",
"1",
"or",
"sequence_number",
">",
"MAX_FRAME_COUNT",
":",
"raise",
"ActionNotAllowedError",
"(",
"\"Invalid frame sequence number: {actual}\\nMust be between 1 and {max}\"",
... | Builds the deterministic IV for a body frame.
:param algorithm: Algorithm for which to build IV
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:param int sequence_number: Frame sequence number
:returns: Generated IV
:rtype: bytes
:raises ActionNotAllowedError: if sequence number of o... | [
"Builds",
"the",
"deterministic",
"IV",
"for",
"a",
"body",
"frame",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/crypto/iv.py#L46-L64 |
15,483 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/identifiers.py | EncryptionSuite.valid_kdf | def valid_kdf(self, kdf):
"""Determine whether a KDFSuite can be used with this EncryptionSuite.
:param kdf: KDFSuite to evaluate
:type kdf: aws_encryption_sdk.identifiers.KDFSuite
:rtype: bool
"""
if kdf.input_length is None:
return True
if self.dat... | python | def valid_kdf(self, kdf):
"""Determine whether a KDFSuite can be used with this EncryptionSuite.
:param kdf: KDFSuite to evaluate
:type kdf: aws_encryption_sdk.identifiers.KDFSuite
:rtype: bool
"""
if kdf.input_length is None:
return True
if self.dat... | [
"def",
"valid_kdf",
"(",
"self",
",",
"kdf",
")",
":",
"if",
"kdf",
".",
"input_length",
"is",
"None",
":",
"return",
"True",
"if",
"self",
".",
"data_key_length",
">",
"kdf",
".",
"input_length",
"(",
"self",
")",
":",
"raise",
"InvalidAlgorithmError",
... | Determine whether a KDFSuite can be used with this EncryptionSuite.
:param kdf: KDFSuite to evaluate
:type kdf: aws_encryption_sdk.identifiers.KDFSuite
:rtype: bool | [
"Determine",
"whether",
"a",
"KDFSuite",
"can",
"be",
"used",
"with",
"this",
"EncryptionSuite",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/identifiers.py#L63-L78 |
15,484 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/formatting/__init__.py | header_length | def header_length(header):
"""Calculates the ciphertext message header length, given a complete header.
:param header: Complete message header object
:type header: aws_encryption_sdk.structures.MessageHeader
:rtype: int
"""
# Because encrypted data key lengths may not be knowable until the ciph... | python | def header_length(header):
"""Calculates the ciphertext message header length, given a complete header.
:param header: Complete message header object
:type header: aws_encryption_sdk.structures.MessageHeader
:rtype: int
"""
# Because encrypted data key lengths may not be knowable until the ciph... | [
"def",
"header_length",
"(",
"header",
")",
":",
"# Because encrypted data key lengths may not be knowable until the ciphertext",
"# is received from the providers, just serialize the header directly.",
"header_length",
"=",
"len",
"(",
"serialize_header",
"(",
"header",
")",
")",
... | Calculates the ciphertext message header length, given a complete header.
:param header: Complete message header object
:type header: aws_encryption_sdk.structures.MessageHeader
:rtype: int | [
"Calculates",
"the",
"ciphertext",
"message",
"header",
"length",
"given",
"a",
"complete",
"header",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/__init__.py#L17-L29 |
15,485 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/formatting/__init__.py | _non_framed_body_length | def _non_framed_body_length(header, plaintext_length):
"""Calculates the length of a non-framed message body, given a complete header.
:param header: Complete message header object
:type header: aws_encryption_sdk.structures.MessageHeader
:param int plaintext_length: Length of plaintext in bytes
:r... | python | def _non_framed_body_length(header, plaintext_length):
"""Calculates the length of a non-framed message body, given a complete header.
:param header: Complete message header object
:type header: aws_encryption_sdk.structures.MessageHeader
:param int plaintext_length: Length of plaintext in bytes
:r... | [
"def",
"_non_framed_body_length",
"(",
"header",
",",
"plaintext_length",
")",
":",
"body_length",
"=",
"header",
".",
"algorithm",
".",
"iv_len",
"# IV",
"body_length",
"+=",
"8",
"# Encrypted Content Length",
"body_length",
"+=",
"plaintext_length",
"# Encrypted Conte... | Calculates the length of a non-framed message body, given a complete header.
:param header: Complete message header object
:type header: aws_encryption_sdk.structures.MessageHeader
:param int plaintext_length: Length of plaintext in bytes
:rtype: int | [
"Calculates",
"the",
"length",
"of",
"a",
"non",
"-",
"framed",
"message",
"body",
"given",
"a",
"complete",
"header",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/__init__.py#L32-L44 |
15,486 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/formatting/__init__.py | _standard_frame_length | def _standard_frame_length(header):
"""Calculates the length of a standard ciphertext frame, given a complete header.
:param header: Complete message header object
:type header: aws_encryption_sdk.structures.MessageHeader
:rtype: int
"""
frame_length = 4 # Sequence Number
frame_length += h... | python | def _standard_frame_length(header):
"""Calculates the length of a standard ciphertext frame, given a complete header.
:param header: Complete message header object
:type header: aws_encryption_sdk.structures.MessageHeader
:rtype: int
"""
frame_length = 4 # Sequence Number
frame_length += h... | [
"def",
"_standard_frame_length",
"(",
"header",
")",
":",
"frame_length",
"=",
"4",
"# Sequence Number",
"frame_length",
"+=",
"header",
".",
"algorithm",
".",
"iv_len",
"# IV",
"frame_length",
"+=",
"header",
".",
"frame_length",
"# Encrypted Content",
"frame_length"... | Calculates the length of a standard ciphertext frame, given a complete header.
:param header: Complete message header object
:type header: aws_encryption_sdk.structures.MessageHeader
:rtype: int | [
"Calculates",
"the",
"length",
"of",
"a",
"standard",
"ciphertext",
"frame",
"given",
"a",
"complete",
"header",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/__init__.py#L47-L58 |
15,487 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/formatting/__init__.py | _final_frame_length | def _final_frame_length(header, final_frame_bytes):
"""Calculates the length of a final ciphertext frame, given a complete header
and the number of bytes of ciphertext in the final frame.
:param header: Complete message header object
:type header: aws_encryption_sdk.structures.MessageHeader
:param ... | python | def _final_frame_length(header, final_frame_bytes):
"""Calculates the length of a final ciphertext frame, given a complete header
and the number of bytes of ciphertext in the final frame.
:param header: Complete message header object
:type header: aws_encryption_sdk.structures.MessageHeader
:param ... | [
"def",
"_final_frame_length",
"(",
"header",
",",
"final_frame_bytes",
")",
":",
"final_frame_length",
"=",
"4",
"# Sequence Number End",
"final_frame_length",
"+=",
"4",
"# Sequence Number",
"final_frame_length",
"+=",
"header",
".",
"algorithm",
".",
"iv_len",
"# IV",... | Calculates the length of a final ciphertext frame, given a complete header
and the number of bytes of ciphertext in the final frame.
:param header: Complete message header object
:type header: aws_encryption_sdk.structures.MessageHeader
:param int final_frame_bytes: Bytes of ciphertext in the final fra... | [
"Calculates",
"the",
"length",
"of",
"a",
"final",
"ciphertext",
"frame",
"given",
"a",
"complete",
"header",
"and",
"the",
"number",
"of",
"bytes",
"of",
"ciphertext",
"in",
"the",
"final",
"frame",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/__init__.py#L61-L76 |
15,488 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/formatting/__init__.py | body_length | def body_length(header, plaintext_length):
"""Calculates the ciphertext message body length, given a complete header.
:param header: Complete message header object
:type header: aws_encryption_sdk.structures.MessageHeader
:param int plaintext_length: Length of plaintext in bytes
:rtype: int
"""... | python | def body_length(header, plaintext_length):
"""Calculates the ciphertext message body length, given a complete header.
:param header: Complete message header object
:type header: aws_encryption_sdk.structures.MessageHeader
:param int plaintext_length: Length of plaintext in bytes
:rtype: int
"""... | [
"def",
"body_length",
"(",
"header",
",",
"plaintext_length",
")",
":",
"body_length",
"=",
"0",
"if",
"header",
".",
"frame_length",
"==",
"0",
":",
"# Non-framed",
"body_length",
"+=",
"_non_framed_body_length",
"(",
"header",
",",
"plaintext_length",
")",
"el... | Calculates the ciphertext message body length, given a complete header.
:param header: Complete message header object
:type header: aws_encryption_sdk.structures.MessageHeader
:param int plaintext_length: Length of plaintext in bytes
:rtype: int | [
"Calculates",
"the",
"ciphertext",
"message",
"body",
"length",
"given",
"a",
"complete",
"header",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/__init__.py#L79-L94 |
15,489 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/formatting/__init__.py | footer_length | def footer_length(header):
"""Calculates the ciphertext message footer length, given a complete header.
:param header: Complete message header object
:type header: aws_encryption_sdk.structures.MessageHeader
:rtype: int
"""
footer_length = 0
if header.algorithm.signing_algorithm_info is not... | python | def footer_length(header):
"""Calculates the ciphertext message footer length, given a complete header.
:param header: Complete message header object
:type header: aws_encryption_sdk.structures.MessageHeader
:rtype: int
"""
footer_length = 0
if header.algorithm.signing_algorithm_info is not... | [
"def",
"footer_length",
"(",
"header",
")",
":",
"footer_length",
"=",
"0",
"if",
"header",
".",
"algorithm",
".",
"signing_algorithm_info",
"is",
"not",
"None",
":",
"footer_length",
"+=",
"2",
"# Signature Length",
"footer_length",
"+=",
"header",
".",
"algori... | Calculates the ciphertext message footer length, given a complete header.
:param header: Complete message header object
:type header: aws_encryption_sdk.structures.MessageHeader
:rtype: int | [
"Calculates",
"the",
"ciphertext",
"message",
"footer",
"length",
"given",
"a",
"complete",
"header",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/__init__.py#L97-L108 |
15,490 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/formatting/__init__.py | ciphertext_length | def ciphertext_length(header, plaintext_length):
"""Calculates the complete ciphertext message length, given a complete header.
:param header: Complete message header object
:type header: aws_encryption_sdk.structures.MessageHeader
:param int plaintext_length: Length of plaintext in bytes
:rtype: i... | python | def ciphertext_length(header, plaintext_length):
"""Calculates the complete ciphertext message length, given a complete header.
:param header: Complete message header object
:type header: aws_encryption_sdk.structures.MessageHeader
:param int plaintext_length: Length of plaintext in bytes
:rtype: i... | [
"def",
"ciphertext_length",
"(",
"header",
",",
"plaintext_length",
")",
":",
"ciphertext_length",
"=",
"header_length",
"(",
"header",
")",
"ciphertext_length",
"+=",
"body_length",
"(",
"header",
",",
"plaintext_length",
")",
"ciphertext_length",
"+=",
"footer_lengt... | Calculates the complete ciphertext message length, given a complete header.
:param header: Complete message header object
:type header: aws_encryption_sdk.structures.MessageHeader
:param int plaintext_length: Length of plaintext in bytes
:rtype: int | [
"Calculates",
"the",
"complete",
"ciphertext",
"message",
"length",
"given",
"a",
"complete",
"header",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/__init__.py#L111-L122 |
15,491 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/key_providers/raw.py | RawMasterKey.owns_data_key | def owns_data_key(self, data_key):
"""Determines if data_key object is owned by this RawMasterKey.
:param data_key: Data key to evaluate
:type data_key: :class:`aws_encryption_sdk.structures.DataKey`,
:class:`aws_encryption_sdk.structures.RawDataKey`,
or :class:`aws_encr... | python | def owns_data_key(self, data_key):
"""Determines if data_key object is owned by this RawMasterKey.
:param data_key: Data key to evaluate
:type data_key: :class:`aws_encryption_sdk.structures.DataKey`,
:class:`aws_encryption_sdk.structures.RawDataKey`,
or :class:`aws_encr... | [
"def",
"owns_data_key",
"(",
"self",
",",
"data_key",
")",
":",
"expected_key_info_len",
"=",
"-",
"1",
"if",
"(",
"self",
".",
"config",
".",
"wrapping_key",
".",
"wrapping_algorithm",
".",
"encryption_type",
"is",
"EncryptionType",
".",
"ASYMMETRIC",
"and",
... | Determines if data_key object is owned by this RawMasterKey.
:param data_key: Data key to evaluate
:type data_key: :class:`aws_encryption_sdk.structures.DataKey`,
:class:`aws_encryption_sdk.structures.RawDataKey`,
or :class:`aws_encryption_sdk.structures.EncryptedDataKey`
... | [
"Determines",
"if",
"data_key",
"object",
"is",
"owned",
"by",
"this",
"RawMasterKey",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/key_providers/raw.py#L75-L113 |
15,492 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/key_providers/raw.py | RawMasterKey._encrypt_data_key | def _encrypt_data_key(self, data_key, algorithm, encryption_context):
"""Performs the provider-specific key encryption actions.
:param data_key: Unencrypted data key
:type data_key: :class:`aws_encryption_sdk.structures.RawDataKey`
or :class:`aws_encryption_sdk.structures.DataKey`
... | python | def _encrypt_data_key(self, data_key, algorithm, encryption_context):
"""Performs the provider-specific key encryption actions.
:param data_key: Unencrypted data key
:type data_key: :class:`aws_encryption_sdk.structures.RawDataKey`
or :class:`aws_encryption_sdk.structures.DataKey`
... | [
"def",
"_encrypt_data_key",
"(",
"self",
",",
"data_key",
",",
"algorithm",
",",
"encryption_context",
")",
":",
"# Raw key string to EncryptedData",
"encrypted_wrapped_key",
"=",
"self",
".",
"config",
".",
"wrapping_key",
".",
"encrypt",
"(",
"plaintext_data_key",
"... | Performs the provider-specific key encryption actions.
:param data_key: Unencrypted data key
:type data_key: :class:`aws_encryption_sdk.structures.RawDataKey`
or :class:`aws_encryption_sdk.structures.DataKey`
:param algorithm: Algorithm object which directs how this Master Key will ... | [
"Performs",
"the",
"provider",
"-",
"specific",
"key",
"encryption",
"actions",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/key_providers/raw.py#L136-L159 |
15,493 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/caches/null.py | NullCryptoMaterialsCache.put_encryption_materials | def put_encryption_materials(self, cache_key, encryption_materials, plaintext_length, entry_hints=None):
"""Does not add encryption materials to the cache since there is no cache to which to add them.
:param bytes cache_key: Identifier for entries in cache
:param encryption_materials: Encryptio... | python | def put_encryption_materials(self, cache_key, encryption_materials, plaintext_length, entry_hints=None):
"""Does not add encryption materials to the cache since there is no cache to which to add them.
:param bytes cache_key: Identifier for entries in cache
:param encryption_materials: Encryptio... | [
"def",
"put_encryption_materials",
"(",
"self",
",",
"cache_key",
",",
"encryption_materials",
",",
"plaintext_length",
",",
"entry_hints",
"=",
"None",
")",
":",
"return",
"CryptoMaterialsCacheEntry",
"(",
"cache_key",
"=",
"cache_key",
",",
"value",
"=",
"encrypti... | Does not add encryption materials to the cache since there is no cache to which to add them.
:param bytes cache_key: Identifier for entries in cache
:param encryption_materials: Encryption materials to add to cache
:type encryption_materials: aws_encryption_sdk.materials_managers.EncryptionMate... | [
"Does",
"not",
"add",
"encryption",
"materials",
"to",
"the",
"cache",
"since",
"there",
"is",
"no",
"cache",
"to",
"which",
"to",
"add",
"them",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/caches/null.py#L25-L36 |
15,494 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/crypto/authentication.py | _PrehashingAuthenticator._set_signature_type | def _set_signature_type(self):
"""Ensures that the algorithm signature type is a known type and sets a reference value."""
try:
verify_interface(ec.EllipticCurve, self.algorithm.signing_algorithm_info)
return ec.EllipticCurve
except InterfaceNotImplemented:
ra... | python | def _set_signature_type(self):
"""Ensures that the algorithm signature type is a known type and sets a reference value."""
try:
verify_interface(ec.EllipticCurve, self.algorithm.signing_algorithm_info)
return ec.EllipticCurve
except InterfaceNotImplemented:
ra... | [
"def",
"_set_signature_type",
"(",
"self",
")",
":",
"try",
":",
"verify_interface",
"(",
"ec",
".",
"EllipticCurve",
",",
"self",
".",
"algorithm",
".",
"signing_algorithm_info",
")",
"return",
"ec",
".",
"EllipticCurve",
"except",
"InterfaceNotImplemented",
":",... | Ensures that the algorithm signature type is a known type and sets a reference value. | [
"Ensures",
"that",
"the",
"algorithm",
"signature",
"type",
"is",
"a",
"known",
"type",
"and",
"sets",
"a",
"reference",
"value",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/crypto/authentication.py#L48-L54 |
15,495 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/crypto/authentication.py | Signer.from_key_bytes | def from_key_bytes(cls, algorithm, key_bytes):
"""Builds a `Signer` from an algorithm suite and a raw signing key.
:param algorithm: Algorithm on which to base signer
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:param bytes key_bytes: Raw signing key
:rtype: aws_en... | python | def from_key_bytes(cls, algorithm, key_bytes):
"""Builds a `Signer` from an algorithm suite and a raw signing key.
:param algorithm: Algorithm on which to base signer
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:param bytes key_bytes: Raw signing key
:rtype: aws_en... | [
"def",
"from_key_bytes",
"(",
"cls",
",",
"algorithm",
",",
"key_bytes",
")",
":",
"key",
"=",
"serialization",
".",
"load_der_private_key",
"(",
"data",
"=",
"key_bytes",
",",
"password",
"=",
"None",
",",
"backend",
"=",
"default_backend",
"(",
")",
")",
... | Builds a `Signer` from an algorithm suite and a raw signing key.
:param algorithm: Algorithm on which to base signer
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:param bytes key_bytes: Raw signing key
:rtype: aws_encryption_sdk.internal.crypto.Signer | [
"Builds",
"a",
"Signer",
"from",
"an",
"algorithm",
"suite",
"and",
"a",
"raw",
"signing",
"key",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/crypto/authentication.py#L74-L83 |
15,496 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/crypto/authentication.py | Signer.key_bytes | def key_bytes(self):
"""Returns the raw signing key.
:rtype: bytes
"""
return self.key.private_bytes(
encoding=serialization.Encoding.DER,
format=serialization.PrivateFormat.PKCS8,
encryption_algorithm=serialization.NoEncryption(),
) | python | def key_bytes(self):
"""Returns the raw signing key.
:rtype: bytes
"""
return self.key.private_bytes(
encoding=serialization.Encoding.DER,
format=serialization.PrivateFormat.PKCS8,
encryption_algorithm=serialization.NoEncryption(),
) | [
"def",
"key_bytes",
"(",
"self",
")",
":",
"return",
"self",
".",
"key",
".",
"private_bytes",
"(",
"encoding",
"=",
"serialization",
".",
"Encoding",
".",
"DER",
",",
"format",
"=",
"serialization",
".",
"PrivateFormat",
".",
"PKCS8",
",",
"encryption_algor... | Returns the raw signing key.
:rtype: bytes | [
"Returns",
"the",
"raw",
"signing",
"key",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/crypto/authentication.py#L85-L94 |
15,497 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/crypto/authentication.py | Signer.finalize | def finalize(self):
"""Finalizes the signer and returns the signature.
:returns: Calculated signer signature
:rtype: bytes
"""
prehashed_digest = self._hasher.finalize()
return _ecc_static_length_signature(key=self.key, algorithm=self.algorithm, digest=prehashed_digest) | python | def finalize(self):
"""Finalizes the signer and returns the signature.
:returns: Calculated signer signature
:rtype: bytes
"""
prehashed_digest = self._hasher.finalize()
return _ecc_static_length_signature(key=self.key, algorithm=self.algorithm, digest=prehashed_digest) | [
"def",
"finalize",
"(",
"self",
")",
":",
"prehashed_digest",
"=",
"self",
".",
"_hasher",
".",
"finalize",
"(",
")",
"return",
"_ecc_static_length_signature",
"(",
"key",
"=",
"self",
".",
"key",
",",
"algorithm",
"=",
"self",
".",
"algorithm",
",",
"dige... | Finalizes the signer and returns the signature.
:returns: Calculated signer signature
:rtype: bytes | [
"Finalizes",
"the",
"signer",
"and",
"returns",
"the",
"signature",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/crypto/authentication.py#L114-L121 |
15,498 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/crypto/authentication.py | Verifier.from_encoded_point | def from_encoded_point(cls, algorithm, encoded_point):
"""Creates a Verifier object based on the supplied algorithm and encoded compressed ECC curve point.
:param algorithm: Algorithm on which to base verifier
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:param bytes encode... | python | def from_encoded_point(cls, algorithm, encoded_point):
"""Creates a Verifier object based on the supplied algorithm and encoded compressed ECC curve point.
:param algorithm: Algorithm on which to base verifier
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:param bytes encode... | [
"def",
"from_encoded_point",
"(",
"cls",
",",
"algorithm",
",",
"encoded_point",
")",
":",
"return",
"cls",
"(",
"algorithm",
"=",
"algorithm",
",",
"key",
"=",
"_ecc_public_numbers_from_compressed_point",
"(",
"curve",
"=",
"algorithm",
".",
"signing_algorithm_info... | Creates a Verifier object based on the supplied algorithm and encoded compressed ECC curve point.
:param algorithm: Algorithm on which to base verifier
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:param bytes encoded_point: ECC public point compressed and encoded with _ecc_encode_... | [
"Creates",
"a",
"Verifier",
"object",
"based",
"on",
"the",
"supplied",
"algorithm",
"and",
"encoded",
"compressed",
"ECC",
"curve",
"point",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/crypto/authentication.py#L137-L151 |
15,499 | aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/crypto/authentication.py | Verifier.from_key_bytes | def from_key_bytes(cls, algorithm, key_bytes):
"""Creates a `Verifier` object based on the supplied algorithm and raw verification key.
:param algorithm: Algorithm on which to base verifier
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:param bytes encoded_point: Raw verific... | python | def from_key_bytes(cls, algorithm, key_bytes):
"""Creates a `Verifier` object based on the supplied algorithm and raw verification key.
:param algorithm: Algorithm on which to base verifier
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:param bytes encoded_point: Raw verific... | [
"def",
"from_key_bytes",
"(",
"cls",
",",
"algorithm",
",",
"key_bytes",
")",
":",
"return",
"cls",
"(",
"algorithm",
"=",
"algorithm",
",",
"key",
"=",
"serialization",
".",
"load_der_public_key",
"(",
"data",
"=",
"key_bytes",
",",
"backend",
"=",
"default... | Creates a `Verifier` object based on the supplied algorithm and raw verification key.
:param algorithm: Algorithm on which to base verifier
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:param bytes encoded_point: Raw verification key
:returns: Instance of Verifier generated... | [
"Creates",
"a",
"Verifier",
"object",
"based",
"on",
"the",
"supplied",
"algorithm",
"and",
"raw",
"verification",
"key",
"."
] | d182155d5fb1ef176d9e7d0647679737d5146495 | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/crypto/authentication.py#L154-L165 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.