repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
svinota/mdns
mdns/zeroconf.py
DNSService.write
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)
python
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", ")", ":", "out", ".", "write_short", "(", "self", ".", "priority", ")", "out", ".", "write_short", "(", "self", ".", "weight", ")", "out", ".", "write_short", "(", "self", ".", "port", ")", "out", ".", "writ...
Used in constructing an outgoing packet
[ "Used", "in", "constructing", "an", "outgoing", "packet" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L666-L671
svinota/mdns
mdns/zeroconf.py
DNSIncoming.read_header
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] ...
python
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", ")", ":", "format", "=", "'!HHHHHH'", "length", "=", "struct", ".", "calcsize", "(", "format", ")", "info", "=", "struct", ".", "unpack", "(", "format", ",", "self", ".", "data", "[", "self", ".", "offset", ":", "se...
Reads header portion of packet
[ "Reads", "header", "portion", "of", "packet" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L708-L721
svinota/mdns
mdns/zeroconf.py
DNSIncoming.read_questions
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...
python
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", ")", ":", "format", "=", "'!HH'", "length", "=", "struct", ".", "calcsize", "(", "format", ")", "for", "i", "in", "range", "(", "0", ",", "self", ".", "num_questions", ")", ":", "name", "=", "self", ".", "read_na...
Reads questions section of packet
[ "Reads", "questions", "section", "of", "packet" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L723-L734
svinota/mdns
mdns/zeroconf.py
DNSIncoming.read_int
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]
python
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", ")", ":", "format", "=", "'!I'", "length", "=", "struct", ".", "calcsize", "(", "format", ")", "info", "=", "struct", ".", "unpack", "(", "format", ",", "self", ".", "data", "[", "self", ".", "offset", ":", "self", "...
Reads an integer from the packet
[ "Reads", "an", "integer", "from", "the", "packet" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L736-L743
svinota/mdns
mdns/zeroconf.py
DNSIncoming.read_character_string
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)
python
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", ")", ":", "length", "=", "ord", "(", "self", ".", "data", "[", "self", ".", "offset", "]", ")", "self", ".", "offset", "+=", "1", "return", "self", ".", "read_string", "(", "length", ")" ]
Reads a character string from the packet
[ "Reads", "a", "character", "string", "from", "the", "packet" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L745-L749
svinota/mdns
mdns/zeroconf.py
DNSIncoming.read_string
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]
python
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", ")", ":", "format", "=", "'!'", "+", "str", "(", "len", ")", "+", "'s'", "length", "=", "struct", ".", "calcsize", "(", "format", ")", "info", "=", "struct", ".", "unpack", "(", "format", ",", "self", ...
Reads a string of a given length from the packet
[ "Reads", "a", "string", "of", "a", "given", "length", "from", "the", "packet" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L751-L758
svinota/mdns
mdns/zeroconf.py
DNSIncoming.read_others
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...
python
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", ")", ":", "format", "=", "'!HHiH'", "length", "=", "struct", ".", "calcsize", "(", "format", ")", "n", "=", "self", ".", "num_answers", "+", "self", ".", "num_authorities", "+", "self", ".", "num_additionals", "for", "i...
Reads the answers, authorities and additionals section of the packet
[ "Reads", "the", "answers", "authorities", "and", "additionals", "section", "of", "the", "packet" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L769-L828
svinota/mdns
mdns/zeroconf.py
DNSIncoming.read_utf
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
python
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", ")", ":", "try", ":", "result", "=", "self", ".", "data", "[", "offset", ":", "offset", "+", "len", "]", ".", "decode", "(", "'utf-8'", ")", "except", "UnicodeDecodeError", ":", "result", "="...
Reads a UTF-8 string of a given length from the packet
[ "Reads", "a", "UTF", "-", "8", "string", "of", "a", "given", "length", "from", "the", "packet" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L838-L844
svinota/mdns
mdns/zeroconf.py
DNSIncoming.read_name
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...
python
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", ")", ":", "result", "=", "''", "off", "=", "self", ".", "offset", "next", "=", "-", "1", "first", "=", "off", "while", "1", ":", "len", "=", "ord", "(", "self", ".", "data", "[", "off", "]", ")", "off", "+=", ...
Reads a domain name from the packet
[ "Reads", "a", "domain", "name", "from", "the", "packet" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L846-L878
svinota/mdns
mdns/zeroconf.py
DNSOutgoing.add_answer
def add_answer(self, inp, record): """Adds an answer""" if not record.suppressed_by(inp): self.add_answer_at_time(record, 0)
python
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", ")", ":", "if", "not", "record", ".", "suppressed_by", "(", "inp", ")", ":", "self", ".", "add_answer_at_time", "(", "record", ",", "0", ")" ]
Adds an answer
[ "Adds", "an", "answer" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L902-L905
svinota/mdns
mdns/zeroconf.py
DNSOutgoing.add_answer_at_time
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...
python
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", ")", ":", "if", "record", "is", "not", "None", ":", "if", "now", "==", "0", "or", "not", "record", ".", "is_expired", "(", "now", ")", ":", "self", ".", "answers", ".", "append", ...
Adds an answer if if does not expire by a certain time
[ "Adds", "an", "answer", "if", "if", "does", "not", "expire", "by", "a", "certain", "time" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L907-L913
svinota/mdns
mdns/zeroconf.py
DNSOutgoing.write_byte
def write_byte(self, value): """Writes a single byte to the packet""" format = '!B' self.data.append(struct.pack(format, value)) self.size += 1
python
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", ")", ":", "format", "=", "'!B'", "self", ".", "data", ".", "append", "(", "struct", ".", "pack", "(", "format", ",", "value", ")", ")", "self", ".", "size", "+=", "1" ]
Writes a single byte to the packet
[ "Writes", "a", "single", "byte", "to", "the", "packet" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L923-L927
svinota/mdns
mdns/zeroconf.py
DNSOutgoing.insert_short
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
python
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", ")", ":", "format", "=", "'!H'", "self", ".", "data", ".", "insert", "(", "index", ",", "struct", ".", "pack", "(", "format", ",", "value", ")", ")", "self", ".", "size", "+=", "2" ]
Inserts an unsigned short in a certain position in the packet
[ "Inserts", "an", "unsigned", "short", "in", "a", "certain", "position", "in", "the", "packet" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L935-L939
svinota/mdns
mdns/zeroconf.py
DNSOutgoing.write_int
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
python
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", ")", ":", "format", "=", "'!I'", "self", ".", "data", ".", "append", "(", "struct", ".", "pack", "(", "format", ",", "int", "(", "value", ")", ")", ")", "self", ".", "size", "+=", "4" ]
Writes an unsigned integer to the packet
[ "Writes", "an", "unsigned", "integer", "to", "the", "packet" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L947-L951
svinota/mdns
mdns/zeroconf.py
DNSOutgoing.write_string
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
python
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", ")", ":", "format", "=", "'!'", "+", "str", "(", "length", ")", "+", "'s'", "self", ".", "data", ".", "append", "(", "struct", ".", "pack", "(", "format", ",", "value", ")", ")", "s...
Writes a string to the packet
[ "Writes", "a", "string", "to", "the", "packet" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L953-L957
svinota/mdns
mdns/zeroconf.py
DNSOutgoing.write_utf
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)
python
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", ")", ":", "utfstr", "=", "s", ".", "encode", "(", "'utf-8'", ")", "length", "=", "len", "(", "utfstr", ")", "if", "length", ">", "64", ":", "raise", "NamePartTooLongException", "self", ".", "write_byte", "(", ...
Writes a UTF-8 string of a given length to the packet
[ "Writes", "a", "UTF", "-", "8", "string", "of", "a", "given", "length", "to", "the", "packet" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L959-L966
svinota/mdns
mdns/zeroconf.py
DNSOutgoing.write_name
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...
python
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", ")", ":", "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...
Writes a domain name to the packet
[ "Writes", "a", "domain", "name", "to", "the", "packet" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L968-L992
svinota/mdns
mdns/zeroconf.py
DNSOutgoing.write_question
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)
python
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", ")", ":", "self", ".", "write_name", "(", "question", ".", "name", ")", "self", ".", "write_short", "(", "question", ".", "type", ")", "self", ".", "write_short", "(", "question", ".", "clazz", ")" ]
Writes a question to the packet
[ "Writes", "a", "question", "to", "the", "packet" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L994-L998
svinota/mdns
mdns/zeroconf.py
DNSOutgoing.write_record
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...
python
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", ")", ":", "self", ".", "write_name", "(", "record", ".", "name", ")", "self", ".", "write_short", "(", "record", ".", "type", ")", "if", "record", ".", "unique", "and", "self", ".", "mult...
Writes a record (answer, authoritative answer, additional) to the packet
[ "Writes", "a", "record", "(", "answer", "authoritative", "answer", "additional", ")", "to", "the", "packet" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1000-L1021
svinota/mdns
mdns/zeroconf.py
DNSOutgoing.packet
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) ...
python
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", ")", ":", "if", "not", "self", ".", "finished", ":", "self", ".", "finished", "=", "1", "for", "question", "in", "self", ".", "questions", ":", "self", ".", "write_question", "(", "question", ")", "for", "answer", ",", "...
Returns a string containing the packet's bytes No further parts should be added to the packet once this is done.
[ "Returns", "a", "string", "containing", "the", "packet", "s", "bytes" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1023-L1048
svinota/mdns
mdns/zeroconf.py
DNSCache.add
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)
python
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", ")", ":", "if", "self", ".", "get", "(", "entry", ")", "is", "not", "None", ":", "return", "try", ":", "list", "=", "self", ".", "cache", "[", "entry", ".", "key", "]", "except", ":", "list", "=", "self"...
Adds an entry
[ "Adds", "an", "entry" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1058-L1066
svinota/mdns
mdns/zeroconf.py
DNSCache.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...
python
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", ")", ":", "if", "(", "self", ".", "get", "(", "entry", ")", "is", "not", "None", ")", ":", "return", "if", "(", "entry", ".", "rrsig", "is", "None", ")", "and", "(", "self", ...
Adds and sign an entry
[ "Adds", "and", "sign", "an", "entry" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1068-L1077
svinota/mdns
mdns/zeroconf.py
DNSCache.remove
def remove(self, entry): """Removes an entry""" try: list = self.cache[entry.key] list.remove(entry) except: pass
python
def remove(self, entry): """Removes an entry""" try: list = self.cache[entry.key] list.remove(entry) except: pass
[ "def", "remove", "(", "self", ",", "entry", ")", ":", "try", ":", "list", "=", "self", ".", "cache", "[", "entry", ".", "key", "]", "list", ".", "remove", "(", "entry", ")", "except", ":", "pass" ]
Removes an entry
[ "Removes", "an", "entry" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1079-L1085
svinota/mdns
mdns/zeroconf.py
DNSCache.get
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
python
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", ")", ":", "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.
[ "Gets", "an", "entry", "by", "key", ".", "Will", "return", "None", "if", "there", "is", "no", "matching", "entry", "." ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1087-L1094
svinota/mdns
mdns/zeroconf.py
DNSCache.get_by_details
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)
python
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", ")", ":", "entry", "=", "DNSEntry", "(", "name", ",", "type", ",", "clazz", ")", "return", "self", ".", "get", "(", "entry", ")" ]
Gets an entry by details. Will return None if there is no matching entry.
[ "Gets", "an", "entry", "by", "details", ".", "Will", "return", "None", "if", "there", "is", "no", "matching", "entry", "." ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1096-L1100
svinota/mdns
mdns/zeroconf.py
DNSCache.entries
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 []
python
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", ")", ":", "def", "add", "(", "x", ",", "y", ")", ":", "return", "x", "+", "y", "try", ":", "return", "reduce", "(", "add", ",", "list", "(", "self", ".", "cache", ".", "values", "(", ")", ")", ")", "except", ":"...
Returns a list of all entries
[ "Returns", "a", "list", "of", "all", "entries" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1109-L1116
svinota/mdns
mdns/zeroconf.py
ServiceBrowser.update_record
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:...
python
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", ")", ":", "if", "record", ".", "type", "==", "_TYPE_PTR", "and", "record", ".", "name", "==", "self", ".", "type", ":", "expired", "=", "record", ".", "is_expired", "(", ...
Callback invoked by Zeroconf when new information arrives. Updates information required by browser in the Zeroconf cache.
[ "Callback", "invoked", "by", "Zeroconf", "when", "new", "information", "arrives", "." ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1273-L1298
svinota/mdns
mdns/zeroconf.py
ServiceInfo.set_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
python
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", ")", ":", "if", "isinstance", "(", "properties", ",", "dict", ")", ":", "self", ".", "properties", "=", "properties", "self", ".", "sync_properties", "(", ")", "else", ":", "self", ".", "text", "="...
Sets properties and text of this info from a dictionary
[ "Sets", "properties", "and", "text", "of", "this", "info", "from", "a", "dictionary" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1399-L1405
svinota/mdns
mdns/zeroconf.py
ServiceInfo.set_text
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
python
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", ")", ":", "self", ".", "text", "=", "text", "try", ":", "self", ".", "properties", "=", "text_to_dict", "(", "text", ")", "except", ":", "traceback", ".", "print_exc", "(", ")", "self", ".", "properties", ...
Sets properties and text given a text field
[ "Sets", "properties", "and", "text", "given", "a", "text", "field" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1407-L1414
svinota/mdns
mdns/zeroconf.py
ServiceInfo.get_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
python
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", ")", ":", "if", "self", ".", "type", "is", "not", "None", "and", "self", ".", "name", ".", "endswith", "(", "\".\"", "+", "self", ".", "type", ")", ":", "return", "self", ".", "name", "[", ":", "len", "(", "self", ...
Name accessor
[ "Name", "accessor" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1420-L1424
svinota/mdns
mdns/zeroconf.py
ServiceInfo.update_record
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: ...
python
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", ")", ":", "if", "record", "is", "not", "None", "and", "not", "record", ".", "is_expired", "(", "now", ")", ":", "if", "record", ".", "type", "==", "_TYPE_A", ":", "if", ...
Updates service information from a DNS record
[ "Updates", "service", "information", "from", "a", "DNS", "record" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1454-L1473
svinota/mdns
mdns/zeroconf.py
ServiceInfo.request
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 ...
python
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", ")", ":", "now", "=", "current_time_millis", "(", ")", "delay", "=", "_LISTENER_TIME", "next", "=", "now", "+", "delay", "last", "=", "now", "+", "timeout", "result", "=", "0", "try", ":",...
Returns true if the service could be discovered on the network, and updates this object with details discovered.
[ "Returns", "true", "if", "the", "service", "could", "be", "discovered", "on", "the", "network", "and", "updates", "this", "object", "with", "details", "discovered", "." ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1475-L1520
svinota/mdns
mdns/zeroconf.py
Heartbeat.wait
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()
python
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", ")", ":", "self", ".", "condition", ".", "acquire", "(", ")", "self", ".", "condition", ".", "wait", "(", "timeout", "//", "1000", ")", "self", ".", "condition", ".", "release", "(", ")" ]
Calling thread waits for a given number of milliseconds or until notified.
[ "Calling", "thread", "waits", "for", "a", "given", "number", "of", "milliseconds", "or", "until", "notified", "." ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1562-L1567
svinota/mdns
mdns/zeroconf.py
Heartbeat.notify_all
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()
python
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", ")", ":", "self", ".", "condition", ".", "acquire", "(", ")", "# python 3.x", "try", ":", "self", ".", "condition", ".", "notify_all", "(", ")", "except", ":", "self", ".", "condition", ".", "notifyAll", "(", ")", "sel...
Notifies all waiting threads
[ "Notifies", "all", "waiting", "threads" ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1569-L1577
svinota/mdns
mdns/zeroconf.py
Zeroconf.get_service_info
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): ...
python
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", ")", ":", "info", "=", "ServiceInfo", "(", "type", ",", "name", ")", "if", "info", ".", "request", "(", "self", ",", "timeout", ")", ":", "return", "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.
[ "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", "." ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1712-L1719
svinota/mdns
mdns/zeroconf.py
Zeroconf.add_serviceListener
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,...
python
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", ")", ":", "self", ".", "remove_service_listener", "(", "listener", ")", "self", ".", "browsers", ".", "append", "(", "ServiceBrowser", "(", "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.
[ "Adds", "a", "listener", "for", "a", "particular", "service", "type", ".", "This", "object", "will", "then", "have", "its", "update_record", "method", "called", "when", "information", "arrives", "for", "that", "type", "." ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1721-L1726
svinota/mdns
mdns/zeroconf.py
Zeroconf.remove_service_listener
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)
python
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", ")", ":", "for", "browser", "in", "self", ".", "browsers", ":", "if", "browser", ".", "listener", "==", "listener", ":", "browser", ".", "cancel", "(", ")", "del", "(", "browser", ")" ]
Removes a listener from the set that is currently listening.
[ "Removes", "a", "listener", "from", "the", "set", "that", "is", "currently", "listening", "." ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1728-L1733
svinota/mdns
mdns/zeroconf.py
Zeroconf.register_service
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...
python
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", ")", ":", "self", ".", "check_service", "(", "info", ")", "self", ".", "services", "[", "info", ".", "name", ".", "lower", "(", ")", "]", "=", "info", "# zone transfer", "self", ".", "transfer_zone", ...
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.
[ "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"...
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1738-L1748
svinota/mdns
mdns/zeroconf.py
Zeroconf.unregister_service
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...
python
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", ")", ":", "try", ":", "del", "(", "self", ".", "services", "[", "info", ".", "name", ".", "lower", "(", ")", "]", ")", "except", ":", "pass", "now", "=", "current_time_millis", "(", ")", "next_ti...
Unregister a service.
[ "Unregister", "a", "service", "." ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1806-L1835
svinota/mdns
mdns/zeroconf.py
Zeroconf.check_service
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): ...
python
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", ")", ":", "now", "=", "current_time_millis", "(", ")", "next_time", "=", "now", "i", "=", "0", "while", "i", "<", "3", ":", "for", "record", "in", "self", ".", "cache", ".", "entries_with_name", "(", ...
Checks the network for a unique service name, modifying the ServiceInfo passed in if it is not unique.
[ "Checks", "the", "network", "for", "a", "unique", "service", "name", "modifying", "the", "ServiceInfo", "passed", "in", "if", "it", "is", "not", "unique", "." ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1868-L1900
svinota/mdns
mdns/zeroconf.py
Zeroconf.add_listener
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...
python
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", ")", ":", "now", "=", "current_time_millis", "(", ")", "self", ".", "listeners", ".", "append", "(", "listener", ")", "if", "question", "is", "not", "None", ":", "for", "record", "in",...
Adds a listener for a given question. The listener will have its update_record method called when information is available to answer the 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", "." ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1906-L1916
svinota/mdns
mdns/zeroconf.py
Zeroconf.update_record
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()
python
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", ")", ":", "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.
[ "Used", "to", "notify", "listeners", "of", "new", "information", "that", "has", "updated", "a", "record", "." ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1926-L1931
svinota/mdns
mdns/zeroconf.py
Zeroconf.handle_response
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...
python
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", ")", ":", "now", "=", "current_time_millis", "(", ")", "sigs", "=", "[", "]", "precache", "=", "[", "]", "for", "record", "in", "msg", ".", "answers", ":", "if", "isinstance", "(", "r...
Deal with incoming response packets. All answers are held in the cache, and listeners are notified.
[ "Deal", "with", "incoming", "response", "packets", ".", "All", "answers", "are", "held", "in", "the", "cache", "and", "listeners", "are", "notified", "." ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1952-L2036
svinota/mdns
mdns/zeroconf.py
Zeroconf.handle_query
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 =...
python
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", ")", ":", "out", "=", "None", "# Support unicast client responses", "#", "if", "port", "!=", "_MDNS_PORT", ":", "out", "=", "DNSOutgoing", "(", "_FLAGS_QR_RESPONSE", "|", ...
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)
[ "Deal", "with", "incoming", "query", "packets", ".", "Provides", "a", "response", "if", "possible", "." ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L2040-L2128
svinota/mdns
mdns/zeroconf.py
Zeroconf.send
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...
python
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", ")", ":", "# This is a quick test to see if we can parse the packets we generate", "#temp = DNSIncoming(out.packet())", "for", "i", "in", "self", ".", "intf", ".", ...
Sends an outgoing packet.
[ "Sends", "an", "outgoing", "packet", "." ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L2130-L2140
svinota/mdns
mdns/zeroconf.py
Zeroconf.close
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() ...
python
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", ")", ":", "if", "globals", "(", ")", "[", "'_GLOBAL_DONE'", "]", "==", "0", ":", "globals", "(", ")", "[", "'_GLOBAL_DONE'", "]", "=", "1", "self", ".", "notify_all", "(", ")", "self", ".", "engine", ".", "notify", "(",...
Ends the background threads, and prevent this instance from servicing further queries.
[ "Ends", "the", "background", "threads", "and", "prevent", "this", "instance", "from", "servicing", "further", "queries", "." ]
train
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L2142-L2158
productml/blurr
blurr/runner/spark_runner.py
SparkRunner.execute
def execute(self, identity_records: 'RDD', old_state_rdd: Optional['RDD'] = None) -> 'RDD': """ Executes Blurr BTS with the given records. old_state_rdd can be provided to load an older state from a previous run. :param identity_records: RDD of the form Tuple[Identity, List[TimeAndRecor...
python
def execute(self, identity_records: 'RDD', old_state_rdd: Optional['RDD'] = None) -> 'RDD': """ Executes Blurr BTS with the given records. old_state_rdd can be provided to load an older state from a previous run. :param identity_records: RDD of the form Tuple[Identity, List[TimeAndRecor...
[ "def", "execute", "(", "self", ",", "identity_records", ":", "'RDD'", ",", "old_state_rdd", ":", "Optional", "[", "'RDD'", "]", "=", "None", ")", "->", "'RDD'", ":", "identity_records_with_state", "=", "identity_records", "if", "old_state_rdd", ":", "identity_re...
Executes Blurr BTS with the given records. old_state_rdd can be provided to load an older state from a previous run. :param identity_records: RDD of the form Tuple[Identity, List[TimeAndRecord]] :param old_state_rdd: A previous streaming BTS state RDD as Tuple[Identity, Streaming BTS ...
[ "Executes", "Blurr", "BTS", "with", "the", "given", "records", ".", "old_state_rdd", "can", "be", "provided", "to", "load", "an", "older", "state", "from", "a", "previous", "run", "." ]
train
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/runner/spark_runner.py#L80-L93
productml/blurr
blurr/runner/spark_runner.py
SparkRunner.get_record_rdd_from_json_files
def get_record_rdd_from_json_files(self, json_files: List[str], data_processor: DataProcessor = SimpleJsonDataProcessor(), spark_session: Optional['SparkSession'] = None) -> 'RDD': """ Re...
python
def get_record_rdd_from_json_files(self, json_files: List[str], data_processor: DataProcessor = SimpleJsonDataProcessor(), spark_session: Optional['SparkSession'] = None) -> 'RDD': """ Re...
[ "def", "get_record_rdd_from_json_files", "(", "self", ",", "json_files", ":", "List", "[", "str", "]", ",", "data_processor", ":", "DataProcessor", "=", "SimpleJsonDataProcessor", "(", ")", ",", "spark_session", ":", "Optional", "[", "'SparkSession'", "]", "=", ...
Reads the data from the given json_files path and converts them into the `Record`s format for processing. `data_processor` is used to process the per event data in those files to convert them into `Record`. :param json_files: List of json file paths. Regular Spark path wildcards are accepted. ...
[ "Reads", "the", "data", "from", "the", "given", "json_files", "path", "and", "converts", "them", "into", "the", "Record", "s", "format", "for", "processing", ".", "data_processor", "is", "used", "to", "process", "the", "per", "event", "data", "in", "those", ...
train
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/runner/spark_runner.py#L95-L115
productml/blurr
blurr/runner/spark_runner.py
SparkRunner.get_record_rdd_from_rdd
def get_record_rdd_from_rdd( self, rdd: 'RDD', data_processor: DataProcessor = SimpleDictionaryDataProcessor(), ) -> 'RDD': """ Converts a RDD of raw events into the `Record`s format for processing. `data_processor` is used to process the per row data to c...
python
def get_record_rdd_from_rdd( self, rdd: 'RDD', data_processor: DataProcessor = SimpleDictionaryDataProcessor(), ) -> 'RDD': """ Converts a RDD of raw events into the `Record`s format for processing. `data_processor` is used to process the per row data to c...
[ "def", "get_record_rdd_from_rdd", "(", "self", ",", "rdd", ":", "'RDD'", ",", "data_processor", ":", "DataProcessor", "=", "SimpleDictionaryDataProcessor", "(", ")", ",", ")", "->", "'RDD'", ":", "return", "rdd", ".", "mapPartitions", "(", "lambda", "x", ":", ...
Converts a RDD of raw events into the `Record`s format for processing. `data_processor` is used to process the per row data to convert them into `Record`. :param rdd: RDD containing the raw events. :param data_processor: `DataProcessor` to process each row in the given `rdd`. :return: R...
[ "Converts", "a", "RDD", "of", "raw", "events", "into", "the", "Record", "s", "format", "for", "processing", ".", "data_processor", "is", "used", "to", "process", "the", "per", "row", "data", "to", "convert", "them", "into", "Record", "." ]
train
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/runner/spark_runner.py#L117-L132
productml/blurr
blurr/runner/spark_runner.py
SparkRunner.write_output_file
def write_output_file(self, path: str, per_identity_data: 'RDD', spark_session: Optional['SparkSession'] = None) -> None: """ Basic helper function to persist data to disk. If window BTS was provided then the window B...
python
def write_output_file(self, path: str, per_identity_data: 'RDD', spark_session: Optional['SparkSession'] = None) -> None: """ Basic helper function to persist data to disk. If window BTS was provided then the window B...
[ "def", "write_output_file", "(", "self", ",", "path", ":", "str", ",", "per_identity_data", ":", "'RDD'", ",", "spark_session", ":", "Optional", "[", "'SparkSession'", "]", "=", "None", ")", "->", "None", ":", "_spark_session_", "=", "get_spark_session", "(", ...
Basic helper function to persist data to disk. If window BTS was provided then the window BTS output to written in csv format, otherwise, the streaming BTS output is written in JSON format to the `path` provided :param path: Path where the output should be written. :param per_identity_...
[ "Basic", "helper", "function", "to", "persist", "data", "to", "disk", "." ]
train
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/runner/spark_runner.py#L134-L158
productml/blurr
blurr/runner/spark_runner.py
SparkRunner.print_output
def print_output(self, per_identity_data: 'RDD') -> None: """ Basic helper function to write data to stdout. If window BTS was provided then the window BTS output is written, otherwise, the streaming BTS output is written to stdout. WARNING - For large datasets this will be extremely sl...
python
def print_output(self, per_identity_data: 'RDD') -> None: """ Basic helper function to write data to stdout. If window BTS was provided then the window BTS output is written, otherwise, the streaming BTS output is written to stdout. WARNING - For large datasets this will be extremely sl...
[ "def", "print_output", "(", "self", ",", "per_identity_data", ":", "'RDD'", ")", "->", "None", ":", "if", "not", "self", ".", "_window_bts", ":", "data", "=", "per_identity_data", ".", "flatMap", "(", "lambda", "x", ":", "[", "json", ".", "dumps", "(", ...
Basic helper function to write data to stdout. If window BTS was provided then the window BTS output is written, otherwise, the streaming BTS output is written to stdout. WARNING - For large datasets this will be extremely slow. :param per_identity_data: Output of the `execute()` call.
[ "Basic", "helper", "function", "to", "write", "data", "to", "stdout", ".", "If", "window", "BTS", "was", "provided", "then", "the", "window", "BTS", "output", "is", "written", "otherwise", "the", "streaming", "BTS", "output", "is", "written", "to", "stdout",...
train
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/runner/spark_runner.py#L160-L177
shin-/dockerpy-creds
dockerpycreds/utils.py
find_executable
def find_executable(executable, path=None): """ As distutils.spawn.find_executable, but on Windows, look up every extension declared in PATHEXT instead of just `.exe` """ if sys.platform != 'win32': return distutils.spawn.find_executable(executable, path) if path is None: path =...
python
def find_executable(executable, path=None): """ As distutils.spawn.find_executable, but on Windows, look up every extension declared in PATHEXT instead of just `.exe` """ if sys.platform != 'win32': return distutils.spawn.find_executable(executable, path) if path is None: path =...
[ "def", "find_executable", "(", "executable", ",", "path", "=", "None", ")", ":", "if", "sys", ".", "platform", "!=", "'win32'", ":", "return", "distutils", ".", "spawn", ".", "find_executable", "(", "executable", ",", "path", ")", "if", "path", "is", "No...
As distutils.spawn.find_executable, but on Windows, look up every extension declared in PATHEXT instead of just `.exe`
[ "As", "distutils", ".", "spawn", ".", "find_executable", "but", "on", "Windows", "look", "up", "every", "extension", "declared", "in", "PATHEXT", "instead", "of", "just", ".", "exe" ]
train
https://github.com/shin-/dockerpy-creds/blob/9c0b66d2e445a838e1518f2c3273df7ddc7ec0d4/dockerpycreds/utils.py#L6-L29
shin-/dockerpy-creds
dockerpycreds/utils.py
create_environment_dict
def create_environment_dict(overrides): """ Create and return a copy of os.environ with the specified overrides """ result = os.environ.copy() result.update(overrides or {}) return result
python
def create_environment_dict(overrides): """ Create and return a copy of os.environ with the specified overrides """ result = os.environ.copy() result.update(overrides or {}) return result
[ "def", "create_environment_dict", "(", "overrides", ")", ":", "result", "=", "os", ".", "environ", ".", "copy", "(", ")", "result", ".", "update", "(", "overrides", "or", "{", "}", ")", "return", "result" ]
Create and return a copy of os.environ with the specified overrides
[ "Create", "and", "return", "a", "copy", "of", "os", ".", "environ", "with", "the", "specified", "overrides" ]
train
https://github.com/shin-/dockerpy-creds/blob/9c0b66d2e445a838e1518f2c3273df7ddc7ec0d4/dockerpycreds/utils.py#L32-L38
shin-/dockerpy-creds
dockerpycreds/store.py
Store.get
def get(self, server): """ Retrieve credentials for `server`. If no credentials are found, a `StoreError` will be raised. """ if not isinstance(server, six.binary_type): server = server.encode('utf-8') data = self._execute('get', server) result = json.load...
python
def get(self, server): """ Retrieve credentials for `server`. If no credentials are found, a `StoreError` will be raised. """ if not isinstance(server, six.binary_type): server = server.encode('utf-8') data = self._execute('get', server) result = json.load...
[ "def", "get", "(", "self", ",", "server", ")", ":", "if", "not", "isinstance", "(", "server", ",", "six", ".", "binary_type", ")", ":", "server", "=", "server", ".", "encode", "(", "'utf-8'", ")", "data", "=", "self", ".", "_execute", "(", "'get'", ...
Retrieve credentials for `server`. If no credentials are found, a `StoreError` will be raised.
[ "Retrieve", "credentials", "for", "server", ".", "If", "no", "credentials", "are", "found", "a", "StoreError", "will", "be", "raised", "." ]
train
https://github.com/shin-/dockerpy-creds/blob/9c0b66d2e445a838e1518f2c3273df7ddc7ec0d4/dockerpycreds/store.py#L29-L47
shin-/dockerpy-creds
dockerpycreds/store.py
Store.store
def store(self, server, username, secret): """ Store credentials for `server`. Raises a `StoreError` if an error occurs. """ data_input = json.dumps({ 'ServerURL': server, 'Username': username, 'Secret': secret }).encode('utf-8') re...
python
def store(self, server, username, secret): """ Store credentials for `server`. Raises a `StoreError` if an error occurs. """ data_input = json.dumps({ 'ServerURL': server, 'Username': username, 'Secret': secret }).encode('utf-8') re...
[ "def", "store", "(", "self", ",", "server", ",", "username", ",", "secret", ")", ":", "data_input", "=", "json", ".", "dumps", "(", "{", "'ServerURL'", ":", "server", ",", "'Username'", ":", "username", ",", "'Secret'", ":", "secret", "}", ")", ".", ...
Store credentials for `server`. Raises a `StoreError` if an error occurs.
[ "Store", "credentials", "for", "server", ".", "Raises", "a", "StoreError", "if", "an", "error", "occurs", "." ]
train
https://github.com/shin-/dockerpy-creds/blob/9c0b66d2e445a838e1518f2c3273df7ddc7ec0d4/dockerpycreds/store.py#L49-L58
shin-/dockerpy-creds
dockerpycreds/store.py
Store.erase
def erase(self, server): """ Erase credentials for `server`. Raises a `StoreError` if an error occurs. """ if not isinstance(server, six.binary_type): server = server.encode('utf-8') self._execute('erase', server)
python
def erase(self, server): """ Erase credentials for `server`. Raises a `StoreError` if an error occurs. """ if not isinstance(server, six.binary_type): server = server.encode('utf-8') self._execute('erase', server)
[ "def", "erase", "(", "self", ",", "server", ")", ":", "if", "not", "isinstance", "(", "server", ",", "six", ".", "binary_type", ")", ":", "server", "=", "server", ".", "encode", "(", "'utf-8'", ")", "self", ".", "_execute", "(", "'erase'", ",", "serv...
Erase credentials for `server`. Raises a `StoreError` if an error occurs.
[ "Erase", "credentials", "for", "server", ".", "Raises", "a", "StoreError", "if", "an", "error", "occurs", "." ]
train
https://github.com/shin-/dockerpy-creds/blob/9c0b66d2e445a838e1518f2c3273df7ddc7ec0d4/dockerpycreds/store.py#L60-L66
productml/blurr
blurr/core/transformer_streaming.py
StreamingTransformerSchema.get_identity
def get_identity(self, record: Record) -> str: """ Evaluates and returns the identity as specified in the schema. :param record: Record which is used to determine the identity. :return: The evaluated identity :raises: IdentityError if identity cannot be determined. """ ...
python
def get_identity(self, record: Record) -> str: """ Evaluates and returns the identity as specified in the schema. :param record: Record which is used to determine the identity. :return: The evaluated identity :raises: IdentityError if identity cannot be determined. """ ...
[ "def", "get_identity", "(", "self", ",", "record", ":", "Record", ")", "->", "str", ":", "context", "=", "self", ".", "schema_context", ".", "context", "context", ".", "add_record", "(", "record", ")", "identity", "=", "self", ".", "identity", ".", "eval...
Evaluates and returns the identity as specified in the schema. :param record: Record which is used to determine the identity. :return: The evaluated identity :raises: IdentityError if identity cannot be determined.
[ "Evaluates", "and", "returns", "the", "identity", "as", "specified", "in", "the", "schema", ".", ":", "param", "record", ":", "Record", "which", "is", "used", "to", "determine", "the", "identity", ".", ":", "return", ":", "The", "evaluated", "identity", ":...
train
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/transformer_streaming.py#L29-L43
productml/blurr
blurr/core/transformer_streaming.py
StreamingTransformer.run_evaluate
def run_evaluate(self, record: Record): """ Evaluates and updates data in the StreamingTransformer. :param record: The 'source' record used for the update. :raises: IdentityError if identity is different from the one used during initialization. """ record_identity...
python
def run_evaluate(self, record: Record): """ Evaluates and updates data in the StreamingTransformer. :param record: The 'source' record used for the update. :raises: IdentityError if identity is different from the one used during initialization. """ record_identity...
[ "def", "run_evaluate", "(", "self", ",", "record", ":", "Record", ")", ":", "record_identity", "=", "self", ".", "_schema", ".", "get_identity", "(", "record", ")", "if", "self", ".", "_identity", "!=", "record_identity", ":", "raise", "IdentityError", "(", ...
Evaluates and updates data in the StreamingTransformer. :param record: The 'source' record used for the update. :raises: IdentityError if identity is different from the one used during initialization.
[ "Evaluates", "and", "updates", "data", "in", "the", "StreamingTransformer", ".", ":", "param", "record", ":", "The", "source", "record", "used", "for", "the", "update", ".", ":", "raises", ":", "IdentityError", "if", "identity", "is", "different", "from", "t...
train
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/transformer_streaming.py#L65-L88
productml/blurr
blurr/core/aggregate.py
AggregateSchema.extend_schema_spec
def extend_schema_spec(self) -> None: """ Injects the identity field """ super().extend_schema_spec() identity_field = { 'Name': '_identity', 'Type': BtsType.STRING, 'Value': 'identity', ATTRIBUTE_INTERNAL: True } if self.ATTRIBUT...
python
def extend_schema_spec(self) -> None: """ Injects the identity field """ super().extend_schema_spec() identity_field = { 'Name': '_identity', 'Type': BtsType.STRING, 'Value': 'identity', ATTRIBUTE_INTERNAL: True } if self.ATTRIBUT...
[ "def", "extend_schema_spec", "(", "self", ")", "->", "None", ":", "super", "(", ")", ".", "extend_schema_spec", "(", ")", "identity_field", "=", "{", "'Name'", ":", "'_identity'", ",", "'Type'", ":", "BtsType", ".", "STRING", ",", "'Value'", ":", "'identit...
Injects the identity field
[ "Injects", "the", "identity", "field" ]
train
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/aggregate.py#L38-L51
productml/blurr
blurr/core/aggregate.py
Aggregate._persist
def _persist(self) -> None: """ Persists the current data group """ if self._store: self._store.save(self._key, self._snapshot)
python
def _persist(self) -> None: """ Persists the current data group """ if self._store: self._store.save(self._key, self._snapshot)
[ "def", "_persist", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_store", ":", "self", ".", "_store", ".", "save", "(", "self", ".", "_key", ",", "self", ".", "_snapshot", ")" ]
Persists the current data group
[ "Persists", "the", "current", "data", "group" ]
train
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/aggregate.py#L97-L102
productml/blurr
blurr/core/schema_loader.py
SchemaLoader.add_schema_spec
def add_schema_spec(self, spec: Dict[str, Any], fully_qualified_parent_name: str = None) -> Optional[str]: """ Add a schema dictionary to the schema loader. The given schema is stored against fully_qualified_parent_name + ITEM_SEPARATOR('.') + schema.name. :param ...
python
def add_schema_spec(self, spec: Dict[str, Any], fully_qualified_parent_name: str = None) -> Optional[str]: """ Add a schema dictionary to the schema loader. The given schema is stored against fully_qualified_parent_name + ITEM_SEPARATOR('.') + schema.name. :param ...
[ "def", "add_schema_spec", "(", "self", ",", "spec", ":", "Dict", "[", "str", ",", "Any", "]", ",", "fully_qualified_parent_name", ":", "str", "=", "None", ")", "->", "Optional", "[", "str", "]", ":", "if", "not", "isinstance", "(", "spec", ",", "dict",...
Add a schema dictionary to the schema loader. The given schema is stored against fully_qualified_parent_name + ITEM_SEPARATOR('.') + schema.name. :param spec: Schema specification. :param fully_qualified_parent_name: Full qualified name of the parent. If None is passed then the schema is...
[ "Add", "a", "schema", "dictionary", "to", "the", "schema", "loader", ".", "The", "given", "schema", "is", "stored", "against", "fully_qualified_parent_name", "+", "ITEM_SEPARATOR", "(", ".", ")", "+", "schema", ".", "name", ".", ":", "param", "spec", ":", ...
train
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/schema_loader.py#L22-L58
productml/blurr
blurr/core/schema_loader.py
SchemaLoader.add_errors
def add_errors(self, *errors: Union[BaseSchemaError, SchemaErrorCollection]) -> None: """ Adds errors to the error store for the schema """ for error in errors: self._error_cache.add(error)
python
def add_errors(self, *errors: Union[BaseSchemaError, SchemaErrorCollection]) -> None: """ Adds errors to the error store for the schema """ for error in errors: self._error_cache.add(error)
[ "def", "add_errors", "(", "self", ",", "*", "errors", ":", "Union", "[", "BaseSchemaError", ",", "SchemaErrorCollection", "]", ")", "->", "None", ":", "for", "error", "in", "errors", ":", "self", ".", "_error_cache", ".", "add", "(", "error", ")" ]
Adds errors to the error store for the schema
[ "Adds", "errors", "to", "the", "error", "store", "for", "the", "schema" ]
train
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/schema_loader.py#L60-L63
productml/blurr
blurr/core/schema_loader.py
SchemaLoader.get_schema_object
def get_schema_object(self, fully_qualified_name: str) -> 'BaseSchema': """ Used to generate a schema object from the given fully_qualified_name. :param fully_qualified_name: The fully qualified name of the object needed. :return: An initialized schema object """ if full...
python
def get_schema_object(self, fully_qualified_name: str) -> 'BaseSchema': """ Used to generate a schema object from the given fully_qualified_name. :param fully_qualified_name: The fully qualified name of the object needed. :return: An initialized schema object """ if full...
[ "def", "get_schema_object", "(", "self", ",", "fully_qualified_name", ":", "str", ")", "->", "'BaseSchema'", ":", "if", "fully_qualified_name", "not", "in", "self", ".", "_schema_cache", ":", "spec", "=", "self", ".", "get_schema_spec", "(", "fully_qualified_name"...
Used to generate a schema object from the given fully_qualified_name. :param fully_qualified_name: The fully qualified name of the object needed. :return: An initialized schema object
[ "Used", "to", "generate", "a", "schema", "object", "from", "the", "given", "fully_qualified_name", ".", ":", "param", "fully_qualified_name", ":", "The", "fully", "qualified", "name", "of", "the", "object", "needed", ".", ":", "return", ":", "An", "initialized...
train
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/schema_loader.py#L80-L100
productml/blurr
blurr/core/schema_loader.py
SchemaLoader.get_store
def get_store(self, fully_qualified_name: str) -> Optional['Store']: """ Used to generate a store object from the given fully_qualified_name. :param fully_qualified_name: The fully qualified name of the store object needed. :return: An initialized store object """ if ful...
python
def get_store(self, fully_qualified_name: str) -> Optional['Store']: """ Used to generate a store object from the given fully_qualified_name. :param fully_qualified_name: The fully qualified name of the store object needed. :return: An initialized store object """ if ful...
[ "def", "get_store", "(", "self", ",", "fully_qualified_name", ":", "str", ")", "->", "Optional", "[", "'Store'", "]", ":", "if", "fully_qualified_name", "not", "in", "self", ".", "_store_cache", ":", "schema", "=", "self", ".", "get_schema_object", "(", "ful...
Used to generate a store object from the given fully_qualified_name. :param fully_qualified_name: The fully qualified name of the store object needed. :return: An initialized store object
[ "Used", "to", "generate", "a", "store", "object", "from", "the", "given", "fully_qualified_name", ".", ":", "param", "fully_qualified_name", ":", "The", "fully", "qualified", "name", "of", "the", "store", "object", "needed", ".", ":", "return", ":", "An", "i...
train
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/schema_loader.py#L102-L122
productml/blurr
blurr/core/schema_loader.py
SchemaLoader.get_nested_schema_object
def get_nested_schema_object(self, fully_qualified_parent_name: str, nested_item_name: str) -> Optional['BaseSchema']: """ Used to generate a schema object from the given fully_qualified_parent_name and the nested_item_name. :param fully_qualified_parent_...
python
def get_nested_schema_object(self, fully_qualified_parent_name: str, nested_item_name: str) -> Optional['BaseSchema']: """ Used to generate a schema object from the given fully_qualified_parent_name and the nested_item_name. :param fully_qualified_parent_...
[ "def", "get_nested_schema_object", "(", "self", ",", "fully_qualified_parent_name", ":", "str", ",", "nested_item_name", ":", "str", ")", "->", "Optional", "[", "'BaseSchema'", "]", ":", "return", "self", ".", "get_schema_object", "(", "self", ".", "get_fully_qual...
Used to generate a schema object from the given fully_qualified_parent_name and the nested_item_name. :param fully_qualified_parent_name: The fully qualified name of the parent. :param nested_item_name: The nested item name. :return: An initialized schema object of the nested item.
[ "Used", "to", "generate", "a", "schema", "object", "from", "the", "given", "fully_qualified_parent_name", "and", "the", "nested_item_name", ".", ":", "param", "fully_qualified_parent_name", ":", "The", "fully", "qualified", "name", "of", "the", "parent", ".", ":",...
train
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/schema_loader.py#L130-L140
productml/blurr
blurr/core/schema_loader.py
SchemaLoader.get_fully_qualified_name
def get_fully_qualified_name(fully_qualified_parent_name: str, nested_item_name: str) -> str: """ Returns the fully qualified name by combining the fully_qualified_parent_name and nested_item_name. :param fully_qualified_parent_name: The fully qualified name of the parent. :param...
python
def get_fully_qualified_name(fully_qualified_parent_name: str, nested_item_name: str) -> str: """ Returns the fully qualified name by combining the fully_qualified_parent_name and nested_item_name. :param fully_qualified_parent_name: The fully qualified name of the parent. :param...
[ "def", "get_fully_qualified_name", "(", "fully_qualified_parent_name", ":", "str", ",", "nested_item_name", ":", "str", ")", "->", "str", ":", "return", "fully_qualified_parent_name", "+", "SchemaLoader", ".", "ITEM_SEPARATOR", "+", "nested_item_name" ]
Returns the fully qualified name by combining the fully_qualified_parent_name and nested_item_name. :param fully_qualified_parent_name: The fully qualified name of the parent. :param nested_item_name: The nested item name. :return: The fully qualified name of the nested item.
[ "Returns", "the", "fully", "qualified", "name", "by", "combining", "the", "fully_qualified_parent_name", "and", "nested_item_name", ".", ":", "param", "fully_qualified_parent_name", ":", "The", "fully", "qualified", "name", "of", "the", "parent", ".", ":", "param", ...
train
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/schema_loader.py#L143-L151
productml/blurr
blurr/core/schema_loader.py
SchemaLoader.get_schema_spec
def get_schema_spec(self, fully_qualified_name: str) -> Dict[str, Any]: """ Used to retrieve the specifications of the schema from the given fully_qualified_name of schema. :param fully_qualified_name: The fully qualified name of the schema needed. :return: Schema dictionary. ...
python
def get_schema_spec(self, fully_qualified_name: str) -> Dict[str, Any]: """ Used to retrieve the specifications of the schema from the given fully_qualified_name of schema. :param fully_qualified_name: The fully qualified name of the schema needed. :return: Schema dictionary. ...
[ "def", "get_schema_spec", "(", "self", ",", "fully_qualified_name", ":", "str", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "if", "fully_qualified_name", "not", "in", "self", ".", "_spec_cache", ":", "self", ".", "add_errors", "(", "SpecNotFoundErro...
Used to retrieve the specifications of the schema from the given fully_qualified_name of schema. :param fully_qualified_name: The fully qualified name of the schema needed. :return: Schema dictionary.
[ "Used", "to", "retrieve", "the", "specifications", "of", "the", "schema", "from", "the", "given", "fully_qualified_name", "of", "schema", ".", ":", "param", "fully_qualified_name", ":", "The", "fully", "qualified", "name", "of", "the", "schema", "needed", ".", ...
train
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/schema_loader.py#L153-L164
productml/blurr
blurr/core/schema_loader.py
SchemaLoader.get_schema_specs_of_type
def get_schema_specs_of_type(self, *schema_types: Type) -> Dict[str, Dict[str, Any]]: """ Returns a list of fully qualified names and schema dictionary tuples for the schema types provided. :param schema_types: Schema types. :return: List of fully qualified names and schema dicti...
python
def get_schema_specs_of_type(self, *schema_types: Type) -> Dict[str, Dict[str, Any]]: """ Returns a list of fully qualified names and schema dictionary tuples for the schema types provided. :param schema_types: Schema types. :return: List of fully qualified names and schema dicti...
[ "def", "get_schema_specs_of_type", "(", "self", ",", "*", "schema_types", ":", "Type", ")", "->", "Dict", "[", "str", ",", "Dict", "[", "str", ",", "Any", "]", "]", ":", "return", "{", "fq_name", ":", "schema", "for", "fq_name", ",", "schema", "in", ...
Returns a list of fully qualified names and schema dictionary tuples for the schema types provided. :param schema_types: Schema types. :return: List of fully qualified names and schema dictionary tuples.
[ "Returns", "a", "list", "of", "fully", "qualified", "names", "and", "schema", "dictionary", "tuples", "for", "the", "schema", "types", "provided", ".", ":", "param", "schema_types", ":", "Schema", "types", ".", ":", "return", ":", "List", "of", "fully", "q...
train
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/schema_loader.py#L175-L187
productml/blurr
blurr/core/evaluation.py
EvaluationContext.global_add
def global_add(self, key: str, value: Any) -> None: """ Adds a key and value to the global dictionary """ self.global_context[key] = value
python
def global_add(self, key: str, value: Any) -> None: """ Adds a key and value to the global dictionary """ self.global_context[key] = value
[ "def", "global_add", "(", "self", ",", "key", ":", "str", ",", "value", ":", "Any", ")", "->", "None", ":", "self", ".", "global_context", "[", "key", "]", "=", "value" ]
Adds a key and value to the global dictionary
[ "Adds", "a", "key", "and", "value", "to", "the", "global", "dictionary" ]
train
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/evaluation.py#L68-L72
productml/blurr
blurr/core/evaluation.py
EvaluationContext.merge
def merge(self, evaluation_context: 'EvaluationContext') -> None: """ Merges the provided evaluation context to the current evaluation context. :param evaluation_context: Evaluation context to merge. """ self.global_context.merge(evaluation_context.global_context) self.lo...
python
def merge(self, evaluation_context: 'EvaluationContext') -> None: """ Merges the provided evaluation context to the current evaluation context. :param evaluation_context: Evaluation context to merge. """ self.global_context.merge(evaluation_context.global_context) self.lo...
[ "def", "merge", "(", "self", ",", "evaluation_context", ":", "'EvaluationContext'", ")", "->", "None", ":", "self", ".", "global_context", ".", "merge", "(", "evaluation_context", ".", "global_context", ")", "self", ".", "local_context", ".", "merge", "(", "ev...
Merges the provided evaluation context to the current evaluation context. :param evaluation_context: Evaluation context to merge.
[ "Merges", "the", "provided", "evaluation", "context", "to", "the", "current", "evaluation", "context", ".", ":", "param", "evaluation_context", ":", "Evaluation", "context", "to", "merge", "." ]
train
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/evaluation.py#L91-L97
productml/blurr
blurr/core/evaluation.py
Expression.evaluate
def evaluate(self, evaluation_context: EvaluationContext) -> Any: """ Evaluates the expression with the context provided. If the execution results in failure, an ExpressionEvaluationException encapsulating the underlying exception is raised. :param evaluation_context: Global and...
python
def evaluate(self, evaluation_context: EvaluationContext) -> Any: """ Evaluates the expression with the context provided. If the execution results in failure, an ExpressionEvaluationException encapsulating the underlying exception is raised. :param evaluation_context: Global and...
[ "def", "evaluate", "(", "self", ",", "evaluation_context", ":", "EvaluationContext", ")", "->", "Any", ":", "try", ":", "if", "self", ".", "type", "==", "ExpressionType", ".", "EVAL", ":", "return", "eval", "(", "self", ".", "code_object", ",", "evaluation...
Evaluates the expression with the context provided. If the execution results in failure, an ExpressionEvaluationException encapsulating the underlying exception is raised. :param evaluation_context: Global and local context dictionary to be passed for evaluation
[ "Evaluates", "the", "expression", "with", "the", "context", "provided", ".", "If", "the", "execution", "results", "in", "failure", "an", "ExpressionEvaluationException", "encapsulating", "the", "underlying", "exception", "is", "raised", ".", ":", "param", "evaluatio...
train
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/evaluation.py#L120-L149
openclimatedata/pymagicc
pymagicc/core.py
_copy_files
def _copy_files(source, target): """ Copy all the files in source directory to target. Ignores subdirectories. """ source_files = listdir(source) if not exists(target): makedirs(target) for filename in source_files: full_filename = join(source, filename) if isfile(fu...
python
def _copy_files(source, target): """ Copy all the files in source directory to target. Ignores subdirectories. """ source_files = listdir(source) if not exists(target): makedirs(target) for filename in source_files: full_filename = join(source, filename) if isfile(fu...
[ "def", "_copy_files", "(", "source", ",", "target", ")", ":", "source_files", "=", "listdir", "(", "source", ")", "if", "not", "exists", "(", "target", ")", ":", "makedirs", "(", "target", ")", "for", "filename", "in", "source_files", ":", "full_filename",...
Copy all the files in source directory to target. Ignores subdirectories.
[ "Copy", "all", "the", "files", "in", "source", "directory", "to", "target", "." ]
train
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L35-L47
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.create_copy
def create_copy(self): """ Initialises a temporary directory structure and copy of MAGICC configuration files and binary. """ if self.executable is None or not isfile(self.executable): raise FileNotFoundError( "Could not find MAGICC{} executable: {}".f...
python
def create_copy(self): """ Initialises a temporary directory structure and copy of MAGICC configuration files and binary. """ if self.executable is None or not isfile(self.executable): raise FileNotFoundError( "Could not find MAGICC{} executable: {}".f...
[ "def", "create_copy", "(", "self", ")", ":", "if", "self", ".", "executable", "is", "None", "or", "not", "isfile", "(", "self", ".", "executable", ")", ":", "raise", "FileNotFoundError", "(", "\"Could not find MAGICC{} executable: {}\"", ".", "format", "(", "s...
Initialises a temporary directory structure and copy of MAGICC configuration files and binary.
[ "Initialises", "a", "temporary", "directory", "structure", "and", "copy", "of", "MAGICC", "configuration", "files", "and", "binary", "." ]
train
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L105-L148
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.run
def run(self, scenario=None, only=None, **kwargs): """ Run MAGICC and parse the output. 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 `...
python
def run(self, scenario=None, only=None, **kwargs): """ Run MAGICC and parse the output. 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 `...
[ "def", "run", "(", "self", ",", "scenario", "=", "None", ",", "only", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "exists", "(", "self", ".", "root_dir", ")", ":", "raise", "FileNotFoundError", "(", "self", ".", "root_dir", ")", "i...
Run MAGICC and parse the output. 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. Parameters ---------...
[ "Run", "MAGICC", "and", "parse", "the", "output", "." ]
train
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L170-L274
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.check_config
def check_config(self): """Check that our MAGICC ``.CFG`` files are set to safely work with PYMAGICC For further detail about why this is required, please see :ref:`MAGICC flags`. Raises ------ ValueError If we are not certain that the config written by PYMAGICC wil...
python
def check_config(self): """Check that our MAGICC ``.CFG`` files are set to safely work with PYMAGICC For further detail about why this is required, please see :ref:`MAGICC flags`. Raises ------ ValueError If we are not certain that the config written by PYMAGICC wil...
[ "def", "check_config", "(", "self", ")", ":", "cfg_error_msg", "=", "(", "\"PYMAGICC is not the only tuning model that will be used by \"", "\"`MAGCFG_USER.CFG`: your run is likely to fail/do odd things\"", ")", "emisscen_error_msg", "=", "(", "\"You have more than one `FILE_EMISSCEN_X...
Check that our MAGICC ``.CFG`` files are set to safely work with PYMAGICC For further detail about why this is required, please see :ref:`MAGICC flags`. Raises ------ ValueError If we are not certain that the config written by PYMAGICC will overwrite all other c...
[ "Check", "that", "our", "MAGICC", ".", "CFG", "files", "are", "set", "to", "safely", "work", "with", "PYMAGICC" ]
train
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L293-L331
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.write
def write(self, mdata, name): """Write an input file to disk Parameters ---------- mdata : :obj:`pymagicc.io.MAGICCData` A MAGICCData instance with the data to write name : str The name of the file to write. The file will be written to the MAGICC ...
python
def write(self, mdata, name): """Write an input file to disk Parameters ---------- mdata : :obj:`pymagicc.io.MAGICCData` A MAGICCData instance with the data to write name : str The name of the file to write. The file will be written to the MAGICC ...
[ "def", "write", "(", "self", ",", "mdata", ",", "name", ")", ":", "mdata", ".", "write", "(", "join", "(", "self", ".", "run_dir", ",", "name", ")", ",", "self", ".", "version", ")" ]
Write an input file to disk Parameters ---------- mdata : :obj:`pymagicc.io.MAGICCData` A MAGICCData instance with the data to write name : str The name of the file to write. The file will be written to the MAGICC instance's run directory i.e. ``self...
[ "Write", "an", "input", "file", "to", "disk" ]
train
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L333-L345
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.read_parameters
def read_parameters(self): """ Read a parameters.out file Returns ------- dict A dictionary containing all the configuration used by MAGICC """ param_fname = join(self.out_dir, "PARAMETERS.OUT") if not exists(param_fname): raise F...
python
def read_parameters(self): """ Read a parameters.out file Returns ------- dict A dictionary containing all the configuration used by MAGICC """ param_fname = join(self.out_dir, "PARAMETERS.OUT") if not exists(param_fname): raise F...
[ "def", "read_parameters", "(", "self", ")", ":", "param_fname", "=", "join", "(", "self", ".", "out_dir", ",", "\"PARAMETERS.OUT\"", ")", "if", "not", "exists", "(", "param_fname", ")", ":", "raise", "FileNotFoundError", "(", "\"No PARAMETERS.OUT found\"", ")", ...
Read a parameters.out file Returns ------- dict A dictionary containing all the configuration used by MAGICC
[ "Read", "a", "parameters", ".", "out", "file" ]
train
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L347-L369
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.remove_temp_copy
def remove_temp_copy(self): """ Removes a temporary copy of the MAGICC version shipped with Pymagicc. """ if self.is_temp and self.root_dir is not None: shutil.rmtree(self.root_dir) self.root_dir = None
python
def remove_temp_copy(self): """ Removes a temporary copy of the MAGICC version shipped with Pymagicc. """ if self.is_temp and self.root_dir is not None: shutil.rmtree(self.root_dir) self.root_dir = None
[ "def", "remove_temp_copy", "(", "self", ")", ":", "if", "self", ".", "is_temp", "and", "self", ".", "root_dir", "is", "not", "None", ":", "shutil", ".", "rmtree", "(", "self", ".", "root_dir", ")", "self", ".", "root_dir", "=", "None" ]
Removes a temporary copy of the MAGICC version shipped with Pymagicc.
[ "Removes", "a", "temporary", "copy", "of", "the", "MAGICC", "version", "shipped", "with", "Pymagicc", "." ]
train
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L371-L377
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.set_config
def set_config( self, filename="MAGTUNE_PYMAGICC.CFG", top_level_key="nml_allcfgs", **kwargs ): """ Create a configuration file for MAGICC. Writes a fortran namelist in run_dir. Parameters ---------- filename : str Name of configuration file to w...
python
def set_config( self, filename="MAGTUNE_PYMAGICC.CFG", top_level_key="nml_allcfgs", **kwargs ): """ Create a configuration file for MAGICC. Writes a fortran namelist in run_dir. Parameters ---------- filename : str Name of configuration file to w...
[ "def", "set_config", "(", "self", ",", "filename", "=", "\"MAGTUNE_PYMAGICC.CFG\"", ",", "top_level_key", "=", "\"nml_allcfgs\"", ",", "*", "*", "kwargs", ")", ":", "kwargs", "=", "self", ".", "_format_config", "(", "kwargs", ")", "fname", "=", "join", "(", ...
Create a configuration file for MAGICC. Writes a fortran namelist in run_dir. Parameters ---------- filename : str Name of configuration file to write top_level_key : str Name of namelist to be written in the configuration file kwar...
[ "Create", "a", "configuration", "file", "for", "MAGICC", "." ]
train
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L379-L411
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.update_config
def update_config( self, filename="MAGTUNE_PYMAGICC.CFG", top_level_key="nml_allcfgs", **kwargs ): """Updates a configuration file for MAGICC Updates the contents of a fortran namelist in the run directory, creating a new namelist if none exists. Parameters --------...
python
def update_config( self, filename="MAGTUNE_PYMAGICC.CFG", top_level_key="nml_allcfgs", **kwargs ): """Updates a configuration file for MAGICC Updates the contents of a fortran namelist in the run directory, creating a new namelist if none exists. Parameters --------...
[ "def", "update_config", "(", "self", ",", "filename", "=", "\"MAGTUNE_PYMAGICC.CFG\"", ",", "top_level_key", "=", "\"nml_allcfgs\"", ",", "*", "*", "kwargs", ")", ":", "kwargs", "=", "self", ".", "_format_config", "(", "kwargs", ")", "fname", "=", "join", "(...
Updates a configuration file for MAGICC Updates the contents of a fortran namelist in the run directory, creating a new namelist if none exists. Parameters ---------- filename : str Name of configuration file to write top_level_key : str Name of...
[ "Updates", "a", "configuration", "file", "for", "MAGICC" ]
train
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L413-L450
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.set_zero_config
def set_zero_config(self): """Set config such that radiative forcing and temperature output will be zero This method is intended as a convenience only, it does not handle everything in an obvious way. Adjusting the parameter settings still requires great care and may behave unepexctedly...
python
def set_zero_config(self): """Set config such that radiative forcing and temperature output will be zero This method is intended as a convenience only, it does not handle everything in an obvious way. Adjusting the parameter settings still requires great care and may behave unepexctedly...
[ "def", "set_zero_config", "(", "self", ")", ":", "# zero_emissions is imported from scenarios module", "zero_emissions", ".", "write", "(", "join", "(", "self", ".", "run_dir", ",", "self", ".", "_scen_file_name", ")", ",", "self", ".", "version", ")", "time", "...
Set config such that radiative forcing and temperature output will be zero This method is intended as a convenience only, it does not handle everything in an obvious way. Adjusting the parameter settings still requires great care and may behave unepexctedly.
[ "Set", "config", "such", "that", "radiative", "forcing", "and", "temperature", "output", "will", "be", "zero" ]
train
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L452-L574
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.set_years
def set_years(self, startyear=1765, endyear=2100): """ Set the start and end dates of the simulations. Parameters ---------- startyear : int Start year of the simulation endyear : int End year of the simulation Returns ------- ...
python
def set_years(self, startyear=1765, endyear=2100): """ Set the start and end dates of the simulations. Parameters ---------- startyear : int Start year of the simulation endyear : int End year of the simulation Returns ------- ...
[ "def", "set_years", "(", "self", ",", "startyear", "=", "1765", ",", "endyear", "=", "2100", ")", ":", "# TODO: test altering stepsperyear, I think 1, 2 and 24 should all work", "return", "self", ".", "set_config", "(", "\"MAGCFG_NMLYEARS.CFG\"", ",", "\"nml_years\"", "...
Set the start and end dates of the simulations. Parameters ---------- startyear : int Start year of the simulation endyear : int End year of the simulation Returns ------- dict The contents of the namelist
[ "Set", "the", "start", "and", "end", "dates", "of", "the", "simulations", "." ]
train
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L606-L630
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.set_output_variables
def set_output_variables(self, write_ascii=True, write_binary=False, **kwargs): """Set the output configuration, minimising output as much as possible There are a number of configuration parameters which control which variables are written to file and in which format. Limiting the variables tha...
python
def set_output_variables(self, write_ascii=True, write_binary=False, **kwargs): """Set the output configuration, minimising output as much as possible There are a number of configuration parameters which control which variables are written to file and in which format. Limiting the variables tha...
[ "def", "set_output_variables", "(", "self", ",", "write_ascii", "=", "True", ",", "write_binary", "=", "False", ",", "*", "*", "kwargs", ")", ":", "assert", "(", "write_ascii", "or", "write_binary", ")", ",", "\"write_binary and/or write_ascii must be configured\"",...
Set the output configuration, minimising output as much as possible There are a number of configuration parameters which control which variables are written to file and in which format. Limiting the variables that are written to file can greatly speed up the running of MAGICC. By default, ...
[ "Set", "the", "output", "configuration", "minimising", "output", "as", "much", "as", "possible" ]
train
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L632-L735
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.diagnose_tcr_ecs
def diagnose_tcr_ecs(self, **kwargs): """Diagnose TCR and ECS The transient climate response (TCR), is the global-mean temperature response at time at which atmopsheric |CO2| concentrations double in a scenario where atmospheric |CO2| concentrations are increased at 1% per year from ...
python
def diagnose_tcr_ecs(self, **kwargs): """Diagnose TCR and ECS The transient climate response (TCR), is the global-mean temperature response at time at which atmopsheric |CO2| concentrations double in a scenario where atmospheric |CO2| concentrations are increased at 1% per year from ...
[ "def", "diagnose_tcr_ecs", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "version", "==", "7", ":", "raise", "NotImplementedError", "(", "\"MAGICC7 cannot yet diagnose ECS and TCR\"", ")", "self", ".", "_diagnose_tcr_ecs_config_setup", "(", "*...
Diagnose TCR and ECS The transient climate response (TCR), is the global-mean temperature response at time at which atmopsheric |CO2| concentrations double in a scenario where atmospheric |CO2| concentrations are increased at 1% per year from pre-industrial levels. The equilibr...
[ "Diagnose", "TCR", "and", "ECS" ]
train
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L740-L783
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.set_emission_scenario_setup
def set_emission_scenario_setup(self, scenario, config_dict): """Set the emissions flags correctly. Parameters ---------- scenario : :obj:`pymagicc.io.MAGICCData` Scenario to run. config_dict : dict Dictionary with current input configurations which is t...
python
def set_emission_scenario_setup(self, scenario, config_dict): """Set the emissions flags correctly. Parameters ---------- scenario : :obj:`pymagicc.io.MAGICCData` Scenario to run. config_dict : dict Dictionary with current input configurations which is t...
[ "def", "set_emission_scenario_setup", "(", "self", ",", "scenario", ",", "config_dict", ")", ":", "self", ".", "write", "(", "scenario", ",", "self", ".", "_scen_file_name", ")", "# can be lazy in this line as fix backwards key handles errors for us", "config_dict", "[", ...
Set the emissions flags correctly. Parameters ---------- scenario : :obj:`pymagicc.io.MAGICCData` Scenario to run. config_dict : dict Dictionary with current input configurations which is to be validated and updated where necessary. Returns ...
[ "Set", "the", "emissions", "flags", "correctly", "." ]
train
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L903-L925
productml/blurr
blurr/core/type.py
Type.contains
def contains(value: Union[str, 'Type']) -> bool: """ Checks if a type is defined """ if isinstance(value, str): return any(value.lower() == i.value for i in Type) return any(value == i for i in Type)
python
def contains(value: Union[str, 'Type']) -> bool: """ Checks if a type is defined """ if isinstance(value, str): return any(value.lower() == i.value for i in Type) return any(value == i for i in Type)
[ "def", "contains", "(", "value", ":", "Union", "[", "str", ",", "'Type'", "]", ")", "->", "bool", ":", "if", "isinstance", "(", "value", ",", "str", ")", ":", "return", "any", "(", "value", ".", "lower", "(", ")", "==", "i", ".", "value", "for", ...
Checks if a type is defined
[ "Checks", "if", "a", "type", "is", "defined" ]
train
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/type.py#L48-L53
hydpy-dev/hydpy
hydpy/exe/replacetools.py
xml_replace
def xml_replace(filename, **replacements): """Read the content of an XML template file (XMLT), apply the given `replacements` to its substitution markers, and write the result into an XML file with the same name but ending with `xml` instead of `xmlt`. First, we write an XMLT file, containing a regula...
python
def xml_replace(filename, **replacements): """Read the content of an XML template file (XMLT), apply the given `replacements` to its substitution markers, and write the result into an XML file with the same name but ending with `xml` instead of `xmlt`. First, we write an XMLT file, containing a regula...
[ "def", "xml_replace", "(", "filename", ",", "*", "*", "replacements", ")", ":", "keywords", "=", "set", "(", "replacements", ".", "keys", "(", ")", ")", "templatename", "=", "f'{filename}.xmlt'", "targetname", "=", "f'{filename}.xml'", "print", "(", "f'templat...
Read the content of an XML template file (XMLT), apply the given `replacements` to its substitution markers, and write the result into an XML file with the same name but ending with `xml` instead of `xmlt`. First, we write an XMLT file, containing a regular HTML comment, a readily defined element `e1`...
[ "Read", "the", "content", "of", "an", "XML", "template", "file", "(", "XMLT", ")", "apply", "the", "given", "replacements", "to", "its", "substitution", "markers", "and", "write", "the", "result", "into", "an", "XML", "file", "with", "the", "same", "name",...
train
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/exe/replacetools.py#L9-L211
hydpy-dev/hydpy
hydpy/core/indextools.py
IndexerProperty._calcidxs
def _calcidxs(func): """Return the required indexes based on the given lambda function and the |Timegrids| object handled by module |pub|. Raise a |RuntimeError| if the latter is not available. """ timegrids = hydpy.pub.get('timegrids') if timegrids is None: ...
python
def _calcidxs(func): """Return the required indexes based on the given lambda function and the |Timegrids| object handled by module |pub|. Raise a |RuntimeError| if the latter is not available. """ timegrids = hydpy.pub.get('timegrids') if timegrids is None: ...
[ "def", "_calcidxs", "(", "func", ")", ":", "timegrids", "=", "hydpy", ".", "pub", ".", "get", "(", "'timegrids'", ")", "if", "timegrids", "is", "None", ":", "raise", "RuntimeError", "(", "'An Indexer object has been asked for an %s array. Such an '", "'array has ne...
Return the required indexes based on the given lambda function and the |Timegrids| object handled by module |pub|. Raise a |RuntimeError| if the latter is not available.
[ "Return", "the", "required", "indexes", "based", "on", "the", "given", "lambda", "function", "and", "the", "|Timegrids|", "object", "handled", "by", "module", "|pub|", ".", "Raise", "a", "|RuntimeError|", "if", "the", "latter", "is", "not", "available", "." ]
train
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/indextools.py#L132-L151
hydpy-dev/hydpy
hydpy/core/indextools.py
Indexer.dayofyear
def dayofyear(self): """Day of the year index (the first of January = 0...). For reasons of consistency between leap years and non-leap years, assuming a daily time step, index 59 is always associated with the 29th of February. Hence, it is missing in non-leap years: >>> from ...
python
def dayofyear(self): """Day of the year index (the first of January = 0...). For reasons of consistency between leap years and non-leap years, assuming a daily time step, index 59 is always associated with the 29th of February. Hence, it is missing in non-leap years: >>> from ...
[ "def", "dayofyear", "(", "self", ")", ":", "def", "_dayofyear", "(", "date", ")", ":", "return", "(", "date", ".", "dayofyear", "-", "1", "+", "(", "(", "date", ".", "month", ">", "2", ")", "and", "(", "not", "date", ".", "leapyear", ")", ")", ...
Day of the year index (the first of January = 0...). For reasons of consistency between leap years and non-leap years, assuming a daily time step, index 59 is always associated with the 29th of February. Hence, it is missing in non-leap years: >>> from hydpy import pub >>> fro...
[ "Day", "of", "the", "year", "index", "(", "the", "first", "of", "January", "=", "0", "...", ")", "." ]
train
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/indextools.py#L188-L207
hydpy-dev/hydpy
hydpy/core/indextools.py
Indexer.timeofyear
def timeofyear(self): """Time of the year index (first simulation step of each year = 0...). The property |Indexer.timeofyear| is best explained through comparing it with property |Indexer.dayofyear|: Let us reconsider one of the examples of the documentation on property |Index...
python
def timeofyear(self): """Time of the year index (first simulation step of each year = 0...). The property |Indexer.timeofyear| is best explained through comparing it with property |Indexer.dayofyear|: Let us reconsider one of the examples of the documentation on property |Index...
[ "def", "timeofyear", "(", "self", ")", ":", "refgrid", "=", "timetools", ".", "Timegrid", "(", "timetools", ".", "Date", "(", "'2000.01.01'", ")", ",", "timetools", ".", "Date", "(", "'2001.01.01'", ")", ",", "hydpy", ".", "pub", ".", "timegrids", ".", ...
Time of the year index (first simulation step of each year = 0...). The property |Indexer.timeofyear| is best explained through comparing it with property |Indexer.dayofyear|: Let us reconsider one of the examples of the documentation on property |Indexer.dayofyear|: >>> from ...
[ "Time", "of", "the", "year", "index", "(", "first", "simulation", "step", "of", "each", "year", "=", "0", "...", ")", "." ]
train
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/indextools.py#L210-L261
hydpy-dev/hydpy
hydpy/core/propertytools.py
BaseProperty.set_doc
def set_doc(self, doc: str): """Assign the given docstring to the property instance and, if possible, to the `__test__` dictionary of the module of its owner class.""" self.__doc__ = doc if hasattr(self, 'module'): ref = f'{self.objtype.__name__}.{self.name}' ...
python
def set_doc(self, doc: str): """Assign the given docstring to the property instance and, if possible, to the `__test__` dictionary of the module of its owner class.""" self.__doc__ = doc if hasattr(self, 'module'): ref = f'{self.objtype.__name__}.{self.name}' ...
[ "def", "set_doc", "(", "self", ",", "doc", ":", "str", ")", ":", "self", ".", "__doc__", "=", "doc", "if", "hasattr", "(", "self", ",", "'module'", ")", ":", "ref", "=", "f'{self.objtype.__name__}.{self.name}'", "self", ".", "module", ".", "__dict__", "[...
Assign the given docstring to the property instance and, if possible, to the `__test__` dictionary of the module of its owner class.
[ "Assign", "the", "given", "docstring", "to", "the", "property", "instance", "and", "if", "possible", "to", "the", "__test__", "dictionary", "of", "the", "module", "of", "its", "owner", "class", "." ]
train
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/propertytools.py#L139-L146
hydpy-dev/hydpy
hydpy/core/propertytools.py
BaseProperty.getter_
def getter_(self, fget) -> 'BaseProperty': """Add the given getter function and its docstring to the property and return it.""" self.fget = fget self.set_doc(fget.__doc__) return self
python
def getter_(self, fget) -> 'BaseProperty': """Add the given getter function and its docstring to the property and return it.""" self.fget = fget self.set_doc(fget.__doc__) return self
[ "def", "getter_", "(", "self", ",", "fget", ")", "->", "'BaseProperty'", ":", "self", ".", "fget", "=", "fget", "self", ".", "set_doc", "(", "fget", ".", "__doc__", ")", "return", "self" ]
Add the given getter function and its docstring to the property and return it.
[ "Add", "the", "given", "getter", "function", "and", "its", "docstring", "to", "the", "property", "and", "return", "it", "." ]
train
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/propertytools.py#L160-L165
hydpy-dev/hydpy
hydpy/core/propertytools.py
ProtectedProperty.isready
def isready(self, obj) -> bool: """Return |True| or |False| to indicate if the protected property is ready for the given object. If the object is unknow, |ProtectedProperty| returns |False|.""" return vars(obj).get(self.name, False)
python
def isready(self, obj) -> bool: """Return |True| or |False| to indicate if the protected property is ready for the given object. If the object is unknow, |ProtectedProperty| returns |False|.""" return vars(obj).get(self.name, False)
[ "def", "isready", "(", "self", ",", "obj", ")", "->", "bool", ":", "return", "vars", "(", "obj", ")", ".", "get", "(", "self", ".", "name", ",", "False", ")" ]
Return |True| or |False| to indicate if the protected property is ready for the given object. If the object is unknow, |ProtectedProperty| returns |False|.
[ "Return", "|True|", "or", "|False|", "to", "indicate", "if", "the", "protected", "property", "is", "ready", "for", "the", "given", "object", ".", "If", "the", "object", "is", "unknow", "|ProtectedProperty|", "returns", "|False|", "." ]
train
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/propertytools.py#L276-L280
hydpy-dev/hydpy
hydpy/core/propertytools.py
ProtectedProperties.allready
def allready(self, obj) -> bool: """Return |True| or |False| to indicate whether all protected properties are ready or not.""" for prop in self.__properties: if not prop.isready(obj): return False return True
python
def allready(self, obj) -> bool: """Return |True| or |False| to indicate whether all protected properties are ready or not.""" for prop in self.__properties: if not prop.isready(obj): return False return True
[ "def", "allready", "(", "self", ",", "obj", ")", "->", "bool", ":", "for", "prop", "in", "self", ".", "__properties", ":", "if", "not", "prop", ".", "isready", "(", "obj", ")", ":", "return", "False", "return", "True" ]
Return |True| or |False| to indicate whether all protected properties are ready or not.
[ "Return", "|True|", "or", "|False|", "to", "indicate", "whether", "all", "protected", "properties", "are", "ready", "or", "not", "." ]
train
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/propertytools.py#L324-L330
hydpy-dev/hydpy
hydpy/core/propertytools.py
DefaultProperty.call_fget
def call_fget(self, obj) -> Any: """Return the predefined custom value when available, otherwise, the value defined by the getter function.""" custom = vars(obj).get(self.name) if custom is None: return self.fget(obj) return custom
python
def call_fget(self, obj) -> Any: """Return the predefined custom value when available, otherwise, the value defined by the getter function.""" custom = vars(obj).get(self.name) if custom is None: return self.fget(obj) return custom
[ "def", "call_fget", "(", "self", ",", "obj", ")", "->", "Any", ":", "custom", "=", "vars", "(", "obj", ")", ".", "get", "(", "self", ".", "name", ")", "if", "custom", "is", "None", ":", "return", "self", ".", "fget", "(", "obj", ")", "return", ...
Return the predefined custom value when available, otherwise, the value defined by the getter function.
[ "Return", "the", "predefined", "custom", "value", "when", "available", "otherwise", "the", "value", "defined", "by", "the", "getter", "function", "." ]
train
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/propertytools.py#L528-L534
hydpy-dev/hydpy
hydpy/core/propertytools.py
DefaultProperty.call_fset
def call_fset(self, obj, value) -> None: """Store the given custom value and call the setter function.""" vars(obj)[self.name] = self.fset(obj, value)
python
def call_fset(self, obj, value) -> None: """Store the given custom value and call the setter function.""" vars(obj)[self.name] = self.fset(obj, value)
[ "def", "call_fset", "(", "self", ",", "obj", ",", "value", ")", "->", "None", ":", "vars", "(", "obj", ")", "[", "self", ".", "name", "]", "=", "self", ".", "fset", "(", "obj", ",", "value", ")" ]
Store the given custom value and call the setter function.
[ "Store", "the", "given", "custom", "value", "and", "call", "the", "setter", "function", "." ]
train
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/propertytools.py#L536-L538
hydpy-dev/hydpy
hydpy/core/propertytools.py
DefaultProperty.call_fdel
def call_fdel(self, obj) -> None: """Remove the predefined custom value and call the delete function.""" self.fdel(obj) try: del vars(obj)[self.name] except KeyError: pass
python
def call_fdel(self, obj) -> None: """Remove the predefined custom value and call the delete function.""" self.fdel(obj) try: del vars(obj)[self.name] except KeyError: pass
[ "def", "call_fdel", "(", "self", ",", "obj", ")", "->", "None", ":", "self", ".", "fdel", "(", "obj", ")", "try", ":", "del", "vars", "(", "obj", ")", "[", "self", ".", "name", "]", "except", "KeyError", ":", "pass" ]
Remove the predefined custom value and call the delete function.
[ "Remove", "the", "predefined", "custom", "value", "and", "call", "the", "delete", "function", "." ]
train
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/propertytools.py#L540-L546
hydpy-dev/hydpy
hydpy/models/lland/lland_control.py
RelWZ.trim
def trim(self, lower=None, upper=None): """Trim upper values in accordance with :math:`RelWB \\leq RelWZ`. >>> from hydpy.models.lland import * >>> parameterstep('1d') >>> nhru(3) >>> lnk(ACKER) >>> relwb.values = 0.5 >>> relwz(0.2, 0.5, 0.8) >>> relwz ...
python
def trim(self, lower=None, upper=None): """Trim upper values in accordance with :math:`RelWB \\leq RelWZ`. >>> from hydpy.models.lland import * >>> parameterstep('1d') >>> nhru(3) >>> lnk(ACKER) >>> relwb.values = 0.5 >>> relwz(0.2, 0.5, 0.8) >>> relwz ...
[ "def", "trim", "(", "self", ",", "lower", "=", "None", ",", "upper", "=", "None", ")", ":", "if", "lower", "is", "None", ":", "lower", "=", "getattr", "(", "self", ".", "subpars", ".", "relwb", ",", "'value'", ",", "None", ")", "lland_parameters", ...
Trim upper values in accordance with :math:`RelWB \\leq RelWZ`. >>> from hydpy.models.lland import * >>> parameterstep('1d') >>> nhru(3) >>> lnk(ACKER) >>> relwb.values = 0.5 >>> relwz(0.2, 0.5, 0.8) >>> relwz relwz(0.5, 0.5, 0.8)
[ "Trim", "upper", "values", "in", "accordance", "with", ":", "math", ":", "RelWB", "\\\\", "leq", "RelWZ", "." ]
train
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/lland/lland_control.py#L313-L327
hydpy-dev/hydpy
hydpy/models/lland/lland_control.py
RelWB.trim
def trim(self, lower=None, upper=None): """Trim upper values in accordance with :math:`RelWB \\leq RelWZ`. >>> from hydpy.models.lland import * >>> parameterstep('1d') >>> nhru(3) >>> lnk(ACKER) >>> relwz.values = 0.5 >>> relwb(0.2, 0.5, 0.8) >>> relwb ...
python
def trim(self, lower=None, upper=None): """Trim upper values in accordance with :math:`RelWB \\leq RelWZ`. >>> from hydpy.models.lland import * >>> parameterstep('1d') >>> nhru(3) >>> lnk(ACKER) >>> relwz.values = 0.5 >>> relwb(0.2, 0.5, 0.8) >>> relwb ...
[ "def", "trim", "(", "self", ",", "lower", "=", "None", ",", "upper", "=", "None", ")", ":", "if", "upper", "is", "None", ":", "upper", "=", "getattr", "(", "self", ".", "subpars", ".", "relwz", ",", "'value'", ",", "None", ")", "lland_parameters", ...
Trim upper values in accordance with :math:`RelWB \\leq RelWZ`. >>> from hydpy.models.lland import * >>> parameterstep('1d') >>> nhru(3) >>> lnk(ACKER) >>> relwz.values = 0.5 >>> relwb(0.2, 0.5, 0.8) >>> relwb relwb(0.2, 0.5, 0.5)
[ "Trim", "upper", "values", "in", "accordance", "with", ":", "math", ":", "RelWB", "\\\\", "leq", "RelWZ", "." ]
train
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/lland/lland_control.py#L336-L350
hydpy-dev/hydpy
hydpy/models/lland/lland_control.py
EQB.trim
def trim(self, lower=None, upper=None): """Trim upper values in accordance with :math:`EQI1 \\leq EQB`. >>> from hydpy.models.lland import * >>> parameterstep('1d') >>> eqi1.value = 2.0 >>> eqb(1.0) >>> eqb eqb(2.0) >>> eqb(2.0) >>> eqb eq...
python
def trim(self, lower=None, upper=None): """Trim upper values in accordance with :math:`EQI1 \\leq EQB`. >>> from hydpy.models.lland import * >>> parameterstep('1d') >>> eqi1.value = 2.0 >>> eqb(1.0) >>> eqb eqb(2.0) >>> eqb(2.0) >>> eqb eq...
[ "def", "trim", "(", "self", ",", "lower", "=", "None", ",", "upper", "=", "None", ")", ":", "if", "lower", "is", "None", ":", "lower", "=", "getattr", "(", "self", ".", "subpars", ".", "eqi1", ",", "'value'", ",", "None", ")", "super", "(", ")", ...
Trim upper values in accordance with :math:`EQI1 \\leq EQB`. >>> from hydpy.models.lland import * >>> parameterstep('1d') >>> eqi1.value = 2.0 >>> eqb(1.0) >>> eqb eqb(2.0) >>> eqb(2.0) >>> eqb eqb(2.0) >>> eqb(3.0) >>> eqb ...
[ "Trim", "upper", "values", "in", "accordance", "with", ":", "math", ":", "EQI1", "\\\\", "leq", "EQB", "." ]
train
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/lland/lland_control.py#L661-L679