repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
CodeReclaimers/neat-python
neat/checkpoint.py
Checkpointer.save_checkpoint
def save_checkpoint(self, config, population, species_set, generation): """ Save the current simulation state. """ filename = '{0}{1}'.format(self.filename_prefix, generation) print("Saving checkpoint to {0}".format(filename)) with gzip.open(filename, 'w', compresslevel=5) as f: ...
python
def save_checkpoint(self, config, population, species_set, generation): """ Save the current simulation state. """ filename = '{0}{1}'.format(self.filename_prefix, generation) print("Saving checkpoint to {0}".format(filename)) with gzip.open(filename, 'w', compresslevel=5) as f: ...
[ "def", "save_checkpoint", "(", "self", ",", "config", ",", "population", ",", "species_set", ",", "generation", ")", ":", "filename", "=", "'{0}{1}'", ".", "format", "(", "self", ".", "filename_prefix", ",", "generation", ")", "print", "(", "\"Saving checkpoin...
Save the current simulation state.
[ "Save", "the", "current", "simulation", "state", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/checkpoint.py#L64-L71
train
CodeReclaimers/neat-python
neat/checkpoint.py
Checkpointer.restore_checkpoint
def restore_checkpoint(filename): """Resumes the simulation from a previous saved point.""" with gzip.open(filename) as f: generation, config, population, species_set, rndstate = pickle.load(f) random.setstate(rndstate) return Population(config, (population, species_s...
python
def restore_checkpoint(filename): """Resumes the simulation from a previous saved point.""" with gzip.open(filename) as f: generation, config, population, species_set, rndstate = pickle.load(f) random.setstate(rndstate) return Population(config, (population, species_s...
[ "def", "restore_checkpoint", "(", "filename", ")", ":", "with", "gzip", ".", "open", "(", "filename", ")", "as", "f", ":", "generation", ",", "config", ",", "population", ",", "species_set", ",", "rndstate", "=", "pickle", ".", "load", "(", "f", ")", "...
Resumes the simulation from a previous saved point.
[ "Resumes", "the", "simulation", "from", "a", "previous", "saved", "point", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/checkpoint.py#L74-L79
train
CodeReclaimers/neat-python
neat/distributed.py
host_is_local
def host_is_local(hostname, port=22): # no port specified, just use the ssh port """ Returns True if the hostname points to the localhost, otherwise False. """ hostname = socket.getfqdn(hostname) if hostname in ("localhost", "0.0.0.0", "127.0.0.1", "1.0.0.127.in-addr.arpa", "1.0....
python
def host_is_local(hostname, port=22): # no port specified, just use the ssh port """ Returns True if the hostname points to the localhost, otherwise False. """ hostname = socket.getfqdn(hostname) if hostname in ("localhost", "0.0.0.0", "127.0.0.1", "1.0.0.127.in-addr.arpa", "1.0....
[ "def", "host_is_local", "(", "hostname", ",", "port", "=", "22", ")", ":", "# no port specified, just use the ssh port", "hostname", "=", "socket", ".", "getfqdn", "(", "hostname", ")", "if", "hostname", "in", "(", "\"localhost\"", ",", "\"0.0.0.0\"", ",", "\"12...
Returns True if the hostname points to the localhost, otherwise False.
[ "Returns", "True", "if", "the", "hostname", "points", "to", "the", "localhost", "otherwise", "False", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L105-L124
train
CodeReclaimers/neat-python
neat/distributed.py
_determine_mode
def _determine_mode(addr, mode): """ Returns the mode which should be used. If mode is MODE_AUTO, this is determined by checking if 'addr' points to the local host. If it does, return MODE_PRIMARY, else return MODE_SECONDARY. If mode is either MODE_PRIMARY or MODE_SECONDARY, return the 'mode' ar...
python
def _determine_mode(addr, mode): """ Returns the mode which should be used. If mode is MODE_AUTO, this is determined by checking if 'addr' points to the local host. If it does, return MODE_PRIMARY, else return MODE_SECONDARY. If mode is either MODE_PRIMARY or MODE_SECONDARY, return the 'mode' ar...
[ "def", "_determine_mode", "(", "addr", ",", "mode", ")", ":", "if", "isinstance", "(", "addr", ",", "tuple", ")", ":", "host", "=", "addr", "[", "0", "]", "elif", "type", "(", "addr", ")", "==", "type", "(", "b\"binary_string\"", ")", ":", "host", ...
Returns the mode which should be used. If mode is MODE_AUTO, this is determined by checking if 'addr' points to the local host. If it does, return MODE_PRIMARY, else return MODE_SECONDARY. If mode is either MODE_PRIMARY or MODE_SECONDARY, return the 'mode' argument. Otherwise, a ValueError is raised.
[ "Returns", "the", "mode", "which", "should", "be", "used", ".", "If", "mode", "is", "MODE_AUTO", "this", "is", "determined", "by", "checking", "if", "addr", "points", "to", "the", "local", "host", ".", "If", "it", "does", "return", "MODE_PRIMARY", "else", ...
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L127-L149
train
CodeReclaimers/neat-python
neat/distributed.py
chunked
def chunked(data, chunksize): """ Returns a list of chunks containing at most ``chunksize`` elements of data. """ if chunksize < 1: raise ValueError("Chunksize must be at least 1!") if int(chunksize) != chunksize: raise ValueError("Chunksize needs to be an integer") res = [] ...
python
def chunked(data, chunksize): """ Returns a list of chunks containing at most ``chunksize`` elements of data. """ if chunksize < 1: raise ValueError("Chunksize must be at least 1!") if int(chunksize) != chunksize: raise ValueError("Chunksize needs to be an integer") res = [] ...
[ "def", "chunked", "(", "data", ",", "chunksize", ")", ":", "if", "chunksize", "<", "1", ":", "raise", "ValueError", "(", "\"Chunksize must be at least 1!\"", ")", "if", "int", "(", "chunksize", ")", "!=", "chunksize", ":", "raise", "ValueError", "(", "\"Chun...
Returns a list of chunks containing at most ``chunksize`` elements of data.
[ "Returns", "a", "list", "of", "chunks", "containing", "at", "most", "chunksize", "elements", "of", "data", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L152-L169
train
CodeReclaimers/neat-python
neat/distributed.py
_ExtendedManager.start
def start(self): """Starts or connects to the manager.""" if self.mode == MODE_PRIMARY: i = self._start() else: i = self._connect() self.manager = i
python
def start(self): """Starts or connects to the manager.""" if self.mode == MODE_PRIMARY: i = self._start() else: i = self._connect() self.manager = i
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "mode", "==", "MODE_PRIMARY", ":", "i", "=", "self", ".", "_start", "(", ")", "else", ":", "i", "=", "self", ".", "_connect", "(", ")", "self", ".", "manager", "=", "i" ]
Starts or connects to the manager.
[ "Starts", "or", "connects", "to", "the", "manager", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L195-L201
train
CodeReclaimers/neat-python
neat/distributed.py
_ExtendedManager.set_secondary_state
def set_secondary_state(self, value): """Sets the value for 'secondary_state'.""" if value not in (_STATE_RUNNING, _STATE_SHUTDOWN, _STATE_FORCED_SHUTDOWN): raise ValueError( "State {!r} is invalid - needs to be one of _STATE_RUNNING, _STATE_SHUTDOWN, or _STATE_FORCED_SHUTDOW...
python
def set_secondary_state(self, value): """Sets the value for 'secondary_state'.""" if value not in (_STATE_RUNNING, _STATE_SHUTDOWN, _STATE_FORCED_SHUTDOWN): raise ValueError( "State {!r} is invalid - needs to be one of _STATE_RUNNING, _STATE_SHUTDOWN, or _STATE_FORCED_SHUTDOW...
[ "def", "set_secondary_state", "(", "self", ",", "value", ")", ":", "if", "value", "not", "in", "(", "_STATE_RUNNING", ",", "_STATE_SHUTDOWN", ",", "_STATE_FORCED_SHUTDOWN", ")", ":", "raise", "ValueError", "(", "\"State {!r} is invalid - needs to be one of _STATE_RUNNIN...
Sets the value for 'secondary_state'.
[ "Sets", "the", "value", "for", "secondary_state", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L207-L216
train
CodeReclaimers/neat-python
neat/distributed.py
_ExtendedManager._get_manager_class
def _get_manager_class(self, register_callables=False): """ Returns a new 'Manager' subclass with registered methods. If 'register_callable' is True, defines the 'callable' arguments. """ class _EvaluatorSyncManager(managers.BaseManager): """ A custom Bas...
python
def _get_manager_class(self, register_callables=False): """ Returns a new 'Manager' subclass with registered methods. If 'register_callable' is True, defines the 'callable' arguments. """ class _EvaluatorSyncManager(managers.BaseManager): """ A custom Bas...
[ "def", "_get_manager_class", "(", "self", ",", "register_callables", "=", "False", ")", ":", "class", "_EvaluatorSyncManager", "(", "managers", ".", "BaseManager", ")", ":", "\"\"\"\n A custom BaseManager.\n Please see the documentation of `multiprocessing` ...
Returns a new 'Manager' subclass with registered methods. If 'register_callable' is True, defines the 'callable' arguments.
[ "Returns", "a", "new", "Manager", "subclass", "with", "registered", "methods", ".", "If", "register_callable", "is", "True", "defines", "the", "callable", "arguments", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L225-L282
train
CodeReclaimers/neat-python
neat/distributed.py
_ExtendedManager._connect
def _connect(self): """Connects to the manager.""" cls = self._get_manager_class(register_callables=False) ins = cls(address=self.addr, authkey=self.authkey) ins.connect() return ins
python
def _connect(self): """Connects to the manager.""" cls = self._get_manager_class(register_callables=False) ins = cls(address=self.addr, authkey=self.authkey) ins.connect() return ins
[ "def", "_connect", "(", "self", ")", ":", "cls", "=", "self", ".", "_get_manager_class", "(", "register_callables", "=", "False", ")", "ins", "=", "cls", "(", "address", "=", "self", ".", "addr", ",", "authkey", "=", "self", ".", "authkey", ")", "ins",...
Connects to the manager.
[ "Connects", "to", "the", "manager", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L284-L289
train
CodeReclaimers/neat-python
neat/distributed.py
_ExtendedManager._start
def _start(self): """Starts the manager.""" cls = self._get_manager_class(register_callables=True) ins = cls(address=self.addr, authkey=self.authkey) ins.start() return ins
python
def _start(self): """Starts the manager.""" cls = self._get_manager_class(register_callables=True) ins = cls(address=self.addr, authkey=self.authkey) ins.start() return ins
[ "def", "_start", "(", "self", ")", ":", "cls", "=", "self", ".", "_get_manager_class", "(", "register_callables", "=", "True", ")", "ins", "=", "cls", "(", "address", "=", "self", ".", "addr", ",", "authkey", "=", "self", ".", "authkey", ")", "ins", ...
Starts the manager.
[ "Starts", "the", "manager", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L291-L296
train
CodeReclaimers/neat-python
neat/distributed.py
DistributedEvaluator._start_primary
def _start_primary(self): """Start as the primary""" self.em.start() self.em.set_secondary_state(_STATE_RUNNING) self._set_shared_instances()
python
def _start_primary(self): """Start as the primary""" self.em.start() self.em.set_secondary_state(_STATE_RUNNING) self._set_shared_instances()
[ "def", "_start_primary", "(", "self", ")", ":", "self", ".", "em", ".", "start", "(", ")", "self", ".", "em", ".", "set_secondary_state", "(", "_STATE_RUNNING", ")", "self", ".", "_set_shared_instances", "(", ")" ]
Start as the primary
[ "Start", "as", "the", "primary" ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L452-L456
train
CodeReclaimers/neat-python
neat/distributed.py
DistributedEvaluator._set_shared_instances
def _set_shared_instances(self): """Sets attributes from the shared instances.""" self.inqueue = self.em.get_inqueue() self.outqueue = self.em.get_outqueue() self.namespace = self.em.get_namespace()
python
def _set_shared_instances(self): """Sets attributes from the shared instances.""" self.inqueue = self.em.get_inqueue() self.outqueue = self.em.get_outqueue() self.namespace = self.em.get_namespace()
[ "def", "_set_shared_instances", "(", "self", ")", ":", "self", ".", "inqueue", "=", "self", ".", "em", ".", "get_inqueue", "(", ")", "self", ".", "outqueue", "=", "self", ".", "em", ".", "get_outqueue", "(", ")", "self", ".", "namespace", "=", "self", ...
Sets attributes from the shared instances.
[ "Sets", "attributes", "from", "the", "shared", "instances", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L463-L467
train
CodeReclaimers/neat-python
neat/distributed.py
DistributedEvaluator._reset_em
def _reset_em(self): """Resets self.em and the shared instances.""" self.em = _ExtendedManager(self.addr, self.authkey, mode=self.mode, start=False) self.em.start() self._set_shared_instances()
python
def _reset_em(self): """Resets self.em and the shared instances.""" self.em = _ExtendedManager(self.addr, self.authkey, mode=self.mode, start=False) self.em.start() self._set_shared_instances()
[ "def", "_reset_em", "(", "self", ")", ":", "self", ".", "em", "=", "_ExtendedManager", "(", "self", ".", "addr", ",", "self", ".", "authkey", ",", "mode", "=", "self", ".", "mode", ",", "start", "=", "False", ")", "self", ".", "em", ".", "start", ...
Resets self.em and the shared instances.
[ "Resets", "self", ".", "em", "and", "the", "shared", "instances", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L469-L473
train
CodeReclaimers/neat-python
neat/distributed.py
DistributedEvaluator._secondary_loop
def _secondary_loop(self, reconnect=False): """The worker loop for the secondary nodes.""" if self.num_workers > 1: pool = multiprocessing.Pool(self.num_workers) else: pool = None should_reconnect = True while should_reconnect: i = 0 ...
python
def _secondary_loop(self, reconnect=False): """The worker loop for the secondary nodes.""" if self.num_workers > 1: pool = multiprocessing.Pool(self.num_workers) else: pool = None should_reconnect = True while should_reconnect: i = 0 ...
[ "def", "_secondary_loop", "(", "self", ",", "reconnect", "=", "False", ")", ":", "if", "self", ".", "num_workers", ">", "1", ":", "pool", "=", "multiprocessing", ".", "Pool", "(", "self", ".", "num_workers", ")", "else", ":", "pool", "=", "None", "shou...
The worker loop for the secondary nodes.
[ "The", "worker", "loop", "for", "the", "secondary", "nodes", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L475-L555
train
CodeReclaimers/neat-python
neat/distributed.py
DistributedEvaluator.evaluate
def evaluate(self, genomes, config): """ Evaluates the genomes. This method raises a ModeError if the DistributedEvaluator is not in primary mode. """ if self.mode != MODE_PRIMARY: raise ModeError("Not in primary mode!") tasks = [(genome_id, genome, co...
python
def evaluate(self, genomes, config): """ Evaluates the genomes. This method raises a ModeError if the DistributedEvaluator is not in primary mode. """ if self.mode != MODE_PRIMARY: raise ModeError("Not in primary mode!") tasks = [(genome_id, genome, co...
[ "def", "evaluate", "(", "self", ",", "genomes", ",", "config", ")", ":", "if", "self", ".", "mode", "!=", "MODE_PRIMARY", ":", "raise", "ModeError", "(", "\"Not in primary mode!\"", ")", "tasks", "=", "[", "(", "genome_id", ",", "genome", ",", "config", ...
Evaluates the genomes. This method raises a ModeError if the DistributedEvaluator is not in primary mode.
[ "Evaluates", "the", "genomes", ".", "This", "method", "raises", "a", "ModeError", "if", "the", "DistributedEvaluator", "is", "not", "in", "primary", "mode", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L557-L583
train
CodeReclaimers/neat-python
neat/reproduction.py
DefaultReproduction.reproduce
def reproduce(self, config, species, pop_size, generation): """ Handles creation of genomes, either from scratch or by sexual or asexual reproduction from parents. """ # TODO: I don't like this modification of the species and stagnation objects, # because it requires inte...
python
def reproduce(self, config, species, pop_size, generation): """ Handles creation of genomes, either from scratch or by sexual or asexual reproduction from parents. """ # TODO: I don't like this modification of the species and stagnation objects, # because it requires inte...
[ "def", "reproduce", "(", "self", ",", "config", ",", "species", ",", "pop_size", ",", "generation", ")", ":", "# TODO: I don't like this modification of the species and stagnation objects,", "# because it requires internal knowledge of the objects.", "# Filter out stagnated species, ...
Handles creation of genomes, either from scratch or by sexual or asexual reproduction from parents.
[ "Handles", "creation", "of", "genomes", "either", "from", "scratch", "or", "by", "sexual", "or", "asexual", "reproduction", "from", "parents", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/reproduction.py#L84-L188
train
CodeReclaimers/neat-python
neat/population.py
Population.run
def run(self, fitness_function, n=None): """ Runs NEAT's genetic algorithm for at most n generations. If n is None, run until solution is found or extinction occurs. The user-provided fitness_function must take only two arguments: 1. The population as a list of (genome id, ...
python
def run(self, fitness_function, n=None): """ Runs NEAT's genetic algorithm for at most n generations. If n is None, run until solution is found or extinction occurs. The user-provided fitness_function must take only two arguments: 1. The population as a list of (genome id, ...
[ "def", "run", "(", "self", ",", "fitness_function", ",", "n", "=", "None", ")", ":", "if", "self", ".", "config", ".", "no_fitness_termination", "and", "(", "n", "is", "None", ")", ":", "raise", "RuntimeError", "(", "\"Cannot have no generational limit with no...
Runs NEAT's genetic algorithm for at most n generations. If n is None, run until solution is found or extinction occurs. The user-provided fitness_function must take only two arguments: 1. The population as a list of (genome id, genome) tuples. 2. The current configuration obje...
[ "Runs", "NEAT", "s", "genetic", "algorithm", "for", "at", "most", "n", "generations", ".", "If", "n", "is", "None", "run", "until", "solution", "is", "found", "or", "extinction", "occurs", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/population.py#L59-L136
train
CodeReclaimers/neat-python
neat/genes.py
BaseGene.crossover
def crossover(self, gene2): """ Creates a new gene randomly inheriting attributes from its parents.""" assert self.key == gene2.key # Note: we use "a if random() > 0.5 else b" instead of choice((a, b)) # here because `choice` is substantially slower. new_gene = self.__class__(se...
python
def crossover(self, gene2): """ Creates a new gene randomly inheriting attributes from its parents.""" assert self.key == gene2.key # Note: we use "a if random() > 0.5 else b" instead of choice((a, b)) # here because `choice` is substantially slower. new_gene = self.__class__(se...
[ "def", "crossover", "(", "self", ",", "gene2", ")", ":", "assert", "self", ".", "key", "==", "gene2", ".", "key", "# Note: we use \"a if random() > 0.5 else b\" instead of choice((a, b))", "# here because `choice` is substantially slower.", "new_gene", "=", "self", ".", "...
Creates a new gene randomly inheriting attributes from its parents.
[ "Creates", "a", "new", "gene", "randomly", "inheriting", "attributes", "from", "its", "parents", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/genes.py#L60-L73
train
CodeReclaimers/neat-python
examples/circuits/evolve.py
CircuitGenome.distance
def distance(self, other, config): """ Returns the genetic distance between this genome and the other. This distance value is used to compute genome compatibility for speciation. """ # Compute node gene distance component. node_distance = 0.0 if self.nodes or oth...
python
def distance(self, other, config): """ Returns the genetic distance between this genome and the other. This distance value is used to compute genome compatibility for speciation. """ # Compute node gene distance component. node_distance = 0.0 if self.nodes or oth...
[ "def", "distance", "(", "self", ",", "other", ",", "config", ")", ":", "# Compute node gene distance component.", "node_distance", "=", "0.0", "if", "self", ".", "nodes", "or", "other", ".", "nodes", ":", "disjoint_nodes", "=", "0", "for", "k2", "in", "iterk...
Returns the genetic distance between this genome and the other. This distance value is used to compute genome compatibility for speciation.
[ "Returns", "the", "genetic", "distance", "between", "this", "genome", "and", "the", "other", ".", "This", "distance", "value", "is", "used", "to", "compute", "genome", "compatibility", "for", "speciation", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/examples/circuits/evolve.py#L227-L273
train
CodeReclaimers/neat-python
neat/ctrnn/__init__.py
CTRNN.advance
def advance(self, inputs, advance_time, time_step=None): """ Advance the simulation by the given amount of time, assuming that inputs are constant at the given values during the simulated time. """ final_time_seconds = self.time_seconds + advance_time # Use half of the m...
python
def advance(self, inputs, advance_time, time_step=None): """ Advance the simulation by the given amount of time, assuming that inputs are constant at the given values during the simulated time. """ final_time_seconds = self.time_seconds + advance_time # Use half of the m...
[ "def", "advance", "(", "self", ",", "inputs", ",", "advance_time", ",", "time_step", "=", "None", ")", ":", "final_time_seconds", "=", "self", ".", "time_seconds", "+", "advance_time", "# Use half of the max allowed time step if none is given.", "if", "time_step", "is...
Advance the simulation by the given amount of time, assuming that inputs are constant at the given values during the simulated time.
[ "Advance", "the", "simulation", "by", "the", "given", "amount", "of", "time", "assuming", "that", "inputs", "are", "constant", "at", "the", "given", "values", "during", "the", "simulated", "time", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/ctrnn/__init__.py#L53-L87
train
CodeReclaimers/neat-python
neat/stagnation.py
DefaultStagnation.update
def update(self, species_set, generation): """ Required interface method. Updates species fitness history information, checking for ones that have not improved in max_stagnation generations, and - unless it would result in the number of species dropping below the configured speci...
python
def update(self, species_set, generation): """ Required interface method. Updates species fitness history information, checking for ones that have not improved in max_stagnation generations, and - unless it would result in the number of species dropping below the configured speci...
[ "def", "update", "(", "self", ",", "species_set", ",", "generation", ")", ":", "species_data", "=", "[", "]", "for", "sid", ",", "s", "in", "iteritems", "(", "species_set", ".", "species", ")", ":", "if", "s", ".", "fitness_history", ":", "prev_fitness",...
Required interface method. Updates species fitness history information, checking for ones that have not improved in max_stagnation generations, and - unless it would result in the number of species dropping below the configured species_elitism parameter if they were removed, in which cas...
[ "Required", "interface", "method", ".", "Updates", "species", "fitness", "history", "information", "checking", "for", "ones", "that", "have", "not", "improved", "in", "max_stagnation", "generations", "and", "-", "unless", "it", "would", "result", "in", "the", "n...
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/stagnation.py#L30-L79
train
CodeReclaimers/neat-python
neat/threaded.py
ThreadedEvaluator.start
def start(self): """Starts the worker threads""" if self.working: return self.working = True for i in range(self.num_workers): w = threading.Thread( name="Worker Thread #{i}".format(i=i), target=self._worker, ) ...
python
def start(self): """Starts the worker threads""" if self.working: return self.working = True for i in range(self.num_workers): w = threading.Thread( name="Worker Thread #{i}".format(i=i), target=self._worker, ) ...
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "working", ":", "return", "self", ".", "working", "=", "True", "for", "i", "in", "range", "(", "self", ".", "num_workers", ")", ":", "w", "=", "threading", ".", "Thread", "(", "name", "=", ...
Starts the worker threads
[ "Starts", "the", "worker", "threads" ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/threaded.py#L51-L63
train
CodeReclaimers/neat-python
neat/threaded.py
ThreadedEvaluator.stop
def stop(self): """Stops the worker threads and waits for them to finish""" self.working = False for w in self.workers: w.join() self.workers = []
python
def stop(self): """Stops the worker threads and waits for them to finish""" self.working = False for w in self.workers: w.join() self.workers = []
[ "def", "stop", "(", "self", ")", ":", "self", ".", "working", "=", "False", "for", "w", "in", "self", ".", "workers", ":", "w", ".", "join", "(", ")", "self", ".", "workers", "=", "[", "]" ]
Stops the worker threads and waits for them to finish
[ "Stops", "the", "worker", "threads", "and", "waits", "for", "them", "to", "finish" ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/threaded.py#L65-L70
train
CodeReclaimers/neat-python
neat/threaded.py
ThreadedEvaluator._worker
def _worker(self): """The worker function""" while self.working: try: genome_id, genome, config = self.inqueue.get( block=True, timeout=0.2, ) except queue.Empty: continue f = ...
python
def _worker(self): """The worker function""" while self.working: try: genome_id, genome, config = self.inqueue.get( block=True, timeout=0.2, ) except queue.Empty: continue f = ...
[ "def", "_worker", "(", "self", ")", ":", "while", "self", ".", "working", ":", "try", ":", "genome_id", ",", "genome", ",", "config", "=", "self", ".", "inqueue", ".", "get", "(", "block", "=", "True", ",", "timeout", "=", "0.2", ",", ")", "except"...
The worker function
[ "The", "worker", "function" ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/threaded.py#L72-L83
train
CodeReclaimers/neat-python
neat/threaded.py
ThreadedEvaluator.evaluate
def evaluate(self, genomes, config): """Evaluate the genomes""" if not self.working: self.start() p = 0 for genome_id, genome in genomes: p += 1 self.inqueue.put((genome_id, genome, config)) # assign the fitness back to each genome whi...
python
def evaluate(self, genomes, config): """Evaluate the genomes""" if not self.working: self.start() p = 0 for genome_id, genome in genomes: p += 1 self.inqueue.put((genome_id, genome, config)) # assign the fitness back to each genome whi...
[ "def", "evaluate", "(", "self", ",", "genomes", ",", "config", ")", ":", "if", "not", "self", ".", "working", ":", "self", ".", "start", "(", ")", "p", "=", "0", "for", "genome_id", ",", "genome", "in", "genomes", ":", "p", "+=", "1", "self", "."...
Evaluate the genomes
[ "Evaluate", "the", "genomes" ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/threaded.py#L85-L98
train
CodeReclaimers/neat-python
neat/iznn/__init__.py
IZNeuron.advance
def advance(self, dt_msec): """ Advances simulation time by the given time step in milliseconds. v' = 0.04 * v^2 + 5v + 140 - u + I u' = a * (b * v - u) if v >= 30 then v <- c, u <- u + d """ # TODO: Make the time step adjustable, and choose an appro...
python
def advance(self, dt_msec): """ Advances simulation time by the given time step in milliseconds. v' = 0.04 * v^2 + 5v + 140 - u + I u' = a * (b * v - u) if v >= 30 then v <- c, u <- u + d """ # TODO: Make the time step adjustable, and choose an appro...
[ "def", "advance", "(", "self", ",", "dt_msec", ")", ":", "# TODO: Make the time step adjustable, and choose an appropriate", "# numerical integration method to maintain stability.", "# TODO: The need to catch overflows indicates that the current method is", "# not stable for all possible netwo...
Advances simulation time by the given time step in milliseconds. v' = 0.04 * v^2 + 5v + 140 - u + I u' = a * (b * v - u) if v >= 30 then v <- c, u <- u + d
[ "Advances", "simulation", "time", "by", "the", "given", "time", "step", "in", "milliseconds", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/iznn/__init__.py#L90-L118
train
CodeReclaimers/neat-python
neat/iznn/__init__.py
IZNeuron.reset
def reset(self): """Resets all state variables.""" self.v = self.c self.u = self.b * self.v self.fired = 0.0 self.current = self.bias
python
def reset(self): """Resets all state variables.""" self.v = self.c self.u = self.b * self.v self.fired = 0.0 self.current = self.bias
[ "def", "reset", "(", "self", ")", ":", "self", ".", "v", "=", "self", ".", "c", "self", ".", "u", "=", "self", ".", "b", "*", "self", ".", "v", "self", ".", "fired", "=", "0.0", "self", ".", "current", "=", "self", ".", "bias" ]
Resets all state variables.
[ "Resets", "all", "state", "variables", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/iznn/__init__.py#L120-L125
train
CodeReclaimers/neat-python
neat/iznn/__init__.py
IZNN.set_inputs
def set_inputs(self, inputs): """Assign input voltages.""" if len(inputs) != len(self.inputs): raise RuntimeError( "Number of inputs {0:d} does not match number of input nodes {1:d}".format( len(inputs), len(self.inputs))) for i, v in zip(self.inpu...
python
def set_inputs(self, inputs): """Assign input voltages.""" if len(inputs) != len(self.inputs): raise RuntimeError( "Number of inputs {0:d} does not match number of input nodes {1:d}".format( len(inputs), len(self.inputs))) for i, v in zip(self.inpu...
[ "def", "set_inputs", "(", "self", ",", "inputs", ")", ":", "if", "len", "(", "inputs", ")", "!=", "len", "(", "self", ".", "inputs", ")", ":", "raise", "RuntimeError", "(", "\"Number of inputs {0:d} does not match number of input nodes {1:d}\"", ".", "format", "...
Assign input voltages.
[ "Assign", "input", "voltages", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/iznn/__init__.py#L136-L143
train
CodeReclaimers/neat-python
examples/xor/evolve-spiking.py
compute_output
def compute_output(t0, t1): '''Compute the network's output based on the "time to first spike" of the two output neurons.''' if t0 is None or t1 is None: # If neither of the output neurons fired within the allotted time, # give a response which produces a large error. return -1.0 els...
python
def compute_output(t0, t1): '''Compute the network's output based on the "time to first spike" of the two output neurons.''' if t0 is None or t1 is None: # If neither of the output neurons fired within the allotted time, # give a response which produces a large error. return -1.0 els...
[ "def", "compute_output", "(", "t0", ",", "t1", ")", ":", "if", "t0", "is", "None", "or", "t1", "is", "None", ":", "# If neither of the output neurons fired within the allotted time,", "# give a response which produces a large error.", "return", "-", "1.0", "else", ":", ...
Compute the network's output based on the "time to first spike" of the two output neurons.
[ "Compute", "the", "network", "s", "output", "based", "on", "the", "time", "to", "first", "spike", "of", "the", "two", "output", "neurons", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/examples/xor/evolve-spiking.py#L19-L30
train
CodeReclaimers/neat-python
neat/species.py
DefaultSpeciesSet.speciate
def speciate(self, config, population, generation): """ Place genomes into species by genetic similarity. Note that this method assumes the current representatives of the species are from the old generation, and that after speciation has been performed, the old representatives should be...
python
def speciate(self, config, population, generation): """ Place genomes into species by genetic similarity. Note that this method assumes the current representatives of the species are from the old generation, and that after speciation has been performed, the old representatives should be...
[ "def", "speciate", "(", "self", ",", "config", ",", "population", ",", "generation", ")", ":", "assert", "isinstance", "(", "population", ",", "dict", ")", "compatibility_threshold", "=", "self", ".", "species_set_config", ".", "compatibility_threshold", "# Find t...
Place genomes into species by genetic similarity. Note that this method assumes the current representatives of the species are from the old generation, and that after speciation has been performed, the old representatives should be dropped and replaced with representatives from the new generati...
[ "Place", "genomes", "into", "species", "by", "genetic", "similarity", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/species.py#L65-L139
train
CodeReclaimers/neat-python
neat/statistics.py
StatisticsReporter.get_average_cross_validation_fitness
def get_average_cross_validation_fitness(self): # pragma: no cover """Get the per-generation average cross_validation fitness.""" avg_cross_validation_fitness = [] for stats in self.generation_cross_validation_statistics: scores = [] for fitness in stats.values(): ...
python
def get_average_cross_validation_fitness(self): # pragma: no cover """Get the per-generation average cross_validation fitness.""" avg_cross_validation_fitness = [] for stats in self.generation_cross_validation_statistics: scores = [] for fitness in stats.values(): ...
[ "def", "get_average_cross_validation_fitness", "(", "self", ")", ":", "# pragma: no cover", "avg_cross_validation_fitness", "=", "[", "]", "for", "stats", "in", "self", ".", "generation_cross_validation_statistics", ":", "scores", "=", "[", "]", "for", "fitness", "in"...
Get the per-generation average cross_validation fitness.
[ "Get", "the", "per", "-", "generation", "average", "cross_validation", "fitness", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/statistics.py#L62-L71
train
CodeReclaimers/neat-python
neat/statistics.py
StatisticsReporter.best_unique_genomes
def best_unique_genomes(self, n): """Returns the most n fit genomes, with no duplication.""" best_unique = {} for g in self.most_fit_genomes: best_unique[g.key] = g best_unique_list = list(best_unique.values()) def key(genome): return genome.fitness ...
python
def best_unique_genomes(self, n): """Returns the most n fit genomes, with no duplication.""" best_unique = {} for g in self.most_fit_genomes: best_unique[g.key] = g best_unique_list = list(best_unique.values()) def key(genome): return genome.fitness ...
[ "def", "best_unique_genomes", "(", "self", ",", "n", ")", ":", "best_unique", "=", "{", "}", "for", "g", "in", "self", ".", "most_fit_genomes", ":", "best_unique", "[", "g", ".", "key", "]", "=", "g", "best_unique_list", "=", "list", "(", "best_unique", ...
Returns the most n fit genomes, with no duplication.
[ "Returns", "the", "most", "n", "fit", "genomes", "with", "no", "duplication", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/statistics.py#L73-L83
train
CodeReclaimers/neat-python
neat/statistics.py
StatisticsReporter.best_genomes
def best_genomes(self, n): """Returns the n most fit genomes ever seen.""" def key(g): return g.fitness return sorted(self.most_fit_genomes, key=key, reverse=True)[:n]
python
def best_genomes(self, n): """Returns the n most fit genomes ever seen.""" def key(g): return g.fitness return sorted(self.most_fit_genomes, key=key, reverse=True)[:n]
[ "def", "best_genomes", "(", "self", ",", "n", ")", ":", "def", "key", "(", "g", ")", ":", "return", "g", ".", "fitness", "return", "sorted", "(", "self", ".", "most_fit_genomes", ",", "key", "=", "key", ",", "reverse", "=", "True", ")", "[", ":", ...
Returns the n most fit genomes ever seen.
[ "Returns", "the", "n", "most", "fit", "genomes", "ever", "seen", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/statistics.py#L85-L90
train
CodeReclaimers/neat-python
neat/statistics.py
StatisticsReporter.save_genome_fitness
def save_genome_fitness(self, delimiter=' ', filename='fitness_history.csv', with_cross_validation=False): """ Saves the population's best and average fitness. """ with open(filename, 'w') as f: w = csv.write...
python
def save_genome_fitness(self, delimiter=' ', filename='fitness_history.csv', with_cross_validation=False): """ Saves the population's best and average fitness. """ with open(filename, 'w') as f: w = csv.write...
[ "def", "save_genome_fitness", "(", "self", ",", "delimiter", "=", "' '", ",", "filename", "=", "'fitness_history.csv'", ",", "with_cross_validation", "=", "False", ")", ":", "with", "open", "(", "filename", ",", "'w'", ")", "as", "f", ":", "w", "=", "csv",...
Saves the population's best and average fitness.
[ "Saves", "the", "population", "s", "best", "and", "average", "fitness", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/statistics.py#L101-L122
train
CodeReclaimers/neat-python
neat/statistics.py
StatisticsReporter.save_species_count
def save_species_count(self, delimiter=' ', filename='speciation.csv'): """ Log speciation throughout evolution. """ with open(filename, 'w') as f: w = csv.writer(f, delimiter=delimiter) for s in self.get_species_sizes(): w.writerow(s)
python
def save_species_count(self, delimiter=' ', filename='speciation.csv'): """ Log speciation throughout evolution. """ with open(filename, 'w') as f: w = csv.writer(f, delimiter=delimiter) for s in self.get_species_sizes(): w.writerow(s)
[ "def", "save_species_count", "(", "self", ",", "delimiter", "=", "' '", ",", "filename", "=", "'speciation.csv'", ")", ":", "with", "open", "(", "filename", ",", "'w'", ")", "as", "f", ":", "w", "=", "csv", ".", "writer", "(", "f", ",", "delimiter", ...
Log speciation throughout evolution.
[ "Log", "speciation", "throughout", "evolution", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/statistics.py#L124-L129
train
CodeReclaimers/neat-python
neat/statistics.py
StatisticsReporter.save_species_fitness
def save_species_fitness(self, delimiter=' ', null_value='NA', filename='species_fitness.csv'): """ Log species' average fitness throughout evolution. """ with open(filename, 'w') as f: w = csv.writer(f, delimiter=delimiter) for s in self.get_species_fitness(null_value): ...
python
def save_species_fitness(self, delimiter=' ', null_value='NA', filename='species_fitness.csv'): """ Log species' average fitness throughout evolution. """ with open(filename, 'w') as f: w = csv.writer(f, delimiter=delimiter) for s in self.get_species_fitness(null_value): ...
[ "def", "save_species_fitness", "(", "self", ",", "delimiter", "=", "' '", ",", "null_value", "=", "'NA'", ",", "filename", "=", "'species_fitness.csv'", ")", ":", "with", "open", "(", "filename", ",", "'w'", ")", "as", "f", ":", "w", "=", "csv", ".", "...
Log species' average fitness throughout evolution.
[ "Log", "species", "average", "fitness", "throughout", "evolution", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/statistics.py#L131-L136
train
CodeReclaimers/neat-python
neat/genome.py
DefaultGenome.configure_new
def configure_new(self, config): """Configure a new genome based on the given configuration.""" # Create node genes for the output pins. for node_key in config.output_keys: self.nodes[node_key] = self.create_node(config, node_key) # Add hidden nodes if requested. if...
python
def configure_new(self, config): """Configure a new genome based on the given configuration.""" # Create node genes for the output pins. for node_key in config.output_keys: self.nodes[node_key] = self.create_node(config, node_key) # Add hidden nodes if requested. if...
[ "def", "configure_new", "(", "self", ",", "config", ")", ":", "# Create node genes for the output pins.", "for", "node_key", "in", "config", ".", "output_keys", ":", "self", ".", "nodes", "[", "node_key", "]", "=", "self", ".", "create_node", "(", "config", ",...
Configure a new genome based on the given configuration.
[ "Configure", "a", "new", "genome", "based", "on", "the", "given", "configuration", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/genome.py#L175-L232
train
CodeReclaimers/neat-python
neat/genome.py
DefaultGenome.configure_crossover
def configure_crossover(self, genome1, genome2, config): """ Configure a new genome by crossover from two parent genomes. """ assert isinstance(genome1.fitness, (int, float)) assert isinstance(genome2.fitness, (int, float)) if genome1.fitness > genome2.fitness: parent1, paren...
python
def configure_crossover(self, genome1, genome2, config): """ Configure a new genome by crossover from two parent genomes. """ assert isinstance(genome1.fitness, (int, float)) assert isinstance(genome2.fitness, (int, float)) if genome1.fitness > genome2.fitness: parent1, paren...
[ "def", "configure_crossover", "(", "self", ",", "genome1", ",", "genome2", ",", "config", ")", ":", "assert", "isinstance", "(", "genome1", ".", "fitness", ",", "(", "int", ",", "float", ")", ")", "assert", "isinstance", "(", "genome2", ".", "fitness", "...
Configure a new genome by crossover from two parent genomes.
[ "Configure", "a", "new", "genome", "by", "crossover", "from", "two", "parent", "genomes", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/genome.py#L234-L265
train
CodeReclaimers/neat-python
neat/genome.py
DefaultGenome.connect_full_direct
def connect_full_direct(self, config): """ Create a fully-connected genome, including direct input-output connections. """ for input_id, output_id in self.compute_full_connections(config, True): connection = self.create_connection(config, input_id, output_id) self.connections[con...
python
def connect_full_direct(self, config): """ Create a fully-connected genome, including direct input-output connections. """ for input_id, output_id in self.compute_full_connections(config, True): connection = self.create_connection(config, input_id, output_id) self.connections[con...
[ "def", "connect_full_direct", "(", "self", ",", "config", ")", ":", "for", "input_id", ",", "output_id", "in", "self", ".", "compute_full_connections", "(", "config", ",", "True", ")", ":", "connection", "=", "self", ".", "create_connection", "(", "config", ...
Create a fully-connected genome, including direct input-output connections.
[ "Create", "a", "fully", "-", "connected", "genome", "including", "direct", "input", "-", "output", "connections", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/genome.py#L541-L545
train
CodeReclaimers/neat-python
neat/config.py
ConfigParameter.interpret
def interpret(self, config_dict): """ Converts the config_parser output into the proper type, supplies defaults if available and needed, and checks for some errors. """ value = config_dict.get(self.name) if value is None: if self.default is None: ...
python
def interpret(self, config_dict): """ Converts the config_parser output into the proper type, supplies defaults if available and needed, and checks for some errors. """ value = config_dict.get(self.name) if value is None: if self.default is None: ...
[ "def", "interpret", "(", "self", ",", "config_dict", ")", ":", "value", "=", "config_dict", ".", "get", "(", "self", ".", "name", ")", "if", "value", "is", "None", ":", "if", "self", ".", "default", "is", "None", ":", "raise", "RuntimeError", "(", "'...
Converts the config_parser output into the proper type, supplies defaults if available and needed, and checks for some errors.
[ "Converts", "the", "config_parser", "output", "into", "the", "proper", "type", "supplies", "defaults", "if", "available", "and", "needed", "and", "checks", "for", "some", "errors", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/config.py#L47-L84
train
CodeReclaimers/neat-python
examples/xor/visualize.py
plot_spikes
def plot_spikes(spikes, view=False, filename=None, title=None): """ Plots the trains for a single spiking neuron. """ t_values = [t for t, I, v, u, f in spikes] v_values = [v for t, I, v, u, f in spikes] u_values = [u for t, I, v, u, f in spikes] I_values = [I for t, I, v, u, f in spikes] f_valu...
python
def plot_spikes(spikes, view=False, filename=None, title=None): """ Plots the trains for a single spiking neuron. """ t_values = [t for t, I, v, u, f in spikes] v_values = [v for t, I, v, u, f in spikes] u_values = [u for t, I, v, u, f in spikes] I_values = [I for t, I, v, u, f in spikes] f_valu...
[ "def", "plot_spikes", "(", "spikes", ",", "view", "=", "False", ",", "filename", "=", "None", ",", "title", "=", "None", ")", ":", "t_values", "=", "[", "t", "for", "t", ",", "I", ",", "v", ",", "u", ",", "f", "in", "spikes", "]", "v_values", "...
Plots the trains for a single spiking neuron.
[ "Plots", "the", "trains", "for", "a", "single", "spiking", "neuron", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/examples/xor/visualize.py#L42-L88
train
carpedm20/fbchat
fbchat/_client.py
Client.isLoggedIn
def isLoggedIn(self): """ Sends a request to Facebook to check the login status :return: True if the client is still logged in :rtype: bool """ # Send a request to the login url, to see if we're directed to the home page r = self._cleanGet(self.req_url.LOGIN, all...
python
def isLoggedIn(self): """ Sends a request to Facebook to check the login status :return: True if the client is still logged in :rtype: bool """ # Send a request to the login url, to see if we're directed to the home page r = self._cleanGet(self.req_url.LOGIN, all...
[ "def", "isLoggedIn", "(", "self", ")", ":", "# Send a request to the login url, to see if we're directed to the home page", "r", "=", "self", ".", "_cleanGet", "(", "self", ".", "req_url", ".", "LOGIN", ",", "allow_redirects", "=", "False", ")", "return", "\"Location\...
Sends a request to Facebook to check the login status :return: True if the client is still logged in :rtype: bool
[ "Sends", "a", "request", "to", "Facebook", "to", "check", "the", "login", "status" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L426-L435
train
carpedm20/fbchat
fbchat/_client.py
Client.setSession
def setSession(self, session_cookies): """Loads session cookies :param session_cookies: A dictionay containing session cookies :type session_cookies: dict :return: False if `session_cookies` does not contain proper cookies :rtype: bool """ # Quick check to see if...
python
def setSession(self, session_cookies): """Loads session cookies :param session_cookies: A dictionay containing session cookies :type session_cookies: dict :return: False if `session_cookies` does not contain proper cookies :rtype: bool """ # Quick check to see if...
[ "def", "setSession", "(", "self", ",", "session_cookies", ")", ":", "# Quick check to see if session_cookies is formatted properly", "if", "not", "session_cookies", "or", "\"c_user\"", "not", "in", "session_cookies", ":", "return", "False", "try", ":", "# Load cookies int...
Loads session cookies :param session_cookies: A dictionay containing session cookies :type session_cookies: dict :return: False if `session_cookies` does not contain proper cookies :rtype: bool
[ "Loads", "session", "cookies" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L445-L467
train
carpedm20/fbchat
fbchat/_client.py
Client.logout
def logout(self): """ Safely logs out the client :param timeout: See `requests timeout <http://docs.python-requests.org/en/master/user/advanced/#timeouts>`_ :return: True if the action was successful :rtype: bool """ if not hasattr(self, "_fb_h"): h_r...
python
def logout(self): """ Safely logs out the client :param timeout: See `requests timeout <http://docs.python-requests.org/en/master/user/advanced/#timeouts>`_ :return: True if the action was successful :rtype: bool """ if not hasattr(self, "_fb_h"): h_r...
[ "def", "logout", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "\"_fb_h\"", ")", ":", "h_r", "=", "self", ".", "_post", "(", "self", ".", "req_url", ".", "MODERN_SETTINGS_MENU", ",", "{", "\"pmid\"", ":", "\"4\"", "}", ")", "self",...
Safely logs out the client :param timeout: See `requests timeout <http://docs.python-requests.org/en/master/user/advanced/#timeouts>`_ :return: True if the action was successful :rtype: bool
[ "Safely", "logs", "out", "the", "client" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L506-L524
train
carpedm20/fbchat
fbchat/_client.py
Client._getThread
def _getThread(self, given_thread_id=None, given_thread_type=None): """ Checks if thread ID is given, checks if default is set and returns correct values :raises ValueError: If thread ID is not given and there is no default :return: Thread ID and thread type :rtype: tuple ...
python
def _getThread(self, given_thread_id=None, given_thread_type=None): """ Checks if thread ID is given, checks if default is set and returns correct values :raises ValueError: If thread ID is not given and there is no default :return: Thread ID and thread type :rtype: tuple ...
[ "def", "_getThread", "(", "self", ",", "given_thread_id", "=", "None", ",", "given_thread_type", "=", "None", ")", ":", "if", "given_thread_id", "is", "None", ":", "if", "self", ".", "_default_thread_id", "is", "not", "None", ":", "return", "self", ".", "_...
Checks if thread ID is given, checks if default is set and returns correct values :raises ValueError: If thread ID is not given and there is no default :return: Thread ID and thread type :rtype: tuple
[ "Checks", "if", "thread", "ID", "is", "given", "checks", "if", "default", "is", "set", "and", "returns", "correct", "values" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L534-L548
train
carpedm20/fbchat
fbchat/_client.py
Client.setDefaultThread
def setDefaultThread(self, thread_id, thread_type): """ Sets default thread to send messages to :param thread_id: User/Group ID to default to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type thread_type: models.ThreadType """ self._def...
python
def setDefaultThread(self, thread_id, thread_type): """ Sets default thread to send messages to :param thread_id: User/Group ID to default to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type thread_type: models.ThreadType """ self._def...
[ "def", "setDefaultThread", "(", "self", ",", "thread_id", ",", "thread_type", ")", ":", "self", ".", "_default_thread_id", "=", "thread_id", "self", ".", "_default_thread_type", "=", "thread_type" ]
Sets default thread to send messages to :param thread_id: User/Group ID to default to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type thread_type: models.ThreadType
[ "Sets", "default", "thread", "to", "send", "messages", "to" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L550-L559
train
carpedm20/fbchat
fbchat/_client.py
Client.fetchThreads
def fetchThreads(self, thread_location, before=None, after=None, limit=None): """ Get all threads in thread_location. Threads will be sorted from newest to oldest. :param thread_location: models.ThreadLocation: INBOX, PENDING, ARCHIVED or OTHER :param before: Fetch only thread b...
python
def fetchThreads(self, thread_location, before=None, after=None, limit=None): """ Get all threads in thread_location. Threads will be sorted from newest to oldest. :param thread_location: models.ThreadLocation: INBOX, PENDING, ARCHIVED or OTHER :param before: Fetch only thread b...
[ "def", "fetchThreads", "(", "self", ",", "thread_location", ",", "before", "=", "None", ",", "after", "=", "None", ",", "limit", "=", "None", ")", ":", "threads", "=", "[", "]", "last_thread_timestamp", "=", "None", "while", "True", ":", "# break if limit ...
Get all threads in thread_location. Threads will be sorted from newest to oldest. :param thread_location: models.ThreadLocation: INBOX, PENDING, ARCHIVED or OTHER :param before: Fetch only thread before this epoch (in ms) (default all threads) :param after: Fetch only thread after this ...
[ "Get", "all", "threads", "in", "thread_location", ".", "Threads", "will", "be", "sorted", "from", "newest", "to", "oldest", "." ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L577-L628
train
carpedm20/fbchat
fbchat/_client.py
Client.fetchAllUsersFromThreads
def fetchAllUsersFromThreads(self, threads): """ Get all users involved in threads. :param threads: models.Thread: List of threads to check for users :return: :class:`models.User` objects :rtype: list :raises: FBchatException if request failed """ users =...
python
def fetchAllUsersFromThreads(self, threads): """ Get all users involved in threads. :param threads: models.Thread: List of threads to check for users :return: :class:`models.User` objects :rtype: list :raises: FBchatException if request failed """ users =...
[ "def", "fetchAllUsersFromThreads", "(", "self", ",", "threads", ")", ":", "users", "=", "[", "]", "users_to_fetch", "=", "[", "]", "# It's more efficient to fetch all users in one request", "for", "thread", "in", "threads", ":", "if", "thread", ".", "type", "==", ...
Get all users involved in threads. :param threads: models.Thread: List of threads to check for users :return: :class:`models.User` objects :rtype: list :raises: FBchatException if request failed
[ "Get", "all", "users", "involved", "in", "threads", "." ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L630-L654
train
carpedm20/fbchat
fbchat/_client.py
Client.fetchAllUsers
def fetchAllUsers(self): """ Gets all users the client is currently chatting with :return: :class:`models.User` objects :rtype: list :raises: FBchatException if request failed """ data = {"viewer": self._uid} j = self._post( self.req_url.ALL_U...
python
def fetchAllUsers(self): """ Gets all users the client is currently chatting with :return: :class:`models.User` objects :rtype: list :raises: FBchatException if request failed """ data = {"viewer": self._uid} j = self._post( self.req_url.ALL_U...
[ "def", "fetchAllUsers", "(", "self", ")", ":", "data", "=", "{", "\"viewer\"", ":", "self", ".", "_uid", "}", "j", "=", "self", ".", "_post", "(", "self", ".", "req_url", ".", "ALL_USERS", ",", "query", "=", "data", ",", "fix_request", "=", "True", ...
Gets all users the client is currently chatting with :return: :class:`models.User` objects :rtype: list :raises: FBchatException if request failed
[ "Gets", "all", "users", "the", "client", "is", "currently", "chatting", "with" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L656-L678
train
carpedm20/fbchat
fbchat/_client.py
Client.searchForPages
def searchForPages(self, name, limit=10): """ Find and get page by its name :param name: Name of the page :return: :class:`models.Page` objects, ordered by relevance :rtype: list :raises: FBchatException if request failed """ params = {"search": name, "li...
python
def searchForPages(self, name, limit=10): """ Find and get page by its name :param name: Name of the page :return: :class:`models.Page` objects, ordered by relevance :rtype: list :raises: FBchatException if request failed """ params = {"search": name, "li...
[ "def", "searchForPages", "(", "self", ",", "name", ",", "limit", "=", "10", ")", ":", "params", "=", "{", "\"search\"", ":", "name", ",", "\"limit\"", ":", "limit", "}", "j", "=", "self", ".", "graphql_request", "(", "GraphQL", "(", "query", "=", "Gr...
Find and get page by its name :param name: Name of the page :return: :class:`models.Page` objects, ordered by relevance :rtype: list :raises: FBchatException if request failed
[ "Find", "and", "get", "page", "by", "its", "name" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L695-L707
train
carpedm20/fbchat
fbchat/_client.py
Client.searchForGroups
def searchForGroups(self, name, limit=10): """ Find and get group thread by its name :param name: Name of the group thread :param limit: The max. amount of groups to fetch :return: :class:`models.Group` objects, ordered by relevance :rtype: list :raises: FBchatEx...
python
def searchForGroups(self, name, limit=10): """ Find and get group thread by its name :param name: Name of the group thread :param limit: The max. amount of groups to fetch :return: :class:`models.Group` objects, ordered by relevance :rtype: list :raises: FBchatEx...
[ "def", "searchForGroups", "(", "self", ",", "name", ",", "limit", "=", "10", ")", ":", "params", "=", "{", "\"search\"", ":", "name", ",", "\"limit\"", ":", "limit", "}", "j", "=", "self", ".", "graphql_request", "(", "GraphQL", "(", "query", "=", "G...
Find and get group thread by its name :param name: Name of the group thread :param limit: The max. amount of groups to fetch :return: :class:`models.Group` objects, ordered by relevance :rtype: list :raises: FBchatException if request failed
[ "Find", "and", "get", "group", "thread", "by", "its", "name" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L709-L722
train
carpedm20/fbchat
fbchat/_client.py
Client.searchForThreads
def searchForThreads(self, name, limit=10): """ Find and get a thread by its name :param name: Name of the thread :param limit: The max. amount of groups to fetch :return: :class:`models.User`, :class:`models.Group` and :class:`models.Page` objects, ordered by relevance ...
python
def searchForThreads(self, name, limit=10): """ Find and get a thread by its name :param name: Name of the thread :param limit: The max. amount of groups to fetch :return: :class:`models.User`, :class:`models.Group` and :class:`models.Page` objects, ordered by relevance ...
[ "def", "searchForThreads", "(", "self", ",", "name", ",", "limit", "=", "10", ")", ":", "params", "=", "{", "\"search\"", ":", "name", ",", "\"limit\"", ":", "limit", "}", "j", "=", "self", ".", "graphql_request", "(", "GraphQL", "(", "query", "=", "...
Find and get a thread by its name :param name: Name of the thread :param limit: The max. amount of groups to fetch :return: :class:`models.User`, :class:`models.Group` and :class:`models.Page` objects, ordered by relevance :rtype: list :raises: FBchatException if request failed
[ "Find", "and", "get", "a", "thread", "by", "its", "name" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L724-L754
train
carpedm20/fbchat
fbchat/_client.py
Client.searchForMessageIDs
def searchForMessageIDs(self, query, offset=0, limit=5, thread_id=None): """ Find and get message IDs by query :param query: Text to search for :param offset: Number of messages to skip :param limit: Max. number of messages to retrieve :param thread_id: User/Group ID to ...
python
def searchForMessageIDs(self, query, offset=0, limit=5, thread_id=None): """ Find and get message IDs by query :param query: Text to search for :param offset: Number of messages to skip :param limit: Max. number of messages to retrieve :param thread_id: User/Group ID to ...
[ "def", "searchForMessageIDs", "(", "self", ",", "query", ",", "offset", "=", "0", ",", "limit", "=", "5", ",", "thread_id", "=", "None", ")", ":", "thread_id", ",", "thread_type", "=", "self", ".", "_getThread", "(", "thread_id", ",", "None", ")", "dat...
Find and get message IDs by query :param query: Text to search for :param offset: Number of messages to skip :param limit: Max. number of messages to retrieve :param thread_id: User/Group ID to search in. See :ref:`intro_threads` :type offset: int :type limit: int ...
[ "Find", "and", "get", "message", "IDs", "by", "query" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L756-L786
train
carpedm20/fbchat
fbchat/_client.py
Client.search
def search(self, query, fetch_messages=False, thread_limit=5, message_limit=5): """ Searches for messages in all threads :param query: Text to search for :param fetch_messages: Whether to fetch :class:`models.Message` objects or IDs only :param thread_limit: Max. number of threa...
python
def search(self, query, fetch_messages=False, thread_limit=5, message_limit=5): """ Searches for messages in all threads :param query: Text to search for :param fetch_messages: Whether to fetch :class:`models.Message` objects or IDs only :param thread_limit: Max. number of threa...
[ "def", "search", "(", "self", ",", "query", ",", "fetch_messages", "=", "False", ",", "thread_limit", "=", "5", ",", "message_limit", "=", "5", ")", ":", "data", "=", "{", "\"query\"", ":", "query", ",", "\"snippetLimit\"", ":", "thread_limit", "}", "j",...
Searches for messages in all threads :param query: Text to search for :param fetch_messages: Whether to fetch :class:`models.Message` objects or IDs only :param thread_limit: Max. number of threads to retrieve :param message_limit: Max. number of messages to retrieve :type threa...
[ "Searches", "for", "messages", "in", "all", "threads" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L811-L839
train
carpedm20/fbchat
fbchat/_client.py
Client.fetchUserInfo
def fetchUserInfo(self, *user_ids): """ Get users' info from IDs, unordered .. warning:: Sends two requests, to fetch all available info! :param user_ids: One or more user ID(s) to query :return: :class:`models.User` objects, labeled by their ID :rtype: dict...
python
def fetchUserInfo(self, *user_ids): """ Get users' info from IDs, unordered .. warning:: Sends two requests, to fetch all available info! :param user_ids: One or more user ID(s) to query :return: :class:`models.User` objects, labeled by their ID :rtype: dict...
[ "def", "fetchUserInfo", "(", "self", ",", "*", "user_ids", ")", ":", "threads", "=", "self", ".", "fetchThreadInfo", "(", "*", "user_ids", ")", "users", "=", "{", "}", "for", "id_", ",", "thread", "in", "threads", ".", "items", "(", ")", ":", "if", ...
Get users' info from IDs, unordered .. warning:: Sends two requests, to fetch all available info! :param user_ids: One or more user ID(s) to query :return: :class:`models.User` objects, labeled by their ID :rtype: dict :raises: FBchatException if request failed
[ "Get", "users", "info", "from", "IDs", "unordered" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L878-L898
train
carpedm20/fbchat
fbchat/_client.py
Client.fetchPageInfo
def fetchPageInfo(self, *page_ids): """ Get pages' info from IDs, unordered .. warning:: Sends two requests, to fetch all available info! :param page_ids: One or more page ID(s) to query :return: :class:`models.Page` objects, labeled by their ID :rtype: dict...
python
def fetchPageInfo(self, *page_ids): """ Get pages' info from IDs, unordered .. warning:: Sends two requests, to fetch all available info! :param page_ids: One or more page ID(s) to query :return: :class:`models.Page` objects, labeled by their ID :rtype: dict...
[ "def", "fetchPageInfo", "(", "self", ",", "*", "page_ids", ")", ":", "threads", "=", "self", ".", "fetchThreadInfo", "(", "*", "page_ids", ")", "pages", "=", "{", "}", "for", "id_", ",", "thread", "in", "threads", ".", "items", "(", ")", ":", "if", ...
Get pages' info from IDs, unordered .. warning:: Sends two requests, to fetch all available info! :param page_ids: One or more page ID(s) to query :return: :class:`models.Page` objects, labeled by their ID :rtype: dict :raises: FBchatException if request failed
[ "Get", "pages", "info", "from", "IDs", "unordered" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L900-L920
train
carpedm20/fbchat
fbchat/_client.py
Client.fetchGroupInfo
def fetchGroupInfo(self, *group_ids): """ Get groups' info from IDs, unordered :param group_ids: One or more group ID(s) to query :return: :class:`models.Group` objects, labeled by their ID :rtype: dict :raises: FBchatException if request failed """ threa...
python
def fetchGroupInfo(self, *group_ids): """ Get groups' info from IDs, unordered :param group_ids: One or more group ID(s) to query :return: :class:`models.Group` objects, labeled by their ID :rtype: dict :raises: FBchatException if request failed """ threa...
[ "def", "fetchGroupInfo", "(", "self", ",", "*", "group_ids", ")", ":", "threads", "=", "self", ".", "fetchThreadInfo", "(", "*", "group_ids", ")", "groups", "=", "{", "}", "for", "id_", ",", "thread", "in", "threads", ".", "items", "(", ")", ":", "if...
Get groups' info from IDs, unordered :param group_ids: One or more group ID(s) to query :return: :class:`models.Group` objects, labeled by their ID :rtype: dict :raises: FBchatException if request failed
[ "Get", "groups", "info", "from", "IDs", "unordered" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L922-L939
train
carpedm20/fbchat
fbchat/_client.py
Client.fetchThreadInfo
def fetchThreadInfo(self, *thread_ids): """ Get threads' info from IDs, unordered .. warning:: Sends two requests if users or pages are present, to fetch all available info! :param thread_ids: One or more thread ID(s) to query :return: :class:`models.Thread` objects...
python
def fetchThreadInfo(self, *thread_ids): """ Get threads' info from IDs, unordered .. warning:: Sends two requests if users or pages are present, to fetch all available info! :param thread_ids: One or more thread ID(s) to query :return: :class:`models.Thread` objects...
[ "def", "fetchThreadInfo", "(", "self", ",", "*", "thread_ids", ")", ":", "queries", "=", "[", "]", "for", "thread_id", "in", "thread_ids", ":", "params", "=", "{", "\"id\"", ":", "thread_id", ",", "\"message_limit\"", ":", "0", ",", "\"load_messages\"", ":...
Get threads' info from IDs, unordered .. warning:: Sends two requests if users or pages are present, to fetch all available info! :param thread_ids: One or more thread ID(s) to query :return: :class:`models.Thread` objects, labeled by their ID :rtype: dict :raises: ...
[ "Get", "threads", "info", "from", "IDs", "unordered" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L941-L1003
train
carpedm20/fbchat
fbchat/_client.py
Client.fetchThreadMessages
def fetchThreadMessages(self, thread_id=None, limit=20, before=None): """ Get the last messages in a thread :param thread_id: User/Group ID to get messages from. See :ref:`intro_threads` :param limit: Max. number of messages to retrieve :param before: A timestamp, indicating fro...
python
def fetchThreadMessages(self, thread_id=None, limit=20, before=None): """ Get the last messages in a thread :param thread_id: User/Group ID to get messages from. See :ref:`intro_threads` :param limit: Max. number of messages to retrieve :param before: A timestamp, indicating fro...
[ "def", "fetchThreadMessages", "(", "self", ",", "thread_id", "=", "None", ",", "limit", "=", "20", ",", "before", "=", "None", ")", ":", "thread_id", ",", "thread_type", "=", "self", ".", "_getThread", "(", "thread_id", ",", "None", ")", "params", "=", ...
Get the last messages in a thread :param thread_id: User/Group ID to get messages from. See :ref:`intro_threads` :param limit: Max. number of messages to retrieve :param before: A timestamp, indicating from which point to retrieve messages :type limit: int :type before: int ...
[ "Get", "the", "last", "messages", "in", "a", "thread" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1005-L1045
train
carpedm20/fbchat
fbchat/_client.py
Client.fetchThreadList
def fetchThreadList( self, offset=None, limit=20, thread_location=ThreadLocation.INBOX, before=None ): """Get thread list of your facebook account :param offset: Deprecated. Do not use! :param limit: Max. number of threads to retrieve. Capped at 20 :param thread_location: mo...
python
def fetchThreadList( self, offset=None, limit=20, thread_location=ThreadLocation.INBOX, before=None ): """Get thread list of your facebook account :param offset: Deprecated. Do not use! :param limit: Max. number of threads to retrieve. Capped at 20 :param thread_location: mo...
[ "def", "fetchThreadList", "(", "self", ",", "offset", "=", "None", ",", "limit", "=", "20", ",", "thread_location", "=", "ThreadLocation", ".", "INBOX", ",", "before", "=", "None", ")", ":", "if", "offset", "is", "not", "None", ":", "log", ".", "warnin...
Get thread list of your facebook account :param offset: Deprecated. Do not use! :param limit: Max. number of threads to retrieve. Capped at 20 :param thread_location: models.ThreadLocation: INBOX, PENDING, ARCHIVED or OTHER :param before: A timestamp (in milliseconds), indicating from w...
[ "Get", "thread", "list", "of", "your", "facebook", "account" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1047-L1097
train
carpedm20/fbchat
fbchat/_client.py
Client.fetchUnread
def fetchUnread(self): """ Get the unread thread list :return: List of unread thread ids :rtype: list :raises: FBchatException if request failed """ form = { "folders[0]": "inbox", "client": "mercury", "last_action_timestamp": ...
python
def fetchUnread(self): """ Get the unread thread list :return: List of unread thread ids :rtype: list :raises: FBchatException if request failed """ form = { "folders[0]": "inbox", "client": "mercury", "last_action_timestamp": ...
[ "def", "fetchUnread", "(", "self", ")", ":", "form", "=", "{", "\"folders[0]\"", ":", "\"inbox\"", ",", "\"client\"", ":", "\"mercury\"", ",", "\"last_action_timestamp\"", ":", "now", "(", ")", "-", "60", "*", "1000", "# 'last_action_timestamp': 0", "}", "j", ...
Get the unread thread list :return: List of unread thread ids :rtype: list :raises: FBchatException if request failed
[ "Get", "the", "unread", "thread", "list" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1099-L1118
train
carpedm20/fbchat
fbchat/_client.py
Client.fetchImageUrl
def fetchImageUrl(self, image_id): """Fetches the url to the original image from an image attachment ID :param image_id: The image you want to fethc :type image_id: str :return: An url where you can download the original image :rtype: str :raises: FBchatException if requ...
python
def fetchImageUrl(self, image_id): """Fetches the url to the original image from an image attachment ID :param image_id: The image you want to fethc :type image_id: str :return: An url where you can download the original image :rtype: str :raises: FBchatException if requ...
[ "def", "fetchImageUrl", "(", "self", ",", "image_id", ")", ":", "image_id", "=", "str", "(", "image_id", ")", "data", "=", "{", "\"photo_id\"", ":", "str", "(", "image_id", ")", "}", "j", "=", "self", ".", "_get", "(", "ReqUrl", ".", "ATTACHMENT_PHOTO"...
Fetches the url to the original image from an image attachment ID :param image_id: The image you want to fethc :type image_id: str :return: An url where you can download the original image :rtype: str :raises: FBchatException if request failed
[ "Fetches", "the", "url", "to", "the", "original", "image", "from", "an", "image", "attachment", "ID" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1135-L1153
train
carpedm20/fbchat
fbchat/_client.py
Client._getSendData
def _getSendData(self, message=None, thread_id=None, thread_type=ThreadType.USER): """Returns the data needed to send a request to `SendURL`""" messageAndOTID = generateOfflineThreadingID() timestamp = now() data = { "client": "mercury", "author": "fbid:{}".format...
python
def _getSendData(self, message=None, thread_id=None, thread_type=ThreadType.USER): """Returns the data needed to send a request to `SendURL`""" messageAndOTID = generateOfflineThreadingID() timestamp = now() data = { "client": "mercury", "author": "fbid:{}".format...
[ "def", "_getSendData", "(", "self", ",", "message", "=", "None", ",", "thread_id", "=", "None", ",", "thread_type", "=", "ThreadType", ".", "USER", ")", ":", "messageAndOTID", "=", "generateOfflineThreadingID", "(", ")", "timestamp", "=", "now", "(", ")", ...
Returns the data needed to send a request to `SendURL`
[ "Returns", "the", "data", "needed", "to", "send", "a", "request", "to", "SendURL" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1247-L1314
train
carpedm20/fbchat
fbchat/_client.py
Client._doSendRequest
def _doSendRequest(self, data, get_thread_id=False): """Sends the data to `SendURL`, and returns the message ID or None on failure""" j = self._post(self.req_url.SEND, data, fix_request=True, as_json=True) # update JS token if received in response fb_dtsg = get_jsmods_require(j, 2) ...
python
def _doSendRequest(self, data, get_thread_id=False): """Sends the data to `SendURL`, and returns the message ID or None on failure""" j = self._post(self.req_url.SEND, data, fix_request=True, as_json=True) # update JS token if received in response fb_dtsg = get_jsmods_require(j, 2) ...
[ "def", "_doSendRequest", "(", "self", ",", "data", ",", "get_thread_id", "=", "False", ")", ":", "j", "=", "self", ".", "_post", "(", "self", ".", "req_url", ".", "SEND", ",", "data", ",", "fix_request", "=", "True", ",", "as_json", "=", "True", ")",...
Sends the data to `SendURL`, and returns the message ID or None on failure
[ "Sends", "the", "data", "to", "SendURL", "and", "returns", "the", "message", "ID", "or", "None", "on", "failure" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1316-L1341
train
carpedm20/fbchat
fbchat/_client.py
Client.send
def send(self, message, thread_id=None, thread_type=ThreadType.USER): """ Sends a message to a thread :param message: Message to send :param thread_id: User/Group ID to send to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type message: models.M...
python
def send(self, message, thread_id=None, thread_type=ThreadType.USER): """ Sends a message to a thread :param message: Message to send :param thread_id: User/Group ID to send to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type message: models.M...
[ "def", "send", "(", "self", ",", "message", ",", "thread_id", "=", "None", ",", "thread_type", "=", "ThreadType", ".", "USER", ")", ":", "thread_id", ",", "thread_type", "=", "self", ".", "_getThread", "(", "thread_id", ",", "thread_type", ")", "data", "...
Sends a message to a thread :param message: Message to send :param thread_id: User/Group ID to send to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type message: models.Message :type thread_type: models.ThreadType :return: :ref:`Message ID <int...
[ "Sends", "a", "message", "to", "a", "thread" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1343-L1359
train
carpedm20/fbchat
fbchat/_client.py
Client.wave
def wave(self, wave_first=True, thread_id=None, thread_type=None): """ Says hello with a wave to a thread! :param wave_first: Whether to wave first or wave back :param thread_id: User/Group ID to send to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` ...
python
def wave(self, wave_first=True, thread_id=None, thread_type=None): """ Says hello with a wave to a thread! :param wave_first: Whether to wave first or wave back :param thread_id: User/Group ID to send to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` ...
[ "def", "wave", "(", "self", ",", "wave_first", "=", "True", ",", "thread_id", "=", "None", ",", "thread_type", "=", "None", ")", ":", "thread_id", ",", "thread_type", "=", "self", ".", "_getThread", "(", "thread_id", ",", "thread_type", ")", "data", "=",...
Says hello with a wave to a thread! :param wave_first: Whether to wave first or wave back :param thread_id: User/Group ID to send to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type thread_type: models.ThreadType :return: :ref:`Message ID <intro_messa...
[ "Says", "hello", "with", "a", "wave", "to", "a", "thread!" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1385-L1405
train
carpedm20/fbchat
fbchat/_client.py
Client.quickReply
def quickReply(self, quick_reply, payload=None, thread_id=None, thread_type=None): """ Replies to a chosen quick reply :param quick_reply: Quick reply to reply to :param payload: Optional answer to the quick reply :param thread_id: User/Group ID to send to. See :ref:`intro_threa...
python
def quickReply(self, quick_reply, payload=None, thread_id=None, thread_type=None): """ Replies to a chosen quick reply :param quick_reply: Quick reply to reply to :param payload: Optional answer to the quick reply :param thread_id: User/Group ID to send to. See :ref:`intro_threa...
[ "def", "quickReply", "(", "self", ",", "quick_reply", ",", "payload", "=", "None", ",", "thread_id", "=", "None", ",", "thread_type", "=", "None", ")", ":", "quick_reply", ".", "is_response", "=", "True", "if", "isinstance", "(", "quick_reply", ",", "Quick...
Replies to a chosen quick reply :param quick_reply: Quick reply to reply to :param payload: Optional answer to the quick reply :param thread_id: User/Group ID to send to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type quick_reply: models.QuickReply ...
[ "Replies", "to", "a", "chosen", "quick", "reply" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1407-L1444
train
carpedm20/fbchat
fbchat/_client.py
Client.sendLocation
def sendLocation(self, location, message=None, thread_id=None, thread_type=None): """ Sends a given location to a thread as the user's current location :param location: Location to send :param message: Additional message :param thread_id: User/Group ID to send to. See :ref:`intr...
python
def sendLocation(self, location, message=None, thread_id=None, thread_type=None): """ Sends a given location to a thread as the user's current location :param location: Location to send :param message: Additional message :param thread_id: User/Group ID to send to. See :ref:`intr...
[ "def", "sendLocation", "(", "self", ",", "location", ",", "message", "=", "None", ",", "thread_id", "=", "None", ",", "thread_type", "=", "None", ")", ":", "self", ".", "_sendLocation", "(", "location", "=", "location", ",", "current", "=", "True", ",", ...
Sends a given location to a thread as the user's current location :param location: Location to send :param message: Additional message :param thread_id: User/Group ID to send to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type location: models.Locatio...
[ "Sends", "a", "given", "location", "to", "a", "thread", "as", "the", "user", "s", "current", "location" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1469-L1489
train
carpedm20/fbchat
fbchat/_client.py
Client.sendPinnedLocation
def sendPinnedLocation( self, location, message=None, thread_id=None, thread_type=None ): """ Sends a given location to a thread as a pinned location :param location: Location to send :param message: Additional message :param thread_id: User/Group ID to send to. See ...
python
def sendPinnedLocation( self, location, message=None, thread_id=None, thread_type=None ): """ Sends a given location to a thread as a pinned location :param location: Location to send :param message: Additional message :param thread_id: User/Group ID to send to. See ...
[ "def", "sendPinnedLocation", "(", "self", ",", "location", ",", "message", "=", "None", ",", "thread_id", "=", "None", ",", "thread_type", "=", "None", ")", ":", "self", ".", "_sendLocation", "(", "location", "=", "location", ",", "current", "=", "False", ...
Sends a given location to a thread as a pinned location :param location: Location to send :param message: Additional message :param thread_id: User/Group ID to send to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type location: models.LocationAttachmen...
[ "Sends", "a", "given", "location", "to", "a", "thread", "as", "a", "pinned", "location" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1491-L1513
train
carpedm20/fbchat
fbchat/_client.py
Client._upload
def _upload(self, files, voice_clip=False): """ Uploads files to Facebook `files` should be a list of files that requests can upload, see: http://docs.python-requests.org/en/master/api/#requests.request Returns a list of tuples with a file's ID and mimetype """ ...
python
def _upload(self, files, voice_clip=False): """ Uploads files to Facebook `files` should be a list of files that requests can upload, see: http://docs.python-requests.org/en/master/api/#requests.request Returns a list of tuples with a file's ID and mimetype """ ...
[ "def", "_upload", "(", "self", ",", "files", ",", "voice_clip", "=", "False", ")", ":", "file_dict", "=", "{", "\"upload_{}\"", ".", "format", "(", "i", ")", ":", "f", "for", "i", ",", "f", "in", "enumerate", "(", "files", ")", "}", "data", "=", ...
Uploads files to Facebook `files` should be a list of files that requests can upload, see: http://docs.python-requests.org/en/master/api/#requests.request Returns a list of tuples with a file's ID and mimetype
[ "Uploads", "files", "to", "Facebook" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1515-L1544
train
carpedm20/fbchat
fbchat/_client.py
Client._sendFiles
def _sendFiles( self, files, message=None, thread_id=None, thread_type=ThreadType.USER ): """ Sends files from file IDs to a thread `files` should be a list of tuples, with a file's ID and mimetype """ thread_id, thread_type = self._getThread(thread_id, thread_type) ...
python
def _sendFiles( self, files, message=None, thread_id=None, thread_type=ThreadType.USER ): """ Sends files from file IDs to a thread `files` should be a list of tuples, with a file's ID and mimetype """ thread_id, thread_type = self._getThread(thread_id, thread_type) ...
[ "def", "_sendFiles", "(", "self", ",", "files", ",", "message", "=", "None", ",", "thread_id", "=", "None", ",", "thread_type", "=", "ThreadType", ".", "USER", ")", ":", "thread_id", ",", "thread_type", "=", "self", ".", "_getThread", "(", "thread_id", "...
Sends files from file IDs to a thread `files` should be a list of tuples, with a file's ID and mimetype
[ "Sends", "files", "from", "file", "IDs", "to", "a", "thread" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1546-L1567
train
carpedm20/fbchat
fbchat/_client.py
Client.sendRemoteFiles
def sendRemoteFiles( self, file_urls, message=None, thread_id=None, thread_type=ThreadType.USER ): """ Sends files from URLs to a thread :param file_urls: URLs of files to upload and send :param message: Additional message :param thread_id: User/Group ID to send to. ...
python
def sendRemoteFiles( self, file_urls, message=None, thread_id=None, thread_type=ThreadType.USER ): """ Sends files from URLs to a thread :param file_urls: URLs of files to upload and send :param message: Additional message :param thread_id: User/Group ID to send to. ...
[ "def", "sendRemoteFiles", "(", "self", ",", "file_urls", ",", "message", "=", "None", ",", "thread_id", "=", "None", ",", "thread_type", "=", "ThreadType", ".", "USER", ")", ":", "file_urls", "=", "require_list", "(", "file_urls", ")", "files", "=", "self"...
Sends files from URLs to a thread :param file_urls: URLs of files to upload and send :param message: Additional message :param thread_id: User/Group ID to send to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type thread_type: models.ThreadType ...
[ "Sends", "files", "from", "URLs", "to", "a", "thread" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1569-L1587
train
carpedm20/fbchat
fbchat/_client.py
Client.sendLocalFiles
def sendLocalFiles( self, file_paths, message=None, thread_id=None, thread_type=ThreadType.USER ): """ Sends local files to a thread :param file_paths: Paths of files to upload and send :param message: Additional message :param thread_id: User/Group ID to send to. Se...
python
def sendLocalFiles( self, file_paths, message=None, thread_id=None, thread_type=ThreadType.USER ): """ Sends local files to a thread :param file_paths: Paths of files to upload and send :param message: Additional message :param thread_id: User/Group ID to send to. Se...
[ "def", "sendLocalFiles", "(", "self", ",", "file_paths", ",", "message", "=", "None", ",", "thread_id", "=", "None", ",", "thread_type", "=", "ThreadType", ".", "USER", ")", ":", "file_paths", "=", "require_list", "(", "file_paths", ")", "with", "get_files_f...
Sends local files to a thread :param file_paths: Paths of files to upload and send :param message: Additional message :param thread_id: User/Group ID to send to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type thread_type: models.ThreadType :r...
[ "Sends", "local", "files", "to", "a", "thread" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1589-L1608
train
carpedm20/fbchat
fbchat/_client.py
Client.sendRemoteVoiceClips
def sendRemoteVoiceClips( self, clip_urls, message=None, thread_id=None, thread_type=ThreadType.USER ): """ Sends voice clips from URLs to a thread :param clip_urls: URLs of clips to upload and send :param message: Additional message :param thread_id: User/Group ID t...
python
def sendRemoteVoiceClips( self, clip_urls, message=None, thread_id=None, thread_type=ThreadType.USER ): """ Sends voice clips from URLs to a thread :param clip_urls: URLs of clips to upload and send :param message: Additional message :param thread_id: User/Group ID t...
[ "def", "sendRemoteVoiceClips", "(", "self", ",", "clip_urls", ",", "message", "=", "None", ",", "thread_id", "=", "None", ",", "thread_type", "=", "ThreadType", ".", "USER", ")", ":", "clip_urls", "=", "require_list", "(", "clip_urls", ")", "files", "=", "...
Sends voice clips from URLs to a thread :param clip_urls: URLs of clips to upload and send :param message: Additional message :param thread_id: User/Group ID to send to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type thread_type: models.ThreadType ...
[ "Sends", "voice", "clips", "from", "URLs", "to", "a", "thread" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1610-L1628
train
carpedm20/fbchat
fbchat/_client.py
Client.sendLocalVoiceClips
def sendLocalVoiceClips( self, clip_paths, message=None, thread_id=None, thread_type=ThreadType.USER ): """ Sends local voice clips to a thread :param clip_paths: Paths of clips to upload and send :param message: Additional message :param thread_id: User/Group ID to ...
python
def sendLocalVoiceClips( self, clip_paths, message=None, thread_id=None, thread_type=ThreadType.USER ): """ Sends local voice clips to a thread :param clip_paths: Paths of clips to upload and send :param message: Additional message :param thread_id: User/Group ID to ...
[ "def", "sendLocalVoiceClips", "(", "self", ",", "clip_paths", ",", "message", "=", "None", ",", "thread_id", "=", "None", ",", "thread_type", "=", "ThreadType", ".", "USER", ")", ":", "clip_paths", "=", "require_list", "(", "clip_paths", ")", "with", "get_fi...
Sends local voice clips to a thread :param clip_paths: Paths of clips to upload and send :param message: Additional message :param thread_id: User/Group ID to send to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type thread_type: models.ThreadType ...
[ "Sends", "local", "voice", "clips", "to", "a", "thread" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1630-L1649
train
carpedm20/fbchat
fbchat/_client.py
Client.forwardAttachment
def forwardAttachment(self, attachment_id, thread_id=None): """ Forwards an attachment :param attachment_id: Attachment ID to forward :param thread_id: User/Group ID to send to. See :ref:`intro_threads` :raises: FBchatException if request failed """ thread_id, th...
python
def forwardAttachment(self, attachment_id, thread_id=None): """ Forwards an attachment :param attachment_id: Attachment ID to forward :param thread_id: User/Group ID to send to. See :ref:`intro_threads` :raises: FBchatException if request failed """ thread_id, th...
[ "def", "forwardAttachment", "(", "self", ",", "attachment_id", ",", "thread_id", "=", "None", ")", ":", "thread_id", ",", "thread_type", "=", "self", ".", "_getThread", "(", "thread_id", ",", "None", ")", "data", "=", "{", "\"attachment_id\"", ":", "attachme...
Forwards an attachment :param attachment_id: Attachment ID to forward :param thread_id: User/Group ID to send to. See :ref:`intro_threads` :raises: FBchatException if request failed
[ "Forwards", "an", "attachment" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1699-L1714
train
carpedm20/fbchat
fbchat/_client.py
Client.createGroup
def createGroup(self, message, user_ids): """ Creates a group with the given ids :param message: The initial message :param user_ids: A list of users to create the group with. :return: ID of the new group :raises: FBchatException if request failed """ dat...
python
def createGroup(self, message, user_ids): """ Creates a group with the given ids :param message: The initial message :param user_ids: A list of users to create the group with. :return: ID of the new group :raises: FBchatException if request failed """ dat...
[ "def", "createGroup", "(", "self", ",", "message", ",", "user_ids", ")", ":", "data", "=", "self", ".", "_getSendData", "(", "message", "=", "self", ".", "_oldMessage", "(", "message", ")", ")", "if", "len", "(", "user_ids", ")", "<", "2", ":", "rais...
Creates a group with the given ids :param message: The initial message :param user_ids: A list of users to create the group with. :return: ID of the new group :raises: FBchatException if request failed
[ "Creates", "a", "group", "with", "the", "given", "ids" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1716-L1738
train
carpedm20/fbchat
fbchat/_client.py
Client.addUsersToGroup
def addUsersToGroup(self, user_ids, thread_id=None): """ Adds users to a group. :param user_ids: One or more user IDs to add :param thread_id: Group ID to add people to. See :ref:`intro_threads` :type user_ids: list :raises: FBchatException if request failed """ ...
python
def addUsersToGroup(self, user_ids, thread_id=None): """ Adds users to a group. :param user_ids: One or more user IDs to add :param thread_id: Group ID to add people to. See :ref:`intro_threads` :type user_ids: list :raises: FBchatException if request failed """ ...
[ "def", "addUsersToGroup", "(", "self", ",", "user_ids", ",", "thread_id", "=", "None", ")", ":", "thread_id", ",", "thread_type", "=", "self", ".", "_getThread", "(", "thread_id", ",", "None", ")", "data", "=", "self", ".", "_getSendData", "(", "thread_id"...
Adds users to a group. :param user_ids: One or more user IDs to add :param thread_id: Group ID to add people to. See :ref:`intro_threads` :type user_ids: list :raises: FBchatException if request failed
[ "Adds", "users", "to", "a", "group", "." ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1740-L1767
train
carpedm20/fbchat
fbchat/_client.py
Client.removeUserFromGroup
def removeUserFromGroup(self, user_id, thread_id=None): """ Removes users from a group. :param user_id: User ID to remove :param thread_id: Group ID to remove people from. See :ref:`intro_threads` :raises: FBchatException if request failed """ thread_id, thread_t...
python
def removeUserFromGroup(self, user_id, thread_id=None): """ Removes users from a group. :param user_id: User ID to remove :param thread_id: Group ID to remove people from. See :ref:`intro_threads` :raises: FBchatException if request failed """ thread_id, thread_t...
[ "def", "removeUserFromGroup", "(", "self", ",", "user_id", ",", "thread_id", "=", "None", ")", ":", "thread_id", ",", "thread_type", "=", "self", ".", "_getThread", "(", "thread_id", ",", "None", ")", "data", "=", "{", "\"uid\"", ":", "user_id", ",", "\"...
Removes users from a group. :param user_id: User ID to remove :param thread_id: Group ID to remove people from. See :ref:`intro_threads` :raises: FBchatException if request failed
[ "Removes", "users", "from", "a", "group", "." ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1769-L1780
train
carpedm20/fbchat
fbchat/_client.py
Client.changeGroupApprovalMode
def changeGroupApprovalMode(self, require_admin_approval, thread_id=None): """ Changes group's approval mode :param require_admin_approval: True or False :param thread_id: Group ID to remove people from. See :ref:`intro_threads` :raises: FBchatException if request failed ...
python
def changeGroupApprovalMode(self, require_admin_approval, thread_id=None): """ Changes group's approval mode :param require_admin_approval: True or False :param thread_id: Group ID to remove people from. See :ref:`intro_threads` :raises: FBchatException if request failed ...
[ "def", "changeGroupApprovalMode", "(", "self", ",", "require_admin_approval", ",", "thread_id", "=", "None", ")", ":", "thread_id", ",", "thread_type", "=", "self", ".", "_getThread", "(", "thread_id", ",", "None", ")", "data", "=", "{", "\"set_mode\"", ":", ...
Changes group's approval mode :param require_admin_approval: True or False :param thread_id: Group ID to remove people from. See :ref:`intro_threads` :raises: FBchatException if request failed
[ "Changes", "group", "s", "approval", "mode" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1814-L1825
train
carpedm20/fbchat
fbchat/_client.py
Client._changeGroupImage
def _changeGroupImage(self, image_id, thread_id=None): """ Changes a thread image from an image id :param image_id: ID of uploaded image :param thread_id: User/Group ID to change image. See :ref:`intro_threads` :raises: FBchatException if request failed """ threa...
python
def _changeGroupImage(self, image_id, thread_id=None): """ Changes a thread image from an image id :param image_id: ID of uploaded image :param thread_id: User/Group ID to change image. See :ref:`intro_threads` :raises: FBchatException if request failed """ threa...
[ "def", "_changeGroupImage", "(", "self", ",", "image_id", ",", "thread_id", "=", "None", ")", ":", "thread_id", ",", "thread_type", "=", "self", ".", "_getThread", "(", "thread_id", ",", "None", ")", "data", "=", "{", "\"thread_image_id\"", ":", "image_id", ...
Changes a thread image from an image id :param image_id: ID of uploaded image :param thread_id: User/Group ID to change image. See :ref:`intro_threads` :raises: FBchatException if request failed
[ "Changes", "a", "thread", "image", "from", "an", "image", "id" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1864-L1877
train
carpedm20/fbchat
fbchat/_client.py
Client.changeGroupImageRemote
def changeGroupImageRemote(self, image_url, thread_id=None): """ Changes a thread image from a URL :param image_url: URL of an image to upload and change :param thread_id: User/Group ID to change image. See :ref:`intro_threads` :raises: FBchatException if request failed ...
python
def changeGroupImageRemote(self, image_url, thread_id=None): """ Changes a thread image from a URL :param image_url: URL of an image to upload and change :param thread_id: User/Group ID to change image. See :ref:`intro_threads` :raises: FBchatException if request failed ...
[ "def", "changeGroupImageRemote", "(", "self", ",", "image_url", ",", "thread_id", "=", "None", ")", ":", "(", "image_id", ",", "mimetype", ")", ",", "=", "self", ".", "_upload", "(", "get_files_from_urls", "(", "[", "image_url", "]", ")", ")", "return", ...
Changes a thread image from a URL :param image_url: URL of an image to upload and change :param thread_id: User/Group ID to change image. See :ref:`intro_threads` :raises: FBchatException if request failed
[ "Changes", "a", "thread", "image", "from", "a", "URL" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1879-L1888
train
carpedm20/fbchat
fbchat/_client.py
Client.changeGroupImageLocal
def changeGroupImageLocal(self, image_path, thread_id=None): """ Changes a thread image from a local path :param image_path: Path of an image to upload and change :param thread_id: User/Group ID to change image. See :ref:`intro_threads` :raises: FBchatException if request failed...
python
def changeGroupImageLocal(self, image_path, thread_id=None): """ Changes a thread image from a local path :param image_path: Path of an image to upload and change :param thread_id: User/Group ID to change image. See :ref:`intro_threads` :raises: FBchatException if request failed...
[ "def", "changeGroupImageLocal", "(", "self", ",", "image_path", ",", "thread_id", "=", "None", ")", ":", "with", "get_files_from_paths", "(", "[", "image_path", "]", ")", "as", "files", ":", "(", "image_id", ",", "mimetype", ")", ",", "=", "self", ".", "...
Changes a thread image from a local path :param image_path: Path of an image to upload and change :param thread_id: User/Group ID to change image. See :ref:`intro_threads` :raises: FBchatException if request failed
[ "Changes", "a", "thread", "image", "from", "a", "local", "path" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1890-L1901
train
carpedm20/fbchat
fbchat/_client.py
Client.changeThreadTitle
def changeThreadTitle(self, title, thread_id=None, thread_type=ThreadType.USER): """ Changes title of a thread. If this is executed on a user thread, this will change the nickname of that user, effectively changing the title :param title: New group thread title :param thread_id:...
python
def changeThreadTitle(self, title, thread_id=None, thread_type=ThreadType.USER): """ Changes title of a thread. If this is executed on a user thread, this will change the nickname of that user, effectively changing the title :param title: New group thread title :param thread_id:...
[ "def", "changeThreadTitle", "(", "self", ",", "title", ",", "thread_id", "=", "None", ",", "thread_type", "=", "ThreadType", ".", "USER", ")", ":", "thread_id", ",", "thread_type", "=", "self", ".", "_getThread", "(", "thread_id", ",", "thread_type", ")", ...
Changes title of a thread. If this is executed on a user thread, this will change the nickname of that user, effectively changing the title :param title: New group thread title :param thread_id: Group ID to change title of. See :ref:`intro_threads` :param thread_type: See :ref:`intro_th...
[ "Changes", "title", "of", "a", "thread", ".", "If", "this", "is", "executed", "on", "a", "user", "thread", "this", "will", "change", "the", "nickname", "of", "that", "user", "effectively", "changing", "the", "title" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1903-L1923
train
carpedm20/fbchat
fbchat/_client.py
Client.changeNickname
def changeNickname( self, nickname, user_id, thread_id=None, thread_type=ThreadType.USER ): """ Changes the nickname of a user in a thread :param nickname: New nickname :param user_id: User that will have their nickname changed :param thread_id: User/Group ID to chan...
python
def changeNickname( self, nickname, user_id, thread_id=None, thread_type=ThreadType.USER ): """ Changes the nickname of a user in a thread :param nickname: New nickname :param user_id: User that will have their nickname changed :param thread_id: User/Group ID to chan...
[ "def", "changeNickname", "(", "self", ",", "nickname", ",", "user_id", ",", "thread_id", "=", "None", ",", "thread_type", "=", "ThreadType", ".", "USER", ")", ":", "thread_id", ",", "thread_type", "=", "self", ".", "_getThread", "(", "thread_id", ",", "thr...
Changes the nickname of a user in a thread :param nickname: New nickname :param user_id: User that will have their nickname changed :param thread_id: User/Group ID to change color of. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type thread_type: models...
[ "Changes", "the", "nickname", "of", "a", "user", "in", "a", "thread" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1925-L1947
train
carpedm20/fbchat
fbchat/_client.py
Client.reactToMessage
def reactToMessage(self, message_id, reaction): """ Reacts to a message, or removes reaction :param message_id: :ref:`Message ID <intro_message_ids>` to react to :param reaction: Reaction emoji to use, if None removes reaction :type reaction: models.MessageReaction or None ...
python
def reactToMessage(self, message_id, reaction): """ Reacts to a message, or removes reaction :param message_id: :ref:`Message ID <intro_message_ids>` to react to :param reaction: Reaction emoji to use, if None removes reaction :type reaction: models.MessageReaction or None ...
[ "def", "reactToMessage", "(", "self", ",", "message_id", ",", "reaction", ")", ":", "data", "=", "{", "\"action\"", ":", "\"ADD_REACTION\"", "if", "reaction", "else", "\"REMOVE_REACTION\"", ",", "\"client_mutation_id\"", ":", "\"1\"", ",", "\"actor_id\"", ":", "...
Reacts to a message, or removes reaction :param message_id: :ref:`Message ID <intro_message_ids>` to react to :param reaction: Reaction emoji to use, if None removes reaction :type reaction: models.MessageReaction or None :raises: FBchatException if request failed
[ "Reacts", "to", "a", "message", "or", "removes", "reaction" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1981-L1998
train
carpedm20/fbchat
fbchat/_client.py
Client.createPlan
def createPlan(self, plan, thread_id=None): """ Sets a plan :param plan: Plan to set :param thread_id: User/Group ID to send plan to. See :ref:`intro_threads` :type plan: models.Plan :raises: FBchatException if request failed """ thread_id, thread_type = ...
python
def createPlan(self, plan, thread_id=None): """ Sets a plan :param plan: Plan to set :param thread_id: User/Group ID to send plan to. See :ref:`intro_threads` :type plan: models.Plan :raises: FBchatException if request failed """ thread_id, thread_type = ...
[ "def", "createPlan", "(", "self", ",", "plan", ",", "thread_id", "=", "None", ")", ":", "thread_id", ",", "thread_type", "=", "self", ".", "_getThread", "(", "thread_id", ",", "None", ")", "data", "=", "{", "\"event_type\"", ":", "\"EVENT\"", ",", "\"eve...
Sets a plan :param plan: Plan to set :param thread_id: User/Group ID to send plan to. See :ref:`intro_threads` :type plan: models.Plan :raises: FBchatException if request failed
[ "Sets", "a", "plan" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L2000-L2020
train
carpedm20/fbchat
fbchat/_client.py
Client.editPlan
def editPlan(self, plan, new_plan): """ Edits a plan :param plan: Plan to edit :param new_plan: New plan :type plan: models.Plan :raises: FBchatException if request failed """ data = { "event_reminder_id": plan.uid, "delete": "fals...
python
def editPlan(self, plan, new_plan): """ Edits a plan :param plan: Plan to edit :param new_plan: New plan :type plan: models.Plan :raises: FBchatException if request failed """ data = { "event_reminder_id": plan.uid, "delete": "fals...
[ "def", "editPlan", "(", "self", ",", "plan", ",", "new_plan", ")", ":", "data", "=", "{", "\"event_reminder_id\"", ":", "plan", ".", "uid", ",", "\"delete\"", ":", "\"false\"", ",", "\"date\"", ":", "new_plan", ".", "time", ",", "\"location_name\"", ":", ...
Edits a plan :param plan: Plan to edit :param new_plan: New plan :type plan: models.Plan :raises: FBchatException if request failed
[ "Edits", "a", "plan" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L2022-L2040
train
carpedm20/fbchat
fbchat/_client.py
Client.deletePlan
def deletePlan(self, plan): """ Deletes a plan :param plan: Plan to delete :raises: FBchatException if request failed """ data = {"event_reminder_id": plan.uid, "delete": "true", "acontext": ACONTEXT} j = self._post(self.req_url.PLAN_CHANGE, data, fix_request=Tru...
python
def deletePlan(self, plan): """ Deletes a plan :param plan: Plan to delete :raises: FBchatException if request failed """ data = {"event_reminder_id": plan.uid, "delete": "true", "acontext": ACONTEXT} j = self._post(self.req_url.PLAN_CHANGE, data, fix_request=Tru...
[ "def", "deletePlan", "(", "self", ",", "plan", ")", ":", "data", "=", "{", "\"event_reminder_id\"", ":", "plan", ".", "uid", ",", "\"delete\"", ":", "\"true\"", ",", "\"acontext\"", ":", "ACONTEXT", "}", "j", "=", "self", ".", "_post", "(", "self", "."...
Deletes a plan :param plan: Plan to delete :raises: FBchatException if request failed
[ "Deletes", "a", "plan" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L2042-L2050
train
carpedm20/fbchat
fbchat/_client.py
Client.changePlanParticipation
def changePlanParticipation(self, plan, take_part=True): """ Changes participation in a plan :param plan: Plan to take part in or not :param take_part: Whether to take part in the plan :raises: FBchatException if request failed """ data = { "event_rem...
python
def changePlanParticipation(self, plan, take_part=True): """ Changes participation in a plan :param plan: Plan to take part in or not :param take_part: Whether to take part in the plan :raises: FBchatException if request failed """ data = { "event_rem...
[ "def", "changePlanParticipation", "(", "self", ",", "plan", ",", "take_part", "=", "True", ")", ":", "data", "=", "{", "\"event_reminder_id\"", ":", "plan", ".", "uid", ",", "\"guest_state\"", ":", "\"GOING\"", "if", "take_part", "else", "\"DECLINED\"", ",", ...
Changes participation in a plan :param plan: Plan to take part in or not :param take_part: Whether to take part in the plan :raises: FBchatException if request failed
[ "Changes", "participation", "in", "a", "plan" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L2052-L2067
train
carpedm20/fbchat
fbchat/_client.py
Client.createPoll
def createPoll(self, poll, thread_id=None): """ Creates poll in a group thread :param poll: Poll to create :param thread_id: User/Group ID to create poll in. See :ref:`intro_threads` :type poll: models.Poll :raises: FBchatException if request failed """ t...
python
def createPoll(self, poll, thread_id=None): """ Creates poll in a group thread :param poll: Poll to create :param thread_id: User/Group ID to create poll in. See :ref:`intro_threads` :type poll: models.Poll :raises: FBchatException if request failed """ t...
[ "def", "createPoll", "(", "self", ",", "poll", ",", "thread_id", "=", "None", ")", ":", "thread_id", ",", "thread_type", "=", "self", ".", "_getThread", "(", "thread_id", ",", "None", ")", "# We're using ordered dicts, because the Facebook endpoint that parses the POS...
Creates poll in a group thread :param poll: Poll to create :param thread_id: User/Group ID to create poll in. See :ref:`intro_threads` :type poll: models.Poll :raises: FBchatException if request failed
[ "Creates", "poll", "in", "a", "group", "thread" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L2076-L2100
train
carpedm20/fbchat
fbchat/_client.py
Client.updatePollVote
def updatePollVote(self, poll_id, option_ids=[], new_options=[]): """ Updates a poll vote :param poll_id: ID of the poll to update vote :param option_ids: List of the option IDs to vote :param new_options: List of the new option names :param thread_id: User/Group ID to c...
python
def updatePollVote(self, poll_id, option_ids=[], new_options=[]): """ Updates a poll vote :param poll_id: ID of the poll to update vote :param option_ids: List of the option IDs to vote :param new_options: List of the new option names :param thread_id: User/Group ID to c...
[ "def", "updatePollVote", "(", "self", ",", "poll_id", ",", "option_ids", "=", "[", "]", ",", "new_options", "=", "[", "]", ")", ":", "data", "=", "{", "\"question_id\"", ":", "poll_id", "}", "for", "i", ",", "option_id", "in", "enumerate", "(", "option...
Updates a poll vote :param poll_id: ID of the poll to update vote :param option_ids: List of the option IDs to vote :param new_options: List of the new option names :param thread_id: User/Group ID to change status in. See :ref:`intro_threads` :param thread_type: See :ref:`intro_...
[ "Updates", "a", "poll", "vote" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L2102-L2122
train
carpedm20/fbchat
fbchat/_client.py
Client.setTypingStatus
def setTypingStatus(self, status, thread_id=None, thread_type=None): """ Sets users typing status in a thread :param status: Specify the typing status :param thread_id: User/Group ID to change status in. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` ...
python
def setTypingStatus(self, status, thread_id=None, thread_type=None): """ Sets users typing status in a thread :param status: Specify the typing status :param thread_id: User/Group ID to change status in. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` ...
[ "def", "setTypingStatus", "(", "self", ",", "status", ",", "thread_id", "=", "None", ",", "thread_type", "=", "None", ")", ":", "thread_id", ",", "thread_type", "=", "self", ".", "_getThread", "(", "thread_id", ",", "thread_type", ")", "data", "=", "{", ...
Sets users typing status in a thread :param status: Specify the typing status :param thread_id: User/Group ID to change status in. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type status: models.TypingStatus :type thread_type: models.ThreadType ...
[ "Sets", "users", "typing", "status", "in", "a", "thread" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L2124-L2143
train
carpedm20/fbchat
fbchat/_client.py
Client.markAsDelivered
def markAsDelivered(self, thread_id, message_id): """ Mark a message as delivered :param thread_id: User/Group ID to which the message belongs. See :ref:`intro_threads` :param message_id: Message ID to set as delivered. See :ref:`intro_threads` :return: Whether the request was s...
python
def markAsDelivered(self, thread_id, message_id): """ Mark a message as delivered :param thread_id: User/Group ID to which the message belongs. See :ref:`intro_threads` :param message_id: Message ID to set as delivered. See :ref:`intro_threads` :return: Whether the request was s...
[ "def", "markAsDelivered", "(", "self", ",", "thread_id", ",", "message_id", ")", ":", "data", "=", "{", "\"message_ids[0]\"", ":", "message_id", ",", "\"thread_ids[%s][0]\"", "%", "thread_id", ":", "message_id", ",", "}", "r", "=", "self", ".", "_post", "(",...
Mark a message as delivered :param thread_id: User/Group ID to which the message belongs. See :ref:`intro_threads` :param message_id: Message ID to set as delivered. See :ref:`intro_threads` :return: Whether the request was successful :raises: FBchatException if request failed
[ "Mark", "a", "message", "as", "delivered" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L2149-L2164
train
carpedm20/fbchat
fbchat/_client.py
Client.removeFriend
def removeFriend(self, friend_id=None): """ Removes a specifed friend from your friend list :param friend_id: The ID of the friend that you want to remove :return: Returns error if the removing was unsuccessful, returns True when successful. """ payload = {"friend_id": f...
python
def removeFriend(self, friend_id=None): """ Removes a specifed friend from your friend list :param friend_id: The ID of the friend that you want to remove :return: Returns error if the removing was unsuccessful, returns True when successful. """ payload = {"friend_id": f...
[ "def", "removeFriend", "(", "self", ",", "friend_id", "=", "None", ")", ":", "payload", "=", "{", "\"friend_id\"", ":", "friend_id", ",", "\"unref\"", ":", "\"none\"", ",", "\"confirm\"", ":", "\"Confirm\"", "}", "r", "=", "self", ".", "_post", "(", "sel...
Removes a specifed friend from your friend list :param friend_id: The ID of the friend that you want to remove :return: Returns error if the removing was unsuccessful, returns True when successful.
[ "Removes", "a", "specifed", "friend", "from", "your", "friend", "list" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L2217-L2232
train
carpedm20/fbchat
fbchat/_client.py
Client.blockUser
def blockUser(self, user_id): """ Blocks messages from a specifed user :param user_id: The ID of the user that you want to block :return: Whether the request was successful :raises: FBchatException if request failed """ data = {"fbid": user_id} r = self._...
python
def blockUser(self, user_id): """ Blocks messages from a specifed user :param user_id: The ID of the user that you want to block :return: Whether the request was successful :raises: FBchatException if request failed """ data = {"fbid": user_id} r = self._...
[ "def", "blockUser", "(", "self", ",", "user_id", ")", ":", "data", "=", "{", "\"fbid\"", ":", "user_id", "}", "r", "=", "self", ".", "_post", "(", "self", ".", "req_url", ".", "BLOCK_USER", ",", "data", ")", "return", "r", ".", "ok" ]
Blocks messages from a specifed user :param user_id: The ID of the user that you want to block :return: Whether the request was successful :raises: FBchatException if request failed
[ "Blocks", "messages", "from", "a", "specifed", "user" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L2234-L2244
train
carpedm20/fbchat
fbchat/_client.py
Client.unblockUser
def unblockUser(self, user_id): """ Unblocks messages from a blocked user :param user_id: The ID of the user that you want to unblock :return: Whether the request was successful :raises: FBchatException if request failed """ data = {"fbid": user_id} r = s...
python
def unblockUser(self, user_id): """ Unblocks messages from a blocked user :param user_id: The ID of the user that you want to unblock :return: Whether the request was successful :raises: FBchatException if request failed """ data = {"fbid": user_id} r = s...
[ "def", "unblockUser", "(", "self", ",", "user_id", ")", ":", "data", "=", "{", "\"fbid\"", ":", "user_id", "}", "r", "=", "self", ".", "_post", "(", "self", ".", "req_url", ".", "UNBLOCK_USER", ",", "data", ")", "return", "r", ".", "ok" ]
Unblocks messages from a blocked user :param user_id: The ID of the user that you want to unblock :return: Whether the request was successful :raises: FBchatException if request failed
[ "Unblocks", "messages", "from", "a", "blocked", "user" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L2246-L2256
train
carpedm20/fbchat
fbchat/_client.py
Client.moveThreads
def moveThreads(self, location, thread_ids): """ Moves threads to specifed location :param location: models.ThreadLocation: INBOX, PENDING, ARCHIVED or OTHER :param thread_ids: Thread IDs to move. See :ref:`intro_threads` :return: Whether the request was successful :rais...
python
def moveThreads(self, location, thread_ids): """ Moves threads to specifed location :param location: models.ThreadLocation: INBOX, PENDING, ARCHIVED or OTHER :param thread_ids: Thread IDs to move. See :ref:`intro_threads` :return: Whether the request was successful :rais...
[ "def", "moveThreads", "(", "self", ",", "location", ",", "thread_ids", ")", ":", "thread_ids", "=", "require_list", "(", "thread_ids", ")", "if", "location", "==", "ThreadLocation", ".", "PENDING", ":", "location", "=", "ThreadLocation", ".", "OTHER", "if", ...
Moves threads to specifed location :param location: models.ThreadLocation: INBOX, PENDING, ARCHIVED or OTHER :param thread_ids: Thread IDs to move. See :ref:`intro_threads` :return: Whether the request was successful :raises: FBchatException if request failed
[ "Moves", "threads", "to", "specifed", "location" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L2258-L2286
train
carpedm20/fbchat
fbchat/_client.py
Client.markAsSpam
def markAsSpam(self, thread_id=None): """ Mark a thread as spam and delete it :param thread_id: User/Group ID to mark as spam. See :ref:`intro_threads` :return: Whether the request was successful :raises: FBchatException if request failed """ thread_id, thread_ty...
python
def markAsSpam(self, thread_id=None): """ Mark a thread as spam and delete it :param thread_id: User/Group ID to mark as spam. See :ref:`intro_threads` :return: Whether the request was successful :raises: FBchatException if request failed """ thread_id, thread_ty...
[ "def", "markAsSpam", "(", "self", ",", "thread_id", "=", "None", ")", ":", "thread_id", ",", "thread_type", "=", "self", ".", "_getThread", "(", "thread_id", ",", "None", ")", "r", "=", "self", ".", "_post", "(", "self", ".", "req_url", ".", "MARK_SPAM...
Mark a thread as spam and delete it :param thread_id: User/Group ID to mark as spam. See :ref:`intro_threads` :return: Whether the request was successful :raises: FBchatException if request failed
[ "Mark", "a", "thread", "as", "spam", "and", "delete", "it" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L2307-L2317
train
carpedm20/fbchat
fbchat/_client.py
Client.deleteMessages
def deleteMessages(self, message_ids): """ Deletes specifed messages :param message_ids: Message IDs to delete :return: Whether the request was successful :raises: FBchatException if request failed """ message_ids = require_list(message_ids) data = dict()...
python
def deleteMessages(self, message_ids): """ Deletes specifed messages :param message_ids: Message IDs to delete :return: Whether the request was successful :raises: FBchatException if request failed """ message_ids = require_list(message_ids) data = dict()...
[ "def", "deleteMessages", "(", "self", ",", "message_ids", ")", ":", "message_ids", "=", "require_list", "(", "message_ids", ")", "data", "=", "dict", "(", ")", "for", "i", ",", "message_id", "in", "enumerate", "(", "message_ids", ")", ":", "data", "[", "...
Deletes specifed messages :param message_ids: Message IDs to delete :return: Whether the request was successful :raises: FBchatException if request failed
[ "Deletes", "specifed", "messages" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L2319-L2332
train