partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
_Reader.process_data
Extract the tabulated data from the input file. Parameters ---------- stream : Streamlike object A Streamlike object (nominally StringIO) containing the table to be extracted metadata : dict Metadata read in from the header and the namelist R...
pymagicc/io.py
def process_data(self, stream, metadata): """ Extract the tabulated data from the input file. Parameters ---------- stream : Streamlike object A Streamlike object (nominally StringIO) containing the table to be extracted metadata : dict ...
def process_data(self, stream, metadata): """ Extract the tabulated data from the input file. Parameters ---------- stream : Streamlike object A Streamlike object (nominally StringIO) containing the table to be extracted metadata : dict ...
[ "Extract", "the", "tabulated", "data", "from", "the", "input", "file", "." ]
openclimatedata/pymagicc
python
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/io.py#L200-L222
[ "def", "process_data", "(", "self", ",", "stream", ",", "metadata", ")", ":", "ch", ",", "metadata", "=", "self", ".", "_get_column_headers_and_update_metadata", "(", "stream", ",", "metadata", ")", "df", "=", "self", ".", "_convert_data_block_and_headers_to_df", ...
d896014832cf458d1e95e5878fd6d5961f3e2e05
train
_Reader._convert_data_block_and_headers_to_df
stream : Streamlike object A Streamlike object (nominally StringIO) containing the data to be extracted ch : dict Column headers to use for the output pd.DataFrame Returns ------- :obj:`pd.DataFrame` Dataframe with processed datablock
pymagicc/io.py
def _convert_data_block_and_headers_to_df(self, stream): """ stream : Streamlike object A Streamlike object (nominally StringIO) containing the data to be extracted ch : dict Column headers to use for the output pd.DataFrame Returns ------- ...
def _convert_data_block_and_headers_to_df(self, stream): """ stream : Streamlike object A Streamlike object (nominally StringIO) containing the data to be extracted ch : dict Column headers to use for the output pd.DataFrame Returns ------- ...
[ "stream", ":", "Streamlike", "object", "A", "Streamlike", "object", "(", "nominally", "StringIO", ")", "containing", "the", "data", "to", "be", "extracted" ]
openclimatedata/pymagicc
python
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/io.py#L224-L252
[ "def", "_convert_data_block_and_headers_to_df", "(", "self", ",", "stream", ")", ":", "df", "=", "pd", ".", "read_csv", "(", "stream", ",", "skip_blank_lines", "=", "True", ",", "delim_whitespace", "=", "True", ",", "header", "=", "None", ",", "index_col", "...
d896014832cf458d1e95e5878fd6d5961f3e2e05
train
_Reader._get_variable_from_filepath
Determine the file variable from the filepath. Returns ------- str Best guess of variable name from the filepath
pymagicc/io.py
def _get_variable_from_filepath(self): """ Determine the file variable from the filepath. Returns ------- str Best guess of variable name from the filepath """ try: return self.regexp_capture_variable.search(self.filepath).group(1) ...
def _get_variable_from_filepath(self): """ Determine the file variable from the filepath. Returns ------- str Best guess of variable name from the filepath """ try: return self.regexp_capture_variable.search(self.filepath).group(1) ...
[ "Determine", "the", "file", "variable", "from", "the", "filepath", "." ]
openclimatedata/pymagicc
python
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/io.py#L359-L371
[ "def", "_get_variable_from_filepath", "(", "self", ")", ":", "try", ":", "return", "self", ".", "regexp_capture_variable", ".", "search", "(", "self", ".", "filepath", ")", ".", "group", "(", "1", ")", "except", "AttributeError", ":", "self", ".", "_raise_ca...
d896014832cf458d1e95e5878fd6d5961f3e2e05
train
_Reader.process_header
Parse the header for additional metadata. Parameters ---------- header : str All the lines in the header. Returns ------- dict The metadata in the header.
pymagicc/io.py
def process_header(self, header): """ Parse the header for additional metadata. Parameters ---------- header : str All the lines in the header. Returns ------- dict The metadata in the header. """ metadata = {} ...
def process_header(self, header): """ Parse the header for additional metadata. Parameters ---------- header : str All the lines in the header. Returns ------- dict The metadata in the header. """ metadata = {} ...
[ "Parse", "the", "header", "for", "additional", "metadata", "." ]
openclimatedata/pymagicc
python
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/io.py#L383-L405
[ "def", "process_header", "(", "self", ",", "header", ")", ":", "metadata", "=", "{", "}", "for", "line", "in", "header", ".", "split", "(", "\"\\n\"", ")", ":", "line", "=", "line", ".", "strip", "(", ")", "for", "tag", "in", "self", ".", "header_t...
d896014832cf458d1e95e5878fd6d5961f3e2e05
train
_Reader._read_data_header_line
Read a data header line, ensuring that it starts with the expected header Parameters ---------- stream : :obj:`StreamIO` Stream object containing the text to read expected_header : str, list of strs Expected header of the data header line
pymagicc/io.py
def _read_data_header_line(self, stream, expected_header): """Read a data header line, ensuring that it starts with the expected header Parameters ---------- stream : :obj:`StreamIO` Stream object containing the text to read expected_header : str, list of strs ...
def _read_data_header_line(self, stream, expected_header): """Read a data header line, ensuring that it starts with the expected header Parameters ---------- stream : :obj:`StreamIO` Stream object containing the text to read expected_header : str, list of strs ...
[ "Read", "a", "data", "header", "line", "ensuring", "that", "it", "starts", "with", "the", "expected", "header" ]
openclimatedata/pymagicc
python
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/io.py#L407-L434
[ "def", "_read_data_header_line", "(", "self", ",", "stream", ",", "expected_header", ")", ":", "pos", "=", "stream", ".", "tell", "(", ")", "expected_header", "=", "(", "[", "expected_header", "]", "if", "isinstance", "(", "expected_header", ",", "str", ")",...
d896014832cf458d1e95e5878fd6d5961f3e2e05
train
_BinData.read_chunk
Read out the next chunk of memory Values in fortran binary streams begin and end with the number of bytes :param t: Data type (same format as used by struct). :return: Numpy array if the variable is an array, otherwise a scalar.
pymagicc/io.py
def read_chunk(self, t): """ Read out the next chunk of memory Values in fortran binary streams begin and end with the number of bytes :param t: Data type (same format as used by struct). :return: Numpy array if the variable is an array, otherwise a scalar. """ s...
def read_chunk(self, t): """ Read out the next chunk of memory Values in fortran binary streams begin and end with the number of bytes :param t: Data type (same format as used by struct). :return: Numpy array if the variable is an array, otherwise a scalar. """ s...
[ "Read", "out", "the", "next", "chunk", "of", "memory" ]
openclimatedata/pymagicc
python
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/io.py#L1017-L1039
[ "def", "read_chunk", "(", "self", ",", "t", ")", ":", "size", "=", "self", ".", "data", "[", "self", ".", "pos", ":", "self", ".", "pos", "+", "4", "]", ".", "cast", "(", "\"i\"", ")", "[", "0", "]", "d", "=", "self", ".", "data", "[", "sel...
d896014832cf458d1e95e5878fd6d5961f3e2e05
train
_BinaryOutReader.process_data
Extract the tabulated data from the input file # Arguments stream (Streamlike object): A Streamlike object (nominally StringIO) containing the table to be extracted metadata (dict): metadata read in from the header and the namelist # Returns df (pandas.DataFrame): c...
pymagicc/io.py
def process_data(self, stream, metadata): """ Extract the tabulated data from the input file # Arguments stream (Streamlike object): A Streamlike object (nominally StringIO) containing the table to be extracted metadata (dict): metadata read in from the header and th...
def process_data(self, stream, metadata): """ Extract the tabulated data from the input file # Arguments stream (Streamlike object): A Streamlike object (nominally StringIO) containing the table to be extracted metadata (dict): metadata read in from the header and th...
[ "Extract", "the", "tabulated", "data", "from", "the", "input", "file" ]
openclimatedata/pymagicc
python
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/io.py#L1055-L1108
[ "def", "process_data", "(", "self", ",", "stream", ",", "metadata", ")", ":", "index", "=", "np", ".", "arange", "(", "metadata", "[", "\"firstyear\"", "]", ",", "metadata", "[", "\"lastyear\"", "]", "+", "1", ")", "# The first variable is the global values", ...
d896014832cf458d1e95e5878fd6d5961f3e2e05
train
_BinaryOutReader.process_header
Reads the first part of the file to get some essential metadata # Returns return (dict): the metadata in the header
pymagicc/io.py
def process_header(self, data): """ Reads the first part of the file to get some essential metadata # Returns return (dict): the metadata in the header """ metadata = { "datacolumns": data.read_chunk("I"), "firstyear": data.read_chunk("I"), ...
def process_header(self, data): """ Reads the first part of the file to get some essential metadata # Returns return (dict): the metadata in the header """ metadata = { "datacolumns": data.read_chunk("I"), "firstyear": data.read_chunk("I"), ...
[ "Reads", "the", "first", "part", "of", "the", "file", "to", "get", "some", "essential", "metadata" ]
openclimatedata/pymagicc
python
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/io.py#L1110-L1128
[ "def", "process_header", "(", "self", ",", "data", ")", ":", "metadata", "=", "{", "\"datacolumns\"", ":", "data", ".", "read_chunk", "(", "\"I\"", ")", ",", "\"firstyear\"", ":", "data", ".", "read_chunk", "(", "\"I\"", ")", ",", "\"lastyear\"", ":", "d...
d896014832cf458d1e95e5878fd6d5961f3e2e05
train
_Writer.write
Write a MAGICC input file from df and metadata Parameters ---------- magicc_input : :obj:`pymagicc.io.MAGICCData` MAGICCData object which holds the data to write filepath : str Filepath of the file to write to.
pymagicc/io.py
def write(self, magicc_input, filepath): """ Write a MAGICC input file from df and metadata Parameters ---------- magicc_input : :obj:`pymagicc.io.MAGICCData` MAGICCData object which holds the data to write filepath : str Filepath of the file to ...
def write(self, magicc_input, filepath): """ Write a MAGICC input file from df and metadata Parameters ---------- magicc_input : :obj:`pymagicc.io.MAGICCData` MAGICCData object which holds the data to write filepath : str Filepath of the file to ...
[ "Write", "a", "MAGICC", "input", "file", "from", "df", "and", "metadata" ]
openclimatedata/pymagicc
python
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/io.py#L1240-L1267
[ "def", "write", "(", "self", ",", "magicc_input", ",", "filepath", ")", ":", "self", ".", "_filepath", "=", "filepath", "# TODO: make copy attribute for MAGICCData", "self", ".", "minput", "=", "deepcopy", "(", "magicc_input", ")", "self", ".", "data_block", "="...
d896014832cf458d1e95e5878fd6d5961f3e2e05
train
MAGICCData.append
Append any input which can be converted to MAGICCData to self. Parameters ---------- other : MAGICCData, pd.DataFrame, pd.Series, str Source of data to append. inplace : bool If True, append ``other`` inplace, otherwise return a new ``MAGICCData`` in...
pymagicc/io.py
def append(self, other, inplace=False, **kwargs): """ Append any input which can be converted to MAGICCData to self. Parameters ---------- other : MAGICCData, pd.DataFrame, pd.Series, str Source of data to append. inplace : bool If True, append `...
def append(self, other, inplace=False, **kwargs): """ Append any input which can be converted to MAGICCData to self. Parameters ---------- other : MAGICCData, pd.DataFrame, pd.Series, str Source of data to append. inplace : bool If True, append `...
[ "Append", "any", "input", "which", "can", "be", "converted", "to", "MAGICCData", "to", "self", "." ]
openclimatedata/pymagicc
python
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/io.py#L1973-L2001
[ "def", "append", "(", "self", ",", "other", ",", "inplace", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "other", ",", "MAGICCData", ")", ":", "other", "=", "MAGICCData", "(", "other", ",", "*", "*", "kwargs", ")...
d896014832cf458d1e95e5878fd6d5961f3e2e05
train
MAGICCData.write
Write an input file to disk. Parameters ---------- filepath : str Filepath of the file to write. magicc_version : int The MAGICC version for which we want to write files. MAGICC7 and MAGICC6 namelists are incompatible hence we need to know which one ...
pymagicc/io.py
def write(self, filepath, magicc_version): """ Write an input file to disk. Parameters ---------- filepath : str Filepath of the file to write. magicc_version : int The MAGICC version for which we want to write files. MAGICC7 and MAGICC6 ...
def write(self, filepath, magicc_version): """ Write an input file to disk. Parameters ---------- filepath : str Filepath of the file to write. magicc_version : int The MAGICC version for which we want to write files. MAGICC7 and MAGICC6 ...
[ "Write", "an", "input", "file", "to", "disk", "." ]
openclimatedata/pymagicc
python
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/io.py#L2003-L2018
[ "def", "write", "(", "self", ",", "filepath", ",", "magicc_version", ")", ":", "writer", "=", "determine_tool", "(", "filepath", ",", "\"writer\"", ")", "(", "magicc_version", "=", "magicc_version", ")", "writer", ".", "write", "(", "self", ",", "filepath", ...
d896014832cf458d1e95e5878fd6d5961f3e2e05
train
validate_python_identifier_attributes
Validates a set of attributes as identifiers in a spec
blurr/core/validator.py
def validate_python_identifier_attributes(fully_qualified_name: str, spec: Dict[str, Any], *attributes: str) -> List[InvalidIdentifierError]: """ Validates a set of attributes as identifiers in a spec """ errors: List[InvalidIdentifierError] = [] checks: List[Tuple...
def validate_python_identifier_attributes(fully_qualified_name: str, spec: Dict[str, Any], *attributes: str) -> List[InvalidIdentifierError]: """ Validates a set of attributes as identifiers in a spec """ errors: List[InvalidIdentifierError] = [] checks: List[Tuple...
[ "Validates", "a", "set", "of", "attributes", "as", "identifiers", "in", "a", "spec" ]
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/validator.py#L11-L32
[ "def", "validate_python_identifier_attributes", "(", "fully_qualified_name", ":", "str", ",", "spec", ":", "Dict", "[", "str", ",", "Any", "]", ",", "*", "attributes", ":", "str", ")", "->", "List", "[", "InvalidIdentifierError", "]", ":", "errors", ":", "Li...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
validate_required_attributes
Validates to ensure that a set of attributes are present in spec
blurr/core/validator.py
def validate_required_attributes(fully_qualified_name: str, spec: Dict[str, Any], *attributes: str) -> List[RequiredAttributeError]: """ Validates to ensure that a set of attributes are present in spec """ return [ RequiredAttributeError(fully_qualified_name, spec, attri...
def validate_required_attributes(fully_qualified_name: str, spec: Dict[str, Any], *attributes: str) -> List[RequiredAttributeError]: """ Validates to ensure that a set of attributes are present in spec """ return [ RequiredAttributeError(fully_qualified_name, spec, attri...
[ "Validates", "to", "ensure", "that", "a", "set", "of", "attributes", "are", "present", "in", "spec" ]
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/validator.py#L35-L42
[ "def", "validate_required_attributes", "(", "fully_qualified_name", ":", "str", ",", "spec", ":", "Dict", "[", "str", ",", "Any", "]", ",", "*", "attributes", ":", "str", ")", "->", "List", "[", "RequiredAttributeError", "]", ":", "return", "[", "RequiredAtt...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
validate_empty_attributes
Validates to ensure that a set of attributes do not contain empty values
blurr/core/validator.py
def validate_empty_attributes(fully_qualified_name: str, spec: Dict[str, Any], *attributes: str) -> List[EmptyAttributeError]: """ Validates to ensure that a set of attributes do not contain empty values """ return [ EmptyAttributeError(fully_qualified_name, spec, attribute...
def validate_empty_attributes(fully_qualified_name: str, spec: Dict[str, Any], *attributes: str) -> List[EmptyAttributeError]: """ Validates to ensure that a set of attributes do not contain empty values """ return [ EmptyAttributeError(fully_qualified_name, spec, attribute...
[ "Validates", "to", "ensure", "that", "a", "set", "of", "attributes", "do", "not", "contain", "empty", "values" ]
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/validator.py#L45-L52
[ "def", "validate_empty_attributes", "(", "fully_qualified_name", ":", "str", ",", "spec", ":", "Dict", "[", "str", ",", "Any", "]", ",", "*", "attributes", ":", "str", ")", "->", "List", "[", "EmptyAttributeError", "]", ":", "return", "[", "EmptyAttributeErr...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
validate_number_attribute
Validates to ensure that the value is a number of the specified type, and lies with the specified range
blurr/core/validator.py
def validate_number_attribute( fully_qualified_name: str, spec: Dict[str, Any], attribute: str, value_type: Union[Type[int], Type[float]] = int, minimum: Optional[Union[int, float]] = None, maximum: Optional[Union[int, float]] = None) -> Optional[InvalidNumberError]: ...
def validate_number_attribute( fully_qualified_name: str, spec: Dict[str, Any], attribute: str, value_type: Union[Type[int], Type[float]] = int, minimum: Optional[Union[int, float]] = None, maximum: Optional[Union[int, float]] = None) -> Optional[InvalidNumberError]: ...
[ "Validates", "to", "ensure", "that", "the", "value", "is", "a", "number", "of", "the", "specified", "type", "and", "lies", "with", "the", "specified", "range" ]
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/validator.py#L55-L73
[ "def", "validate_number_attribute", "(", "fully_qualified_name", ":", "str", ",", "spec", ":", "Dict", "[", "str", ",", "Any", "]", ",", "attribute", ":", "str", ",", "value_type", ":", "Union", "[", "Type", "[", "int", "]", ",", "Type", "[", "float", ...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
validate_enum_attribute
Validates to ensure that the value of an attribute lies within an allowed set of candidates
blurr/core/validator.py
def validate_enum_attribute(fully_qualified_name: str, spec: Dict[str, Any], attribute: str, candidates: Set[Union[str, int, float]]) -> Optional[InvalidValueError]: """ Validates to ensure that the value of an attribute lies within an allowed set of candidates """ if attribute not ...
def validate_enum_attribute(fully_qualified_name: str, spec: Dict[str, Any], attribute: str, candidates: Set[Union[str, int, float]]) -> Optional[InvalidValueError]: """ Validates to ensure that the value of an attribute lies within an allowed set of candidates """ if attribute not ...
[ "Validates", "to", "ensure", "that", "the", "value", "of", "an", "attribute", "lies", "within", "an", "allowed", "set", "of", "candidates" ]
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/validator.py#L76-L84
[ "def", "validate_enum_attribute", "(", "fully_qualified_name", ":", "str", ",", "spec", ":", "Dict", "[", "str", ",", "Any", "]", ",", "attribute", ":", "str", ",", "candidates", ":", "Set", "[", "Union", "[", "str", ",", "int", ",", "float", "]", "]",...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
Key.parse
Parses a flat key string and returns a key
blurr/core/store_key.py
def parse(key_string: str) -> 'Key': """ Parses a flat key string and returns a key """ parts = key_string.split(Key.PARTITION) key_type = KeyType.DIMENSION if parts[3]: key_type = KeyType.TIMESTAMP return Key(key_type, parts[0], parts[1], parts[2].split(Key.DIMENSION...
def parse(key_string: str) -> 'Key': """ Parses a flat key string and returns a key """ parts = key_string.split(Key.PARTITION) key_type = KeyType.DIMENSION if parts[3]: key_type = KeyType.TIMESTAMP return Key(key_type, parts[0], parts[1], parts[2].split(Key.DIMENSION...
[ "Parses", "a", "flat", "key", "string", "and", "returns", "a", "key" ]
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/store_key.py#L62-L70
[ "def", "parse", "(", "key_string", ":", "str", ")", "->", "'Key'", ":", "parts", "=", "key_string", ".", "split", "(", "Key", ".", "PARTITION", ")", "key_type", "=", "KeyType", ".", "DIMENSION", "if", "parts", "[", "3", "]", ":", "key_type", "=", "Ke...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
Key.parse_sort_key
Parses a flat key string and returns a key
blurr/core/store_key.py
def parse_sort_key(identity: str, sort_key_string: str) -> 'Key': """ Parses a flat key string and returns a key """ parts = sort_key_string.split(Key.PARTITION) key_type = KeyType.DIMENSION if parts[2]: key_type = KeyType.TIMESTAMP return Key(key_type, identity, part...
def parse_sort_key(identity: str, sort_key_string: str) -> 'Key': """ Parses a flat key string and returns a key """ parts = sort_key_string.split(Key.PARTITION) key_type = KeyType.DIMENSION if parts[2]: key_type = KeyType.TIMESTAMP return Key(key_type, identity, part...
[ "Parses", "a", "flat", "key", "string", "and", "returns", "a", "key" ]
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/store_key.py#L73-L81
[ "def", "parse_sort_key", "(", "identity", ":", "str", ",", "sort_key_string", ":", "str", ")", "->", "'Key'", ":", "parts", "=", "sort_key_string", ".", "split", "(", "Key", ".", "PARTITION", ")", "key_type", "=", "KeyType", ".", "DIMENSION", "if", "parts"...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
Key.starts_with
Checks if this key starts with the other key provided. Returns False if key_type, identity or group are different. For `KeyType.TIMESTAMP` returns True. For `KeyType.DIMENSION` does prefix match between the two dimensions property.
blurr/core/store_key.py
def starts_with(self, other: 'Key') -> bool: """ Checks if this key starts with the other key provided. Returns False if key_type, identity or group are different. For `KeyType.TIMESTAMP` returns True. For `KeyType.DIMENSION` does prefix match between the two dimensions property....
def starts_with(self, other: 'Key') -> bool: """ Checks if this key starts with the other key provided. Returns False if key_type, identity or group are different. For `KeyType.TIMESTAMP` returns True. For `KeyType.DIMENSION` does prefix match between the two dimensions property....
[ "Checks", "if", "this", "key", "starts", "with", "the", "other", "key", "provided", ".", "Returns", "False", "if", "key_type", "identity", "or", "group", "are", "different", ".", "For", "KeyType", ".", "TIMESTAMP", "returns", "True", ".", "For", "KeyType", ...
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/store_key.py#L141-L156
[ "def", "starts_with", "(", "self", ",", "other", ":", "'Key'", ")", "->", "bool", ":", "if", "(", "self", ".", "key_type", ",", "self", ".", "identity", ",", "self", ".", "group", ")", "!=", "(", "other", ".", "key_type", ",", "other", ".", "identi...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
IdentityAggregate._evaluate_dimension_fields
Evaluates the dimension fields. Returns False if any of the fields could not be evaluated.
blurr/core/aggregate_identity.py
def _evaluate_dimension_fields(self) -> bool: """ Evaluates the dimension fields. Returns False if any of the fields could not be evaluated. """ for _, item in self._dimension_fields.items(): item.run_evaluate() if item.eval_error: return False ...
def _evaluate_dimension_fields(self) -> bool: """ Evaluates the dimension fields. Returns False if any of the fields could not be evaluated. """ for _, item in self._dimension_fields.items(): item.run_evaluate() if item.eval_error: return False ...
[ "Evaluates", "the", "dimension", "fields", ".", "Returns", "False", "if", "any", "of", "the", "fields", "could", "not", "be", "evaluated", "." ]
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/aggregate_identity.py#L85-L93
[ "def", "_evaluate_dimension_fields", "(", "self", ")", "->", "bool", ":", "for", "_", ",", "item", "in", "self", ".", "_dimension_fields", ".", "items", "(", ")", ":", "item", ".", "run_evaluate", "(", ")", "if", "item", ".", "eval_error", ":", "return",...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
IdentityAggregate._compare_dimensions_to_fields
Compares the dimension field values to the value in regular fields.
blurr/core/aggregate_identity.py
def _compare_dimensions_to_fields(self) -> bool: """ Compares the dimension field values to the value in regular fields.""" for name, item in self._dimension_fields.items(): if item.value != self._nested_items[name].value: return False return True
def _compare_dimensions_to_fields(self) -> bool: """ Compares the dimension field values to the value in regular fields.""" for name, item in self._dimension_fields.items(): if item.value != self._nested_items[name].value: return False return True
[ "Compares", "the", "dimension", "field", "values", "to", "the", "value", "in", "regular", "fields", "." ]
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/aggregate_identity.py#L95-L100
[ "def", "_compare_dimensions_to_fields", "(", "self", ")", "->", "bool", ":", "for", "name", ",", "item", "in", "self", ".", "_dimension_fields", ".", "items", "(", ")", ":", "if", "item", ".", "value", "!=", "self", ".", "_nested_items", "[", "name", "]"...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
IdentityAggregate._key
Generates the Key object based on dimension fields.
blurr/core/aggregate_identity.py
def _key(self): """ Generates the Key object based on dimension fields. """ return Key(self._schema.key_type, self._identity, self._name, [str(item.value) for item in self._dimension_fields.values()])
def _key(self): """ Generates the Key object based on dimension fields. """ return Key(self._schema.key_type, self._identity, self._name, [str(item.value) for item in self._dimension_fields.values()])
[ "Generates", "the", "Key", "object", "based", "on", "dimension", "fields", "." ]
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/aggregate_identity.py#L103-L106
[ "def", "_key", "(", "self", ")", ":", "return", "Key", "(", "self", ".", "_schema", ".", "key_type", ",", "self", ".", "_identity", ",", "self", ".", "_name", ",", "[", "str", "(", "item", ".", "value", ")", "for", "item", "in", "self", ".", "_di...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
run
Run a MAGICC scenario and return output data and (optionally) config parameters. As a reminder, putting ``out_parameters=1`` will cause MAGICC to write out its parameters into ``out/PARAMETERS.OUT`` and they will then be read into ``output.metadata["parameters"]`` where ``output`` is the returned object. ...
pymagicc/__init__.py
def run(scenario, magicc_version=6, **kwargs): """ Run a MAGICC scenario and return output data and (optionally) config parameters. As a reminder, putting ``out_parameters=1`` will cause MAGICC to write out its parameters into ``out/PARAMETERS.OUT`` and they will then be read into ``output.metadata...
def run(scenario, magicc_version=6, **kwargs): """ Run a MAGICC scenario and return output data and (optionally) config parameters. As a reminder, putting ``out_parameters=1`` will cause MAGICC to write out its parameters into ``out/PARAMETERS.OUT`` and they will then be read into ``output.metadata...
[ "Run", "a", "MAGICC", "scenario", "and", "return", "output", "data", "and", "(", "optionally", ")", "config", "parameters", "." ]
openclimatedata/pymagicc
python
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/__init__.py#L37-L77
[ "def", "run", "(", "scenario", ",", "magicc_version", "=", "6", ",", "*", "*", "kwargs", ")", ":", "if", "magicc_version", "==", "6", ":", "magicc_cls", "=", "MAGICC6", "elif", "magicc_version", "==", "7", ":", "magicc_cls", "=", "MAGICC7", "else", ":", ...
d896014832cf458d1e95e5878fd6d5961f3e2e05
train
WindowTransformer.run_evaluate
Evaluates the anchor condition against the specified block. :param block: Block to run the anchor condition against. :return: True, if the anchor condition is met, otherwise, False.
blurr/core/transformer_window.py
def run_evaluate(self, block: TimeAggregate) -> bool: """ Evaluates the anchor condition against the specified block. :param block: Block to run the anchor condition against. :return: True, if the anchor condition is met, otherwise, False. """ if self._anchor.evaluate_anc...
def run_evaluate(self, block: TimeAggregate) -> bool: """ Evaluates the anchor condition against the specified block. :param block: Block to run the anchor condition against. :return: True, if the anchor condition is met, otherwise, False. """ if self._anchor.evaluate_anc...
[ "Evaluates", "the", "anchor", "condition", "against", "the", "specified", "block", ".", ":", "param", "block", ":", "Block", "to", "run", "the", "anchor", "condition", "against", ".", ":", "return", ":", "True", "if", "the", "anchor", "condition", "is", "m...
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/transformer_window.py#L51-L68
[ "def", "run_evaluate", "(", "self", ",", "block", ":", "TimeAggregate", ")", "->", "bool", ":", "if", "self", ".", "_anchor", ".", "evaluate_anchor", "(", "block", ",", "self", ".", "_evaluation_context", ")", ":", "try", ":", "self", ".", "run_reset", "...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
TimeAggregateSchema.extend_schema_spec
Injects the block start and end times
blurr/core/aggregate_time.py
def extend_schema_spec(self) -> None: """ Injects the block start and end times """ super().extend_schema_spec() if self.ATTRIBUTE_FIELDS in self._spec: # Add new fields to the schema spec. Since `_identity` is added by the super, new elements are added after predefined_...
def extend_schema_spec(self) -> None: """ Injects the block start and end times """ super().extend_schema_spec() if self.ATTRIBUTE_FIELDS in self._spec: # Add new fields to the schema spec. Since `_identity` is added by the super, new elements are added after predefined_...
[ "Injects", "the", "block", "start", "and", "end", "times" ]
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/aggregate_time.py#L12-L23
[ "def", "extend_schema_spec", "(", "self", ")", "->", "None", ":", "super", "(", ")", ".", "extend_schema_spec", "(", ")", "if", "self", ".", "ATTRIBUTE_FIELDS", "in", "self", ".", "_spec", ":", "# Add new fields to the schema spec. Since `_identity` is added by the su...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
TimeAggregateSchema._build_time_fields_spec
Constructs the spec for predefined fields that are to be included in the master spec prior to schema load :param name_in_context: Name of the current object in the context :return:
blurr/core/aggregate_time.py
def _build_time_fields_spec(name_in_context: str) -> List[Dict[str, Any]]: """ Constructs the spec for predefined fields that are to be included in the master spec prior to schema load :param name_in_context: Name of the current object in the context :return: """ return [...
def _build_time_fields_spec(name_in_context: str) -> List[Dict[str, Any]]: """ Constructs the spec for predefined fields that are to be included in the master spec prior to schema load :param name_in_context: Name of the current object in the context :return: """ return [...
[ "Constructs", "the", "spec", "for", "predefined", "fields", "that", "are", "to", "be", "included", "in", "the", "master", "spec", "prior", "to", "schema", "load", ":", "param", "name_in_context", ":", "Name", "of", "the", "current", "object", "in", "the", ...
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/aggregate_time.py#L26-L49
[ "def", "_build_time_fields_spec", "(", "name_in_context", ":", "str", ")", "->", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ":", "return", "[", "{", "'Name'", ":", "'_start_time'", ",", "'Type'", ":", "Type", ".", "DATETIME", ",", "'Value'", ...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
apply_string_substitutions
Apply a number of substitutions to a string(s). The substitutions are applied effectively all at once. This means that conflicting substitutions don't interact. Where substitutions are conflicting, the one which is longer takes precedance. This is confusing so we recommend that you look at the examples...
pymagicc/utils.py
def apply_string_substitutions( inputs, substitutions, inverse=False, case_insensitive=False, unused_substitutions="ignore", ): """Apply a number of substitutions to a string(s). The substitutions are applied effectively all at once. This means that conflicting substitutions don't inter...
def apply_string_substitutions( inputs, substitutions, inverse=False, case_insensitive=False, unused_substitutions="ignore", ): """Apply a number of substitutions to a string(s). The substitutions are applied effectively all at once. This means that conflicting substitutions don't inter...
[ "Apply", "a", "number", "of", "substitutions", "to", "a", "string", "(", "s", ")", "." ]
openclimatedata/pymagicc
python
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/utils.py#L82-L188
[ "def", "apply_string_substitutions", "(", "inputs", ",", "substitutions", ",", "inverse", "=", "False", ",", "case_insensitive", "=", "False", ",", "unused_substitutions", "=", "\"ignore\"", ",", ")", ":", "if", "inverse", ":", "substitutions", "=", "{", "v", ...
d896014832cf458d1e95e5878fd6d5961f3e2e05
train
Store.get_range
Returns the list of items from the store based on the given time range or count. :param base_key: Items which don't start with the base_key are filtered out. :param start_time: Start time to for the range query :param end_time: End time of the range query. If None count is used. :param c...
blurr/core/store.py
def get_range(self, base_key: Key, start_time: datetime, end_time: datetime = None, count: int = 0) -> List[Tuple[Key, Any]]: """ Returns the list of items from the store based on the given time range or count. :param base_k...
def get_range(self, base_key: Key, start_time: datetime, end_time: datetime = None, count: int = 0) -> List[Tuple[Key, Any]]: """ Returns the list of items from the store based on the given time range or count. :param base_k...
[ "Returns", "the", "list", "of", "items", "from", "the", "store", "based", "on", "the", "given", "time", "range", "or", "count", ".", ":", "param", "base_key", ":", "Items", "which", "don", "t", "start", "with", "the", "base_key", "are", "filtered", "out"...
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/store.py#L30-L60
[ "def", "get_range", "(", "self", ",", "base_key", ":", "Key", ",", "start_time", ":", "datetime", ",", "end_time", ":", "datetime", "=", "None", ",", "count", ":", "int", "=", "0", ")", "->", "List", "[", "Tuple", "[", "Key", ",", "Any", "]", "]", ...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
Store._get_range_timestamp_key
Returns the list of items from the store based on the given time range or count. This is used when the key being used is a TIMESTAMP key.
blurr/core/store.py
def _get_range_timestamp_key(self, start: Key, end: Key, count: int = 0) -> List[Tuple[Key, Any]]: """ Returns the list of items from the store based on the given time range or count. This is used when the key being used is a TIMESTAMP key. """ r...
def _get_range_timestamp_key(self, start: Key, end: Key, count: int = 0) -> List[Tuple[Key, Any]]: """ Returns the list of items from the store based on the given time range or count. This is used when the key being used is a TIMESTAMP key. """ r...
[ "Returns", "the", "list", "of", "items", "from", "the", "store", "based", "on", "the", "given", "time", "range", "or", "count", "." ]
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/store.py#L63-L70
[ "def", "_get_range_timestamp_key", "(", "self", ",", "start", ":", "Key", ",", "end", ":", "Key", ",", "count", ":", "int", "=", "0", ")", "->", "List", "[", "Tuple", "[", "Key", ",", "Any", "]", "]", ":", "raise", "NotImplementedError", "(", ")" ]
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
Store._get_range_dimension_key
Returns the list of items from the store based on the given time range or count. This is used when the key being used is a DIMENSION key.
blurr/core/store.py
def _get_range_dimension_key(self, base_key: Key, start_time: datetime, end_time: datetime, count: int = 0) -> List[Tuple[Key, Any]]: """ Returns the list of items from the...
def _get_range_dimension_key(self, base_key: Key, start_time: datetime, end_time: datetime, count: int = 0) -> List[Tuple[Key, Any]]: """ Returns the list of items from the...
[ "Returns", "the", "list", "of", "items", "from", "the", "store", "based", "on", "the", "given", "time", "range", "or", "count", "." ]
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/store.py#L79-L89
[ "def", "_get_range_dimension_key", "(", "self", ",", "base_key", ":", "Key", ",", "start_time", ":", "datetime", ",", "end_time", ":", "datetime", ",", "count", ":", "int", "=", "0", ")", "->", "List", "[", "Tuple", "[", "Key", ",", "Any", "]", "]", ...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
Store._restrict_items_to_count
Restricts items to count number if len(items) is larger than abs(count). This function assumes that items is sorted by time. :param items: The items to restrict. :param count: The number of items returned.
blurr/core/store.py
def _restrict_items_to_count(items: List[Tuple[Key, Any]], count: int) -> List[Tuple[Key, Any]]: """ Restricts items to count number if len(items) is larger than abs(count). This function assumes that items is sorted by time. :param items: The items to restrict. :param count: Th...
def _restrict_items_to_count(items: List[Tuple[Key, Any]], count: int) -> List[Tuple[Key, Any]]: """ Restricts items to count number if len(items) is larger than abs(count). This function assumes that items is sorted by time. :param items: The items to restrict. :param count: Th...
[ "Restricts", "items", "to", "count", "number", "if", "len", "(", "items", ")", "is", "larger", "than", "abs", "(", "count", ")", ".", "This", "function", "assumes", "that", "items", "is", "sorted", "by", "time", "." ]
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/store.py#L92-L106
[ "def", "_restrict_items_to_count", "(", "items", ":", "List", "[", "Tuple", "[", "Key", ",", "Any", "]", "]", ",", "count", ":", "int", ")", "->", "List", "[", "Tuple", "[", "Key", ",", "Any", "]", "]", ":", "if", "abs", "(", "count", ")", ">", ...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
BaseSchema.build_expression
Builds an expression object. Adds an error if expression creation has errors.
blurr/core/base.py
def build_expression(self, attribute: str) -> Optional[Expression]: """ Builds an expression object. Adds an error if expression creation has errors. """ expression_string = self._spec.get(attribute, None) if expression_string: try: return Expression(str(expression_...
def build_expression(self, attribute: str) -> Optional[Expression]: """ Builds an expression object. Adds an error if expression creation has errors. """ expression_string = self._spec.get(attribute, None) if expression_string: try: return Expression(str(expression_...
[ "Builds", "an", "expression", "object", ".", "Adds", "an", "error", "if", "expression", "creation", "has", "errors", "." ]
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/base.py#L41-L52
[ "def", "build_expression", "(", "self", ",", "attribute", ":", "str", ")", "->", "Optional", "[", "Expression", "]", ":", "expression_string", "=", "self", ".", "_spec", ".", "get", "(", "attribute", ",", "None", ")", "if", "expression_string", ":", "try",...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
BaseSchema.add_errors
Adds errors to the error repository in schema loader
blurr/core/base.py
def add_errors(self, *errors: Union[BaseSchemaError, List[BaseSchemaError]]) -> None: """ Adds errors to the error repository in schema loader """ self.schema_loader.add_errors(*errors)
def add_errors(self, *errors: Union[BaseSchemaError, List[BaseSchemaError]]) -> None: """ Adds errors to the error repository in schema loader """ self.schema_loader.add_errors(*errors)
[ "Adds", "errors", "to", "the", "error", "repository", "in", "schema", "loader" ]
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/base.py#L54-L56
[ "def", "add_errors", "(", "self", ",", "*", "errors", ":", "Union", "[", "BaseSchemaError", ",", "List", "[", "BaseSchemaError", "]", "]", ")", "->", "None", ":", "self", ".", "schema_loader", ".", "add_errors", "(", "*", "errors", ")" ]
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
BaseSchema.validate_required_attributes
Validates that the schema contains a series of required attributes
blurr/core/base.py
def validate_required_attributes(self, *attributes: str) -> None: """ Validates that the schema contains a series of required attributes """ self.add_errors( validate_required_attributes(self.fully_qualified_name, self._spec, *attributes))
def validate_required_attributes(self, *attributes: str) -> None: """ Validates that the schema contains a series of required attributes """ self.add_errors( validate_required_attributes(self.fully_qualified_name, self._spec, *attributes))
[ "Validates", "that", "the", "schema", "contains", "a", "series", "of", "required", "attributes" ]
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/base.py#L63-L66
[ "def", "validate_required_attributes", "(", "self", ",", "*", "attributes", ":", "str", ")", "->", "None", ":", "self", ".", "add_errors", "(", "validate_required_attributes", "(", "self", ".", "fully_qualified_name", ",", "self", ".", "_spec", ",", "*", "attr...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
BaseSchema.validate_number_attribute
Validates that the attribute contains a numeric value within boundaries if specified
blurr/core/base.py
def validate_number_attribute(self, attribute: str, value_type: Union[Type[int], Type[float]] = int, minimum: Optional[Union[int, float]] = None, maximum: Optional[Union[int, float]] =...
def validate_number_attribute(self, attribute: str, value_type: Union[Type[int], Type[float]] = int, minimum: Optional[Union[int, float]] = None, maximum: Optional[Union[int, float]] =...
[ "Validates", "that", "the", "attribute", "contains", "a", "numeric", "value", "within", "boundaries", "if", "specified" ]
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/base.py#L68-L76
[ "def", "validate_number_attribute", "(", "self", ",", "attribute", ":", "str", ",", "value_type", ":", "Union", "[", "Type", "[", "int", "]", ",", "Type", "[", "float", "]", "]", "=", "int", ",", "minimum", ":", "Optional", "[", "Union", "[", "int", ...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
BaseSchema.validate_enum_attribute
Validates that the attribute value is among the candidates
blurr/core/base.py
def validate_enum_attribute(self, attribute: str, candidates: Set[Union[str, int, float]]) -> None: """ Validates that the attribute value is among the candidates """ self.add_errors( validate_enum_attribute(self.fully_qualified_name, self._spec, attribute, ca...
def validate_enum_attribute(self, attribute: str, candidates: Set[Union[str, int, float]]) -> None: """ Validates that the attribute value is among the candidates """ self.add_errors( validate_enum_attribute(self.fully_qualified_name, self._spec, attribute, ca...
[ "Validates", "that", "the", "attribute", "value", "is", "among", "the", "candidates" ]
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/base.py#L78-L82
[ "def", "validate_enum_attribute", "(", "self", ",", "attribute", ":", "str", ",", "candidates", ":", "Set", "[", "Union", "[", "str", ",", "int", ",", "float", "]", "]", ")", "->", "None", ":", "self", ".", "add_errors", "(", "validate_enum_attribute", "...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
BaseSchema.validate_schema_spec
Contains the validation routines that are to be executed as part of initialization by subclasses. When this method is being extended, the first line should always be: ```super().validate_schema_spec()```
blurr/core/base.py
def validate_schema_spec(self) -> None: """ Contains the validation routines that are to be executed as part of initialization by subclasses. When this method is being extended, the first line should always be: ```super().validate_schema_spec()``` """ self.add_errors( validate_empty_...
def validate_schema_spec(self) -> None: """ Contains the validation routines that are to be executed as part of initialization by subclasses. When this method is being extended, the first line should always be: ```super().validate_schema_spec()``` """ self.add_errors( validate_empty_...
[ "Contains", "the", "validation", "routines", "that", "are", "to", "be", "executed", "as", "part", "of", "initialization", "by", "subclasses", ".", "When", "this", "method", "is", "being", "extended", "the", "first", "line", "should", "always", "be", ":", "su...
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/base.py#L84-L91
[ "def", "validate_schema_spec", "(", "self", ")", "->", "None", ":", "self", ".", "add_errors", "(", "validate_empty_attributes", "(", "self", ".", "fully_qualified_name", ",", "self", ".", "_spec", ",", "*", "self", ".", "_spec", ".", "keys", "(", ")", ")"...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
BaseItem._needs_evaluation
Returns True when: 1. Where clause is not specified 2. Where WHERE clause is specified and it evaluates to True Returns false if a where clause is specified and it evaluates to False
blurr/core/base.py
def _needs_evaluation(self) -> bool: """ Returns True when: 1. Where clause is not specified 2. Where WHERE clause is specified and it evaluates to True Returns false if a where clause is specified and it evaluates to False """ return self._schema.when is ...
def _needs_evaluation(self) -> bool: """ Returns True when: 1. Where clause is not specified 2. Where WHERE clause is specified and it evaluates to True Returns false if a where clause is specified and it evaluates to False """ return self._schema.when is ...
[ "Returns", "True", "when", ":", "1", ".", "Where", "clause", "is", "not", "specified", "2", ".", "Where", "WHERE", "clause", "is", "specified", "and", "it", "evaluates", "to", "True", "Returns", "false", "if", "a", "where", "clause", "is", "specified", "...
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/base.py#L147-L154
[ "def", "_needs_evaluation", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_schema", ".", "when", "is", "None", "or", "self", ".", "_schema", ".", "when", ".", "evaluate", "(", "self", ".", "_evaluation_context", ")" ]
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
BaseItemCollection.run_evaluate
Evaluates the current item :returns An evaluation result object containing the result, or reasons why evaluation failed
blurr/core/base.py
def run_evaluate(self, *args, **kwargs) -> None: """ Evaluates the current item :returns An evaluation result object containing the result, or reasons why evaluation failed """ if self._needs_evaluation: for _, item in self._nested_items.items(): ...
def run_evaluate(self, *args, **kwargs) -> None: """ Evaluates the current item :returns An evaluation result object containing the result, or reasons why evaluation failed """ if self._needs_evaluation: for _, item in self._nested_items.items(): ...
[ "Evaluates", "the", "current", "item", ":", "returns", "An", "evaluation", "result", "object", "containing", "the", "result", "or", "reasons", "why", "evaluation", "failed" ]
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/base.py#L208-L216
[ "def", "run_evaluate", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "->", "None", ":", "if", "self", ".", "_needs_evaluation", ":", "for", "_", ",", "item", "in", "self", ".", "_nested_items", ".", "items", "(", ")", ":", "item", "....
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
BaseItemCollection._snapshot
Implements snapshot for collections by recursively invoking snapshot of all child items
blurr/core/base.py
def _snapshot(self) -> Dict[str, Any]: """ Implements snapshot for collections by recursively invoking snapshot of all child items """ try: return {name: item._snapshot for name, item in self._nested_items.items()} except Exception as e: raise SnapshotErro...
def _snapshot(self) -> Dict[str, Any]: """ Implements snapshot for collections by recursively invoking snapshot of all child items """ try: return {name: item._snapshot for name, item in self._nested_items.items()} except Exception as e: raise SnapshotErro...
[ "Implements", "snapshot", "for", "collections", "by", "recursively", "invoking", "snapshot", "of", "all", "child", "items" ]
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/base.py#L219-L226
[ "def", "_snapshot", "(", "self", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "try", ":", "return", "{", "name", ":", "item", ".", "_snapshot", "for", "name", ",", "item", "in", "self", ".", "_nested_items", ".", "items", "(", ")", "}", "...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
BaseItemCollection.run_restore
Restores the state of a collection from a snapshot
blurr/core/base.py
def run_restore(self, snapshot: Dict[Union[str, Key], Any]) -> 'BaseItemCollection': """ Restores the state of a collection from a snapshot """ try: for name, snap in snapshot.items(): if isinstance(name, Key): self._nested_items[name.grou...
def run_restore(self, snapshot: Dict[Union[str, Key], Any]) -> 'BaseItemCollection': """ Restores the state of a collection from a snapshot """ try: for name, snap in snapshot.items(): if isinstance(name, Key): self._nested_items[name.grou...
[ "Restores", "the", "state", "of", "a", "collection", "from", "a", "snapshot" ]
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/base.py#L228-L242
[ "def", "run_restore", "(", "self", ",", "snapshot", ":", "Dict", "[", "Union", "[", "str", ",", "Key", "]", ",", "Any", "]", ")", "->", "'BaseItemCollection'", ":", "try", ":", "for", "name", ",", "snap", "in", "snapshot", ".", "items", "(", ")", "...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
WindowAggregate._prepare_window
Prepares window if any is specified. :param start_time: The anchor block start_time from where the window should be generated.
blurr/core/aggregate_window.py
def _prepare_window(self, start_time: datetime) -> None: """ Prepares window if any is specified. :param start_time: The anchor block start_time from where the window should be generated. """ # evaluate window first which sets the correct window in the store store...
def _prepare_window(self, start_time: datetime) -> None: """ Prepares window if any is specified. :param start_time: The anchor block start_time from where the window should be generated. """ # evaluate window first which sets the correct window in the store store...
[ "Prepares", "window", "if", "any", "is", "specified", ".", ":", "param", "start_time", ":", "The", "anchor", "block", "start_time", "from", "where", "the", "window", "should", "be", "generated", "." ]
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/aggregate_window.py#L60-L82
[ "def", "_prepare_window", "(", "self", ",", "start_time", ":", "datetime", ")", "->", "None", ":", "# evaluate window first which sets the correct window in the store", "store", "=", "self", ".", "_schema", ".", "schema_loader", ".", "get_store", "(", "self", ".", "...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
WindowAggregate._get_end_time
Generates the end time to be used for the store range query. :param start_time: Start time to use as an offset to calculate the end time based on the window type in the schema. :return:
blurr/core/aggregate_window.py
def _get_end_time(self, start_time: datetime) -> datetime: """ Generates the end time to be used for the store range query. :param start_time: Start time to use as an offset to calculate the end time based on the window type in the schema. :return: """ if Type.is_...
def _get_end_time(self, start_time: datetime) -> datetime: """ Generates the end time to be used for the store range query. :param start_time: Start time to use as an offset to calculate the end time based on the window type in the schema. :return: """ if Type.is_...
[ "Generates", "the", "end", "time", "to", "be", "used", "for", "the", "store", "range", "query", ".", ":", "param", "start_time", ":", "Start", "time", "to", "use", "as", "an", "offset", "to", "calculate", "the", "end", "time", "based", "on", "the", "wi...
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/aggregate_window.py#L100-L110
[ "def", "_get_end_time", "(", "self", ",", "start_time", ":", "datetime", ")", "->", "datetime", ":", "if", "Type", ".", "is_type_equal", "(", "self", ".", "_schema", ".", "window_type", ",", "Type", ".", "DAY", ")", ":", "return", "start_time", "+", "tim...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
WindowAggregate._load_blocks
Converts [(Key, block)] to [BlockAggregate] :param blocks: List of (Key, block) blocks. :return: List of BlockAggregate
blurr/core/aggregate_window.py
def _load_blocks(self, blocks: List[Tuple[Key, Any]]) -> List[TimeAggregate]: """ Converts [(Key, block)] to [BlockAggregate] :param blocks: List of (Key, block) blocks. :return: List of BlockAggregate """ return [ TypeLoader.load_item(self._schema.source.type...
def _load_blocks(self, blocks: List[Tuple[Key, Any]]) -> List[TimeAggregate]: """ Converts [(Key, block)] to [BlockAggregate] :param blocks: List of (Key, block) blocks. :return: List of BlockAggregate """ return [ TypeLoader.load_item(self._schema.source.type...
[ "Converts", "[", "(", "Key", "block", ")", "]", "to", "[", "BlockAggregate", "]", ":", "param", "blocks", ":", "List", "of", "(", "Key", "block", ")", "blocks", ".", ":", "return", ":", "List", "of", "BlockAggregate" ]
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/aggregate_window.py#L112-L122
[ "def", "_load_blocks", "(", "self", ",", "blocks", ":", "List", "[", "Tuple", "[", "Key", ",", "Any", "]", "]", ")", "->", "List", "[", "TimeAggregate", "]", ":", "return", "[", "TypeLoader", ".", "load_item", "(", "self", ".", "_schema", ".", "sourc...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
Runner.execute_per_identity_records
Executes the streaming and window BTS on the given records. An option old state can provided which initializes the state for execution. This is useful for batch execution where the previous state is written out to storage and can be loaded for the next batch run. :param identity: Identity of th...
blurr/runner/runner.py
def execute_per_identity_records( self, identity: str, records: List[TimeAndRecord], old_state: Optional[Dict[Key, Any]] = None) -> Tuple[str, Tuple[Dict, List]]: """ Executes the streaming and window BTS on the given records. An option old state can provi...
def execute_per_identity_records( self, identity: str, records: List[TimeAndRecord], old_state: Optional[Dict[Key, Any]] = None) -> Tuple[str, Tuple[Dict, List]]: """ Executes the streaming and window BTS on the given records. An option old state can provi...
[ "Executes", "the", "streaming", "and", "window", "BTS", "on", "the", "given", "records", ".", "An", "option", "old", "state", "can", "provided", "which", "initializes", "the", "state", "for", "execution", ".", "This", "is", "useful", "for", "batch", "executi...
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/runner/runner.py#L55-L80
[ "def", "execute_per_identity_records", "(", "self", ",", "identity", ":", "str", ",", "records", ":", "List", "[", "TimeAndRecord", "]", ",", "old_state", ":", "Optional", "[", "Dict", "[", "Key", ",", "Any", "]", "]", "=", "None", ")", "->", "Tuple", ...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
Runner.get_per_identity_records
Uses the given iteratable events and the data processor convert the event into a list of Records along with its identity and time. :param events: iteratable events. :param data_processor: DataProcessor to process each event in events. :return: yields Tuple[Identity, TimeAndRecord] for al...
blurr/runner/runner.py
def get_per_identity_records(self, events: Iterable, data_processor: DataProcessor ) -> Generator[Tuple[str, TimeAndRecord], None, None]: """ Uses the given iteratable events and the data processor convert the event into a list of Records along with its identity ...
def get_per_identity_records(self, events: Iterable, data_processor: DataProcessor ) -> Generator[Tuple[str, TimeAndRecord], None, None]: """ Uses the given iteratable events and the data processor convert the event into a list of Records along with its identity ...
[ "Uses", "the", "given", "iteratable", "events", "and", "the", "data", "processor", "convert", "the", "event", "into", "a", "list", "of", "Records", "along", "with", "its", "identity", "and", "time", ".", ":", "param", "events", ":", "iteratable", "events", ...
productml/blurr
python
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/runner/runner.py#L82-L105
[ "def", "get_per_identity_records", "(", "self", ",", "events", ":", "Iterable", ",", "data_processor", ":", "DataProcessor", ")", "->", "Generator", "[", "Tuple", "[", "str", ",", "TimeAndRecord", "]", ",", "None", ",", "None", "]", ":", "schema_loader", "="...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
train
DNSEntry.to_string
String representation with additional information
mdns/zeroconf.py
def to_string(self, hdr, other): """String representation with additional information""" result = "%s[%s,%s" % ( hdr, self.get_type(self.type), self.get_clazz(self.clazz)) if self.unique: result += "-unique," else: result += "," result += s...
def to_string(self, hdr, other): """String representation with additional information""" result = "%s[%s,%s" % ( hdr, self.get_type(self.type), self.get_clazz(self.clazz)) if self.unique: result += "-unique," else: result += "," result += s...
[ "String", "representation", "with", "additional", "information" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L342-L355
[ "def", "to_string", "(", "self", ",", "hdr", ",", "other", ")", ":", "result", "=", "\"%s[%s,%s\"", "%", "(", "hdr", ",", "self", ".", "get_type", "(", "self", ".", "type", ")", ",", "self", ".", "get_clazz", "(", "self", ".", "clazz", ")", ")", ...
295f6407132616a0ff7401124b9057d89555f91d
train
DNSQuestion.answered_by
Returns true if the question is answered by the record
mdns/zeroconf.py
def answered_by(self, rec): """Returns true if the question is answered by the record""" return self.clazz == rec.clazz and \ (self.type == rec.type or self.type == _TYPE_ANY) and \ self.name == rec.name
def answered_by(self, rec): """Returns true if the question is answered by the record""" return self.clazz == rec.clazz and \ (self.type == rec.type or self.type == _TYPE_ANY) and \ self.name == rec.name
[ "Returns", "true", "if", "the", "question", "is", "answered", "by", "the", "record" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L370-L374
[ "def", "answered_by", "(", "self", ",", "rec", ")", ":", "return", "self", ".", "clazz", "==", "rec", ".", "clazz", "and", "(", "self", ".", "type", "==", "rec", ".", "type", "or", "self", ".", "type", "==", "_TYPE_ANY", ")", "and", "self", ".", ...
295f6407132616a0ff7401124b9057d89555f91d
train
DNSRecord.reset_ttl
Sets this record's TTL and created time to that of another record.
mdns/zeroconf.py
def reset_ttl(self, other): """Sets this record's TTL and created time to that of another record.""" self.created = other.created self.ttl = other.ttl
def reset_ttl(self, other): """Sets this record's TTL and created time to that of another record.""" self.created = other.created self.ttl = other.ttl
[ "Sets", "this", "record", "s", "TTL", "and", "created", "time", "to", "that", "of", "another", "record", "." ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L425-L429
[ "def", "reset_ttl", "(", "self", ",", "other", ")", ":", "self", ".", "created", "=", "other", ".", "created", "self", ".", "ttl", "=", "other", ".", "ttl" ]
295f6407132616a0ff7401124b9057d89555f91d
train
DNSRecord.to_string
String representation with addtional information
mdns/zeroconf.py
def to_string(self, other): """String representation with addtional information""" arg = "%s/%s,%s" % ( self.ttl, self.get_remaining_ttl(current_time_millis()), other) return DNSEntry.to_string(self, "record", arg)
def to_string(self, other): """String representation with addtional information""" arg = "%s/%s,%s" % ( self.ttl, self.get_remaining_ttl(current_time_millis()), other) return DNSEntry.to_string(self, "record", arg)
[ "String", "representation", "with", "addtional", "information" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L435-L439
[ "def", "to_string", "(", "self", ",", "other", ")", ":", "arg", "=", "\"%s/%s,%s\"", "%", "(", "self", ".", "ttl", ",", "self", ".", "get_remaining_ttl", "(", "current_time_millis", "(", ")", ")", ",", "other", ")", "return", "DNSEntry", ".", "to_string"...
295f6407132616a0ff7401124b9057d89555f91d
train
DNSAddress.write
Used in constructing an outgoing packet
mdns/zeroconf.py
def write(self, out): """Used in constructing an outgoing packet""" out.write_string(self.address, len(self.address))
def write(self, out): """Used in constructing an outgoing packet""" out.write_string(self.address, len(self.address))
[ "Used", "in", "constructing", "an", "outgoing", "packet" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L528-L530
[ "def", "write", "(", "self", ",", "out", ")", ":", "out", ".", "write_string", "(", "self", ".", "address", ",", "len", "(", "self", ".", "address", ")", ")" ]
295f6407132616a0ff7401124b9057d89555f91d
train
DNSHinfo.write
Used in constructing an outgoing packet
mdns/zeroconf.py
def write(self, out): """Used in constructing an outgoing packet""" out.write_string(self.cpu, len(self.cpu)) out.write_string(self.os, len(self.os))
def write(self, out): """Used in constructing an outgoing packet""" out.write_string(self.cpu, len(self.cpu)) out.write_string(self.os, len(self.os))
[ "Used", "in", "constructing", "an", "outgoing", "packet" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L568-L571
[ "def", "write", "(", "self", ",", "out", ")", ":", "out", ".", "write_string", "(", "self", ".", "cpu", ",", "len", "(", "self", ".", "cpu", ")", ")", "out", ".", "write_string", "(", "self", ".", "os", ",", "len", "(", "self", ".", "os", ")", ...
295f6407132616a0ff7401124b9057d89555f91d
train
DNSText.write
Used in constructing an outgoing packet
mdns/zeroconf.py
def write(self, out): """Used in constructing an outgoing packet""" out.write_string(self.text, len(self.text))
def write(self, out): """Used in constructing an outgoing packet""" out.write_string(self.text, len(self.text))
[ "Used", "in", "constructing", "an", "outgoing", "packet" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L620-L622
[ "def", "write", "(", "self", ",", "out", ")", ":", "out", ".", "write_string", "(", "self", ".", "text", ",", "len", "(", "self", ".", "text", ")", ")" ]
295f6407132616a0ff7401124b9057d89555f91d
train
DNSText.set_property
Update only one property in the dict
mdns/zeroconf.py
def set_property(self, key, value): """ Update only one property in the dict """ self.properties[key] = value self.sync_properties()
def set_property(self, key, value): """ Update only one property in the dict """ self.properties[key] = value self.sync_properties()
[ "Update", "only", "one", "property", "in", "the", "dict" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L624-L629
[ "def", "set_property", "(", "self", ",", "key", ",", "value", ")", ":", "self", ".", "properties", "[", "key", "]", "=", "value", "self", ".", "sync_properties", "(", ")" ]
295f6407132616a0ff7401124b9057d89555f91d
train
DNSService.write
Used in constructing an outgoing packet
mdns/zeroconf.py
def write(self, out): """Used in constructing an outgoing packet""" out.write_short(self.priority) out.write_short(self.weight) out.write_short(self.port) out.write_name(self.server)
def write(self, out): """Used in constructing an outgoing packet""" out.write_short(self.priority) out.write_short(self.weight) out.write_short(self.port) out.write_name(self.server)
[ "Used", "in", "constructing", "an", "outgoing", "packet" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L666-L671
[ "def", "write", "(", "self", ",", "out", ")", ":", "out", ".", "write_short", "(", "self", ".", "priority", ")", "out", ".", "write_short", "(", "self", ".", "weight", ")", "out", ".", "write_short", "(", "self", ".", "port", ")", "out", ".", "writ...
295f6407132616a0ff7401124b9057d89555f91d
train
DNSIncoming.read_header
Reads header portion of packet
mdns/zeroconf.py
def read_header(self): """Reads header portion of packet""" format = '!HHHHHH' length = struct.calcsize(format) info = struct.unpack(format, self.data[self.offset:self.offset + length]) self.offset += length self.id = info[0] self.flags = info[1] ...
def read_header(self): """Reads header portion of packet""" format = '!HHHHHH' length = struct.calcsize(format) info = struct.unpack(format, self.data[self.offset:self.offset + length]) self.offset += length self.id = info[0] self.flags = info[1] ...
[ "Reads", "header", "portion", "of", "packet" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L708-L721
[ "def", "read_header", "(", "self", ")", ":", "format", "=", "'!HHHHHH'", "length", "=", "struct", ".", "calcsize", "(", "format", ")", "info", "=", "struct", ".", "unpack", "(", "format", ",", "self", ".", "data", "[", "self", ".", "offset", ":", "se...
295f6407132616a0ff7401124b9057d89555f91d
train
DNSIncoming.read_questions
Reads questions section of packet
mdns/zeroconf.py
def read_questions(self): """Reads questions section of packet""" format = '!HH' length = struct.calcsize(format) for i in range(0, self.num_questions): name = self.read_name() info = struct.unpack(format, self.data[self.offset:self.offset + le...
def read_questions(self): """Reads questions section of packet""" format = '!HH' length = struct.calcsize(format) for i in range(0, self.num_questions): name = self.read_name() info = struct.unpack(format, self.data[self.offset:self.offset + le...
[ "Reads", "questions", "section", "of", "packet" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L723-L734
[ "def", "read_questions", "(", "self", ")", ":", "format", "=", "'!HH'", "length", "=", "struct", ".", "calcsize", "(", "format", ")", "for", "i", "in", "range", "(", "0", ",", "self", ".", "num_questions", ")", ":", "name", "=", "self", ".", "read_na...
295f6407132616a0ff7401124b9057d89555f91d
train
DNSIncoming.read_int
Reads an integer from the packet
mdns/zeroconf.py
def read_int(self): """Reads an integer from the packet""" format = '!I' length = struct.calcsize(format) info = struct.unpack(format, self.data[self.offset:self.offset + length]) self.offset += length return info[0]
def read_int(self): """Reads an integer from the packet""" format = '!I' length = struct.calcsize(format) info = struct.unpack(format, self.data[self.offset:self.offset + length]) self.offset += length return info[0]
[ "Reads", "an", "integer", "from", "the", "packet" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L736-L743
[ "def", "read_int", "(", "self", ")", ":", "format", "=", "'!I'", "length", "=", "struct", ".", "calcsize", "(", "format", ")", "info", "=", "struct", ".", "unpack", "(", "format", ",", "self", ".", "data", "[", "self", ".", "offset", ":", "self", "...
295f6407132616a0ff7401124b9057d89555f91d
train
DNSIncoming.read_character_string
Reads a character string from the packet
mdns/zeroconf.py
def read_character_string(self): """Reads a character string from the packet""" length = ord(self.data[self.offset]) self.offset += 1 return self.read_string(length)
def read_character_string(self): """Reads a character string from the packet""" length = ord(self.data[self.offset]) self.offset += 1 return self.read_string(length)
[ "Reads", "a", "character", "string", "from", "the", "packet" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L745-L749
[ "def", "read_character_string", "(", "self", ")", ":", "length", "=", "ord", "(", "self", ".", "data", "[", "self", ".", "offset", "]", ")", "self", ".", "offset", "+=", "1", "return", "self", ".", "read_string", "(", "length", ")" ]
295f6407132616a0ff7401124b9057d89555f91d
train
DNSIncoming.read_string
Reads a string of a given length from the packet
mdns/zeroconf.py
def read_string(self, len): """Reads a string of a given length from the packet""" format = '!' + str(len) + 's' length = struct.calcsize(format) info = struct.unpack(format, self.data[self.offset:self.offset + length]) self.offset += length return info[0]
def read_string(self, len): """Reads a string of a given length from the packet""" format = '!' + str(len) + 's' length = struct.calcsize(format) info = struct.unpack(format, self.data[self.offset:self.offset + length]) self.offset += length return info[0]
[ "Reads", "a", "string", "of", "a", "given", "length", "from", "the", "packet" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L751-L758
[ "def", "read_string", "(", "self", ",", "len", ")", ":", "format", "=", "'!'", "+", "str", "(", "len", ")", "+", "'s'", "length", "=", "struct", ".", "calcsize", "(", "format", ")", "info", "=", "struct", ".", "unpack", "(", "format", ",", "self", ...
295f6407132616a0ff7401124b9057d89555f91d
train
DNSIncoming.read_others
Reads the answers, authorities and additionals section of the packet
mdns/zeroconf.py
def read_others(self): """Reads the answers, authorities and additionals section of the packet""" format = '!HHiH' length = struct.calcsize(format) n = self.num_answers + self.num_authorities + self.num_additionals for i in range(0, n): domain = self.read_name...
def read_others(self): """Reads the answers, authorities and additionals section of the packet""" format = '!HHiH' length = struct.calcsize(format) n = self.num_answers + self.num_authorities + self.num_additionals for i in range(0, n): domain = self.read_name...
[ "Reads", "the", "answers", "authorities", "and", "additionals", "section", "of", "the", "packet" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L769-L828
[ "def", "read_others", "(", "self", ")", ":", "format", "=", "'!HHiH'", "length", "=", "struct", ".", "calcsize", "(", "format", ")", "n", "=", "self", ".", "num_answers", "+", "self", ".", "num_authorities", "+", "self", ".", "num_additionals", "for", "i...
295f6407132616a0ff7401124b9057d89555f91d
train
DNSIncoming.read_utf
Reads a UTF-8 string of a given length from the packet
mdns/zeroconf.py
def read_utf(self, offset, len): """Reads a UTF-8 string of a given length from the packet""" try: result = self.data[offset:offset + len].decode('utf-8') except UnicodeDecodeError: result = str('') return result
def read_utf(self, offset, len): """Reads a UTF-8 string of a given length from the packet""" try: result = self.data[offset:offset + len].decode('utf-8') except UnicodeDecodeError: result = str('') return result
[ "Reads", "a", "UTF", "-", "8", "string", "of", "a", "given", "length", "from", "the", "packet" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L838-L844
[ "def", "read_utf", "(", "self", ",", "offset", ",", "len", ")", ":", "try", ":", "result", "=", "self", ".", "data", "[", "offset", ":", "offset", "+", "len", "]", ".", "decode", "(", "'utf-8'", ")", "except", "UnicodeDecodeError", ":", "result", "="...
295f6407132616a0ff7401124b9057d89555f91d
train
DNSIncoming.read_name
Reads a domain name from the packet
mdns/zeroconf.py
def read_name(self): """Reads a domain name from the packet""" result = '' off = self.offset next = -1 first = off while 1: len = ord(self.data[off]) off += 1 if len == 0: break t = len & 0xC0 if...
def read_name(self): """Reads a domain name from the packet""" result = '' off = self.offset next = -1 first = off while 1: len = ord(self.data[off]) off += 1 if len == 0: break t = len & 0xC0 if...
[ "Reads", "a", "domain", "name", "from", "the", "packet" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L846-L878
[ "def", "read_name", "(", "self", ")", ":", "result", "=", "''", "off", "=", "self", ".", "offset", "next", "=", "-", "1", "first", "=", "off", "while", "1", ":", "len", "=", "ord", "(", "self", ".", "data", "[", "off", "]", ")", "off", "+=", ...
295f6407132616a0ff7401124b9057d89555f91d
train
DNSOutgoing.add_answer
Adds an answer
mdns/zeroconf.py
def add_answer(self, inp, record): """Adds an answer""" if not record.suppressed_by(inp): self.add_answer_at_time(record, 0)
def add_answer(self, inp, record): """Adds an answer""" if not record.suppressed_by(inp): self.add_answer_at_time(record, 0)
[ "Adds", "an", "answer" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L902-L905
[ "def", "add_answer", "(", "self", ",", "inp", ",", "record", ")", ":", "if", "not", "record", ".", "suppressed_by", "(", "inp", ")", ":", "self", ".", "add_answer_at_time", "(", "record", ",", "0", ")" ]
295f6407132616a0ff7401124b9057d89555f91d
train
DNSOutgoing.add_answer_at_time
Adds an answer if if does not expire by a certain time
mdns/zeroconf.py
def add_answer_at_time(self, record, now): """Adds an answer if if does not expire by a certain time""" if record is not None: if now == 0 or not record.is_expired(now): self.answers.append((record, now)) if record.rrsig is not None: self.a...
def add_answer_at_time(self, record, now): """Adds an answer if if does not expire by a certain time""" if record is not None: if now == 0 or not record.is_expired(now): self.answers.append((record, now)) if record.rrsig is not None: self.a...
[ "Adds", "an", "answer", "if", "if", "does", "not", "expire", "by", "a", "certain", "time" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L907-L913
[ "def", "add_answer_at_time", "(", "self", ",", "record", ",", "now", ")", ":", "if", "record", "is", "not", "None", ":", "if", "now", "==", "0", "or", "not", "record", ".", "is_expired", "(", "now", ")", ":", "self", ".", "answers", ".", "append", ...
295f6407132616a0ff7401124b9057d89555f91d
train
DNSOutgoing.write_byte
Writes a single byte to the packet
mdns/zeroconf.py
def write_byte(self, value): """Writes a single byte to the packet""" format = '!B' self.data.append(struct.pack(format, value)) self.size += 1
def write_byte(self, value): """Writes a single byte to the packet""" format = '!B' self.data.append(struct.pack(format, value)) self.size += 1
[ "Writes", "a", "single", "byte", "to", "the", "packet" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L923-L927
[ "def", "write_byte", "(", "self", ",", "value", ")", ":", "format", "=", "'!B'", "self", ".", "data", ".", "append", "(", "struct", ".", "pack", "(", "format", ",", "value", ")", ")", "self", ".", "size", "+=", "1" ]
295f6407132616a0ff7401124b9057d89555f91d
train
DNSOutgoing.insert_short
Inserts an unsigned short in a certain position in the packet
mdns/zeroconf.py
def insert_short(self, index, value): """Inserts an unsigned short in a certain position in the packet""" format = '!H' self.data.insert(index, struct.pack(format, value)) self.size += 2
def insert_short(self, index, value): """Inserts an unsigned short in a certain position in the packet""" format = '!H' self.data.insert(index, struct.pack(format, value)) self.size += 2
[ "Inserts", "an", "unsigned", "short", "in", "a", "certain", "position", "in", "the", "packet" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L935-L939
[ "def", "insert_short", "(", "self", ",", "index", ",", "value", ")", ":", "format", "=", "'!H'", "self", ".", "data", ".", "insert", "(", "index", ",", "struct", ".", "pack", "(", "format", ",", "value", ")", ")", "self", ".", "size", "+=", "2" ]
295f6407132616a0ff7401124b9057d89555f91d
train
DNSOutgoing.write_int
Writes an unsigned integer to the packet
mdns/zeroconf.py
def write_int(self, value): """Writes an unsigned integer to the packet""" format = '!I' self.data.append(struct.pack(format, int(value))) self.size += 4
def write_int(self, value): """Writes an unsigned integer to the packet""" format = '!I' self.data.append(struct.pack(format, int(value))) self.size += 4
[ "Writes", "an", "unsigned", "integer", "to", "the", "packet" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L947-L951
[ "def", "write_int", "(", "self", ",", "value", ")", ":", "format", "=", "'!I'", "self", ".", "data", ".", "append", "(", "struct", ".", "pack", "(", "format", ",", "int", "(", "value", ")", ")", ")", "self", ".", "size", "+=", "4" ]
295f6407132616a0ff7401124b9057d89555f91d
train
DNSOutgoing.write_string
Writes a string to the packet
mdns/zeroconf.py
def write_string(self, value, length): """Writes a string to the packet""" format = '!' + str(length) + 's' self.data.append(struct.pack(format, value)) self.size += length
def write_string(self, value, length): """Writes a string to the packet""" format = '!' + str(length) + 's' self.data.append(struct.pack(format, value)) self.size += length
[ "Writes", "a", "string", "to", "the", "packet" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L953-L957
[ "def", "write_string", "(", "self", ",", "value", ",", "length", ")", ":", "format", "=", "'!'", "+", "str", "(", "length", ")", "+", "'s'", "self", ".", "data", ".", "append", "(", "struct", ".", "pack", "(", "format", ",", "value", ")", ")", "s...
295f6407132616a0ff7401124b9057d89555f91d
train
DNSOutgoing.write_utf
Writes a UTF-8 string of a given length to the packet
mdns/zeroconf.py
def write_utf(self, s): """Writes a UTF-8 string of a given length to the packet""" utfstr = s.encode('utf-8') length = len(utfstr) if length > 64: raise NamePartTooLongException self.write_byte(length) self.write_string(utfstr, length)
def write_utf(self, s): """Writes a UTF-8 string of a given length to the packet""" utfstr = s.encode('utf-8') length = len(utfstr) if length > 64: raise NamePartTooLongException self.write_byte(length) self.write_string(utfstr, length)
[ "Writes", "a", "UTF", "-", "8", "string", "of", "a", "given", "length", "to", "the", "packet" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L959-L966
[ "def", "write_utf", "(", "self", ",", "s", ")", ":", "utfstr", "=", "s", ".", "encode", "(", "'utf-8'", ")", "length", "=", "len", "(", "utfstr", ")", "if", "length", ">", "64", ":", "raise", "NamePartTooLongException", "self", ".", "write_byte", "(", ...
295f6407132616a0ff7401124b9057d89555f91d
train
DNSOutgoing.write_name
Writes a domain name to the packet
mdns/zeroconf.py
def write_name(self, name): """Writes a domain name to the packet""" try: # Find existing instance of this name in packet # index = self.names[name] except KeyError: # No record of this name already, so write it # out as normal, record...
def write_name(self, name): """Writes a domain name to the packet""" try: # Find existing instance of this name in packet # index = self.names[name] except KeyError: # No record of this name already, so write it # out as normal, record...
[ "Writes", "a", "domain", "name", "to", "the", "packet" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L968-L992
[ "def", "write_name", "(", "self", ",", "name", ")", ":", "try", ":", "# Find existing instance of this name in packet", "#", "index", "=", "self", ".", "names", "[", "name", "]", "except", "KeyError", ":", "# No record of this name already, so write it", "# out as nor...
295f6407132616a0ff7401124b9057d89555f91d
train
DNSOutgoing.write_question
Writes a question to the packet
mdns/zeroconf.py
def write_question(self, question): """Writes a question to the packet""" self.write_name(question.name) self.write_short(question.type) self.write_short(question.clazz)
def write_question(self, question): """Writes a question to the packet""" self.write_name(question.name) self.write_short(question.type) self.write_short(question.clazz)
[ "Writes", "a", "question", "to", "the", "packet" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L994-L998
[ "def", "write_question", "(", "self", ",", "question", ")", ":", "self", ".", "write_name", "(", "question", ".", "name", ")", "self", ".", "write_short", "(", "question", ".", "type", ")", "self", ".", "write_short", "(", "question", ".", "clazz", ")" ]
295f6407132616a0ff7401124b9057d89555f91d
train
DNSOutgoing.write_record
Writes a record (answer, authoritative answer, additional) to the packet
mdns/zeroconf.py
def write_record(self, record, now): """Writes a record (answer, authoritative answer, additional) to the packet""" self.write_name(record.name) self.write_short(record.type) if record.unique and self.multicast: self.write_short(record.clazz | _CLASS_UNIQUE) e...
def write_record(self, record, now): """Writes a record (answer, authoritative answer, additional) to the packet""" self.write_name(record.name) self.write_short(record.type) if record.unique and self.multicast: self.write_short(record.clazz | _CLASS_UNIQUE) e...
[ "Writes", "a", "record", "(", "answer", "authoritative", "answer", "additional", ")", "to", "the", "packet" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1000-L1021
[ "def", "write_record", "(", "self", ",", "record", ",", "now", ")", ":", "self", ".", "write_name", "(", "record", ".", "name", ")", "self", ".", "write_short", "(", "record", ".", "type", ")", "if", "record", ".", "unique", "and", "self", ".", "mult...
295f6407132616a0ff7401124b9057d89555f91d
train
DNSOutgoing.packet
Returns a string containing the packet's bytes No further parts should be added to the packet once this is done.
mdns/zeroconf.py
def packet(self): """Returns a string containing the packet's bytes No further parts should be added to the packet once this is done.""" if not self.finished: self.finished = 1 for question in self.questions: self.write_question(question) ...
def packet(self): """Returns a string containing the packet's bytes No further parts should be added to the packet once this is done.""" if not self.finished: self.finished = 1 for question in self.questions: self.write_question(question) ...
[ "Returns", "a", "string", "containing", "the", "packet", "s", "bytes" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1023-L1048
[ "def", "packet", "(", "self", ")", ":", "if", "not", "self", ".", "finished", ":", "self", ".", "finished", "=", "1", "for", "question", "in", "self", ".", "questions", ":", "self", ".", "write_question", "(", "question", ")", "for", "answer", ",", "...
295f6407132616a0ff7401124b9057d89555f91d
train
DNSCache.add
Adds an entry
mdns/zeroconf.py
def add(self, entry): """Adds an entry""" if self.get(entry) is not None: return try: list = self.cache[entry.key] except: list = self.cache[entry.key] = [] list.append(entry)
def add(self, entry): """Adds an entry""" if self.get(entry) is not None: return try: list = self.cache[entry.key] except: list = self.cache[entry.key] = [] list.append(entry)
[ "Adds", "an", "entry" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1058-L1066
[ "def", "add", "(", "self", ",", "entry", ")", ":", "if", "self", ".", "get", "(", "entry", ")", "is", "not", "None", ":", "return", "try", ":", "list", "=", "self", ".", "cache", "[", "entry", ".", "key", "]", "except", ":", "list", "=", "self"...
295f6407132616a0ff7401124b9057d89555f91d
train
DNSCache.sign
Adds and sign an entry
mdns/zeroconf.py
def sign(self, entry, signer=None): """Adds and sign an entry""" if (self.get(entry) is not None): return if (entry.rrsig is None) and (self.private is not None): entry.rrsig = DNSSignatureS(entry.name, _TYPE_RRSIG, _CLASS_IN, entry, self.private, sign...
def sign(self, entry, signer=None): """Adds and sign an entry""" if (self.get(entry) is not None): return if (entry.rrsig is None) and (self.private is not None): entry.rrsig = DNSSignatureS(entry.name, _TYPE_RRSIG, _CLASS_IN, entry, self.private, sign...
[ "Adds", "and", "sign", "an", "entry" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1068-L1077
[ "def", "sign", "(", "self", ",", "entry", ",", "signer", "=", "None", ")", ":", "if", "(", "self", ".", "get", "(", "entry", ")", "is", "not", "None", ")", ":", "return", "if", "(", "entry", ".", "rrsig", "is", "None", ")", "and", "(", "self", ...
295f6407132616a0ff7401124b9057d89555f91d
train
DNSCache.remove
Removes an entry
mdns/zeroconf.py
def remove(self, entry): """Removes an entry""" try: list = self.cache[entry.key] list.remove(entry) except: pass
def remove(self, entry): """Removes an entry""" try: list = self.cache[entry.key] list.remove(entry) except: pass
[ "Removes", "an", "entry" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1079-L1085
[ "def", "remove", "(", "self", ",", "entry", ")", ":", "try", ":", "list", "=", "self", ".", "cache", "[", "entry", ".", "key", "]", "list", ".", "remove", "(", "entry", ")", "except", ":", "pass" ]
295f6407132616a0ff7401124b9057d89555f91d
train
DNSCache.get
Gets an entry by key. Will return None if there is no matching entry.
mdns/zeroconf.py
def get(self, entry): """Gets an entry by key. Will return None if there is no matching entry.""" try: list = self.cache[entry.key] return list[list.index(entry)] except: return None
def get(self, entry): """Gets an entry by key. Will return None if there is no matching entry.""" try: list = self.cache[entry.key] return list[list.index(entry)] except: return None
[ "Gets", "an", "entry", "by", "key", ".", "Will", "return", "None", "if", "there", "is", "no", "matching", "entry", "." ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1087-L1094
[ "def", "get", "(", "self", ",", "entry", ")", ":", "try", ":", "list", "=", "self", ".", "cache", "[", "entry", ".", "key", "]", "return", "list", "[", "list", ".", "index", "(", "entry", ")", "]", "except", ":", "return", "None" ]
295f6407132616a0ff7401124b9057d89555f91d
train
DNSCache.get_by_details
Gets an entry by details. Will return None if there is no matching entry.
mdns/zeroconf.py
def get_by_details(self, name, type, clazz): """Gets an entry by details. Will return None if there is no matching entry.""" entry = DNSEntry(name, type, clazz) return self.get(entry)
def get_by_details(self, name, type, clazz): """Gets an entry by details. Will return None if there is no matching entry.""" entry = DNSEntry(name, type, clazz) return self.get(entry)
[ "Gets", "an", "entry", "by", "details", ".", "Will", "return", "None", "if", "there", "is", "no", "matching", "entry", "." ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1096-L1100
[ "def", "get_by_details", "(", "self", ",", "name", ",", "type", ",", "clazz", ")", ":", "entry", "=", "DNSEntry", "(", "name", ",", "type", ",", "clazz", ")", "return", "self", ".", "get", "(", "entry", ")" ]
295f6407132616a0ff7401124b9057d89555f91d
train
DNSCache.entries
Returns a list of all entries
mdns/zeroconf.py
def entries(self): """Returns a list of all entries""" def add(x, y): return x + y try: return reduce(add, list(self.cache.values())) except: return []
def entries(self): """Returns a list of all entries""" def add(x, y): return x + y try: return reduce(add, list(self.cache.values())) except: return []
[ "Returns", "a", "list", "of", "all", "entries" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1109-L1116
[ "def", "entries", "(", "self", ")", ":", "def", "add", "(", "x", ",", "y", ")", ":", "return", "x", "+", "y", "try", ":", "return", "reduce", "(", "add", ",", "list", "(", "self", ".", "cache", ".", "values", "(", ")", ")", ")", "except", ":"...
295f6407132616a0ff7401124b9057d89555f91d
train
ServiceBrowser.update_record
Callback invoked by Zeroconf when new information arrives. Updates information required by browser in the Zeroconf cache.
mdns/zeroconf.py
def update_record(self, zeroconf, now, record): """Callback invoked by Zeroconf when new information arrives. Updates information required by browser in the Zeroconf cache.""" if record.type == _TYPE_PTR and record.name == self.type: expired = record.is_expired(now) try:...
def update_record(self, zeroconf, now, record): """Callback invoked by Zeroconf when new information arrives. Updates information required by browser in the Zeroconf cache.""" if record.type == _TYPE_PTR and record.name == self.type: expired = record.is_expired(now) try:...
[ "Callback", "invoked", "by", "Zeroconf", "when", "new", "information", "arrives", "." ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1273-L1298
[ "def", "update_record", "(", "self", ",", "zeroconf", ",", "now", ",", "record", ")", ":", "if", "record", ".", "type", "==", "_TYPE_PTR", "and", "record", ".", "name", "==", "self", ".", "type", ":", "expired", "=", "record", ".", "is_expired", "(", ...
295f6407132616a0ff7401124b9057d89555f91d
train
ServiceInfo.set_properties
Sets properties and text of this info from a dictionary
mdns/zeroconf.py
def set_properties(self, properties): """Sets properties and text of this info from a dictionary""" if isinstance(properties, dict): self.properties = properties self.sync_properties() else: self.text = properties
def set_properties(self, properties): """Sets properties and text of this info from a dictionary""" if isinstance(properties, dict): self.properties = properties self.sync_properties() else: self.text = properties
[ "Sets", "properties", "and", "text", "of", "this", "info", "from", "a", "dictionary" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1399-L1405
[ "def", "set_properties", "(", "self", ",", "properties", ")", ":", "if", "isinstance", "(", "properties", ",", "dict", ")", ":", "self", ".", "properties", "=", "properties", "self", ".", "sync_properties", "(", ")", "else", ":", "self", ".", "text", "="...
295f6407132616a0ff7401124b9057d89555f91d
train
ServiceInfo.set_text
Sets properties and text given a text field
mdns/zeroconf.py
def set_text(self, text): """Sets properties and text given a text field""" self.text = text try: self.properties = text_to_dict(text) except: traceback.print_exc() self.properties = None
def set_text(self, text): """Sets properties and text given a text field""" self.text = text try: self.properties = text_to_dict(text) except: traceback.print_exc() self.properties = None
[ "Sets", "properties", "and", "text", "given", "a", "text", "field" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1407-L1414
[ "def", "set_text", "(", "self", ",", "text", ")", ":", "self", ".", "text", "=", "text", "try", ":", "self", ".", "properties", "=", "text_to_dict", "(", "text", ")", "except", ":", "traceback", ".", "print_exc", "(", ")", "self", ".", "properties", ...
295f6407132616a0ff7401124b9057d89555f91d
train
ServiceInfo.get_name
Name accessor
mdns/zeroconf.py
def get_name(self): """Name accessor""" if self.type is not None and self.name.endswith("." + self.type): return self.name[:len(self.name) - len(self.type) - 1] return self.name
def get_name(self): """Name accessor""" if self.type is not None and self.name.endswith("." + self.type): return self.name[:len(self.name) - len(self.type) - 1] return self.name
[ "Name", "accessor" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1420-L1424
[ "def", "get_name", "(", "self", ")", ":", "if", "self", ".", "type", "is", "not", "None", "and", "self", ".", "name", ".", "endswith", "(", "\".\"", "+", "self", ".", "type", ")", ":", "return", "self", ".", "name", "[", ":", "len", "(", "self", ...
295f6407132616a0ff7401124b9057d89555f91d
train
ServiceInfo.update_record
Updates service information from a DNS record
mdns/zeroconf.py
def update_record(self, zeroconf, now, record): """Updates service information from a DNS record""" if record is not None and not record.is_expired(now): if record.type == _TYPE_A: if record.name == self.name: if not record.address in self.address: ...
def update_record(self, zeroconf, now, record): """Updates service information from a DNS record""" if record is not None and not record.is_expired(now): if record.type == _TYPE_A: if record.name == self.name: if not record.address in self.address: ...
[ "Updates", "service", "information", "from", "a", "DNS", "record" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1454-L1473
[ "def", "update_record", "(", "self", ",", "zeroconf", ",", "now", ",", "record", ")", ":", "if", "record", "is", "not", "None", "and", "not", "record", ".", "is_expired", "(", "now", ")", ":", "if", "record", ".", "type", "==", "_TYPE_A", ":", "if", ...
295f6407132616a0ff7401124b9057d89555f91d
train
ServiceInfo.request
Returns true if the service could be discovered on the network, and updates this object with details discovered.
mdns/zeroconf.py
def request(self, zeroconf, timeout): """Returns true if the service could be discovered on the network, and updates this object with details discovered. """ now = current_time_millis() delay = _LISTENER_TIME next = now + delay last = now + timeout result ...
def request(self, zeroconf, timeout): """Returns true if the service could be discovered on the network, and updates this object with details discovered. """ now = current_time_millis() delay = _LISTENER_TIME next = now + delay last = now + timeout result ...
[ "Returns", "true", "if", "the", "service", "could", "be", "discovered", "on", "the", "network", "and", "updates", "this", "object", "with", "details", "discovered", "." ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1475-L1520
[ "def", "request", "(", "self", ",", "zeroconf", ",", "timeout", ")", ":", "now", "=", "current_time_millis", "(", ")", "delay", "=", "_LISTENER_TIME", "next", "=", "now", "+", "delay", "last", "=", "now", "+", "timeout", "result", "=", "0", "try", ":",...
295f6407132616a0ff7401124b9057d89555f91d
train
Heartbeat.wait
Calling thread waits for a given number of milliseconds or until notified.
mdns/zeroconf.py
def wait(self, timeout): """Calling thread waits for a given number of milliseconds or until notified.""" self.condition.acquire() self.condition.wait(timeout // 1000) self.condition.release()
def wait(self, timeout): """Calling thread waits for a given number of milliseconds or until notified.""" self.condition.acquire() self.condition.wait(timeout // 1000) self.condition.release()
[ "Calling", "thread", "waits", "for", "a", "given", "number", "of", "milliseconds", "or", "until", "notified", "." ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1562-L1567
[ "def", "wait", "(", "self", ",", "timeout", ")", ":", "self", ".", "condition", ".", "acquire", "(", ")", "self", ".", "condition", ".", "wait", "(", "timeout", "//", "1000", ")", "self", ".", "condition", ".", "release", "(", ")" ]
295f6407132616a0ff7401124b9057d89555f91d
train
Heartbeat.notify_all
Notifies all waiting threads
mdns/zeroconf.py
def notify_all(self): """Notifies all waiting threads""" self.condition.acquire() # python 3.x try: self.condition.notify_all() except: self.condition.notifyAll() self.condition.release()
def notify_all(self): """Notifies all waiting threads""" self.condition.acquire() # python 3.x try: self.condition.notify_all() except: self.condition.notifyAll() self.condition.release()
[ "Notifies", "all", "waiting", "threads" ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1569-L1577
[ "def", "notify_all", "(", "self", ")", ":", "self", ".", "condition", ".", "acquire", "(", ")", "# python 3.x", "try", ":", "self", ".", "condition", ".", "notify_all", "(", ")", "except", ":", "self", ".", "condition", ".", "notifyAll", "(", ")", "sel...
295f6407132616a0ff7401124b9057d89555f91d
train
Zeroconf.get_service_info
Returns network's service information for a particular name and type, or None if no service matches by the timeout, which defaults to 3 seconds.
mdns/zeroconf.py
def get_service_info(self, type, name, timeout=3000): """Returns network's service information for a particular name and type, or None if no service matches by the timeout, which defaults to 3 seconds.""" info = ServiceInfo(type, name) if info.request(self, timeout): ...
def get_service_info(self, type, name, timeout=3000): """Returns network's service information for a particular name and type, or None if no service matches by the timeout, which defaults to 3 seconds.""" info = ServiceInfo(type, name) if info.request(self, timeout): ...
[ "Returns", "network", "s", "service", "information", "for", "a", "particular", "name", "and", "type", "or", "None", "if", "no", "service", "matches", "by", "the", "timeout", "which", "defaults", "to", "3", "seconds", "." ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1712-L1719
[ "def", "get_service_info", "(", "self", ",", "type", ",", "name", ",", "timeout", "=", "3000", ")", ":", "info", "=", "ServiceInfo", "(", "type", ",", "name", ")", "if", "info", ".", "request", "(", "self", ",", "timeout", ")", ":", "return", "info",...
295f6407132616a0ff7401124b9057d89555f91d
train
Zeroconf.add_serviceListener
Adds a listener for a particular service type. This object will then have its update_record method called when information arrives for that type.
mdns/zeroconf.py
def add_serviceListener(self, type, listener): """Adds a listener for a particular service type. This object will then have its update_record method called when information arrives for that type.""" self.remove_service_listener(listener) self.browsers.append(ServiceBrowser(self,...
def add_serviceListener(self, type, listener): """Adds a listener for a particular service type. This object will then have its update_record method called when information arrives for that type.""" self.remove_service_listener(listener) self.browsers.append(ServiceBrowser(self,...
[ "Adds", "a", "listener", "for", "a", "particular", "service", "type", ".", "This", "object", "will", "then", "have", "its", "update_record", "method", "called", "when", "information", "arrives", "for", "that", "type", "." ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1721-L1726
[ "def", "add_serviceListener", "(", "self", ",", "type", ",", "listener", ")", ":", "self", ".", "remove_service_listener", "(", "listener", ")", "self", ".", "browsers", ".", "append", "(", "ServiceBrowser", "(", "self", ",", "type", ",", "listener", ")", ...
295f6407132616a0ff7401124b9057d89555f91d
train
Zeroconf.remove_service_listener
Removes a listener from the set that is currently listening.
mdns/zeroconf.py
def remove_service_listener(self, listener): """Removes a listener from the set that is currently listening.""" for browser in self.browsers: if browser.listener == listener: browser.cancel() del(browser)
def remove_service_listener(self, listener): """Removes a listener from the set that is currently listening.""" for browser in self.browsers: if browser.listener == listener: browser.cancel() del(browser)
[ "Removes", "a", "listener", "from", "the", "set", "that", "is", "currently", "listening", "." ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1728-L1733
[ "def", "remove_service_listener", "(", "self", ",", "listener", ")", ":", "for", "browser", "in", "self", ".", "browsers", ":", "if", "browser", ".", "listener", "==", "listener", ":", "browser", ".", "cancel", "(", ")", "del", "(", "browser", ")" ]
295f6407132616a0ff7401124b9057d89555f91d
train
Zeroconf.register_service
Registers service information to the network with a default TTL of 60 seconds. Zeroconf will then respond to requests for information for that service. The name of the service may be changed if needed to make it unique on the network.
mdns/zeroconf.py
def register_service(self, info): """Registers service information to the network with a default TTL of 60 seconds. Zeroconf will then respond to requests for information for that service. The name of the service may be changed if needed to make it unique on the network.""" sel...
def register_service(self, info): """Registers service information to the network with a default TTL of 60 seconds. Zeroconf will then respond to requests for information for that service. The name of the service may be changed if needed to make it unique on the network.""" sel...
[ "Registers", "service", "information", "to", "the", "network", "with", "a", "default", "TTL", "of", "60", "seconds", ".", "Zeroconf", "will", "then", "respond", "to", "requests", "for", "information", "for", "that", "service", ".", "The", "name", "of", "the"...
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1738-L1748
[ "def", "register_service", "(", "self", ",", "info", ")", ":", "self", ".", "check_service", "(", "info", ")", "self", ".", "services", "[", "info", ".", "name", ".", "lower", "(", ")", "]", "=", "info", "# zone transfer", "self", ".", "transfer_zone", ...
295f6407132616a0ff7401124b9057d89555f91d
train
Zeroconf.unregister_service
Unregister a service.
mdns/zeroconf.py
def unregister_service(self, info): """Unregister a service.""" try: del(self.services[info.name.lower()]) except: pass now = current_time_millis() next_time = now i = 0 while i < 3: if now < next_time: self.wait...
def unregister_service(self, info): """Unregister a service.""" try: del(self.services[info.name.lower()]) except: pass now = current_time_millis() next_time = now i = 0 while i < 3: if now < next_time: self.wait...
[ "Unregister", "a", "service", "." ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1806-L1835
[ "def", "unregister_service", "(", "self", ",", "info", ")", ":", "try", ":", "del", "(", "self", ".", "services", "[", "info", ".", "name", ".", "lower", "(", ")", "]", ")", "except", ":", "pass", "now", "=", "current_time_millis", "(", ")", "next_ti...
295f6407132616a0ff7401124b9057d89555f91d
train
Zeroconf.check_service
Checks the network for a unique service name, modifying the ServiceInfo passed in if it is not unique.
mdns/zeroconf.py
def check_service(self, info): """Checks the network for a unique service name, modifying the ServiceInfo passed in if it is not unique.""" now = current_time_millis() next_time = now i = 0 while i < 3: for record in self.cache.entries_with_name(info.type): ...
def check_service(self, info): """Checks the network for a unique service name, modifying the ServiceInfo passed in if it is not unique.""" now = current_time_millis() next_time = now i = 0 while i < 3: for record in self.cache.entries_with_name(info.type): ...
[ "Checks", "the", "network", "for", "a", "unique", "service", "name", "modifying", "the", "ServiceInfo", "passed", "in", "if", "it", "is", "not", "unique", "." ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1868-L1900
[ "def", "check_service", "(", "self", ",", "info", ")", ":", "now", "=", "current_time_millis", "(", ")", "next_time", "=", "now", "i", "=", "0", "while", "i", "<", "3", ":", "for", "record", "in", "self", ".", "cache", ".", "entries_with_name", "(", ...
295f6407132616a0ff7401124b9057d89555f91d
train
Zeroconf.add_listener
Adds a listener for a given question. The listener will have its update_record method called when information is available to answer the question.
mdns/zeroconf.py
def add_listener(self, listener, question): """Adds a listener for a given question. The listener will have its update_record method called when information is available to answer the question.""" now = current_time_millis() self.listeners.append(listener) if question is...
def add_listener(self, listener, question): """Adds a listener for a given question. The listener will have its update_record method called when information is available to answer the question.""" now = current_time_millis() self.listeners.append(listener) if question is...
[ "Adds", "a", "listener", "for", "a", "given", "question", ".", "The", "listener", "will", "have", "its", "update_record", "method", "called", "when", "information", "is", "available", "to", "answer", "the", "question", "." ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1906-L1916
[ "def", "add_listener", "(", "self", ",", "listener", ",", "question", ")", ":", "now", "=", "current_time_millis", "(", ")", "self", ".", "listeners", ".", "append", "(", "listener", ")", "if", "question", "is", "not", "None", ":", "for", "record", "in",...
295f6407132616a0ff7401124b9057d89555f91d
train
Zeroconf.update_record
Used to notify listeners of new information that has updated a record.
mdns/zeroconf.py
def update_record(self, now, rec): """Used to notify listeners of new information that has updated a record.""" for listener in self.listeners: listener.update_record(self, now, rec) self.notify_all()
def update_record(self, now, rec): """Used to notify listeners of new information that has updated a record.""" for listener in self.listeners: listener.update_record(self, now, rec) self.notify_all()
[ "Used", "to", "notify", "listeners", "of", "new", "information", "that", "has", "updated", "a", "record", "." ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1926-L1931
[ "def", "update_record", "(", "self", ",", "now", ",", "rec", ")", ":", "for", "listener", "in", "self", ".", "listeners", ":", "listener", ".", "update_record", "(", "self", ",", "now", ",", "rec", ")", "self", ".", "notify_all", "(", ")" ]
295f6407132616a0ff7401124b9057d89555f91d
train
Zeroconf.handle_response
Deal with incoming response packets. All answers are held in the cache, and listeners are notified.
mdns/zeroconf.py
def handle_response(self, msg, address): """Deal with incoming response packets. All answers are held in the cache, and listeners are notified.""" now = current_time_millis() sigs = [] precache = [] for record in msg.answers: if isinstance(record, DNSSignat...
def handle_response(self, msg, address): """Deal with incoming response packets. All answers are held in the cache, and listeners are notified.""" now = current_time_millis() sigs = [] precache = [] for record in msg.answers: if isinstance(record, DNSSignat...
[ "Deal", "with", "incoming", "response", "packets", ".", "All", "answers", "are", "held", "in", "the", "cache", "and", "listeners", "are", "notified", "." ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1952-L2036
[ "def", "handle_response", "(", "self", ",", "msg", ",", "address", ")", ":", "now", "=", "current_time_millis", "(", ")", "sigs", "=", "[", "]", "precache", "=", "[", "]", "for", "record", "in", "msg", ".", "answers", ":", "if", "isinstance", "(", "r...
295f6407132616a0ff7401124b9057d89555f91d
train
Zeroconf.handle_query
Deal with incoming query packets. Provides a response if possible. msg - message to process addr - dst addr port - dst port orig - originating address (for adaptive records)
mdns/zeroconf.py
def handle_query(self, msg, addr, port, orig): """ Deal with incoming query packets. Provides a response if possible. msg - message to process addr - dst addr port - dst port orig - originating address (for adaptive records) """ out =...
def handle_query(self, msg, addr, port, orig): """ Deal with incoming query packets. Provides a response if possible. msg - message to process addr - dst addr port - dst port orig - originating address (for adaptive records) """ out =...
[ "Deal", "with", "incoming", "query", "packets", ".", "Provides", "a", "response", "if", "possible", "." ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L2040-L2128
[ "def", "handle_query", "(", "self", ",", "msg", ",", "addr", ",", "port", ",", "orig", ")", ":", "out", "=", "None", "# Support unicast client responses", "#", "if", "port", "!=", "_MDNS_PORT", ":", "out", "=", "DNSOutgoing", "(", "_FLAGS_QR_RESPONSE", "|", ...
295f6407132616a0ff7401124b9057d89555f91d
train
Zeroconf.send
Sends an outgoing packet.
mdns/zeroconf.py
def send(self, out, addr=_MDNS_ADDR, port=_MDNS_PORT): """Sends an outgoing packet.""" # This is a quick test to see if we can parse the packets we generate #temp = DNSIncoming(out.packet()) for i in self.intf.values(): try: return i.sendto(out.packet(), 0, (a...
def send(self, out, addr=_MDNS_ADDR, port=_MDNS_PORT): """Sends an outgoing packet.""" # This is a quick test to see if we can parse the packets we generate #temp = DNSIncoming(out.packet()) for i in self.intf.values(): try: return i.sendto(out.packet(), 0, (a...
[ "Sends", "an", "outgoing", "packet", "." ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L2130-L2140
[ "def", "send", "(", "self", ",", "out", ",", "addr", "=", "_MDNS_ADDR", ",", "port", "=", "_MDNS_PORT", ")", ":", "# This is a quick test to see if we can parse the packets we generate", "#temp = DNSIncoming(out.packet())", "for", "i", "in", "self", ".", "intf", ".", ...
295f6407132616a0ff7401124b9057d89555f91d
train
Zeroconf.close
Ends the background threads, and prevent this instance from servicing further queries.
mdns/zeroconf.py
def close(self): """Ends the background threads, and prevent this instance from servicing further queries.""" if globals()['_GLOBAL_DONE'] == 0: globals()['_GLOBAL_DONE'] = 1 self.notify_all() self.engine.notify() self.unregister_all_services() ...
def close(self): """Ends the background threads, and prevent this instance from servicing further queries.""" if globals()['_GLOBAL_DONE'] == 0: globals()['_GLOBAL_DONE'] = 1 self.notify_all() self.engine.notify() self.unregister_all_services() ...
[ "Ends", "the", "background", "threads", "and", "prevent", "this", "instance", "from", "servicing", "further", "queries", "." ]
svinota/mdns
python
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L2142-L2158
[ "def", "close", "(", "self", ")", ":", "if", "globals", "(", ")", "[", "'_GLOBAL_DONE'", "]", "==", "0", ":", "globals", "(", ")", "[", "'_GLOBAL_DONE'", "]", "=", "1", "self", ".", "notify_all", "(", ")", "self", ".", "engine", ".", "notify", "(",...
295f6407132616a0ff7401124b9057d89555f91d