INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Return True if import is spans multiples lines. | def multiline_import(line, previous_line=''):
"""Return True if import is spans multiples lines."""
for symbol in '()':
if symbol in line:
return True
# Ignore doctests.
if line.lstrip().startswith('>'):
return True
return multiline_statement(line, previous_line) |
Return True if this is part of a multiline statement. | def multiline_statement(line, previous_line=''):
"""Return True if this is part of a multiline statement."""
for symbol in '\\:;':
if symbol in line:
return True
sio = io.StringIO(line)
try:
list(tokenize.generate_tokens(sio.readline))
return previous_line.rstrip().e... |
Parse and filter from something import a b c. | def filter_from_import(line, unused_module):
"""Parse and filter ``from something import a, b, c``.
Return line without unused import modules, or `pass` if all of the
module in import is unused.
"""
(indentation, imports) = re.split(pattern=r'\bimport\b',
strin... |
Return line with imports on separate lines. | def break_up_import(line):
"""Return line with imports on separate lines."""
assert '\\' not in line
assert '(' not in line
assert ')' not in line
assert ';' not in line
assert '#' not in line
assert not line.lstrip().startswith('from')
newline = get_line_ending(line)
if not newline... |
Yield code with unused imports removed. | def filter_code(source, additional_imports=None,
expand_star_imports=False,
remove_all_unused_imports=False,
remove_duplicate_keys=False,
remove_unused_variables=False,
ignore_init_module_imports=False,
):
"""Yield code ... |
Return dictionary that maps line number to message. | def get_messages_by_line(messages):
"""Return dictionary that maps line number to message."""
line_messages = {}
for message in messages:
line_messages[message.lineno] = message
return line_messages |
Return line with the star import expanded. | def filter_star_import(line, marked_star_import_undefined_name):
"""Return line with the star import expanded."""
undefined_name = sorted(set(marked_star_import_undefined_name))
return re.sub(r'\*', ', '.join(undefined_name), line) |
Return line if used otherwise return None. | def filter_unused_import(line, unused_module, remove_all_unused_imports,
imports, previous_line=''):
"""Return line if used, otherwise return None."""
if multiline_import(line, previous_line):
return line
is_from_import = line.lstrip().startswith('from')
if ',' in line... |
Return line if used otherwise return None. | def filter_unused_variable(line, previous_line=''):
"""Return line if used, otherwise return None."""
if re.match(EXCEPT_REGEX, line):
return re.sub(r' as \w+:$', ':', line, count=1)
elif multiline_statement(line, previous_line):
return line
elif line.count('=') == 1:
split_line ... |
Return if first occurrence of the key otherwise return line. | def filter_duplicate_key(line, message, line_number, marked_line_numbers,
source, previous_line=''):
"""Return '' if first occurrence of the key otherwise return `line`."""
if marked_line_numbers and line_number == sorted(marked_line_numbers)[0]:
return ''
return line |
Return True if line is a dict entry that uses key. | def dict_entry_has_key(line, key):
"""Return True if `line` is a dict entry that uses `key`.
Return False for multiline cases where the line should not be removed by
itself.
"""
if '#' in line:
return False
result = re.match(r'\s*(.*)\s*:\s*(.*),\s*$', line)
if not result:
... |
Return True if value is a literal or a name. | def is_literal_or_name(value):
"""Return True if value is a literal or a name."""
try:
ast.literal_eval(value)
return True
except (SyntaxError, ValueError):
pass
if value.strip() in ['dict()', 'list()', 'set()']:
return True
# Support removal of variables on the rig... |
Yield line numbers of unneeded pass statements. | def useless_pass_line_numbers(source):
"""Yield line numbers of unneeded "pass" statements."""
sio = io.StringIO(source)
previous_token_type = None
last_pass_row = None
last_pass_indentation = None
previous_line = ''
for token in tokenize.generate_tokens(sio.readline):
token_type = t... |
Yield code with useless pass lines removed. | def filter_useless_pass(source):
"""Yield code with useless "pass" lines removed."""
try:
marked_lines = frozenset(useless_pass_line_numbers(source))
except (SyntaxError, tokenize.TokenError):
marked_lines = frozenset()
sio = io.StringIO(source)
for line_number, line in enumerate(si... |
Return leading whitespace. | def get_indentation(line):
"""Return leading whitespace."""
if line.strip():
non_whitespace_index = len(line) - len(line.lstrip())
return line[:non_whitespace_index]
else:
return '' |
Return line ending. | def get_line_ending(line):
"""Return line ending."""
non_whitespace_index = len(line.rstrip()) - len(line)
if not non_whitespace_index:
return ''
else:
return line[non_whitespace_index:] |
Return code with all filtering run on it. | def fix_code(source, additional_imports=None, expand_star_imports=False,
remove_all_unused_imports=False, remove_duplicate_keys=False,
remove_unused_variables=False, ignore_init_module_imports=False):
"""Return code with all filtering run on it."""
if not source:
return source
... |
Run fix_code () on a file. | def fix_file(filename, args, standard_out):
"""Run fix_code() on a file."""
encoding = detect_encoding(filename)
with open_with_encoding(filename, encoding=encoding) as input_file:
source = input_file.read()
original_source = source
isInitFile = os.path.basename(filename) == '__init__.py'
... |
Return file encoding. | def detect_encoding(filename, limit_byte_check=-1):
"""Return file encoding."""
try:
with open(filename, 'rb') as input_file:
encoding = _detect_encoding(input_file.readline)
# Check for correctness of encoding.
with open_with_encoding(filename, encoding) as input_fi... |
Return file encoding. | def _detect_encoding(readline):
"""Return file encoding."""
try:
from lib2to3.pgen2 import tokenize as lib2to3_tokenize
encoding = lib2to3_tokenize.detect_encoding(readline)[0]
return encoding
except (LookupError, SyntaxError, UnicodeDecodeError):
return 'latin-1' |
Return a set of strings. | def _split_comma_separated(string):
"""Return a set of strings."""
return set(text.strip() for text in string.split(',') if text.strip()) |
Return True if filename is Python file. | def is_python_file(filename):
"""Return True if filename is Python file."""
if filename.endswith('.py'):
return True
try:
with open_with_encoding(
filename,
None,
limit_byte_check=MAX_PYTHON_FILE_DETECTION_BYTES) as f:
text = f.rea... |
Return True if file matches exclude pattern. | def is_exclude_file(filename, exclude):
"""Return True if file matches exclude pattern."""
base_name = os.path.basename(filename)
if base_name.startswith('.'):
return True
for pattern in exclude:
if fnmatch.fnmatch(base_name, pattern):
return True
if fnmatch.fnmatch... |
Return True if file is okay for modifying/ recursing. | def match_file(filename, exclude):
"""Return True if file is okay for modifying/recursing."""
if is_exclude_file(filename, exclude):
return False
if not os.path.isdir(filename) and not is_python_file(filename):
return False
return True |
Yield filenames. | def find_files(filenames, recursive, exclude):
"""Yield filenames."""
while filenames:
name = filenames.pop(0)
if recursive and os.path.isdir(name):
for root, directories, children in os.walk(name):
filenames += [os.path.join(root, f) for f in children
... |
Return exit status. | def _main(argv, standard_out, standard_error):
"""Return exit status.
0 means no error.
"""
import argparse
parser = argparse.ArgumentParser(description=__doc__, prog='autoflake')
parser.add_argument('-c', '--check', action='store_true',
help='return error code if change... |
Read the data encoding the ObtainLease response payload and decode it into its constituent parts. | def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the ObtainLease response payload and decode it
into its constituent parts.
Args:
input_stream (stream): A data stream containing encoded object
data, supporting ... |
Write the data encoding the ObtainLease response payload to a stream. | def write(self, output_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the data encoding the ObtainLease response payload to a stream.
Args:
output_stream (stream): A data stream in which to encode object
data, supporting a write method; usually a Bytearr... |
Write the data encoding the Cancel request payload to a stream. | def write(self, output_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the data encoding the Cancel request payload to a stream.
Args:
output_stream (stream): A data stream in which to encode object
data, supporting a write method; usually a BytearrayStre... |
Read the data encoding the Cancel response payload and decode it into its constituent parts. | def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the Cancel response payload and decode it into
its constituent parts.
Args:
input_stream (stream): A data stream containing encoded object
data, supporting a rea... |
Returns a Name object populated with the given value and type | def create(cls, name_value, name_type):
'''
Returns a Name object, populated with the given value and type
'''
if isinstance(name_value, Name.NameValue):
value = name_value
elif isinstance(name_value, str):
value = cls.NameValue(name_value)
els... |
Read the data encoding the Digest object and decode it into its constituent parts. | def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the Digest object and decode it into its
constituent parts.
Args:
istream (Stream): A data stream containing encoded object data,
supporting a read method; usually a ... |
Write the data encoding the Digest object to a stream. | def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the data encoding the Digest object to a stream.
Args:
ostream (Stream): A data stream in which to encode object data,
supporting a write method; usually a BytearrayStream object.
... |
Construct a Digest object from provided digest values. | def create(cls,
hashing_algorithm=HashingAlgorithmEnum.SHA_256,
digest_value=b'',
key_format_type=KeyFormatTypeEnum.RAW):
"""
Construct a Digest object from provided digest values.
Args:
hashing_algorithm (HashingAlgorithm): An enumeratio... |
Read the data encoding the ApplicationSpecificInformation object and decode it into its constituent parts. | def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the ApplicationSpecificInformation object and
decode it into its constituent parts.
Args:
istream (Stream): A data stream containing encoded object data,
supporting a... |
Write the data encoding the ApplicationSpecificInformation object to a stream. | def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the data encoding the ApplicationSpecificInformation object to a
stream.
Args:
ostream (Stream): A data stream in which to encode object data,
supporting a write method; usually a By... |
Construct an ApplicationSpecificInformation object from provided data and namespace values. | def create(cls, application_namespace, application_data):
"""
Construct an ApplicationSpecificInformation object from provided data
and namespace values.
Args:
application_namespace (str): The name of the application namespace.
application_data (str): Application... |
Read the data encoding the DerivationParameters struct and decode it into its constituent parts. | def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the DerivationParameters struct and decode it
into its constituent parts.
Args:
input_stream (stream): A data stream containing encoded object
data, supporting a... |
Write the data encoding the DerivationParameters struct to a stream. | def write(self, output_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the data encoding the DerivationParameters struct to a stream.
Args:
output_stream (stream): A data stream in which to encode object
data, supporting a write method; usually a Bytearra... |
Read the data encoding the Get request payload and decode it into its constituent parts. | def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the Get request payload and decode it into its
constituent parts.
Args:
input_stream (stream): A data stream containing encoded object
data, supporting a read me... |
Write the data encoding the Get request payload to a stream. | def write(self, output_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the data encoding the Get request payload to a stream.
Args:
output_stream (stream): A data stream in which to encode object
data, supporting a write method; usually a BytearrayStream
... |
Read the data encoding the Get response payload and decode it into its constituent parts. | def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the Get response payload and decode it
into its constituent parts.
Args:
input_stream (stream): A data stream containing encoded object
data, supporting a read m... |
Write the data encoding the Get response payload to a stream. | def write(self, output_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the data encoding the Get response payload to a stream.
Args:
output_stream (stream): A data stream in which to encode object
data, supporting a write method; usually a BytearrayStream... |
Read the data encoding the SignatureVerify request payload and decode it into its constituent parts. | def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the SignatureVerify request payload and decode
it into its constituent parts.
Args:
input_stream (stream): A data stream containing encoded object
data, supporti... |
Write the data encoding the SignatureVerify request payload to a stream. | def write(self, output_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the data encoding the SignatureVerify request payload to a
stream.
Args:
output_stream (stream): A data stream in which to encode object
data, supporting a write method; usuall... |
Read the data encoding the SignatureVerify response payload and decode it into its constituent parts. | def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the SignatureVerify response payload and decode
it into its constituent parts.
Args:
input_stream (stream): A data stream containing encoded object
data, support... |
Process a KMIP request message. | def process_request(self, request, credential=None):
"""
Process a KMIP request message.
This routine is the main driver of the KmipEngine. It breaks apart and
processes the request header, handles any message errors that may
result, and then passes the set of request batch item... |
Build a simple ResponseMessage with a single error result. | def build_error_response(self, version, reason, message):
"""
Build a simple ResponseMessage with a single error result.
Args:
version (ProtocolVersion): The protocol version the response
should be addressed with.
reason (ResultReason): An enumeration cla... |
Given a kmip. core TemplateAttribute object extract the attribute value data into a usable dictionary format. | def _process_template_attribute(self, template_attribute):
"""
Given a kmip.core TemplateAttribute object, extract the attribute
value data into a usable dictionary format.
"""
attributes = {}
if len(template_attribute.names) > 0:
raise exceptions.ItemNotFoun... |
Given a kmip. pie object and a list of attribute names attempt to get all of the existing attribute values from the object. | def _get_attributes_from_managed_object(self, managed_object, attr_names):
"""
Given a kmip.pie object and a list of attribute names, attempt to get
all of the existing attribute values from the object.
"""
attr_factory = attribute_factory.AttributeFactory()
retrieved_att... |
Get the attribute value from the kmip. pie managed object. | def _get_attribute_from_managed_object(self, managed_object, attr_name):
"""
Get the attribute value from the kmip.pie managed object.
"""
if attr_name == 'Unique Identifier':
return str(managed_object.unique_identifier)
elif attr_name == 'Name':
names = l... |
Given a kmip. pie object and a dictionary of attributes attempt to set the attribute values on the object. | def _set_attributes_on_managed_object(self, managed_object, attributes):
"""
Given a kmip.pie object and a dictionary of attributes, attempt to set
the attribute values on the object.
"""
for attribute_name, attribute_value in six.iteritems(attributes):
object_type = ... |
Set the attribute value on the kmip. pie managed object. | def _set_attribute_on_managed_object(self, managed_object, attribute):
"""
Set the attribute value on the kmip.pie managed object.
"""
attribute_name = attribute[0]
attribute_value = attribute[1]
if self._attribute_policy.is_attribute_multivalued(attribute_name):
... |
Look up the policy corresponding to the provided policy name and group ( optional ). Log any issues found during the look up. | def get_relevant_policy_section(self, policy_name, group=None):
"""
Look up the policy corresponding to the provided policy name and
group (optional). Log any issues found during the look up.
"""
policy_bundle = self._operation_policies.get(policy_name)
if not policy_bun... |
Determine if object access is allowed for the provided policy and session settings. | def is_allowed(
self,
policy_name,
session_user,
session_group,
object_owner,
object_type,
operation
):
"""
Determine if object access is allowed for the provided policy and
session settings.
"""
... |
Write the data encoding the Decrypt request payload to a stream. | def write(self, output_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the data encoding the Decrypt request payload to a stream.
Args:
output_stream (stream): A data stream in which to encode object
data, supporting a write method; usually a BytearrayStr... |
Read the data encoding the RevokeRequestPayload object and decode it into its constituent parts. Args: istream ( Stream ): A data stream containing encoded object data supporting a read method ; usually a BytearrayStream object. kmip_version ( KMIPVersion ): An enumeration defining the KMIP version with which the objec... | def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the RevokeRequestPayload object and decode it
into its constituent parts.
Args:
istream (Stream): A data stream containing encoded object data,
supporting a read metho... |
Write the data encoding the RevokeRequestPayload object to a stream. Args: ostream ( Stream ): A data stream in which to encode object data supporting a write method ; usually a BytearrayStream object. kmip_version ( KMIPVersion ): An enumeration defining the KMIP version with which the object will be encoded. Optional... | def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the data encoding the RevokeRequestPayload object to a stream.
Args:
ostream (Stream): A data stream in which to encode object data,
supporting a write method; usually a BytearrayStream objec... |
Error check the attributes of the ActivateRequestPayload object. | def validate(self):
"""
Error check the attributes of the ActivateRequestPayload object.
"""
if self.unique_identifier is not None:
if not isinstance(self.unique_identifier,
attributes.UniqueIdentifier):
msg = "invalid unique iden... |
Read the data encoding the RevokeResponsePayload object and decode it into its constituent parts. Args: istream ( Stream ): A data stream containing encoded object data supporting a read method ; usually a BytearrayStream object. kmip_version ( KMIPVersion ): An enumeration defining the KMIP version with which the obje... | def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the RevokeResponsePayload object and decode it
into its constituent parts.
Args:
istream (Stream): A data stream containing encoded object data,
supporting a read meth... |
Create a secret object of the specified type with the given value. | def create(self, secret_type, value=None):
"""
Create a secret object of the specified type with the given value.
Args:
secret_type (ObjectType): An ObjectType enumeration specifying the
type of secret to create.
value (dict): A dictionary containing secr... |
Set a specific setting value. | def set_setting(self, setting, value):
"""
Set a specific setting value.
This will overwrite the current setting value for the specified
setting.
Args:
setting (string): The name of the setting to set (e.g.,
'certificate_path', 'hostname'). Required.... |
Load configuration settings from the file pointed to by path. | def load_settings(self, path):
"""
Load configuration settings from the file pointed to by path.
This will overwrite all current setting values.
Args:
path (string): The path to the configuration file containing
the settings to load. Required.
Raises... |
Returns the integer value of the usage mask bitmask. This value is stored in the database. | def process_bind_param(self, value, dialect):
"""
Returns the integer value of the usage mask bitmask. This value is
stored in the database.
Args:
value(list<enums.CryptographicUsageMask>): list of enums in the
usage mask
dialect(string): SQL dialect
... |
Returns a new list of enums. CryptographicUsageMask Enums. This converts the integer value into the list of enums. | def process_result_value(self, value, dialect):
"""
Returns a new list of enums.CryptographicUsageMask Enums. This converts
the integer value into the list of enums.
Args:
value(int): The integer value stored in the database that is used
to create the list of... |
Read the encoding of the LongInteger from the input stream. | def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the encoding of the LongInteger from the input stream.
Args:
istream (stream): A buffer containing the encoded bytes of a
LongInteger. Usually a BytearrayStream object. Required.
k... |
Write the encoding of the LongInteger to the output stream. | def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the encoding of the LongInteger to the output stream.
Args:
ostream (stream): A buffer to contain the encoded bytes of a
LongInteger. Usually a BytearrayStream object. Required.
... |
Verify that the value of the LongInteger is valid. | def validate(self):
"""
Verify that the value of the LongInteger is valid.
Raises:
TypeError: if the value is not of type int or long
ValueError: if the value cannot be represented by a signed 64-bit
integer
"""
if self.value is not None:
... |
Read the encoding of the BigInteger from the input stream. | def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the encoding of the BigInteger from the input stream.
Args:
istream (stream): A buffer containing the encoded bytes of the
value of a BigInteger. Usually a BytearrayStream object.
... |
Write the encoding of the BigInteger to the output stream. | def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the encoding of the BigInteger to the output stream.
Args:
ostream (Stream): A buffer to contain the encoded bytes of a
BigInteger object. Usually a BytearrayStream object.
R... |
Verify that the value of the BigInteger is valid. | def validate(self):
"""
Verify that the value of the BigInteger is valid.
Raises:
TypeError: if the value is not of type int or long
"""
if self.value is not None:
if not isinstance(self.value, six.integer_types):
raise TypeError('expected... |
Verify that the value of the Enumeration is valid. | def validate(self):
"""
Verify that the value of the Enumeration is valid.
Raises:
TypeError: if the enum is not of type Enum
ValueError: if the value is not of the expected Enum subtype or if
the value cannot be represented by an unsigned 32-bit integer
... |
Read the value of the Boolean object from the input stream. | def read_value(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the value of the Boolean object from the input stream.
Args:
istream (Stream): A buffer containing the encoded bytes of the
value of a Boolean object. Usually a BytearrayStream object.
... |
Write the value of the Boolean object to the output stream. | def write_value(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the value of the Boolean object to the output stream.
Args:
ostream (Stream): A buffer to contain the encoded bytes of the
value of a Boolean object. Usually a BytearrayStream object.
... |
Write the encoding of the Boolean object to the output stream. | def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the encoding of the Boolean object to the output stream.
Args:
ostream (Stream): A buffer to contain the encoded bytes of a
Boolean object. Usually a BytearrayStream object. Required.
... |
Verify that the value of the Boolean object is valid. | def validate(self):
"""
Verify that the value of the Boolean object is valid.
Raises:
TypeError: if the value is not of type bool.
"""
if self.value:
if not isinstance(self.value, bool):
raise TypeError("expected: {0}, observed: {1}".forma... |
Read the encoding of the Interval from the input stream. | def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the encoding of the Interval from the input stream.
Args:
istream (stream): A buffer containing the encoded bytes of the
value of an Interval. Usually a BytearrayStream object.
... |
Verify that the value of the Interval is valid. | def validate(self):
"""
Verify that the value of the Interval is valid.
Raises:
TypeError: if the value is not of type int or long
ValueError: if the value cannot be represented by an unsigned
32-bit integer
"""
if self.value is not None:
... |
Retrieve all of the relevant key wrapping data fields and return them as a dictionary. | def key_wrapping_data(self):
"""
Retrieve all of the relevant key wrapping data fields and return them
as a dictionary.
"""
key_wrapping_data = {}
encryption_key_info = {
'unique_identifier': self._kdw_eki_unique_identifier,
'cryptographic_paramete... |
Set the key wrapping data attributes using a dictionary. | def key_wrapping_data(self, value):
"""
Set the key wrapping data attributes using a dictionary.
"""
if value is None:
value = {}
elif not isinstance(value, dict):
raise TypeError("Key wrapping data must be a dictionary.")
self._kdw_wrapping_metho... |
Verify that the contents of the PublicKey object are valid. | def validate(self):
"""
Verify that the contents of the PublicKey object are valid.
Raises:
TypeError: if the types of any PublicKey attributes are invalid.
"""
if not isinstance(self.value, bytes):
raise TypeError("key value must be bytes")
elif ... |
Verify that the contents of the SecretData object are valid. | def validate(self):
"""
Verify that the contents of the SecretData object are valid.
Raises:
TypeError: if the types of any SecretData attributes are invalid.
"""
if not isinstance(self.value, bytes):
raise TypeError("secret value must be bytes")
... |
Verify that the contents of the OpaqueObject are valid. | def validate(self):
"""
Verify that the contents of the OpaqueObject are valid.
Raises:
TypeError: if the types of any OpaqueObject attributes are invalid.
"""
if not isinstance(self.value, bytes):
raise TypeError("opaque value must be bytes")
eli... |
A utility function that converts an attribute name string into the corresponding attribute tag. | def convert_attribute_name_to_tag(value):
"""
A utility function that converts an attribute name string into the
corresponding attribute tag.
For example: 'State' -> enums.Tags.STATE
Args:
value (string): The string name of the attribute.
Returns:
enum: The Tags enumeration va... |
A utility function that converts an attribute tag into the corresponding attribute name string. | def convert_attribute_tag_to_name(value):
"""
A utility function that converts an attribute tag into the corresponding
attribute name string.
For example: enums.Tags.STATE -> 'State'
Args:
value (enum): The Tags enumeration value of the attribute.
Returns:
string: The attribut... |
A utility function that computes a bit mask from a collection of enumeration values. | def get_bit_mask_from_enumerations(enumerations):
"""
A utility function that computes a bit mask from a collection of
enumeration values.
Args:
enumerations (list): A list of enumeration values to be combined in a
composite bit mask.
Returns:
int: The composite bit mas... |
A utility function that creates a list of enumeration values from a bit mask for a specific mask enumeration class. | def get_enumerations_from_bit_mask(enumeration, mask):
"""
A utility function that creates a list of enumeration values from a bit
mask for a specific mask enumeration class.
Args:
enumeration (class): The enumeration class from which to draw
enumeration values.
mask (int): ... |
A utility function that checks if the provided value is a composite bit mask of enumeration values in the specified enumeration class. | def is_bit_mask(enumeration, potential_mask):
"""
A utility function that checks if the provided value is a composite bit
mask of enumeration values in the specified enumeration class.
Args:
enumeration (class): One of the mask enumeration classes found in this
file. These include:
... |
A utility function that checks if the tag is a valid attribute tag. | def is_attribute(tag, kmip_version=None):
"""
A utility function that checks if the tag is a valid attribute tag.
Args:
tag (enum): A Tags enumeration that may or may not correspond to a
KMIP attribute type.
kmip_version (enum): The KMIPVersion enumeration that should be used
... |
Read the data encoding the CreateKeyPair request payload and decode it into its constituent parts. | def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the CreateKeyPair request payload and decode it
into its constituent parts.
Args:
input_buffer (stream): A data buffer containing encoded object
data, supporting... |
Write the data encoding the CreateKeyPair request payload to a buffer. | def write(self, output_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the data encoding the CreateKeyPair request payload to a buffer.
Args:
output_buffer (stream): A data buffer in which to encode object
data, supporting a write method.
kmip... |
Read the data encoding the CreateKeyPair response payload and decode it into its constituent parts. | def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the CreateKeyPair response payload and decode it
into its constituent parts.
Args:
input_buffer (stream): A data buffer containing encoded object
data, supportin... |
Write the data encoding the CreateKeyPair response payload to a buffer. | def write(self, output_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the data encoding the CreateKeyPair response payload to a buffer.
Args:
output_buffer (stream): A data buffer in which to encode object
data, supporting a write method.
kmi... |
Read the data encoding the GetAttributeList request payload and decode it into its constituent parts. | def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the GetAttributeList request payload and decode
it into its constituent parts.
Args:
input_buffer (stream): A data stream containing encoded object
data, support... |
Write the data encoding the GetAttributeList request payload to a stream. | def write(self, output_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the data encoding the GetAttributeList request payload to a
stream.
Args:
output_buffer (stream): A data stream in which to encode object
data, supporting a write method; usual... |
Read the data encoding the GetAttributeList response payload and decode it into its constituent parts. | def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the GetAttributeList response payload and
decode it into its constituent parts.
Args:
input_buffer (stream): A data stream containing encoded object
data, suppor... |
Write the data encoding the GetAttributeList response payload to a stream. | def write(self, output_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the data encoding the GetAttributeList response payload to a
stream.
Args:
output_buffer (stream): A data stream in which to encode object
data, supporting a write method; usua... |
Scan the provided policy directory for all JSON policy files. | def get_json_files(p):
"""
Scan the provided policy directory for all JSON policy files.
"""
f = [os.path.join(p, x) for x in os.listdir(p) if x.endswith(".json")]
return sorted(f) |
Scan the policy directory for policy data. | def scan_policies(self):
"""
Scan the policy directory for policy data.
"""
policy_files = get_json_files(self.policy_directory)
for f in set(policy_files) - set(self.policy_files):
self.file_timestamps[f] = 0
for f in set(self.policy_files) - set(policy_files... |
Start monitoring operation policy files. | def run(self):
"""
Start monitoring operation policy files.
"""
self.initialize_tracking_structures()
if self.live_monitoring:
self.logger.info("Starting up the operation policy file monitor.")
while not self.halt_trigger.is_set():
time.sl... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.