repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
goshuirc/irc | girc/client.py | ServerConnection.action | def action(self, target, message, formatted=True, tags=None):
"""Send an action to the given target."""
if formatted:
message = unescape(message)
self.ctcp(target, 'ACTION', message) | python | def action(self, target, message, formatted=True, tags=None):
"""Send an action to the given target."""
if formatted:
message = unescape(message)
self.ctcp(target, 'ACTION', message) | [
"def",
"action",
"(",
"self",
",",
"target",
",",
"message",
",",
"formatted",
"=",
"True",
",",
"tags",
"=",
"None",
")",
":",
"if",
"formatted",
":",
"message",
"=",
"unescape",
"(",
"message",
")",
"self",
".",
"ctcp",
"(",
"target",
",",
"'ACTION... | Send an action to the given target. | [
"Send",
"an",
"action",
"to",
"the",
"given",
"target",
"."
] | train | https://github.com/goshuirc/irc/blob/d6a5e3e04d337566c009b087f108cd76f9e122cc/girc/client.py#L330-L335 |
goshuirc/irc | girc/client.py | ServerConnection.msg | def msg(self, target, message, formatted=True, tags=None):
"""Send a privmsg to the given target."""
if formatted:
message = unescape(message)
self.send('PRIVMSG', params=[target, message], source=self.nick, tags=tags) | python | def msg(self, target, message, formatted=True, tags=None):
"""Send a privmsg to the given target."""
if formatted:
message = unescape(message)
self.send('PRIVMSG', params=[target, message], source=self.nick, tags=tags) | [
"def",
"msg",
"(",
"self",
",",
"target",
",",
"message",
",",
"formatted",
"=",
"True",
",",
"tags",
"=",
"None",
")",
":",
"if",
"formatted",
":",
"message",
"=",
"unescape",
"(",
"message",
")",
"self",
".",
"send",
"(",
"'PRIVMSG'",
",",
"params"... | Send a privmsg to the given target. | [
"Send",
"a",
"privmsg",
"to",
"the",
"given",
"target",
"."
] | train | https://github.com/goshuirc/irc/blob/d6a5e3e04d337566c009b087f108cd76f9e122cc/girc/client.py#L337-L342 |
goshuirc/irc | girc/client.py | ServerConnection.ctcp | def ctcp(self, target, ctcp_verb, argument=None):
"""Send a CTCP request to the given target."""
# we don't support complex ctcp encapsulation because we're somewhat sane
atoms = [ctcp_verb]
if argument is not None:
atoms.append(argument)
X_DELIM = '\x01'
self... | python | def ctcp(self, target, ctcp_verb, argument=None):
"""Send a CTCP request to the given target."""
# we don't support complex ctcp encapsulation because we're somewhat sane
atoms = [ctcp_verb]
if argument is not None:
atoms.append(argument)
X_DELIM = '\x01'
self... | [
"def",
"ctcp",
"(",
"self",
",",
"target",
",",
"ctcp_verb",
",",
"argument",
"=",
"None",
")",
":",
"# we don't support complex ctcp encapsulation because we're somewhat sane",
"atoms",
"=",
"[",
"ctcp_verb",
"]",
"if",
"argument",
"is",
"not",
"None",
":",
"atom... | Send a CTCP request to the given target. | [
"Send",
"a",
"CTCP",
"request",
"to",
"the",
"given",
"target",
"."
] | train | https://github.com/goshuirc/irc/blob/d6a5e3e04d337566c009b087f108cd76f9e122cc/girc/client.py#L351-L358 |
goshuirc/irc | girc/client.py | ServerConnection.ctcp_reply | def ctcp_reply(self, target, ctcp_verb, argument=None):
"""Send a CTCP reply to the given target."""
# we don't support complex ctcp encapsulation because we're somewhat sane
atoms = [ctcp_verb]
if argument is not None:
atoms.append(argument)
X_DELIM = '\x01'
... | python | def ctcp_reply(self, target, ctcp_verb, argument=None):
"""Send a CTCP reply to the given target."""
# we don't support complex ctcp encapsulation because we're somewhat sane
atoms = [ctcp_verb]
if argument is not None:
atoms.append(argument)
X_DELIM = '\x01'
... | [
"def",
"ctcp_reply",
"(",
"self",
",",
"target",
",",
"ctcp_verb",
",",
"argument",
"=",
"None",
")",
":",
"# we don't support complex ctcp encapsulation because we're somewhat sane",
"atoms",
"=",
"[",
"ctcp_verb",
"]",
"if",
"argument",
"is",
"not",
"None",
":",
... | Send a CTCP reply to the given target. | [
"Send",
"a",
"CTCP",
"reply",
"to",
"the",
"given",
"target",
"."
] | train | https://github.com/goshuirc/irc/blob/d6a5e3e04d337566c009b087f108cd76f9e122cc/girc/client.py#L360-L367 |
goshuirc/irc | girc/client.py | ServerConnection.join_channel | def join_channel(self, channel, key=None, tags=None):
"""Join the given channel."""
params = [channel]
if key:
params.append(key)
self.send('JOIN', params=params, tags=tags) | python | def join_channel(self, channel, key=None, tags=None):
"""Join the given channel."""
params = [channel]
if key:
params.append(key)
self.send('JOIN', params=params, tags=tags) | [
"def",
"join_channel",
"(",
"self",
",",
"channel",
",",
"key",
"=",
"None",
",",
"tags",
"=",
"None",
")",
":",
"params",
"=",
"[",
"channel",
"]",
"if",
"key",
":",
"params",
".",
"append",
"(",
"key",
")",
"self",
".",
"send",
"(",
"'JOIN'",
"... | Join the given channel. | [
"Join",
"the",
"given",
"channel",
"."
] | train | https://github.com/goshuirc/irc/blob/d6a5e3e04d337566c009b087f108cd76f9e122cc/girc/client.py#L369-L374 |
goshuirc/irc | girc/client.py | ServerConnection.part_channel | def part_channel(self, channel, reason=None, tags=None):
"""Part the given channel."""
params = [channel]
if reason:
params.append(reason)
self.send('PART', params=params, tags=tags) | python | def part_channel(self, channel, reason=None, tags=None):
"""Part the given channel."""
params = [channel]
if reason:
params.append(reason)
self.send('PART', params=params, tags=tags) | [
"def",
"part_channel",
"(",
"self",
",",
"channel",
",",
"reason",
"=",
"None",
",",
"tags",
"=",
"None",
")",
":",
"params",
"=",
"[",
"channel",
"]",
"if",
"reason",
":",
"params",
".",
"append",
"(",
"reason",
")",
"self",
".",
"send",
"(",
"'PA... | Part the given channel. | [
"Part",
"the",
"given",
"channel",
"."
] | train | https://github.com/goshuirc/irc/blob/d6a5e3e04d337566c009b087f108cd76f9e122cc/girc/client.py#L376-L381 |
goshuirc/irc | girc/client.py | ServerConnection.mode | def mode(self, target, mode_string=None, tags=None):
"""Sends new modes to or requests existing modes from the given target."""
params = [target]
if mode_string:
params += mode_string
self.send('MODE', params=params, source=self.nick, tags=tags) | python | def mode(self, target, mode_string=None, tags=None):
"""Sends new modes to or requests existing modes from the given target."""
params = [target]
if mode_string:
params += mode_string
self.send('MODE', params=params, source=self.nick, tags=tags) | [
"def",
"mode",
"(",
"self",
",",
"target",
",",
"mode_string",
"=",
"None",
",",
"tags",
"=",
"None",
")",
":",
"params",
"=",
"[",
"target",
"]",
"if",
"mode_string",
":",
"params",
"+=",
"mode_string",
"self",
".",
"send",
"(",
"'MODE'",
",",
"para... | Sends new modes to or requests existing modes from the given target. | [
"Sends",
"new",
"modes",
"to",
"or",
"requests",
"existing",
"modes",
"from",
"the",
"given",
"target",
"."
] | train | https://github.com/goshuirc/irc/blob/d6a5e3e04d337566c009b087f108cd76f9e122cc/girc/client.py#L383-L388 |
goshuirc/irc | girc/client.py | ServerConnection.topic | def topic(self, channel, new_topic=None, tags=None):
"""Requests or sets the topic for the given channel."""
params = [channel]
if new_topic:
params += new_topic
self.send('TOPIC', params=params, source=self.nick, tags=tags) | python | def topic(self, channel, new_topic=None, tags=None):
"""Requests or sets the topic for the given channel."""
params = [channel]
if new_topic:
params += new_topic
self.send('TOPIC', params=params, source=self.nick, tags=tags) | [
"def",
"topic",
"(",
"self",
",",
"channel",
",",
"new_topic",
"=",
"None",
",",
"tags",
"=",
"None",
")",
":",
"params",
"=",
"[",
"channel",
"]",
"if",
"new_topic",
":",
"params",
"+=",
"new_topic",
"self",
".",
"send",
"(",
"'TOPIC'",
",",
"params... | Requests or sets the topic for the given channel. | [
"Requests",
"or",
"sets",
"the",
"topic",
"for",
"the",
"given",
"channel",
"."
] | train | https://github.com/goshuirc/irc/blob/d6a5e3e04d337566c009b087f108cd76f9e122cc/girc/client.py#L390-L395 |
goshuirc/irc | girc/client.py | ServerConnection.start | def start(self):
"""Start our welcome!"""
if ('sasl' in self.capabilities.enabled and self._sasl_info and
(not self.capabilities.available['sasl']['value'] or
(self.capabilities.available['sasl']['value'] and
self._sasl_info['method'] in
... | python | def start(self):
"""Start our welcome!"""
if ('sasl' in self.capabilities.enabled and self._sasl_info and
(not self.capabilities.available['sasl']['value'] or
(self.capabilities.available['sasl']['value'] and
self._sasl_info['method'] in
... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"(",
"'sasl'",
"in",
"self",
".",
"capabilities",
".",
"enabled",
"and",
"self",
".",
"_sasl_info",
"and",
"(",
"not",
"self",
".",
"capabilities",
".",
"available",
"[",
"'sasl'",
"]",
"[",
"'value'",
"]",
... | Start our welcome! | [
"Start",
"our",
"welcome!"
] | train | https://github.com/goshuirc/irc/blob/d6a5e3e04d337566c009b087f108cd76f9e122cc/girc/client.py#L424-L434 |
goshuirc/irc | girc/client.py | ServerConnection.nickserv_identify | def nickserv_identify(self, password, use_nick=None):
"""Identify to NickServ (legacy)."""
if self.ready:
if use_nick:
self.msg(use_nick, 'IDENTIFY {}'.format(password))
else:
self.send('NICKSERV', params=['IDENTIFY', password])
else:
... | python | def nickserv_identify(self, password, use_nick=None):
"""Identify to NickServ (legacy)."""
if self.ready:
if use_nick:
self.msg(use_nick, 'IDENTIFY {}'.format(password))
else:
self.send('NICKSERV', params=['IDENTIFY', password])
else:
... | [
"def",
"nickserv_identify",
"(",
"self",
",",
"password",
",",
"use_nick",
"=",
"None",
")",
":",
"if",
"self",
".",
"ready",
":",
"if",
"use_nick",
":",
"self",
".",
"msg",
"(",
"use_nick",
",",
"'IDENTIFY {}'",
".",
"format",
"(",
"password",
")",
")... | Identify to NickServ (legacy). | [
"Identify",
"to",
"NickServ",
"(",
"legacy",
")",
"."
] | train | https://github.com/goshuirc/irc/blob/d6a5e3e04d337566c009b087f108cd76f9e122cc/girc/client.py#L548-L559 |
goshuirc/irc | girc/client.py | ServerConnection.sasl_plain | def sasl_plain(self, name, password, identity=None):
"""Authenticate to a server using SASL plain, or does so on connection.
Args:
name (str): Name to auth with.
password (str): Password to auth with.
identity (str): Identity to auth with (defaults to name).
... | python | def sasl_plain(self, name, password, identity=None):
"""Authenticate to a server using SASL plain, or does so on connection.
Args:
name (str): Name to auth with.
password (str): Password to auth with.
identity (str): Identity to auth with (defaults to name).
... | [
"def",
"sasl_plain",
"(",
"self",
",",
"name",
",",
"password",
",",
"identity",
"=",
"None",
")",
":",
"if",
"identity",
"is",
"None",
":",
"identity",
"=",
"name",
"self",
".",
"sasl",
"(",
"'plain'",
",",
"name",
",",
"password",
",",
"identity",
... | Authenticate to a server using SASL plain, or does so on connection.
Args:
name (str): Name to auth with.
password (str): Password to auth with.
identity (str): Identity to auth with (defaults to name). | [
"Authenticate",
"to",
"a",
"server",
"using",
"SASL",
"plain",
"or",
"does",
"so",
"on",
"connection",
"."
] | train | https://github.com/goshuirc/irc/blob/d6a5e3e04d337566c009b087f108cd76f9e122cc/girc/client.py#L593-L604 |
nikcub/paths | paths/__init__.py | find_executable | def find_executable(executable, path=None):
"""Tries to find 'executable' in the directories listed in 'path'.
A string listing directories separated by 'os.pathsep'; defaults to
os.environ['PATH']. Returns the complete filename or None if not found.
"""
if path is None:
path = os.environ['PATH']
path... | python | def find_executable(executable, path=None):
"""Tries to find 'executable' in the directories listed in 'path'.
A string listing directories separated by 'os.pathsep'; defaults to
os.environ['PATH']. Returns the complete filename or None if not found.
"""
if path is None:
path = os.environ['PATH']
path... | [
"def",
"find_executable",
"(",
"executable",
",",
"path",
"=",
"None",
")",
":",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"os",
".",
"environ",
"[",
"'PATH'",
"]",
"paths",
"=",
"path",
".",
"split",
"(",
"os",
".",
"pathsep",
")",
"base",
","... | Tries to find 'executable' in the directories listed in 'path'.
A string listing directories separated by 'os.pathsep'; defaults to
os.environ['PATH']. Returns the complete filename or None if not found. | [
"Tries",
"to",
"find",
"executable",
"in",
"the",
"directories",
"listed",
"in",
"path",
"."
] | train | https://github.com/nikcub/paths/blob/2200b85273d07d7a3c8b15ceb3b03cbb5c11439a/paths/__init__.py#L85-L107 |
carta/franz | franz/base.py | BaseProducer.serialize_message | def serialize_message(message):
"""
Serializes an object. It must subclass :class:`FranzEvent`.
Parameters
----------
message : FranzEvent
The object to be serialized.
Returns
-------
bytes
"""
try:
return bson.dum... | python | def serialize_message(message):
"""
Serializes an object. It must subclass :class:`FranzEvent`.
Parameters
----------
message : FranzEvent
The object to be serialized.
Returns
-------
bytes
"""
try:
return bson.dum... | [
"def",
"serialize_message",
"(",
"message",
")",
":",
"try",
":",
"return",
"bson",
".",
"dumps",
"(",
"message",
".",
"serialize",
"(",
")",
")",
"except",
"bson",
".",
"UnknownSerializerError",
":",
"raise",
"SerializationError",
"(",
"\"Unable to serialize me... | Serializes an object. It must subclass :class:`FranzEvent`.
Parameters
----------
message : FranzEvent
The object to be serialized.
Returns
-------
bytes | [
"Serializes",
"an",
"object",
".",
"It",
"must",
"subclass",
":",
"class",
":",
"FranzEvent",
"."
] | train | https://github.com/carta/franz/blob/85678878eee8dad0fbe933d0cff819c2d16caa12/franz/base.py#L17-L35 |
rjw57/starman | starman/linearsystem.py | measure_states | def measure_states(states, measurement_matrix, measurement_covariance):
"""
Measure a list of states with a measurement matrix in the presence of
measurement noise.
Args:
states (array): states to measure. Shape is NxSTATE_DIM.
measurement_matrix (array): Each state in *states* is measu... | python | def measure_states(states, measurement_matrix, measurement_covariance):
"""
Measure a list of states with a measurement matrix in the presence of
measurement noise.
Args:
states (array): states to measure. Shape is NxSTATE_DIM.
measurement_matrix (array): Each state in *states* is measu... | [
"def",
"measure_states",
"(",
"states",
",",
"measurement_matrix",
",",
"measurement_covariance",
")",
":",
"# Sanitise input",
"measurement_matrix",
"=",
"np",
".",
"atleast_2d",
"(",
"measurement_matrix",
")",
"measurement_covariance",
"=",
"np",
".",
"atleast_2d",
... | Measure a list of states with a measurement matrix in the presence of
measurement noise.
Args:
states (array): states to measure. Shape is NxSTATE_DIM.
measurement_matrix (array): Each state in *states* is measured with this
matrix. Should be MEAS_DIMxSTATE_DIM in shape.
mea... | [
"Measure",
"a",
"list",
"of",
"states",
"with",
"a",
"measurement",
"matrix",
"in",
"the",
"presence",
"of",
"measurement",
"noise",
"."
] | train | https://github.com/rjw57/starman/blob/1f9475e2354c9630a61f4898ad871de1d2fdbc71/starman/linearsystem.py#L8-L45 |
rjw57/starman | starman/linearsystem.py | generate_states | def generate_states(state_count, process_matrix, process_covariance,
initial_state=None):
"""
Generate states by simulating a linear system with constant process matrix
and process noise covariance.
Args:
state_count (int): Number of states to generate.
process_matri... | python | def generate_states(state_count, process_matrix, process_covariance,
initial_state=None):
"""
Generate states by simulating a linear system with constant process matrix
and process noise covariance.
Args:
state_count (int): Number of states to generate.
process_matri... | [
"def",
"generate_states",
"(",
"state_count",
",",
"process_matrix",
",",
"process_covariance",
",",
"initial_state",
"=",
"None",
")",
":",
"# Sanitise input",
"process_matrix",
"=",
"np",
".",
"atleast_2d",
"(",
"process_matrix",
")",
"process_covariance",
"=",
"n... | Generate states by simulating a linear system with constant process matrix
and process noise covariance.
Args:
state_count (int): Number of states to generate.
process_matrix (array): Square array
process_covariance (array): Square array specifying process noise
covariance.
... | [
"Generate",
"states",
"by",
"simulating",
"a",
"linear",
"system",
"with",
"constant",
"process",
"matrix",
"and",
"process",
"noise",
"covariance",
"."
] | train | https://github.com/rjw57/starman/blob/1f9475e2354c9630a61f4898ad871de1d2fdbc71/starman/linearsystem.py#L47-L86 |
joac/singing-girl | singing_girl/singer.py | Singer.calcular_limite | def calcular_limite(self):
"""
Calcula el numero maximo que se puede imprimir
"""
self.exponentes = sorted(list(exponentes_plural.keys()), reverse=True)
exp = self.exponentes[0]
self.limite = 10 ** (exp + 6) - 1 | python | def calcular_limite(self):
"""
Calcula el numero maximo que se puede imprimir
"""
self.exponentes = sorted(list(exponentes_plural.keys()), reverse=True)
exp = self.exponentes[0]
self.limite = 10 ** (exp + 6) - 1 | [
"def",
"calcular_limite",
"(",
"self",
")",
":",
"self",
".",
"exponentes",
"=",
"sorted",
"(",
"list",
"(",
"exponentes_plural",
".",
"keys",
"(",
")",
")",
",",
"reverse",
"=",
"True",
")",
"exp",
"=",
"self",
".",
"exponentes",
"[",
"0",
"]",
"sel... | Calcula el numero maximo que se puede imprimir | [
"Calcula",
"el",
"numero",
"maximo",
"que",
"se",
"puede",
"imprimir"
] | train | https://github.com/joac/singing-girl/blob/3409025541072080803a6b4c84126b1709c957e3/singing_girl/singer.py#L12-L18 |
joac/singing-girl | singing_girl/singer.py | Singer.sing | def sing(self, number):
"""Interfaz publica para convertir numero a texto"""
if type(number) != Decimal:
number = Decimal(str(number))
if number > self.limite:
msg = "El maximo numero procesable es {} ({})".format(self.limite,
... | python | def sing(self, number):
"""Interfaz publica para convertir numero a texto"""
if type(number) != Decimal:
number = Decimal(str(number))
if number > self.limite:
msg = "El maximo numero procesable es {} ({})".format(self.limite,
... | [
"def",
"sing",
"(",
"self",
",",
"number",
")",
":",
"if",
"type",
"(",
"number",
")",
"!=",
"Decimal",
":",
"number",
"=",
"Decimal",
"(",
"str",
"(",
"number",
")",
")",
"if",
"number",
">",
"self",
".",
"limite",
":",
"msg",
"=",
"\"El maximo nu... | Interfaz publica para convertir numero a texto | [
"Interfaz",
"publica",
"para",
"convertir",
"numero",
"a",
"texto"
] | train | https://github.com/joac/singing-girl/blob/3409025541072080803a6b4c84126b1709c957e3/singing_girl/singer.py#L20-L34 |
joac/singing-girl | singing_girl/singer.py | Singer.__to_text | def __to_text(self, number, indice = 0, sing=False):
"""Convierte un numero a texto, recursivamente"""
number = int(number)
exp = self.exponentes[indice]
indice += 1
divisor = 10 ** exp
if exp == 3:
func = self.__numero_tres_cifras
else:
... | python | def __to_text(self, number, indice = 0, sing=False):
"""Convierte un numero a texto, recursivamente"""
number = int(number)
exp = self.exponentes[indice]
indice += 1
divisor = 10 ** exp
if exp == 3:
func = self.__numero_tres_cifras
else:
... | [
"def",
"__to_text",
"(",
"self",
",",
"number",
",",
"indice",
"=",
"0",
",",
"sing",
"=",
"False",
")",
":",
"number",
"=",
"int",
"(",
"number",
")",
"exp",
"=",
"self",
".",
"exponentes",
"[",
"indice",
"]",
"indice",
"+=",
"1",
"divisor",
"=",
... | Convierte un numero a texto, recursivamente | [
"Convierte",
"un",
"numero",
"a",
"texto",
"recursivamente"
] | train | https://github.com/joac/singing-girl/blob/3409025541072080803a6b4c84126b1709c957e3/singing_girl/singer.py#L54-L97 |
joac/singing-girl | singing_girl/singer.py | Singer.__numero_tres_cifras | def __numero_tres_cifras(self, number, indice=None, sing=False):
"""Convierte a texto numeros de tres cifras"""
number = int(number)
if number < 30:
if sing:
return especiales_apocopado[number]
else:
return especiales_masculino[number]
... | python | def __numero_tres_cifras(self, number, indice=None, sing=False):
"""Convierte a texto numeros de tres cifras"""
number = int(number)
if number < 30:
if sing:
return especiales_apocopado[number]
else:
return especiales_masculino[number]
... | [
"def",
"__numero_tres_cifras",
"(",
"self",
",",
"number",
",",
"indice",
"=",
"None",
",",
"sing",
"=",
"False",
")",
":",
"number",
"=",
"int",
"(",
"number",
")",
"if",
"number",
"<",
"30",
":",
"if",
"sing",
":",
"return",
"especiales_apocopado",
"... | Convierte a texto numeros de tres cifras | [
"Convierte",
"a",
"texto",
"numeros",
"de",
"tres",
"cifras"
] | train | https://github.com/joac/singing-girl/blob/3409025541072080803a6b4c84126b1709c957e3/singing_girl/singer.py#L99-L124 |
vreon/figment | examples/theworldfoundry/theworldfoundry/components/spatial.py | Spatial.pick | def pick(self, selector, entity_set, min_quantity=None):
"""
Pick entities from a set by selector. In most cases you should use one
of the higher-level pick_* functions.
"""
if isinstance(selector, int):
for e in entity_set:
if e.id == selector:
... | python | def pick(self, selector, entity_set, min_quantity=None):
"""
Pick entities from a set by selector. In most cases you should use one
of the higher-level pick_* functions.
"""
if isinstance(selector, int):
for e in entity_set:
if e.id == selector:
... | [
"def",
"pick",
"(",
"self",
",",
"selector",
",",
"entity_set",
",",
"min_quantity",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"selector",
",",
"int",
")",
":",
"for",
"e",
"in",
"entity_set",
":",
"if",
"e",
".",
"id",
"==",
"selector",
":",
... | Pick entities from a set by selector. In most cases you should use one
of the higher-level pick_* functions. | [
"Pick",
"entities",
"from",
"a",
"set",
"by",
"selector",
".",
"In",
"most",
"cases",
"you",
"should",
"use",
"one",
"of",
"the",
"higher",
"-",
"level",
"pick_",
"*",
"functions",
"."
] | train | https://github.com/vreon/figment/blob/78248b53d06bc525004a0f5b19c45afd1536083c/examples/theworldfoundry/theworldfoundry/components/spatial.py#L247-L265 |
vreon/figment | examples/theworldfoundry/theworldfoundry/components/spatial.py | Spatial.emit | def emit(self, sound, exclude=set()):
"""Send text to entities nearby this one."""
nearby = self.nearby()
try:
exclude = set(exclude)
except TypeError:
exclude = set([exclude])
exclude.add(self.entity)
listeners = nearby - exclude
for liste... | python | def emit(self, sound, exclude=set()):
"""Send text to entities nearby this one."""
nearby = self.nearby()
try:
exclude = set(exclude)
except TypeError:
exclude = set([exclude])
exclude.add(self.entity)
listeners = nearby - exclude
for liste... | [
"def",
"emit",
"(",
"self",
",",
"sound",
",",
"exclude",
"=",
"set",
"(",
")",
")",
":",
"nearby",
"=",
"self",
".",
"nearby",
"(",
")",
"try",
":",
"exclude",
"=",
"set",
"(",
"exclude",
")",
"except",
"TypeError",
":",
"exclude",
"=",
"set",
"... | Send text to entities nearby this one. | [
"Send",
"text",
"to",
"entities",
"nearby",
"this",
"one",
"."
] | train | https://github.com/vreon/figment/blob/78248b53d06bc525004a0f5b19c45afd1536083c/examples/theworldfoundry/theworldfoundry/components/spatial.py#L283-L293 |
KelSolaar/Foundations | foundations/strings.py | get_nice_name | def get_nice_name(name):
"""
Converts a string to nice string: **currentLogText** -> **Current Log Text**.
Usage::
>>> get_nice_name("getMeANiceName")
u'Get Me A Nice Name'
>>> get_nice_name("__getMeANiceName")
u'__Get Me A Nice Name'
:param name: Current string to be ... | python | def get_nice_name(name):
"""
Converts a string to nice string: **currentLogText** -> **Current Log Text**.
Usage::
>>> get_nice_name("getMeANiceName")
u'Get Me A Nice Name'
>>> get_nice_name("__getMeANiceName")
u'__Get Me A Nice Name'
:param name: Current string to be ... | [
"def",
"get_nice_name",
"(",
"name",
")",
":",
"chunks",
"=",
"re",
".",
"sub",
"(",
"r\"(.)([A-Z][a-z]+)\"",
",",
"r\"\\1 \\2\"",
",",
"name",
")",
"return",
"\" \"",
".",
"join",
"(",
"element",
".",
"title",
"(",
")",
"for",
"element",
"in",
"re",
"... | Converts a string to nice string: **currentLogText** -> **Current Log Text**.
Usage::
>>> get_nice_name("getMeANiceName")
u'Get Me A Nice Name'
>>> get_nice_name("__getMeANiceName")
u'__Get Me A Nice Name'
:param name: Current string to be nicified.
:type name: unicode
... | [
"Converts",
"a",
"string",
"to",
"nice",
"string",
":",
"**",
"currentLogText",
"**",
"-",
">",
"**",
"Current",
"Log",
"Text",
"**",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/strings.py#L62-L80 |
KelSolaar/Foundations | foundations/strings.py | get_version_rank | def get_version_rank(version):
"""
Converts a version string to it's rank.
Usage::
>>> get_version_rank("4.2.8")
4002008000000
>>> get_version_rank("4.0")
4000000000000
>>> get_version_rank("4.2.8").__class__
<type 'int'>
:param version: Current version... | python | def get_version_rank(version):
"""
Converts a version string to it's rank.
Usage::
>>> get_version_rank("4.2.8")
4002008000000
>>> get_version_rank("4.0")
4000000000000
>>> get_version_rank("4.2.8").__class__
<type 'int'>
:param version: Current version... | [
"def",
"get_version_rank",
"(",
"version",
")",
":",
"tokens",
"=",
"list",
"(",
"foundations",
".",
"common",
".",
"unpack_default",
"(",
"filter",
"(",
"any",
",",
"re",
".",
"split",
"(",
"\"\\.|-|,\"",
",",
"version",
")",
")",
",",
"length",
"=",
... | Converts a version string to it's rank.
Usage::
>>> get_version_rank("4.2.8")
4002008000000
>>> get_version_rank("4.0")
4000000000000
>>> get_version_rank("4.2.8").__class__
<type 'int'>
:param version: Current version to calculate rank.
:type version: unic... | [
"Converts",
"a",
"version",
"string",
"to",
"it",
"s",
"rank",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/strings.py#L83-L105 |
KelSolaar/Foundations | foundations/strings.py | get_splitext_basename | def get_splitext_basename(path):
"""
Gets the basename of a path without its extension.
Usage::
>>> get_splitext_basename("/Users/JohnDoe/Documents/Test.txt")
u'Test'
:param path: Path to extract the basename without extension.
:type path: unicode
:return: Splitext basename.
... | python | def get_splitext_basename(path):
"""
Gets the basename of a path without its extension.
Usage::
>>> get_splitext_basename("/Users/JohnDoe/Documents/Test.txt")
u'Test'
:param path: Path to extract the basename without extension.
:type path: unicode
:return: Splitext basename.
... | [
"def",
"get_splitext_basename",
"(",
"path",
")",
":",
"basename",
"=",
"foundations",
".",
"common",
".",
"get_first_item",
"(",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"os",
".",
"path",
".",
"normpath",
"(",
... | Gets the basename of a path without its extension.
Usage::
>>> get_splitext_basename("/Users/JohnDoe/Documents/Test.txt")
u'Test'
:param path: Path to extract the basename without extension.
:type path: unicode
:return: Splitext basename.
:rtype: unicode | [
"Gets",
"the",
"basename",
"of",
"a",
"path",
"without",
"its",
"extension",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/strings.py#L108-L125 |
KelSolaar/Foundations | foundations/strings.py | get_common_ancestor | def get_common_ancestor(*args):
"""
Gets common ancestor of given iterables.
Usage::
>>> get_common_ancestor(("1", "2", "3"), ("1", "2", "0"), ("1", "2", "3", "4"))
(u'1', u'2')
>>> get_common_ancestor("azerty", "azetty", "azello")
u'aze'
:param \*args: Iterables to re... | python | def get_common_ancestor(*args):
"""
Gets common ancestor of given iterables.
Usage::
>>> get_common_ancestor(("1", "2", "3"), ("1", "2", "0"), ("1", "2", "3", "4"))
(u'1', u'2')
>>> get_common_ancestor("azerty", "azetty", "azello")
u'aze'
:param \*args: Iterables to re... | [
"def",
"get_common_ancestor",
"(",
"*",
"args",
")",
":",
"array",
"=",
"map",
"(",
"set",
",",
"zip",
"(",
"*",
"args",
")",
")",
"divergence",
"=",
"filter",
"(",
"lambda",
"i",
":",
"len",
"(",
"i",
")",
">",
"1",
",",
"array",
")",
"if",
"d... | Gets common ancestor of given iterables.
Usage::
>>> get_common_ancestor(("1", "2", "3"), ("1", "2", "0"), ("1", "2", "3", "4"))
(u'1', u'2')
>>> get_common_ancestor("azerty", "azetty", "azello")
u'aze'
:param \*args: Iterables to retrieve common ancestor from.
:type \*arg... | [
"Gets",
"common",
"ancestor",
"of",
"given",
"iterables",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/strings.py#L128-L152 |
KelSolaar/Foundations | foundations/strings.py | get_common_paths_ancestor | def get_common_paths_ancestor(*args):
"""
Gets common paths ancestor of given paths.
Usage::
>>> get_common_paths_ancestor("/Users/JohnDoe/Documents", "/Users/JohnDoe/Documents/Test.txt")
u'/Users/JohnDoe/Documents'
:param \*args: Paths to retrieve common ancestor from.
:type \*ar... | python | def get_common_paths_ancestor(*args):
"""
Gets common paths ancestor of given paths.
Usage::
>>> get_common_paths_ancestor("/Users/JohnDoe/Documents", "/Users/JohnDoe/Documents/Test.txt")
u'/Users/JohnDoe/Documents'
:param \*args: Paths to retrieve common ancestor from.
:type \*ar... | [
"def",
"get_common_paths_ancestor",
"(",
"*",
"args",
")",
":",
"path_ancestor",
"=",
"os",
".",
"sep",
".",
"join",
"(",
"get_common_ancestor",
"(",
"*",
"[",
"path",
".",
"split",
"(",
"os",
".",
"sep",
")",
"for",
"path",
"in",
"args",
"]",
")",
"... | Gets common paths ancestor of given paths.
Usage::
>>> get_common_paths_ancestor("/Users/JohnDoe/Documents", "/Users/JohnDoe/Documents/Test.txt")
u'/Users/JohnDoe/Documents'
:param \*args: Paths to retrieve common ancestor from.
:type \*args: [unicode]
:return: Common path ancestor.
... | [
"Gets",
"common",
"paths",
"ancestor",
"of",
"given",
"paths",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/strings.py#L155-L172 |
KelSolaar/Foundations | foundations/strings.py | get_words | def get_words(data):
"""
Extracts the words from given string.
Usage::
>>> get_words("Users are: John Doe, Jane Doe, Z6PO.")
[u'Users', u'are', u'John', u'Doe', u'Jane', u'Doe', u'Z6PO']
:param data: Data to extract words from.
:type data: unicode
:return: Words.
:rtype: l... | python | def get_words(data):
"""
Extracts the words from given string.
Usage::
>>> get_words("Users are: John Doe, Jane Doe, Z6PO.")
[u'Users', u'are', u'John', u'Doe', u'Jane', u'Doe', u'Z6PO']
:param data: Data to extract words from.
:type data: unicode
:return: Words.
:rtype: l... | [
"def",
"get_words",
"(",
"data",
")",
":",
"words",
"=",
"re",
".",
"findall",
"(",
"r\"\\w+\"",
",",
"data",
")",
"LOGGER",
".",
"debug",
"(",
"\"> Words: '{0}'\"",
".",
"format",
"(",
"\", \"",
".",
"join",
"(",
"words",
")",
")",
")",
"return",
"w... | Extracts the words from given string.
Usage::
>>> get_words("Users are: John Doe, Jane Doe, Z6PO.")
[u'Users', u'are', u'John', u'Doe', u'Jane', u'Doe', u'Z6PO']
:param data: Data to extract words from.
:type data: unicode
:return: Words.
:rtype: list | [
"Extracts",
"the",
"words",
"from",
"given",
"string",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/strings.py#L175-L192 |
KelSolaar/Foundations | foundations/strings.py | filter_words | def filter_words(words, filters_in=None, filters_out=None, flags=0):
"""
Filters the words using the given filters.
Usage::
>>> filter_words(["Users", "are", "John", "Doe", "Jane", "Doe", "Z6PO"], filters_in=("John", "Doe"))
[u'John', u'Doe', u'Doe']
>>> filter_words(["Users", "are... | python | def filter_words(words, filters_in=None, filters_out=None, flags=0):
"""
Filters the words using the given filters.
Usage::
>>> filter_words(["Users", "are", "John", "Doe", "Jane", "Doe", "Z6PO"], filters_in=("John", "Doe"))
[u'John', u'Doe', u'Doe']
>>> filter_words(["Users", "are... | [
"def",
"filter_words",
"(",
"words",
",",
"filters_in",
"=",
"None",
",",
"filters_out",
"=",
"None",
",",
"flags",
"=",
"0",
")",
":",
"filtered_words",
"=",
"[",
"]",
"for",
"word",
"in",
"words",
":",
"if",
"filters_in",
":",
"filter_matched",
"=",
... | Filters the words using the given filters.
Usage::
>>> filter_words(["Users", "are", "John", "Doe", "Jane", "Doe", "Z6PO"], filters_in=("John", "Doe"))
[u'John', u'Doe', u'Doe']
>>> filter_words(["Users", "are", "John", "Doe", "Jane", "Doe", "Z6PO"], filters_in=("\w*r",))
[u'Users'... | [
"Filters",
"the",
"words",
"using",
"the",
"given",
"filters",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/strings.py#L195-L242 |
KelSolaar/Foundations | foundations/strings.py | replace | def replace(string, data):
"""
Replaces the data occurrences in the string.
Usage::
>>> replace("Users are: John Doe, Jane Doe, Z6PO.", {"John" : "Luke", "Jane" : "Anakin", "Doe" : "Skywalker",
"Z6PO" : "R2D2"})
u'Users are: Luke Skywalker, Anakin Skywalker, R2D2.'
:param str... | python | def replace(string, data):
"""
Replaces the data occurrences in the string.
Usage::
>>> replace("Users are: John Doe, Jane Doe, Z6PO.", {"John" : "Luke", "Jane" : "Anakin", "Doe" : "Skywalker",
"Z6PO" : "R2D2"})
u'Users are: Luke Skywalker, Anakin Skywalker, R2D2.'
:param str... | [
"def",
"replace",
"(",
"string",
",",
"data",
")",
":",
"for",
"old",
",",
"new",
"in",
"data",
".",
"iteritems",
"(",
")",
":",
"string",
"=",
"string",
".",
"replace",
"(",
"old",
",",
"new",
")",
"return",
"string"
] | Replaces the data occurrences in the string.
Usage::
>>> replace("Users are: John Doe, Jane Doe, Z6PO.", {"John" : "Luke", "Jane" : "Anakin", "Doe" : "Skywalker",
"Z6PO" : "R2D2"})
u'Users are: Luke Skywalker, Anakin Skywalker, R2D2.'
:param string: String to manipulate.
:type st... | [
"Replaces",
"the",
"data",
"occurrences",
"in",
"the",
"string",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/strings.py#L245-L265 |
KelSolaar/Foundations | foundations/strings.py | to_forward_slashes | def to_forward_slashes(data):
"""
Converts backward slashes to forward slashes.
Usage::
>>> to_forward_slashes("To\Forward\Slashes")
u'To/Forward/Slashes'
:param data: Data to convert.
:type data: unicode
:return: Converted path.
:rtype: unicode
"""
data = data.re... | python | def to_forward_slashes(data):
"""
Converts backward slashes to forward slashes.
Usage::
>>> to_forward_slashes("To\Forward\Slashes")
u'To/Forward/Slashes'
:param data: Data to convert.
:type data: unicode
:return: Converted path.
:rtype: unicode
"""
data = data.re... | [
"def",
"to_forward_slashes",
"(",
"data",
")",
":",
"data",
"=",
"data",
".",
"replace",
"(",
"\"\\\\\"",
",",
"\"/\"",
")",
"LOGGER",
".",
"debug",
"(",
"\"> Data: '{0}' to forward slashes.\"",
".",
"format",
"(",
"data",
")",
")",
"return",
"data"
] | Converts backward slashes to forward slashes.
Usage::
>>> to_forward_slashes("To\Forward\Slashes")
u'To/Forward/Slashes'
:param data: Data to convert.
:type data: unicode
:return: Converted path.
:rtype: unicode | [
"Converts",
"backward",
"slashes",
"to",
"forward",
"slashes",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/strings.py#L288-L305 |
KelSolaar/Foundations | foundations/strings.py | to_backward_slashes | def to_backward_slashes(data):
"""
Converts forward slashes to backward slashes.
Usage::
>>> to_backward_slashes("/Users/JohnDoe/Documents")
u'\\Users\\JohnDoe\\Documents'
:param data: Data to convert.
:type data: unicode
:return: Converted path.
:rtype: unicode
"""
... | python | def to_backward_slashes(data):
"""
Converts forward slashes to backward slashes.
Usage::
>>> to_backward_slashes("/Users/JohnDoe/Documents")
u'\\Users\\JohnDoe\\Documents'
:param data: Data to convert.
:type data: unicode
:return: Converted path.
:rtype: unicode
"""
... | [
"def",
"to_backward_slashes",
"(",
"data",
")",
":",
"data",
"=",
"data",
".",
"replace",
"(",
"\"/\"",
",",
"\"\\\\\"",
")",
"LOGGER",
".",
"debug",
"(",
"\"> Data: '{0}' to backward slashes.\"",
".",
"format",
"(",
"data",
")",
")",
"return",
"data"
] | Converts forward slashes to backward slashes.
Usage::
>>> to_backward_slashes("/Users/JohnDoe/Documents")
u'\\Users\\JohnDoe\\Documents'
:param data: Data to convert.
:type data: unicode
:return: Converted path.
:rtype: unicode | [
"Converts",
"forward",
"slashes",
"to",
"backward",
"slashes",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/strings.py#L308-L325 |
KelSolaar/Foundations | foundations/strings.py | to_posix_path | def to_posix_path(path):
"""
Converts Windows path to Posix path while stripping drives letters and network server slashes.
Usage::
>>> to_posix_path("c:\\Users\\JohnDoe\\Documents")
u'/Users/JohnDoe/Documents'
:param path: Windows path.
:type path: unicode
:return: Path conve... | python | def to_posix_path(path):
"""
Converts Windows path to Posix path while stripping drives letters and network server slashes.
Usage::
>>> to_posix_path("c:\\Users\\JohnDoe\\Documents")
u'/Users/JohnDoe/Documents'
:param path: Windows path.
:type path: unicode
:return: Path conve... | [
"def",
"to_posix_path",
"(",
"path",
")",
":",
"posix_path",
"=",
"posixpath",
".",
"normpath",
"(",
"to_forward_slashes",
"(",
"re",
".",
"sub",
"(",
"r\"[a-zA-Z]:\\\\|\\\\\\\\\"",
",",
"\"/\"",
",",
"os",
".",
"path",
".",
"normpath",
"(",
"path",
")",
"... | Converts Windows path to Posix path while stripping drives letters and network server slashes.
Usage::
>>> to_posix_path("c:\\Users\\JohnDoe\\Documents")
u'/Users/JohnDoe/Documents'
:param path: Windows path.
:type path: unicode
:return: Path converted to Posix path.
:rtype: unico... | [
"Converts",
"Windows",
"path",
"to",
"Posix",
"path",
"while",
"stripping",
"drives",
"letters",
"and",
"network",
"server",
"slashes",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/strings.py#L328-L345 |
KelSolaar/Foundations | foundations/strings.py | get_normalized_path | def get_normalized_path(path):
"""
Normalizes a path, escaping slashes if needed on Windows.
Usage::
>>> get_normalized_path("C:\\Users/johnDoe\\Documents")
u'C:\\Users\\JohnDoe\\Documents'
:param path: Path to normalize.
:type path: unicode
:return: Normalized path.
:rtyp... | python | def get_normalized_path(path):
"""
Normalizes a path, escaping slashes if needed on Windows.
Usage::
>>> get_normalized_path("C:\\Users/johnDoe\\Documents")
u'C:\\Users\\JohnDoe\\Documents'
:param path: Path to normalize.
:type path: unicode
:return: Normalized path.
:rtyp... | [
"def",
"get_normalized_path",
"(",
"path",
")",
":",
"if",
"platform",
".",
"system",
"(",
")",
"==",
"\"Windows\"",
"or",
"platform",
".",
"system",
"(",
")",
"==",
"\"Microsoft\"",
":",
"path",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"path",
")... | Normalizes a path, escaping slashes if needed on Windows.
Usage::
>>> get_normalized_path("C:\\Users/johnDoe\\Documents")
u'C:\\Users\\JohnDoe\\Documents'
:param path: Path to normalize.
:type path: unicode
:return: Normalized path.
:rtype: unicode | [
"Normalizes",
"a",
"path",
"escaping",
"slashes",
"if",
"needed",
"on",
"Windows",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/strings.py#L348-L370 |
KelSolaar/Foundations | foundations/strings.py | is_email | def is_email(data):
"""
Check if given data string is an email.
Usage::
>>> is_email("john.doe@domain.com")
True
>>> is_email("john.doe:domain.com")
False
:param data: Data to check.
:type data: unicode
:return: Is email.
:rtype: bool
"""
if re.mat... | python | def is_email(data):
"""
Check if given data string is an email.
Usage::
>>> is_email("john.doe@domain.com")
True
>>> is_email("john.doe:domain.com")
False
:param data: Data to check.
:type data: unicode
:return: Is email.
:rtype: bool
"""
if re.mat... | [
"def",
"is_email",
"(",
"data",
")",
":",
"if",
"re",
".",
"match",
"(",
"r\"[\\w.%+-]+@[\\w.]+\\.[a-zA-Z]{2,4}\"",
",",
"data",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"> {0}' is matched as email.\"",
".",
"format",
"(",
"data",
")",
")",
"return",
"True",
... | Check if given data string is an email.
Usage::
>>> is_email("john.doe@domain.com")
True
>>> is_email("john.doe:domain.com")
False
:param data: Data to check.
:type data: unicode
:return: Is email.
:rtype: bool | [
"Check",
"if",
"given",
"data",
"string",
"is",
"an",
"email",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/strings.py#L391-L413 |
KelSolaar/Foundations | foundations/strings.py | is_website | def is_website(url):
"""
Check if given url string is a website.
Usage::
>>> is_website("http://www.domain.com")
True
>>> is_website("domain.com")
False
:param data: Data to check.
:type data: unicode
:return: Is website.
:rtype: bool
"""
if re.mat... | python | def is_website(url):
"""
Check if given url string is a website.
Usage::
>>> is_website("http://www.domain.com")
True
>>> is_website("domain.com")
False
:param data: Data to check.
:type data: unicode
:return: Is website.
:rtype: bool
"""
if re.mat... | [
"def",
"is_website",
"(",
"url",
")",
":",
"if",
"re",
".",
"match",
"(",
"r\"(http|ftp|https)://([\\w\\-\\.]+)/?\"",
",",
"url",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"> {0}' is matched as website.\"",
".",
"format",
"(",
"url",
")",
")",
"return",
"True",... | Check if given url string is a website.
Usage::
>>> is_website("http://www.domain.com")
True
>>> is_website("domain.com")
False
:param data: Data to check.
:type data: unicode
:return: Is website.
:rtype: bool | [
"Check",
"if",
"given",
"url",
"string",
"is",
"a",
"website",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/strings.py#L416-L438 |
matttproud/python_quantile_estimation | com/matttproud/quantile/__init__.py | Estimator.observe | def observe(self, value):
"""Samples an observation's value.
Args:
value: A numeric value signifying the value to be sampled.
"""
self._buffer.append(value)
if len(self._buffer) == _BUFFER_SIZE:
self._flush() | python | def observe(self, value):
"""Samples an observation's value.
Args:
value: A numeric value signifying the value to be sampled.
"""
self._buffer.append(value)
if len(self._buffer) == _BUFFER_SIZE:
self._flush() | [
"def",
"observe",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_buffer",
".",
"append",
"(",
"value",
")",
"if",
"len",
"(",
"self",
".",
"_buffer",
")",
"==",
"_BUFFER_SIZE",
":",
"self",
".",
"_flush",
"(",
")"
] | Samples an observation's value.
Args:
value: A numeric value signifying the value to be sampled. | [
"Samples",
"an",
"observation",
"s",
"value",
"."
] | train | https://github.com/matttproud/python_quantile_estimation/blob/698c329077805375d2a5e4191ec4709289150fd6/com/matttproud/quantile/__init__.py#L50-L58 |
matttproud/python_quantile_estimation | com/matttproud/quantile/__init__.py | Estimator.query | def query(self, rank):
"""Retrieves the value estimate for the requested quantile rank.
The requested quantile rank must be registered in the estimator's
invariants a priori!
Args:
rank: A floating point quantile rank along the interval [0, 1].
Returns:
... | python | def query(self, rank):
"""Retrieves the value estimate for the requested quantile rank.
The requested quantile rank must be registered in the estimator's
invariants a priori!
Args:
rank: A floating point quantile rank along the interval [0, 1].
Returns:
... | [
"def",
"query",
"(",
"self",
",",
"rank",
")",
":",
"self",
".",
"_flush",
"(",
")",
"current",
"=",
"self",
".",
"_head",
"if",
"not",
"current",
":",
"return",
"0",
"mid_rank",
"=",
"math",
".",
"floor",
"(",
"rank",
"*",
"self",
".",
"_observati... | Retrieves the value estimate for the requested quantile rank.
The requested quantile rank must be registered in the estimator's
invariants a priori!
Args:
rank: A floating point quantile rank along the interval [0, 1].
Returns:
A numeric value for the quantile ... | [
"Retrieves",
"the",
"value",
"estimate",
"for",
"the",
"requested",
"quantile",
"rank",
"."
] | train | https://github.com/matttproud/python_quantile_estimation/blob/698c329077805375d2a5e4191ec4709289150fd6/com/matttproud/quantile/__init__.py#L60-L90 |
matttproud/python_quantile_estimation | com/matttproud/quantile/__init__.py | Estimator._flush | def _flush(self):
"""Purges the buffer and commits all pending values into the estimator."""
self._buffer.sort()
self._replace_batch()
self._buffer = []
self._compress() | python | def _flush(self):
"""Purges the buffer and commits all pending values into the estimator."""
self._buffer.sort()
self._replace_batch()
self._buffer = []
self._compress() | [
"def",
"_flush",
"(",
"self",
")",
":",
"self",
".",
"_buffer",
".",
"sort",
"(",
")",
"self",
".",
"_replace_batch",
"(",
")",
"self",
".",
"_buffer",
"=",
"[",
"]",
"self",
".",
"_compress",
"(",
")"
] | Purges the buffer and commits all pending values into the estimator. | [
"Purges",
"the",
"buffer",
"and",
"commits",
"all",
"pending",
"values",
"into",
"the",
"estimator",
"."
] | train | https://github.com/matttproud/python_quantile_estimation/blob/698c329077805375d2a5e4191ec4709289150fd6/com/matttproud/quantile/__init__.py#L92-L97 |
matttproud/python_quantile_estimation | com/matttproud/quantile/__init__.py | Estimator._replace_batch | def _replace_batch(self):
"""Incorporates all pending values into the estimator."""
if not self._head:
self._head, self._buffer = self._record(self._buffer[0], 1, 0, None), self._buffer[1:]
rank = 0.0
current = self._head
for b in self._buffer:
if b < self... | python | def _replace_batch(self):
"""Incorporates all pending values into the estimator."""
if not self._head:
self._head, self._buffer = self._record(self._buffer[0], 1, 0, None), self._buffer[1:]
rank = 0.0
current = self._head
for b in self._buffer:
if b < self... | [
"def",
"_replace_batch",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_head",
":",
"self",
".",
"_head",
",",
"self",
".",
"_buffer",
"=",
"self",
".",
"_record",
"(",
"self",
".",
"_buffer",
"[",
"0",
"]",
",",
"1",
",",
"0",
",",
"None",
... | Incorporates all pending values into the estimator. | [
"Incorporates",
"all",
"pending",
"values",
"into",
"the",
"estimator",
"."
] | train | https://github.com/matttproud/python_quantile_estimation/blob/698c329077805375d2a5e4191ec4709289150fd6/com/matttproud/quantile/__init__.py#L99-L118 |
matttproud/python_quantile_estimation | com/matttproud/quantile/__init__.py | Estimator._record | def _record(self, value, rank, delta, successor):
"""Catalogs a sample."""
self._observations += 1
self._items += 1
return _Sample(value, rank, delta, successor) | python | def _record(self, value, rank, delta, successor):
"""Catalogs a sample."""
self._observations += 1
self._items += 1
return _Sample(value, rank, delta, successor) | [
"def",
"_record",
"(",
"self",
",",
"value",
",",
"rank",
",",
"delta",
",",
"successor",
")",
":",
"self",
".",
"_observations",
"+=",
"1",
"self",
".",
"_items",
"+=",
"1",
"return",
"_Sample",
"(",
"value",
",",
"rank",
",",
"delta",
",",
"success... | Catalogs a sample. | [
"Catalogs",
"a",
"sample",
"."
] | train | https://github.com/matttproud/python_quantile_estimation/blob/698c329077805375d2a5e4191ec4709289150fd6/com/matttproud/quantile/__init__.py#L121-L126 |
matttproud/python_quantile_estimation | com/matttproud/quantile/__init__.py | Estimator._invariant | def _invariant(self, rank, n):
"""Computes the delta value for the sample."""
minimum = n + 1
for i in self._invariants:
delta = i._delta(rank, n)
if delta < minimum:
minimum = delta
return math.floor(minimum) | python | def _invariant(self, rank, n):
"""Computes the delta value for the sample."""
minimum = n + 1
for i in self._invariants:
delta = i._delta(rank, n)
if delta < minimum:
minimum = delta
return math.floor(minimum) | [
"def",
"_invariant",
"(",
"self",
",",
"rank",
",",
"n",
")",
":",
"minimum",
"=",
"n",
"+",
"1",
"for",
"i",
"in",
"self",
".",
"_invariants",
":",
"delta",
"=",
"i",
".",
"_delta",
"(",
"rank",
",",
"n",
")",
"if",
"delta",
"<",
"minimum",
":... | Computes the delta value for the sample. | [
"Computes",
"the",
"delta",
"value",
"for",
"the",
"sample",
"."
] | train | https://github.com/matttproud/python_quantile_estimation/blob/698c329077805375d2a5e4191ec4709289150fd6/com/matttproud/quantile/__init__.py#L129-L138 |
matttproud/python_quantile_estimation | com/matttproud/quantile/__init__.py | Estimator._compress | def _compress(self):
"""Prunes the cataloged observations."""
rank = 0.0
current = self._head
while current and current._successor:
if current._rank + current._successor._rank + current._successor._delta <= self._invariant(rank, self._observations):
removed =... | python | def _compress(self):
"""Prunes the cataloged observations."""
rank = 0.0
current = self._head
while current and current._successor:
if current._rank + current._successor._rank + current._successor._delta <= self._invariant(rank, self._observations):
removed =... | [
"def",
"_compress",
"(",
"self",
")",
":",
"rank",
"=",
"0.0",
"current",
"=",
"self",
".",
"_head",
"while",
"current",
"and",
"current",
".",
"_successor",
":",
"if",
"current",
".",
"_rank",
"+",
"current",
".",
"_successor",
".",
"_rank",
"+",
"cur... | Prunes the cataloged observations. | [
"Prunes",
"the",
"cataloged",
"observations",
"."
] | train | https://github.com/matttproud/python_quantile_estimation/blob/698c329077805375d2a5e4191ec4709289150fd6/com/matttproud/quantile/__init__.py#L140-L155 |
heuer/cablemap | cablemap.nlp/cablemap/nlp/defaultcorpus.py | create_corpus | def create_corpus(src, out_dir, no_below=20, keep_words=_DEFAULT_KEEP_WORDS):
"""\
"""
wordid_filename = os.path.join(out_dir, 'cables_wordids.pickle')
bow_filename = os.path.join(out_dir, 'cables_bow.mm')
tfidf_filename = os.path.join(out_dir, 'cables_tfidf.mm')
predicate = None # Could be set... | python | def create_corpus(src, out_dir, no_below=20, keep_words=_DEFAULT_KEEP_WORDS):
"""\
"""
wordid_filename = os.path.join(out_dir, 'cables_wordids.pickle')
bow_filename = os.path.join(out_dir, 'cables_bow.mm')
tfidf_filename = os.path.join(out_dir, 'cables_tfidf.mm')
predicate = None # Could be set... | [
"def",
"create_corpus",
"(",
"src",
",",
"out_dir",
",",
"no_below",
"=",
"20",
",",
"keep_words",
"=",
"_DEFAULT_KEEP_WORDS",
")",
":",
"wordid_filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"out_dir",
",",
"'cables_wordids.pickle'",
")",
"bow_filename"... | \ | [
"\\"
] | train | https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.nlp/cablemap/nlp/defaultcorpus.py#L52-L76 |
jrabbit/taskd-client-py | taskc/simple.py | _is_path | def _is_path(instance, attribute, s, exists=True):
"Validator for path-yness"
if not s:
# allow False as a default
return
if exists:
if os.path.exists(s):
return
else:
raise OSError("path does not exist")
else:
# how do we tell if it's a pa... | python | def _is_path(instance, attribute, s, exists=True):
"Validator for path-yness"
if not s:
# allow False as a default
return
if exists:
if os.path.exists(s):
return
else:
raise OSError("path does not exist")
else:
# how do we tell if it's a pa... | [
"def",
"_is_path",
"(",
"instance",
",",
"attribute",
",",
"s",
",",
"exists",
"=",
"True",
")",
":",
"if",
"not",
"s",
":",
"# allow False as a default",
"return",
"if",
"exists",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"s",
")",
":",
"ret... | Validator for path-yness | [
"Validator",
"for",
"path",
"-",
"yness"
] | train | https://github.com/jrabbit/taskd-client-py/blob/473f121eca7fdb358874c9c00827f9a6ecdcda4e/taskc/simple.py#L16-L28 |
PMBio/limix-backup | limix/mtSet/iset_strat.py | ISet_Strat.getVC | def getVC(self):
"""
Variance componenrs
"""
_Cr = decompose_GxE(self.full['Cr'])
RV = {}
for key in list(_Cr.keys()):
RV['var_%s' % key] = sp.array([var_CoXX(_Cr[key], self.Xr)])
RV['var_c'] = self.full['var_c']
RV['var_n'] = self.full['var_n... | python | def getVC(self):
"""
Variance componenrs
"""
_Cr = decompose_GxE(self.full['Cr'])
RV = {}
for key in list(_Cr.keys()):
RV['var_%s' % key] = sp.array([var_CoXX(_Cr[key], self.Xr)])
RV['var_c'] = self.full['var_c']
RV['var_n'] = self.full['var_n... | [
"def",
"getVC",
"(",
"self",
")",
":",
"_Cr",
"=",
"decompose_GxE",
"(",
"self",
".",
"full",
"[",
"'Cr'",
"]",
")",
"RV",
"=",
"{",
"}",
"for",
"key",
"in",
"list",
"(",
"_Cr",
".",
"keys",
"(",
")",
")",
":",
"RV",
"[",
"'var_%s'",
"%",
"ke... | Variance componenrs | [
"Variance",
"componenrs"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/mtSet/iset_strat.py#L165-L175 |
KelSolaar/Foundations | foundations/parsers.py | get_attribute_compound | def get_attribute_compound(attribute, value=None, splitter="|", binding_identifier="@"):
"""
Returns an attribute compound.
Usage::
>>> data = "@Link | Value | Boolean | Link Parameter"
>>> attribute_compound = foundations.parsers.get_attribute_compound("Attribute Compound", data)
... | python | def get_attribute_compound(attribute, value=None, splitter="|", binding_identifier="@"):
"""
Returns an attribute compound.
Usage::
>>> data = "@Link | Value | Boolean | Link Parameter"
>>> attribute_compound = foundations.parsers.get_attribute_compound("Attribute Compound", data)
... | [
"def",
"get_attribute_compound",
"(",
"attribute",
",",
"value",
"=",
"None",
",",
"splitter",
"=",
"\"|\"",
",",
"binding_identifier",
"=",
"\"@\"",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"> Attribute: '{0}', value: '{1}'.\"",
".",
"format",
"(",
"attribute",
... | Returns an attribute compound.
Usage::
>>> data = "@Link | Value | Boolean | Link Parameter"
>>> attribute_compound = foundations.parsers.get_attribute_compound("Attribute Compound", data)
>>> attribute_compound.name
u'Attribute Compound'
>>> attribute_compound.value
... | [
"Returns",
"an",
"attribute",
"compound",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L1377-L1423 |
KelSolaar/Foundations | foundations/parsers.py | SectionsFileParser.splitters | def splitters(self, value):
"""
Setter for **self.__splitters** attribute.
:param value: Attribute value.
:type value: tuple or list
"""
if value is not None:
assert type(value) in (tuple, list), "'{0}' attribute: '{1}' type is not 'tuple' or 'list'!".format... | python | def splitters(self, value):
"""
Setter for **self.__splitters** attribute.
:param value: Attribute value.
:type value: tuple or list
"""
if value is not None:
assert type(value) in (tuple, list), "'{0}' attribute: '{1}' type is not 'tuple' or 'list'!".format... | [
"def",
"splitters",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"in",
"(",
"tuple",
",",
"list",
")",
",",
"\"'{0}' attribute: '{1}' type is not 'tuple' or 'list'!\"",
".",
"format",
"(",... | Setter for **self.__splitters** attribute.
:param value: Attribute value.
:type value: tuple or list | [
"Setter",
"for",
"**",
"self",
".",
"__splitters",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L195-L213 |
KelSolaar/Foundations | foundations/parsers.py | SectionsFileParser.namespace_splitter | def namespace_splitter(self, value):
"""
Setter for **self.__namespace_splitter** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
... | python | def namespace_splitter(self, value):
"""
Setter for **self.__namespace_splitter** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
... | [
"def",
"namespace_splitter",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"unicode",
",",
"\"'{0}' attribute: '{1}' type is not 'unicode'!\"",
".",
"format",
"(",
"\"namespace_splitter\"",... | Setter for **self.__namespace_splitter** attribute.
:param value: Attribute value.
:type value: unicode | [
"Setter",
"for",
"**",
"self",
".",
"__namespace_splitter",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L238-L253 |
KelSolaar/Foundations | foundations/parsers.py | SectionsFileParser.comment_limiters | def comment_limiters(self, value):
"""
Setter for **self.__comment_limiters** attribute.
:param value: Attribute value.
:type value: tuple or list
"""
if value is not None:
assert type(value) in (tuple, list), "'{0}' attribute: '{1}' type is not 'tuple' or '... | python | def comment_limiters(self, value):
"""
Setter for **self.__comment_limiters** attribute.
:param value: Attribute value.
:type value: tuple or list
"""
if value is not None:
assert type(value) in (tuple, list), "'{0}' attribute: '{1}' type is not 'tuple' or '... | [
"def",
"comment_limiters",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"in",
"(",
"tuple",
",",
"list",
")",
",",
"\"'{0}' attribute: '{1}' type is not 'tuple' or 'list'!\"",
".",
"format",... | Setter for **self.__comment_limiters** attribute.
:param value: Attribute value.
:type value: tuple or list | [
"Setter",
"for",
"**",
"self",
".",
"__comment_limiters",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L278-L292 |
KelSolaar/Foundations | foundations/parsers.py | SectionsFileParser.comment_marker | def comment_marker(self, value):
"""
Setter for **self.__comment_marker** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
... | python | def comment_marker(self, value):
"""
Setter for **self.__comment_marker** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
... | [
"def",
"comment_marker",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"unicode",
",",
"\"'{0}' attribute: '{1}' type is not 'unicode'!\"",
".",
"format",
"(",
"\"comment_marker\"",
",",
... | Setter for **self.__comment_marker** attribute.
:param value: Attribute value.
:type value: unicode | [
"Setter",
"for",
"**",
"self",
".",
"__comment_marker",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L317-L330 |
KelSolaar/Foundations | foundations/parsers.py | SectionsFileParser.quotation_markers | def quotation_markers(self, value):
"""
Setter for **self.__quotation_markers** attribute.
:param value: Attribute value.
:type value: tuple or list
"""
if value is not None:
assert type(value) in (tuple, list), "'{0}' attribute: '{1}' type is not 'tuple' or... | python | def quotation_markers(self, value):
"""
Setter for **self.__quotation_markers** attribute.
:param value: Attribute value.
:type value: tuple or list
"""
if value is not None:
assert type(value) in (tuple, list), "'{0}' attribute: '{1}' type is not 'tuple' or... | [
"def",
"quotation_markers",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"in",
"(",
"tuple",
",",
"list",
")",
",",
"\"'{0}' attribute: '{1}' type is not 'tuple' or 'list'!\"",
".",
"format"... | Setter for **self.__quotation_markers** attribute.
:param value: Attribute value.
:type value: tuple or list | [
"Setter",
"for",
"**",
"self",
".",
"__quotation_markers",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L355-L373 |
KelSolaar/Foundations | foundations/parsers.py | SectionsFileParser.raw_section_content_identifier | def raw_section_content_identifier(self, value):
"""
Setter for **self. __raw_section_content_identifier** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is... | python | def raw_section_content_identifier(self, value):
"""
Setter for **self. __raw_section_content_identifier** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is... | [
"def",
"raw_section_content_identifier",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"unicode",
",",
"\"'{0}' attribute: '{1}' type is not 'unicode'!\"",
".",
"format",
"(",
"\"raw_sectio... | Setter for **self. __raw_section_content_identifier** attribute.
:param value: Attribute value.
:type value: unicode | [
"Setter",
"for",
"**",
"self",
".",
"__raw_section_content_identifier",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L398-L409 |
KelSolaar/Foundations | foundations/parsers.py | SectionsFileParser.defaults_section | def defaults_section(self, value):
"""
Setter for **self.__defaults_section** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
... | python | def defaults_section(self, value):
"""
Setter for **self.__defaults_section** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
... | [
"def",
"defaults_section",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"unicode",
",",
"\"'{0}' attribute: '{1}' type is not 'unicode'!\"",
".",
"format",
"(",
"\"defaults_section\"",
"... | Setter for **self.__defaults_section** attribute.
:param value: Attribute value.
:type value: unicode | [
"Setter",
"for",
"**",
"self",
".",
"__defaults_section",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L434-L445 |
KelSolaar/Foundations | foundations/parsers.py | SectionsFileParser.sections | def sections(self, value):
"""
Setter for **self.__sections** attribute.
:param value: Attribute value.
:type value: OrderedDict or dict
"""
if value is not None:
assert type(value) in (OrderedDict, dict), "'{0}' attribute: '{1}' type is not \
'O... | python | def sections(self, value):
"""
Setter for **self.__sections** attribute.
:param value: Attribute value.
:type value: OrderedDict or dict
"""
if value is not None:
assert type(value) in (OrderedDict, dict), "'{0}' attribute: '{1}' type is not \
'O... | [
"def",
"sections",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"in",
"(",
"OrderedDict",
",",
"dict",
")",
",",
"\"'{0}' attribute: '{1}' type is not \\\n 'OrderedDict' or 'dict'!\""... | Setter for **self.__sections** attribute.
:param value: Attribute value.
:type value: OrderedDict or dict | [
"Setter",
"for",
"**",
"self",
".",
"__sections",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L470-L486 |
KelSolaar/Foundations | foundations/parsers.py | SectionsFileParser.comments | def comments(self, value):
"""
Setter for **self.__comments** attribute.
:param value: Attribute value.
:type value: OrderedDict or dict
"""
if value is not None:
assert type(value) in (OrderedDict, dict), "'{0}' attribute: '{1}' type is not \
'O... | python | def comments(self, value):
"""
Setter for **self.__comments** attribute.
:param value: Attribute value.
:type value: OrderedDict or dict
"""
if value is not None:
assert type(value) in (OrderedDict, dict), "'{0}' attribute: '{1}' type is not \
'O... | [
"def",
"comments",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"in",
"(",
"OrderedDict",
",",
"dict",
")",
",",
"\"'{0}' attribute: '{1}' type is not \\\n 'OrderedDict' or 'dict'!\""... | Setter for **self.__comments** attribute.
:param value: Attribute value.
:type value: OrderedDict or dict | [
"Setter",
"for",
"**",
"self",
".",
"__comments",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L511-L527 |
KelSolaar/Foundations | foundations/parsers.py | SectionsFileParser.parsing_errors | def parsing_errors(self, value):
"""
Setter for **self.__parsing_errors** attribute.
:param value: Attribute value.
:type value: list
"""
if value is not None:
assert type(value) is list, "'{0}' attribute: '{1}' type is not 'list'!".format("parsing_errors", ... | python | def parsing_errors(self, value):
"""
Setter for **self.__parsing_errors** attribute.
:param value: Attribute value.
:type value: list
"""
if value is not None:
assert type(value) is list, "'{0}' attribute: '{1}' type is not 'list'!".format("parsing_errors", ... | [
"def",
"parsing_errors",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"list",
",",
"\"'{0}' attribute: '{1}' type is not 'list'!\"",
".",
"format",
"(",
"\"parsing_errors\"",
",",
"val... | Setter for **self.__parsing_errors** attribute.
:param value: Attribute value.
:type value: list | [
"Setter",
"for",
"**",
"self",
".",
"__parsing_errors",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L552-L566 |
KelSolaar/Foundations | foundations/parsers.py | SectionsFileParser.preserve_order | def preserve_order(self, value):
"""
Setter method for **self.__preserve_order** attribute.
:param value: Attribute value.
:type value: bool
"""
if value is not None:
assert type(value) is bool, "'{0}' attribute: '{1}' type is not 'bool'!".format("preserve_o... | python | def preserve_order(self, value):
"""
Setter method for **self.__preserve_order** attribute.
:param value: Attribute value.
:type value: bool
"""
if value is not None:
assert type(value) is bool, "'{0}' attribute: '{1}' type is not 'bool'!".format("preserve_o... | [
"def",
"preserve_order",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"bool",
",",
"\"'{0}' attribute: '{1}' type is not 'bool'!\"",
".",
"format",
"(",
"\"preserve_order\"",
",",
"val... | Setter method for **self.__preserve_order** attribute.
:param value: Attribute value.
:type value: bool | [
"Setter",
"method",
"for",
"**",
"self",
".",
"__preserve_order",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L591-L601 |
KelSolaar/Foundations | foundations/parsers.py | SectionsFileParser.parse | def parse(self,
raw_sections=None,
namespaces=True,
strip_comments=True,
strip_whitespaces=True,
strip_quotation_markers=True,
raise_parsing_errors=True):
"""
Process the file content and extracts the sections / attribut... | python | def parse(self,
raw_sections=None,
namespaces=True,
strip_comments=True,
strip_whitespaces=True,
strip_quotation_markers=True,
raise_parsing_errors=True):
"""
Process the file content and extracts the sections / attribut... | [
"def",
"parse",
"(",
"self",
",",
"raw_sections",
"=",
"None",
",",
"namespaces",
"=",
"True",
",",
"strip_comments",
"=",
"True",
",",
"strip_whitespaces",
"=",
"True",
",",
"strip_quotation_markers",
"=",
"True",
",",
"raise_parsing_errors",
"=",
"True",
")"... | Process the file content and extracts the sections / attributes
as nested :class:`collections.OrderedDict` dictionaries or dictionaries.
Usage::
>>> content = ["; Comment.\\n", "Attribute 1 = \\"Value A\\"\\n", "Attribute 2 = \\"Value B\\"\\n"]
>>> sections_file_parser = Se... | [
"Process",
"the",
"file",
"content",
"and",
"extracts",
"the",
"sections",
"/",
"attributes",
"as",
"nested",
":",
"class",
":",
"collections",
".",
"OrderedDict",
"dictionaries",
"or",
"dictionaries",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L672-L798 |
KelSolaar/Foundations | foundations/parsers.py | SectionsFileParser.section_exists | def section_exists(self, section):
"""
Checks if given section exists.
Usage::
>>> content = ["[Section A]\\n", "; Comment.\\n", "Attribute 1 = \\"Value A\\"\\n", "\\n", \
"[Section B]\\n", "Attribute 2 = \\"Value B\\"\\n"]
>>> sections_file_parser = SectionsFileParser(... | python | def section_exists(self, section):
"""
Checks if given section exists.
Usage::
>>> content = ["[Section A]\\n", "; Comment.\\n", "Attribute 1 = \\"Value A\\"\\n", "\\n", \
"[Section B]\\n", "Attribute 2 = \\"Value B\\"\\n"]
>>> sections_file_parser = SectionsFileParser(... | [
"def",
"section_exists",
"(",
"self",
",",
"section",
")",
":",
"if",
"section",
"in",
"self",
".",
"__sections",
":",
"LOGGER",
".",
"debug",
"(",
"\"> '{0}' section exists in '{1}'.\"",
".",
"format",
"(",
"section",
",",
"self",
")",
")",
"return",
"True"... | Checks if given section exists.
Usage::
>>> content = ["[Section A]\\n", "; Comment.\\n", "Attribute 1 = \\"Value A\\"\\n", "\\n", \
"[Section B]\\n", "Attribute 2 = \\"Value B\\"\\n"]
>>> sections_file_parser = SectionsFileParser()
>>> sections_file_parser.content = conten... | [
"Checks",
"if",
"given",
"section",
"exists",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L800-L828 |
KelSolaar/Foundations | foundations/parsers.py | SectionsFileParser.attribute_exists | def attribute_exists(self, attribute, section):
"""
Checks if given attribute exists.
Usage::
>>> content = ["[Section A]\\n", "; Comment.\\n", "Attribute 1 = \\"Value A\\"\\n", "\\n", \
"[Section B]\\n", "Attribute 2 = \\"Value B\\"\\n"]
>>> sections_file_parser = Sect... | python | def attribute_exists(self, attribute, section):
"""
Checks if given attribute exists.
Usage::
>>> content = ["[Section A]\\n", "; Comment.\\n", "Attribute 1 = \\"Value A\\"\\n", "\\n", \
"[Section B]\\n", "Attribute 2 = \\"Value B\\"\\n"]
>>> sections_file_parser = Sect... | [
"def",
"attribute_exists",
"(",
"self",
",",
"attribute",
",",
"section",
")",
":",
"if",
"foundations",
".",
"namespace",
".",
"remove_namespace",
"(",
"attribute",
",",
"root_only",
"=",
"True",
")",
"in",
"self",
".",
"get_attributes",
"(",
"section",
","... | Checks if given attribute exists.
Usage::
>>> content = ["[Section A]\\n", "; Comment.\\n", "Attribute 1 = \\"Value A\\"\\n", "\\n", \
"[Section B]\\n", "Attribute 2 = \\"Value B\\"\\n"]
>>> sections_file_parser = SectionsFileParser()
>>> sections_file_parser.content = cont... | [
"Checks",
"if",
"given",
"attribute",
"exists",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L830-L861 |
KelSolaar/Foundations | foundations/parsers.py | SectionsFileParser.get_attributes | def get_attributes(self, section, strip_namespaces=False):
"""
Returns given section attributes.
Usage::
>>> content = ["[Section A]\\n", "; Comment.\\n", "Attribute 1 = \\"Value A\\"\\n", "\\n", \
"[Section B]\\n", "Attribute 2 = \\"Value B\\"\\n"]
>>> sections_file_pa... | python | def get_attributes(self, section, strip_namespaces=False):
"""
Returns given section attributes.
Usage::
>>> content = ["[Section A]\\n", "; Comment.\\n", "Attribute 1 = \\"Value A\\"\\n", "\\n", \
"[Section B]\\n", "Attribute 2 = \\"Value B\\"\\n"]
>>> sections_file_pa... | [
"def",
"get_attributes",
"(",
"self",
",",
"section",
",",
"strip_namespaces",
"=",
"False",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"> Getting section '{0}' attributes.\"",
".",
"format",
"(",
"section",
")",
")",
"attributes",
"=",
"OrderedDict",
"(",
")",
... | Returns given section attributes.
Usage::
>>> content = ["[Section A]\\n", "; Comment.\\n", "Attribute 1 = \\"Value A\\"\\n", "\\n", \
"[Section B]\\n", "Attribute 2 = \\"Value B\\"\\n"]
>>> sections_file_parser = SectionsFileParser()
>>> sections_file_parser.content = cont... | [
"Returns",
"given",
"section",
"attributes",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L863-L904 |
KelSolaar/Foundations | foundations/parsers.py | SectionsFileParser.get_all_attributes | def get_all_attributes(self):
"""
Returns all sections attributes.
Usage::
>>> content = ["[Section A]\\n", "; Comment.\\n", "Attribute 1 = \\"Value A\\"\\n", "\\n", \
"[Section B]\\n", "Attribute 2 = \\"Value B\\"\\n"]
>>> sections_file_parser = SectionsFileParser()
... | python | def get_all_attributes(self):
"""
Returns all sections attributes.
Usage::
>>> content = ["[Section A]\\n", "; Comment.\\n", "Attribute 1 = \\"Value A\\"\\n", "\\n", \
"[Section B]\\n", "Attribute 2 = \\"Value B\\"\\n"]
>>> sections_file_parser = SectionsFileParser()
... | [
"def",
"get_all_attributes",
"(",
"self",
")",
":",
"all_attributes",
"=",
"OrderedDict",
"(",
")",
"if",
"self",
".",
"__preserve_order",
"else",
"dict",
"(",
")",
"for",
"attributes",
"in",
"self",
".",
"__sections",
".",
"itervalues",
"(",
")",
":",
"fo... | Returns all sections attributes.
Usage::
>>> content = ["[Section A]\\n", "; Comment.\\n", "Attribute 1 = \\"Value A\\"\\n", "\\n", \
"[Section B]\\n", "Attribute 2 = \\"Value B\\"\\n"]
>>> sections_file_parser = SectionsFileParser()
>>> sections_file_parser.content = conte... | [
"Returns",
"all",
"sections",
"attributes",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L906-L933 |
KelSolaar/Foundations | foundations/parsers.py | SectionsFileParser.get_value | def get_value(self, attribute, section, default=""):
"""
Returns requested attribute value.
Usage::
>>> content = ["[Section A]\\n", "; Comment.\\n", "Attribute 1 = \\"Value A\\"\\n", "\\n", \
"[Section B]\\n", "Attribute 2 = \\"Value B\\"\\n"]
>>> sections_file_parser ... | python | def get_value(self, attribute, section, default=""):
"""
Returns requested attribute value.
Usage::
>>> content = ["[Section A]\\n", "; Comment.\\n", "Attribute 1 = \\"Value A\\"\\n", "\\n", \
"[Section B]\\n", "Attribute 2 = \\"Value B\\"\\n"]
>>> sections_file_parser ... | [
"def",
"get_value",
"(",
"self",
",",
"attribute",
",",
"section",
",",
"default",
"=",
"\"\"",
")",
":",
"if",
"not",
"self",
".",
"attribute_exists",
"(",
"attribute",
",",
"section",
")",
":",
"return",
"default",
"if",
"attribute",
"in",
"self",
".",... | Returns requested attribute value.
Usage::
>>> content = ["[Section A]\\n", "; Comment.\\n", "Attribute 1 = \\"Value A\\"\\n", "\\n", \
"[Section B]\\n", "Attribute 2 = \\"Value B\\"\\n"]
>>> sections_file_parser = SectionsFileParser()
>>> sections_file_parser.content = con... | [
"Returns",
"requested",
"attribute",
"value",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L936-L969 |
KelSolaar/Foundations | foundations/parsers.py | SectionsFileParser.set_value | def set_value(self, attribute, section, value):
"""
Sets requested attribute value.
Usage::
>>> content = ["[Section A]\\n", "; Comment.\\n", "Attribute 1 = \\"Value A\\"\\n", "\\n", \
"[Section B]\\n", "Attribute 2 = \\"Value B\\"\\n"]
>>> sections_file_parser = Sectio... | python | def set_value(self, attribute, section, value):
"""
Sets requested attribute value.
Usage::
>>> content = ["[Section A]\\n", "; Comment.\\n", "Attribute 1 = \\"Value A\\"\\n", "\\n", \
"[Section B]\\n", "Attribute 2 = \\"Value B\\"\\n"]
>>> sections_file_parser = Sectio... | [
"def",
"set_value",
"(",
"self",
",",
"attribute",
",",
"section",
",",
"value",
")",
":",
"if",
"not",
"self",
".",
"section_exists",
"(",
"section",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"> Adding '{0}' section.\"",
".",
"format",
"(",
"section",
")",... | Sets requested attribute value.
Usage::
>>> content = ["[Section A]\\n", "; Comment.\\n", "Attribute 1 = \\"Value A\\"\\n", "\\n", \
"[Section B]\\n", "Attribute 2 = \\"Value B\\"\\n"]
>>> sections_file_parser = SectionsFileParser()
>>> sections_file_parser.content = conten... | [
"Sets",
"requested",
"attribute",
"value",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L971-L1002 |
KelSolaar/Foundations | foundations/parsers.py | SectionsFileParser.write | def write(self,
namespaces=False,
splitter="=",
comment_limiter=(";"),
spaces_around_splitter=True,
space_after_comment_limiter=True):
"""
Writes defined file using :obj:`SectionsFileParser.sections` and
:obj:`SectionsFile... | python | def write(self,
namespaces=False,
splitter="=",
comment_limiter=(";"),
spaces_around_splitter=True,
space_after_comment_limiter=True):
"""
Writes defined file using :obj:`SectionsFileParser.sections` and
:obj:`SectionsFile... | [
"def",
"write",
"(",
"self",
",",
"namespaces",
"=",
"False",
",",
"splitter",
"=",
"\"=\"",
",",
"comment_limiter",
"=",
"(",
"\";\"",
")",
",",
"spaces_around_splitter",
"=",
"True",
",",
"space_after_comment_limiter",
"=",
"True",
")",
":",
"self",
".",
... | Writes defined file using :obj:`SectionsFileParser.sections` and
:obj:`SectionsFileParser.comments` class properties content.
Usage::
>>> sections = {"Section A": {"Section A|Attribute 1": "Value A"}, \
"Section B": {"Section B|Attribute 2": "Value B"}}
>>> sections_file_pa... | [
"Writes",
"defined",
"file",
"using",
":",
"obj",
":",
"SectionsFileParser",
".",
"sections",
"and",
":",
"obj",
":",
"SectionsFileParser",
".",
"comments",
"class",
"properties",
"content",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L1004-L1089 |
KelSolaar/Foundations | foundations/parsers.py | PlistFileParser.elements | def elements(self, value):
"""
Setter for **self.__elements** attribute.
:param value: Attribute value.
:type value: OrderedDict or dict
"""
if value is not None:
assert type(value) is dict, "'{0}' attribute: '{1}' type is not dict'!".format("elements", val... | python | def elements(self, value):
"""
Setter for **self.__elements** attribute.
:param value: Attribute value.
:type value: OrderedDict or dict
"""
if value is not None:
assert type(value) is dict, "'{0}' attribute: '{1}' type is not dict'!".format("elements", val... | [
"def",
"elements",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"dict",
",",
"\"'{0}' attribute: '{1}' type is not dict'!\"",
".",
"format",
"(",
"\"elements\"",
",",
"value",
")",
... | Setter for **self.__elements** attribute.
:param value: Attribute value.
:type value: OrderedDict or dict | [
"Setter",
"for",
"**",
"self",
".",
"__elements",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L1147-L1157 |
KelSolaar/Foundations | foundations/parsers.py | PlistFileParser.unserializers | def unserializers(self, value):
"""
Setter for **self.__unserializers** attribute.
:param value: Attribute value.
:type value: dict
"""
raise foundations.exceptions.ProgrammingError(
"{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "unse... | python | def unserializers(self, value):
"""
Setter for **self.__unserializers** attribute.
:param value: Attribute value.
:type value: dict
"""
raise foundations.exceptions.ProgrammingError(
"{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "unse... | [
"def",
"unserializers",
"(",
"self",
",",
"value",
")",
":",
"raise",
"foundations",
".",
"exceptions",
".",
"ProgrammingError",
"(",
"\"{0} | '{1}' attribute is read only!\"",
".",
"format",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"\"unserializers\"",
... | Setter for **self.__unserializers** attribute.
:param value: Attribute value.
:type value: dict | [
"Setter",
"for",
"**",
"self",
".",
"__unserializers",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L1221-L1230 |
KelSolaar/Foundations | foundations/parsers.py | PlistFileParser.parse | def parse(self, raise_parsing_errors=True):
"""
Process the file content.
Usage::
>>> plist_file_parser = PlistFileParser("standard.plist")
>>> plist_file_parser.parse()
True
>>> plist_file_parser.elements.keys()
[u'Dictionary A', u'N... | python | def parse(self, raise_parsing_errors=True):
"""
Process the file content.
Usage::
>>> plist_file_parser = PlistFileParser("standard.plist")
>>> plist_file_parser.parse()
True
>>> plist_file_parser.elements.keys()
[u'Dictionary A', u'N... | [
"def",
"parse",
"(",
"self",
",",
"raise_parsing_errors",
"=",
"True",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"> Reading elements from: '{0}'.\"",
".",
"format",
"(",
"self",
".",
"path",
")",
")",
"element_tree_parser",
"=",
"ElementTree",
".",
"iterparse",
... | Process the file content.
Usage::
>>> plist_file_parser = PlistFileParser("standard.plist")
>>> plist_file_parser.parse()
True
>>> plist_file_parser.elements.keys()
[u'Dictionary A', u'Number A', u'Array A', u'String A', u'Date A', u'Boolean A', u'Da... | [
"Process",
"the",
"file",
"content",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L1243-L1283 |
KelSolaar/Foundations | foundations/parsers.py | PlistFileParser.element_exists | def element_exists(self, element):
"""
Checks if given element exists.
Usage::
>>> plist_file_parser = PlistFileParser("standard.plist")
>>> plist_file_parser.parse()
True
>>> plist_file_parser.element_exists("String A")
True
... | python | def element_exists(self, element):
"""
Checks if given element exists.
Usage::
>>> plist_file_parser = PlistFileParser("standard.plist")
>>> plist_file_parser.parse()
True
>>> plist_file_parser.element_exists("String A")
True
... | [
"def",
"element_exists",
"(",
"self",
",",
"element",
")",
":",
"if",
"not",
"self",
".",
"__elements",
":",
"return",
"False",
"for",
"item",
"in",
"foundations",
".",
"walkers",
".",
"dictionaries_walker",
"(",
"self",
".",
"__elements",
")",
":",
"path"... | Checks if given element exists.
Usage::
>>> plist_file_parser = PlistFileParser("standard.plist")
>>> plist_file_parser.parse()
True
>>> plist_file_parser.element_exists("String A")
True
>>> plist_file_parser.element_exists("String Nemo")... | [
"Checks",
"if",
"given",
"element",
"exists",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L1285-L1315 |
KelSolaar/Foundations | foundations/parsers.py | PlistFileParser.filter_values | def filter_values(self, pattern, flags=0):
"""
| Filters the :meth:`PlistFileParser.elements` class property elements using given pattern.
| Will return a list of matching elements values, if you want to get only one element value, use
the :meth:`PlistFileParser.get_value` method ins... | python | def filter_values(self, pattern, flags=0):
"""
| Filters the :meth:`PlistFileParser.elements` class property elements using given pattern.
| Will return a list of matching elements values, if you want to get only one element value, use
the :meth:`PlistFileParser.get_value` method ins... | [
"def",
"filter_values",
"(",
"self",
",",
"pattern",
",",
"flags",
"=",
"0",
")",
":",
"values",
"=",
"[",
"]",
"if",
"not",
"self",
".",
"__elements",
":",
"return",
"values",
"for",
"item",
"in",
"foundations",
".",
"walkers",
".",
"dictionaries_walker... | | Filters the :meth:`PlistFileParser.elements` class property elements using given pattern.
| Will return a list of matching elements values, if you want to get only one element value, use
the :meth:`PlistFileParser.get_value` method instead.
Usage::
>>> plist_file_parser = Pli... | [
"|",
"Filters",
"the",
":",
"meth",
":",
"PlistFileParser",
".",
"elements",
"class",
"property",
"elements",
"using",
"given",
"pattern",
".",
"|",
"Will",
"return",
"a",
"list",
"of",
"matching",
"elements",
"values",
"if",
"you",
"want",
"to",
"get",
"o... | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L1317-L1349 |
KelSolaar/Foundations | foundations/parsers.py | PlistFileParser.get_value | def get_value(self, element):
"""
| Returns the given element value.
| If multiple elements with the same name exists, only the first encountered will be returned.
Usage::
>>> plist_file_parser = PlistFileParser("standard.plist")
>>> plist_file_parser.parse()
... | python | def get_value(self, element):
"""
| Returns the given element value.
| If multiple elements with the same name exists, only the first encountered will be returned.
Usage::
>>> plist_file_parser = PlistFileParser("standard.plist")
>>> plist_file_parser.parse()
... | [
"def",
"get_value",
"(",
"self",
",",
"element",
")",
":",
"if",
"not",
"self",
".",
"__elements",
":",
"return",
"values",
"=",
"self",
".",
"filter_values",
"(",
"r\"^{0}$\"",
".",
"format",
"(",
"element",
")",
")",
"return",
"foundations",
".",
"comm... | | Returns the given element value.
| If multiple elements with the same name exists, only the first encountered will be returned.
Usage::
>>> plist_file_parser = PlistFileParser("standard.plist")
>>> plist_file_parser.parse()
True
>>> plist_file_parser.g... | [
"|",
"Returns",
"the",
"given",
"element",
"value",
".",
"|",
"If",
"multiple",
"elements",
"with",
"the",
"same",
"name",
"exists",
"only",
"the",
"first",
"encountered",
"will",
"be",
"returned",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/parsers.py#L1351-L1374 |
heuer/cablemap | cablemap.nlp/cablemap/nlp/utils.py | IncrementalMmWriter.add_vector | def add_vector(self, vector):
"""\
Writes the provided vector to the matrix.
`vector`
An iterable of ``(word-id, word-frequency)`` tuples
"""
self._num_docs+=1
max_id, veclen = self._mmw.write_vector(self._num_docs, vector)
self._num_terms = max(self.... | python | def add_vector(self, vector):
"""\
Writes the provided vector to the matrix.
`vector`
An iterable of ``(word-id, word-frequency)`` tuples
"""
self._num_docs+=1
max_id, veclen = self._mmw.write_vector(self._num_docs, vector)
self._num_terms = max(self.... | [
"def",
"add_vector",
"(",
"self",
",",
"vector",
")",
":",
"self",
".",
"_num_docs",
"+=",
"1",
"max_id",
",",
"veclen",
"=",
"self",
".",
"_mmw",
".",
"write_vector",
"(",
"self",
".",
"_num_docs",
",",
"vector",
")",
"self",
".",
"_num_terms",
"=",
... | \
Writes the provided vector to the matrix.
`vector`
An iterable of ``(word-id, word-frequency)`` tuples | [
"\\",
"Writes",
"the",
"provided",
"vector",
"to",
"the",
"matrix",
"."
] | train | https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.nlp/cablemap/nlp/utils.py#L65-L75 |
heuer/cablemap | cablemap.nlp/cablemap/nlp/utils.py | IncrementalMmWriter.close | def close(self):
"""\
Closes the writer.
This method MUST be called once all vectors are added.
"""
self._mmw.fake_headers(self._num_docs+1, self._num_terms, self._num_nnz)
self._mmw.close() | python | def close(self):
"""\
Closes the writer.
This method MUST be called once all vectors are added.
"""
self._mmw.fake_headers(self._num_docs+1, self._num_terms, self._num_nnz)
self._mmw.close() | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"_mmw",
".",
"fake_headers",
"(",
"self",
".",
"_num_docs",
"+",
"1",
",",
"self",
".",
"_num_terms",
",",
"self",
".",
"_num_nnz",
")",
"self",
".",
"_mmw",
".",
"close",
"(",
")"
] | \
Closes the writer.
This method MUST be called once all vectors are added. | [
"\\",
"Closes",
"the",
"writer",
"."
] | train | https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.nlp/cablemap/nlp/utils.py#L77-L84 |
quantmind/pulsar-odm | odm/dialects/postgresql/green.py | psycopg2_wait_callback | def psycopg2_wait_callback(conn):
"""A wait callback to allow greenlet to work with Psycopg.
The caller must be from a greenlet other than the main one.
:param conn: psycopg2 connection or file number
This function must be invoked from a coroutine with parent, therefore
invoking it from the main g... | python | def psycopg2_wait_callback(conn):
"""A wait callback to allow greenlet to work with Psycopg.
The caller must be from a greenlet other than the main one.
:param conn: psycopg2 connection or file number
This function must be invoked from a coroutine with parent, therefore
invoking it from the main g... | [
"def",
"psycopg2_wait_callback",
"(",
"conn",
")",
":",
"while",
"True",
":",
"state",
"=",
"conn",
".",
"poll",
"(",
")",
"if",
"state",
"==",
"extensions",
".",
"POLL_OK",
":",
"# Done with waiting",
"break",
"elif",
"state",
"==",
"extensions",
".",
"PO... | A wait callback to allow greenlet to work with Psycopg.
The caller must be from a greenlet other than the main one.
:param conn: psycopg2 connection or file number
This function must be invoked from a coroutine with parent, therefore
invoking it from the main greenlet will raise an exception. | [
"A",
"wait",
"callback",
"to",
"allow",
"greenlet",
"to",
"work",
"with",
"Psycopg",
".",
"The",
"caller",
"must",
"be",
"from",
"a",
"greenlet",
"other",
"than",
"the",
"main",
"one",
"."
] | train | https://github.com/quantmind/pulsar-odm/blob/5955c20beca0a89270c2b390335838deb7d5915e/odm/dialects/postgresql/green.py#L12-L31 |
quantmind/pulsar-odm | odm/dialects/postgresql/green.py | _wait_fd | def _wait_fd(conn, read=True):
'''Wait for an event on file descriptor ``fd``.
:param conn: file descriptor
:param read: wait for a read event if ``True``, otherwise a wait
for write event.
This function must be invoked from a coroutine with parent, therefore
invoking it from the main gree... | python | def _wait_fd(conn, read=True):
'''Wait for an event on file descriptor ``fd``.
:param conn: file descriptor
:param read: wait for a read event if ``True``, otherwise a wait
for write event.
This function must be invoked from a coroutine with parent, therefore
invoking it from the main gree... | [
"def",
"_wait_fd",
"(",
"conn",
",",
"read",
"=",
"True",
")",
":",
"current",
"=",
"getcurrent",
"(",
")",
"parent",
"=",
"current",
".",
"parent",
"assert",
"parent",
",",
"'\"_wait_fd\" must be called by greenlet with a parent'",
"try",
":",
"fileno",
"=",
... | Wait for an event on file descriptor ``fd``.
:param conn: file descriptor
:param read: wait for a read event if ``True``, otherwise a wait
for write event.
This function must be invoked from a coroutine with parent, therefore
invoking it from the main greenlet will raise an exception. | [
"Wait",
"for",
"an",
"event",
"on",
"file",
"descriptor",
"fd",
"."
] | train | https://github.com/quantmind/pulsar-odm/blob/5955c20beca0a89270c2b390335838deb7d5915e/odm/dialects/postgresql/green.py#L36-L62 |
goshuirc/irc | girc/__init__.py | Reactor.shutdown | def shutdown(self, message=None):
"""Disconnect all servers with a message.
Args:
message (str): Quit message to use on each connection.
"""
for name, server in self.servers.items():
server.quit(message) | python | def shutdown(self, message=None):
"""Disconnect all servers with a message.
Args:
message (str): Quit message to use on each connection.
"""
for name, server in self.servers.items():
server.quit(message) | [
"def",
"shutdown",
"(",
"self",
",",
"message",
"=",
"None",
")",
":",
"for",
"name",
",",
"server",
"in",
"self",
".",
"servers",
".",
"items",
"(",
")",
":",
"server",
".",
"quit",
"(",
"message",
")"
] | Disconnect all servers with a message.
Args:
message (str): Quit message to use on each connection. | [
"Disconnect",
"all",
"servers",
"with",
"a",
"message",
"."
] | train | https://github.com/goshuirc/irc/blob/d6a5e3e04d337566c009b087f108cd76f9e122cc/girc/__init__.py#L53-L60 |
goshuirc/irc | girc/__init__.py | Reactor.create_server | def create_server(self, server_name, *args, **kwargs):
"""Create an IRC server connection slot.
The server will actually be connected to when
:meth:`girc.client.ServerConnection.connect` is called later.
Args:
server_name (str): Name of the server, to be used for functions ... | python | def create_server(self, server_name, *args, **kwargs):
"""Create an IRC server connection slot.
The server will actually be connected to when
:meth:`girc.client.ServerConnection.connect` is called later.
Args:
server_name (str): Name of the server, to be used for functions ... | [
"def",
"create_server",
"(",
"self",
",",
"server_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"server",
"=",
"ServerConnection",
"(",
"name",
"=",
"server_name",
",",
"reactor",
"=",
"self",
")",
"if",
"args",
"or",
"kwargs",
":",
"serv... | Create an IRC server connection slot.
The server will actually be connected to when
:meth:`girc.client.ServerConnection.connect` is called later.
Args:
server_name (str): Name of the server, to be used for functions and accessing the
server later through the reactor... | [
"Create",
"an",
"IRC",
"server",
"connection",
"slot",
"."
] | train | https://github.com/goshuirc/irc/blob/d6a5e3e04d337566c009b087f108cd76f9e122cc/girc/__init__.py#L63-L89 |
goshuirc/irc | girc/__init__.py | Reactor._destroy_server | def _destroy_server(self, server_name):
"""Destroys the given server, called internally."""
try:
del self.servers[server_name]
except KeyError:
pass
if self.auto_close and not self.servers:
loop.stop() | python | def _destroy_server(self, server_name):
"""Destroys the given server, called internally."""
try:
del self.servers[server_name]
except KeyError:
pass
if self.auto_close and not self.servers:
loop.stop() | [
"def",
"_destroy_server",
"(",
"self",
",",
"server_name",
")",
":",
"try",
":",
"del",
"self",
".",
"servers",
"[",
"server_name",
"]",
"except",
"KeyError",
":",
"pass",
"if",
"self",
".",
"auto_close",
"and",
"not",
"self",
".",
"servers",
":",
"loop"... | Destroys the given server, called internally. | [
"Destroys",
"the",
"given",
"server",
"called",
"internally",
"."
] | train | https://github.com/goshuirc/irc/blob/d6a5e3e04d337566c009b087f108cd76f9e122cc/girc/__init__.py#L91-L99 |
goshuirc/irc | girc/__init__.py | Reactor.handler | def handler(self, direction, verb, priority=10):
"""Register this function as an event handler.
Args:
direction (str): ``in``, ``out``, ``both``, ``raw``.
verb (str): Event name.
priority (int): Handler priority (lower priority executes first).
Example:
... | python | def handler(self, direction, verb, priority=10):
"""Register this function as an event handler.
Args:
direction (str): ``in``, ``out``, ``both``, ``raw``.
verb (str): Event name.
priority (int): Handler priority (lower priority executes first).
Example:
... | [
"def",
"handler",
"(",
"self",
",",
"direction",
",",
"verb",
",",
"priority",
"=",
"10",
")",
":",
"def",
"parent_fn",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"child_fn",
"(",
"msg",
")",
":",
"func",
"(",
... | Register this function as an event handler.
Args:
direction (str): ``in``, ``out``, ``both``, ``raw``.
verb (str): Event name.
priority (int): Handler priority (lower priority executes first).
Example:
These handlers print out a pretty raw log::
... | [
"Register",
"this",
"function",
"as",
"an",
"event",
"handler",
"."
] | train | https://github.com/goshuirc/irc/blob/d6a5e3e04d337566c009b087f108cd76f9e122cc/girc/__init__.py#L102-L130 |
goshuirc/irc | girc/__init__.py | Reactor.register_event | def register_event(self, direction, verb, child_fn, priority=10):
"""Register an event with all servers.
Args:
direction (str): `in`, `out`, `both`, `raw`.
verb (str): Event name.
child_fn (function): Handler function.
priority (int): Handler priority (lo... | python | def register_event(self, direction, verb, child_fn, priority=10):
"""Register an event with all servers.
Args:
direction (str): `in`, `out`, `both`, `raw`.
verb (str): Event name.
child_fn (function): Handler function.
priority (int): Handler priority (lo... | [
"def",
"register_event",
"(",
"self",
",",
"direction",
",",
"verb",
",",
"child_fn",
",",
"priority",
"=",
"10",
")",
":",
"if",
"verb",
"not",
"in",
"self",
".",
"_event_handlers",
":",
"self",
".",
"_event_handlers",
"[",
"verb",
"]",
"=",
"[",
"]",... | Register an event with all servers.
Args:
direction (str): `in`, `out`, `both`, `raw`.
verb (str): Event name.
child_fn (function): Handler function.
priority (int): Handler priority (lower priority executes first). | [
"Register",
"an",
"event",
"with",
"all",
"servers",
"."
] | train | https://github.com/goshuirc/irc/blob/d6a5e3e04d337566c009b087f108cd76f9e122cc/girc/__init__.py#L132-L151 |
limodou/par | par/semantic_ext.py | semantic_alert | def semantic_alert(visitor, block):
"""
Format:
{% alert class=error %}
message
{% endalert %}
"""
txt = []
cls = block['kwargs'].get('class', '')
txt.append('<div class="ui %s message">' % cls)
text = visitor.parse_text(block['body'], 'article')
txt.appe... | python | def semantic_alert(visitor, block):
"""
Format:
{% alert class=error %}
message
{% endalert %}
"""
txt = []
cls = block['kwargs'].get('class', '')
txt.append('<div class="ui %s message">' % cls)
text = visitor.parse_text(block['body'], 'article')
txt.appe... | [
"def",
"semantic_alert",
"(",
"visitor",
",",
"block",
")",
":",
"txt",
"=",
"[",
"]",
"cls",
"=",
"block",
"[",
"'kwargs'",
"]",
".",
"get",
"(",
"'class'",
",",
"''",
")",
"txt",
".",
"append",
"(",
"'<div class=\"ui %s message\">'",
"%",
"cls",
")",... | Format:
{% alert class=error %}
message
{% endalert %} | [
"Format",
":",
"{",
"%",
"alert",
"class",
"=",
"error",
"%",
"}",
"message",
"{",
"%",
"endalert",
"%",
"}"
] | train | https://github.com/limodou/par/blob/0863c339c8d0d46f8516eb4577b459b9cf2dec8d/par/semantic_ext.py#L2-L16 |
limodou/par | par/semantic_ext.py | semantic_tabs | def semantic_tabs(visitor, block):
"""
Render text as bootstrap tabs, for example:
{% tabs %}
-- name --
...
...
-- name --
...
...
{% endtabs %}
"""
import re
global __section__
__section__ += 1
r_name = re.c... | python | def semantic_tabs(visitor, block):
"""
Render text as bootstrap tabs, for example:
{% tabs %}
-- name --
...
...
-- name --
...
...
{% endtabs %}
"""
import re
global __section__
__section__ += 1
r_name = re.c... | [
"def",
"semantic_tabs",
"(",
"visitor",
",",
"block",
")",
":",
"import",
"re",
"global",
"__section__",
"__section__",
"+=",
"1",
"r_name",
"=",
"re",
".",
"compile",
"(",
"r'(^-- [^-]+ --$)'",
",",
"re",
".",
"M",
")",
"def",
"get_id",
"(",
")",
":",
... | Render text as bootstrap tabs, for example:
{% tabs %}
-- name --
...
...
-- name --
...
...
{% endtabs %} | [
"Render",
"text",
"as",
"bootstrap",
"tabs",
"for",
"example",
":",
"{",
"%",
"tabs",
"%",
"}",
"--",
"name",
"--",
"...",
"...",
"--",
"name",
"--",
"...",
"...",
"{",
"%",
"endtabs",
"%",
"}"
] | train | https://github.com/limodou/par/blob/0863c339c8d0d46f8516eb4577b459b9cf2dec8d/par/semantic_ext.py#L21-L88 |
hamstah/ukpostcodeparser | ukpostcodeparser/parser.py | parse_uk_postcode | def parse_uk_postcode(postcode, strict=True, incode_mandatory=True):
'''Split UK postcode into outcode and incode portions.
Arguments:
postcode The postcode to be split.
strict If true, the postcode will be validated according to
the rules as specified at... | python | def parse_uk_postcode(postcode, strict=True, incode_mandatory=True):
'''Split UK postcode into outcode and incode portions.
Arguments:
postcode The postcode to be split.
strict If true, the postcode will be validated according to
the rules as specified at... | [
"def",
"parse_uk_postcode",
"(",
"postcode",
",",
"strict",
"=",
"True",
",",
"incode_mandatory",
"=",
"True",
")",
":",
"postcode",
"=",
"postcode",
".",
"replace",
"(",
"' '",
",",
"''",
")",
".",
"upper",
"(",
")",
"# Normalize",
"if",
"len",
"(",
"... | Split UK postcode into outcode and incode portions.
Arguments:
postcode The postcode to be split.
strict If true, the postcode will be validated according to
the rules as specified at the Universal Postal Union[1]
and The UK Government... | [
"Split",
"UK",
"postcode",
"into",
"outcode",
"and",
"incode",
"portions",
"."
] | train | https://github.com/hamstah/ukpostcodeparser/blob/e36d6f07e5d410382641b5599f122d7c1b3dabdd/ukpostcodeparser/parser.py#L66-L146 |
splitkeycoffee/pyhottop | pyhottop/pyhottop.py | now_time | def now_time(str=False):
"""Get the current time."""
if str:
return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
return datetime.datetime.now() | python | def now_time(str=False):
"""Get the current time."""
if str:
return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
return datetime.datetime.now() | [
"def",
"now_time",
"(",
"str",
"=",
"False",
")",
":",
"if",
"str",
":",
"return",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
".",
"strftime",
"(",
"\"%Y-%m-%d %H:%M:%S\"",
")",
"return",
"datetime",
".",
"datetime",
".",
"now",
"(",
")"
] | Get the current time. | [
"Get",
"the",
"current",
"time",
"."
] | train | https://github.com/splitkeycoffee/pyhottop/blob/2986bbb2d848f7e41fa3ece5ebb1b33c8882219c/pyhottop/pyhottop.py#L79-L83 |
splitkeycoffee/pyhottop | pyhottop/pyhottop.py | now_date | def now_date(str=False):
"""Get the current date."""
if str:
return datetime.datetime.now().strftime("%Y-%m-%d")
return datetime.date.today() | python | def now_date(str=False):
"""Get the current date."""
if str:
return datetime.datetime.now().strftime("%Y-%m-%d")
return datetime.date.today() | [
"def",
"now_date",
"(",
"str",
"=",
"False",
")",
":",
"if",
"str",
":",
"return",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
".",
"strftime",
"(",
"\"%Y-%m-%d\"",
")",
"return",
"datetime",
".",
"date",
".",
"today",
"(",
")"
] | Get the current date. | [
"Get",
"the",
"current",
"date",
"."
] | train | https://github.com/splitkeycoffee/pyhottop/blob/2986bbb2d848f7e41fa3ece5ebb1b33c8882219c/pyhottop/pyhottop.py#L86-L90 |
splitkeycoffee/pyhottop | pyhottop/pyhottop.py | timedelta2millisecond | def timedelta2millisecond(td):
"""Get milliseconds from a timedelta."""
milliseconds = td.days * 24 * 60 * 60 * 1000
milliseconds += td.seconds * 1000
milliseconds += td.microseconds / 1000
return milliseconds | python | def timedelta2millisecond(td):
"""Get milliseconds from a timedelta."""
milliseconds = td.days * 24 * 60 * 60 * 1000
milliseconds += td.seconds * 1000
milliseconds += td.microseconds / 1000
return milliseconds | [
"def",
"timedelta2millisecond",
"(",
"td",
")",
":",
"milliseconds",
"=",
"td",
".",
"days",
"*",
"24",
"*",
"60",
"*",
"60",
"*",
"1000",
"milliseconds",
"+=",
"td",
".",
"seconds",
"*",
"1000",
"milliseconds",
"+=",
"td",
".",
"microseconds",
"/",
"1... | Get milliseconds from a timedelta. | [
"Get",
"milliseconds",
"from",
"a",
"timedelta",
"."
] | train | https://github.com/splitkeycoffee/pyhottop/blob/2986bbb2d848f7e41fa3ece5ebb1b33c8882219c/pyhottop/pyhottop.py#L98-L103 |
splitkeycoffee/pyhottop | pyhottop/pyhottop.py | timedelta2period | def timedelta2period(duration):
"""Convert timedelta to different formats."""
seconds = duration.seconds
minutes = (seconds % 3600) // 60
seconds = (seconds % 60)
return '{0:0>2}:{1:0>2}'.format(minutes, seconds) | python | def timedelta2period(duration):
"""Convert timedelta to different formats."""
seconds = duration.seconds
minutes = (seconds % 3600) // 60
seconds = (seconds % 60)
return '{0:0>2}:{1:0>2}'.format(minutes, seconds) | [
"def",
"timedelta2period",
"(",
"duration",
")",
":",
"seconds",
"=",
"duration",
".",
"seconds",
"minutes",
"=",
"(",
"seconds",
"%",
"3600",
")",
"//",
"60",
"seconds",
"=",
"(",
"seconds",
"%",
"60",
")",
"return",
"'{0:0>2}:{1:0>2}'",
".",
"format",
... | Convert timedelta to different formats. | [
"Convert",
"timedelta",
"to",
"different",
"formats",
"."
] | train | https://github.com/splitkeycoffee/pyhottop/blob/2986bbb2d848f7e41fa3ece5ebb1b33c8882219c/pyhottop/pyhottop.py#L106-L111 |
splitkeycoffee/pyhottop | pyhottop/pyhottop.py | ControlProcess._generate_config | def _generate_config(self):
"""Generate a configuration that can be sent to the Hottop roaster.
Configuration settings need to be represented inside of a byte array
that is then written to the serial interface. Much of the configuration
is static, but control settings are also included ... | python | def _generate_config(self):
"""Generate a configuration that can be sent to the Hottop roaster.
Configuration settings need to be represented inside of a byte array
that is then written to the serial interface. Much of the configuration
is static, but control settings are also included ... | [
"def",
"_generate_config",
"(",
"self",
")",
":",
"config",
"=",
"bytearray",
"(",
"[",
"0x00",
"]",
"*",
"36",
")",
"config",
"[",
"0",
"]",
"=",
"0xA5",
"config",
"[",
"1",
"]",
"=",
"0x96",
"config",
"[",
"2",
"]",
"=",
"0xB0",
"config",
"[",
... | Generate a configuration that can be sent to the Hottop roaster.
Configuration settings need to be represented inside of a byte array
that is then written to the serial interface. Much of the configuration
is static, but control settings are also included and pulled from the
shared dict... | [
"Generate",
"a",
"configuration",
"that",
"can",
"be",
"sent",
"to",
"the",
"Hottop",
"roaster",
"."
] | train | https://github.com/splitkeycoffee/pyhottop/blob/2986bbb2d848f7e41fa3ece5ebb1b33c8882219c/pyhottop/pyhottop.py#L148-L176 |
splitkeycoffee/pyhottop | pyhottop/pyhottop.py | ControlProcess._send_config | def _send_config(self):
"""Send configuration data to the hottop.
:returns: bool
:raises: Generic exceptions if an error is identified.
"""
serialized = self._generate_config()
self._log.debug("Configuration has been serialized")
try:
self._conn.flush... | python | def _send_config(self):
"""Send configuration data to the hottop.
:returns: bool
:raises: Generic exceptions if an error is identified.
"""
serialized = self._generate_config()
self._log.debug("Configuration has been serialized")
try:
self._conn.flush... | [
"def",
"_send_config",
"(",
"self",
")",
":",
"serialized",
"=",
"self",
".",
"_generate_config",
"(",
")",
"self",
".",
"_log",
".",
"debug",
"(",
"\"Configuration has been serialized\"",
")",
"try",
":",
"self",
".",
"_conn",
".",
"flushInput",
"(",
")",
... | Send configuration data to the hottop.
:returns: bool
:raises: Generic exceptions if an error is identified. | [
"Send",
"configuration",
"data",
"to",
"the",
"hottop",
"."
] | train | https://github.com/splitkeycoffee/pyhottop/blob/2986bbb2d848f7e41fa3ece5ebb1b33c8882219c/pyhottop/pyhottop.py#L178-L193 |
splitkeycoffee/pyhottop | pyhottop/pyhottop.py | ControlProcess._validate_checksum | def _validate_checksum(self, buffer):
"""Validate the buffer response against the checksum.
When reading the serial interface, data will come back in a raw format
with an included checksum process.
:returns: bool
"""
self._log.debug("Validating the buffer")
if l... | python | def _validate_checksum(self, buffer):
"""Validate the buffer response against the checksum.
When reading the serial interface, data will come back in a raw format
with an included checksum process.
:returns: bool
"""
self._log.debug("Validating the buffer")
if l... | [
"def",
"_validate_checksum",
"(",
"self",
",",
"buffer",
")",
":",
"self",
".",
"_log",
".",
"debug",
"(",
"\"Validating the buffer\"",
")",
"if",
"len",
"(",
"buffer",
")",
"==",
"0",
":",
"self",
".",
"_log",
".",
"debug",
"(",
"\"Buffer was empty\"",
... | Validate the buffer response against the checksum.
When reading the serial interface, data will come back in a raw format
with an included checksum process.
:returns: bool | [
"Validate",
"the",
"buffer",
"response",
"against",
"the",
"checksum",
"."
] | train | https://github.com/splitkeycoffee/pyhottop/blob/2986bbb2d848f7e41fa3ece5ebb1b33c8882219c/pyhottop/pyhottop.py#L195-L217 |
splitkeycoffee/pyhottop | pyhottop/pyhottop.py | ControlProcess._read_settings | def _read_settings(self, retry=True):
"""Read the information from the Hottop.
Read the settings from the serial interface and convert them into a
human-readable format that can be shared back to the end-user. Reading
from the serial interface will occasionally produce strange results o... | python | def _read_settings(self, retry=True):
"""Read the information from the Hottop.
Read the settings from the serial interface and convert them into a
human-readable format that can be shared back to the end-user. Reading
from the serial interface will occasionally produce strange results o... | [
"def",
"_read_settings",
"(",
"self",
",",
"retry",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"_conn",
".",
"isOpen",
"(",
")",
":",
"self",
".",
"_log",
".",
"debug",
"(",
"\"Reopening connection\"",
")",
"self",
".",
"_conn",
".",
"open",
"(... | Read the information from the Hottop.
Read the settings from the serial interface and convert them into a
human-readable format that can be shared back to the end-user. Reading
from the serial interface will occasionally produce strange results or
blank reads, so a retry process has bee... | [
"Read",
"the",
"information",
"from",
"the",
"Hottop",
"."
] | train | https://github.com/splitkeycoffee/pyhottop/blob/2986bbb2d848f7e41fa3ece5ebb1b33c8882219c/pyhottop/pyhottop.py#L219-L273 |
splitkeycoffee/pyhottop | pyhottop/pyhottop.py | ControlProcess._valid_config | def _valid_config(self, settings):
"""Scan through the returned settings to ensure they appear sane.
There are time when the returned buffer has the proper information, but
the reading is inaccurate. When this happens, temperatures will swing
or system values will be set to improper val... | python | def _valid_config(self, settings):
"""Scan through the returned settings to ensure they appear sane.
There are time when the returned buffer has the proper information, but
the reading is inaccurate. When this happens, temperatures will swing
or system values will be set to improper val... | [
"def",
"_valid_config",
"(",
"self",
",",
"settings",
")",
":",
"if",
"(",
"(",
"int",
"(",
"settings",
"[",
"'environment_temp'",
"]",
")",
">",
"self",
".",
"MAX_BOUND_TEMP",
"or",
"int",
"(",
"settings",
"[",
"'environment_temp'",
"]",
")",
"<",
"self... | Scan through the returned settings to ensure they appear sane.
There are time when the returned buffer has the proper information, but
the reading is inaccurate. When this happens, temperatures will swing
or system values will be set to improper values.
:param settings: Configuration d... | [
"Scan",
"through",
"the",
"returned",
"settings",
"to",
"ensure",
"they",
"appear",
"sane",
"."
] | train | https://github.com/splitkeycoffee/pyhottop/blob/2986bbb2d848f7e41fa3ece5ebb1b33c8882219c/pyhottop/pyhottop.py#L275-L297 |
splitkeycoffee/pyhottop | pyhottop/pyhottop.py | ControlProcess.run | def run(self):
"""Run the core loop of reading and writing configurations.
This is where all the roaster magic occurs. On the initial run, we
prime the roaster with some data to wake it up. Once awoke, we check
our shared queue to identify if the user has passed any updated
conf... | python | def run(self):
"""Run the core loop of reading and writing configurations.
This is where all the roaster magic occurs. On the initial run, we
prime the roaster with some data to wake it up. Once awoke, we check
our shared queue to identify if the user has passed any updated
conf... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"_wake_up",
"(",
")",
"while",
"not",
"self",
".",
"_q",
".",
"empty",
"(",
")",
":",
"self",
".",
"_config",
"=",
"self",
".",
"_q",
".",
"get",
"(",
")",
"while",
"not",
"self",
".",
"exit",
... | Run the core loop of reading and writing configurations.
This is where all the roaster magic occurs. On the initial run, we
prime the roaster with some data to wake it up. Once awoke, we check
our shared queue to identify if the user has passed any updated
configuration. Once checked, s... | [
"Run",
"the",
"core",
"loop",
"of",
"reading",
"and",
"writing",
"configurations",
"."
] | train | https://github.com/splitkeycoffee/pyhottop/blob/2986bbb2d848f7e41fa3ece5ebb1b33c8882219c/pyhottop/pyhottop.py#L313-L351 |
splitkeycoffee/pyhottop | pyhottop/pyhottop.py | Hottop._autodiscover_usb | def _autodiscover_usb(self):
"""Attempt to find the serial adapter for the hottop.
This will loop over the USB serial interfaces looking for a connection
that appears to match the naming convention of the Hottop roaster.
:returns: string
"""
if sys.platform.startswith('... | python | def _autodiscover_usb(self):
"""Attempt to find the serial adapter for the hottop.
This will loop over the USB serial interfaces looking for a connection
that appears to match the naming convention of the Hottop roaster.
:returns: string
"""
if sys.platform.startswith('... | [
"def",
"_autodiscover_usb",
"(",
"self",
")",
":",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"'win'",
")",
":",
"ports",
"=",
"[",
"'COM%s'",
"%",
"(",
"i",
"+",
"1",
")",
"for",
"i",
"in",
"range",
"(",
"256",
")",
"]",
"elif",
"sys"... | Attempt to find the serial adapter for the hottop.
This will loop over the USB serial interfaces looking for a connection
that appears to match the naming convention of the Hottop roaster.
:returns: string | [
"Attempt",
"to",
"find",
"the",
"serial",
"adapter",
"for",
"the",
"hottop",
"."
] | train | https://github.com/splitkeycoffee/pyhottop/blob/2986bbb2d848f7e41fa3ece5ebb1b33c8882219c/pyhottop/pyhottop.py#L415-L444 |
splitkeycoffee/pyhottop | pyhottop/pyhottop.py | Hottop.connect | def connect(self, interface=None):
"""Connect to the USB for the hottop.
Attempt to discover the USB port used for the Hottop and then form a
connection using the serial library.
:returns: bool
:raises SerialConnectionError:
"""
if self._simulate:
re... | python | def connect(self, interface=None):
"""Connect to the USB for the hottop.
Attempt to discover the USB port used for the Hottop and then form a
connection using the serial library.
:returns: bool
:raises SerialConnectionError:
"""
if self._simulate:
re... | [
"def",
"connect",
"(",
"self",
",",
"interface",
"=",
"None",
")",
":",
"if",
"self",
".",
"_simulate",
":",
"return",
"True",
"if",
"not",
"interface",
":",
"match",
"=",
"self",
".",
"_autodiscover_usb",
"(",
")",
"self",
".",
"_log",
".",
"debug",
... | Connect to the USB for the hottop.
Attempt to discover the USB port used for the Hottop and then form a
connection using the serial library.
:returns: bool
:raises SerialConnectionError: | [
"Connect",
"to",
"the",
"USB",
"for",
"the",
"hottop",
"."
] | train | https://github.com/splitkeycoffee/pyhottop/blob/2986bbb2d848f7e41fa3ece5ebb1b33c8882219c/pyhottop/pyhottop.py#L446-L476 |
splitkeycoffee/pyhottop | pyhottop/pyhottop.py | Hottop._init_controls | def _init_controls(self):
"""Establish a set of base controls the user can influence.
:returns: None
"""
self._config['heater'] = 0
self._config['fan'] = 0
self._config['main_fan'] = 0
self._config['drum_motor'] = 1
self._config['solenoid'] = 0
se... | python | def _init_controls(self):
"""Establish a set of base controls the user can influence.
:returns: None
"""
self._config['heater'] = 0
self._config['fan'] = 0
self._config['main_fan'] = 0
self._config['drum_motor'] = 1
self._config['solenoid'] = 0
se... | [
"def",
"_init_controls",
"(",
"self",
")",
":",
"self",
".",
"_config",
"[",
"'heater'",
"]",
"=",
"0",
"self",
".",
"_config",
"[",
"'fan'",
"]",
"=",
"0",
"self",
".",
"_config",
"[",
"'main_fan'",
"]",
"=",
"0",
"self",
".",
"_config",
"[",
"'dr... | Establish a set of base controls the user can influence.
:returns: None | [
"Establish",
"a",
"set",
"of",
"base",
"controls",
"the",
"user",
"can",
"influence",
"."
] | train | https://github.com/splitkeycoffee/pyhottop/blob/2986bbb2d848f7e41fa3ece5ebb1b33c8882219c/pyhottop/pyhottop.py#L478-L506 |
splitkeycoffee/pyhottop | pyhottop/pyhottop.py | Hottop._callback | def _callback(self, data):
"""Processor callback to clean-up stream data.
This function provides a hook into the output stream of data from the
controller processing thread. Hottop readings are saved into a local
class variable for later saving. If the user has defined a callback, it
... | python | def _callback(self, data):
"""Processor callback to clean-up stream data.
This function provides a hook into the output stream of data from the
controller processing thread. Hottop readings are saved into a local
class variable for later saving. If the user has defined a callback, it
... | [
"def",
"_callback",
"(",
"self",
",",
"data",
")",
":",
"local",
"=",
"copy",
".",
"deepcopy",
"(",
"data",
")",
"output",
"=",
"dict",
"(",
")",
"output",
"[",
"'config'",
"]",
"=",
"local",
"if",
"self",
".",
"_roast_start",
":",
"td",
"=",
"(",
... | Processor callback to clean-up stream data.
This function provides a hook into the output stream of data from the
controller processing thread. Hottop readings are saved into a local
class variable for later saving. If the user has defined a callback, it
will be called within this priva... | [
"Processor",
"callback",
"to",
"clean",
"-",
"up",
"stream",
"data",
"."
] | train | https://github.com/splitkeycoffee/pyhottop/blob/2986bbb2d848f7e41fa3ece5ebb1b33c8882219c/pyhottop/pyhottop.py#L508-L550 |
splitkeycoffee/pyhottop | pyhottop/pyhottop.py | Hottop._derive_charge | def _derive_charge(self, config):
"""Use a temperature window to identify the roast charge.
The charge will manifest as a sudden downward trend on the temperature.
Once found, we save it and avoid overwriting. The charge is needed in
order to derive the turning point.
:param co... | python | def _derive_charge(self, config):
"""Use a temperature window to identify the roast charge.
The charge will manifest as a sudden downward trend on the temperature.
Once found, we save it and avoid overwriting. The charge is needed in
order to derive the turning point.
:param co... | [
"def",
"_derive_charge",
"(",
"self",
",",
"config",
")",
":",
"if",
"self",
".",
"_roast",
".",
"get",
"(",
"'charge'",
")",
":",
"return",
"None",
"self",
".",
"_window",
".",
"append",
"(",
"config",
")",
"time",
",",
"temp",
"=",
"list",
"(",
"... | Use a temperature window to identify the roast charge.
The charge will manifest as a sudden downward trend on the temperature.
Once found, we save it and avoid overwriting. The charge is needed in
order to derive the turning point.
:param config: Current snapshot of the configuration
... | [
"Use",
"a",
"temperature",
"window",
"to",
"identify",
"the",
"roast",
"charge",
"."
] | train | https://github.com/splitkeycoffee/pyhottop/blob/2986bbb2d848f7e41fa3ece5ebb1b33c8882219c/pyhottop/pyhottop.py#L552-L575 |
splitkeycoffee/pyhottop | pyhottop/pyhottop.py | Hottop.start | def start(self, func=None):
"""Start the roaster control process.
This function will kick off the processing thread for the Hottop and
register any user-defined callback function. By default, it will not
begin collecting any reading information or saving it. In order to do
that ... | python | def start(self, func=None):
"""Start the roaster control process.
This function will kick off the processing thread for the Hottop and
register any user-defined callback function. By default, it will not
begin collecting any reading information or saving it. In order to do
that ... | [
"def",
"start",
"(",
"self",
",",
"func",
"=",
"None",
")",
":",
"self",
".",
"_user_callback",
"=",
"func",
"if",
"not",
"self",
".",
"_simulate",
":",
"self",
".",
"_process",
"=",
"ControlProcess",
"(",
"self",
".",
"_conn",
",",
"self",
".",
"_co... | Start the roaster control process.
This function will kick off the processing thread for the Hottop and
register any user-defined callback function. By default, it will not
begin collecting any reading information or saving it. In order to do
that users, must issue the monitor/record bi... | [
"Start",
"the",
"roaster",
"control",
"process",
"."
] | train | https://github.com/splitkeycoffee/pyhottop/blob/2986bbb2d848f7e41fa3ece5ebb1b33c8882219c/pyhottop/pyhottop.py#L604-L624 |
splitkeycoffee/pyhottop | pyhottop/pyhottop.py | Hottop.end | def end(self):
"""End the roaster control process via thread signal.
This simply sends an exit signal to the thread, and shuts it down. In
order to stop monitoring, call the `set_monitor` method with false.
:returns: None
"""
self._process.shutdown()
self._roast... | python | def end(self):
"""End the roaster control process via thread signal.
This simply sends an exit signal to the thread, and shuts it down. In
order to stop monitoring, call the `set_monitor` method with false.
:returns: None
"""
self._process.shutdown()
self._roast... | [
"def",
"end",
"(",
"self",
")",
":",
"self",
".",
"_process",
".",
"shutdown",
"(",
")",
"self",
".",
"_roasting",
"=",
"False",
"self",
".",
"_roast",
"[",
"'date'",
"]",
"=",
"now_date",
"(",
"str",
"=",
"True",
")"
] | End the roaster control process via thread signal.
This simply sends an exit signal to the thread, and shuts it down. In
order to stop monitoring, call the `set_monitor` method with false.
:returns: None | [
"End",
"the",
"roaster",
"control",
"process",
"via",
"thread",
"signal",
"."
] | train | https://github.com/splitkeycoffee/pyhottop/blob/2986bbb2d848f7e41fa3ece5ebb1b33c8882219c/pyhottop/pyhottop.py#L626-L636 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.