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
johnbywater/eventsourcing
eventsourcing/infrastructure/base.py
AbstractSequencedItemRecordManager.get_item
def get_item(self, sequence_id, position): """ Gets sequenced item from the datastore. """ return self.from_record(self.get_record(sequence_id, position))
python
def get_item(self, sequence_id, position): """ Gets sequenced item from the datastore. """ return self.from_record(self.get_record(sequence_id, position))
[ "def", "get_item", "(", "self", ",", "sequence_id", ",", "position", ")", ":", "return", "self", ".", "from_record", "(", "self", ".", "get_record", "(", "sequence_id", ",", "position", ")", ")" ]
Gets sequenced item from the datastore.
[ "Gets", "sequenced", "item", "from", "the", "datastore", "." ]
de2c22c653fdccf2f5ee96faea74453ff1847e42
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/infrastructure/base.py#L55-L59
train
johnbywater/eventsourcing
eventsourcing/infrastructure/base.py
AbstractSequencedItemRecordManager.get_items
def get_items(self, sequence_id, gt=None, gte=None, lt=None, lte=None, limit=None, query_ascending=True, results_ascending=True): """ Returns sequenced item generator. """ records = self.get_records( sequence_id=sequence_id, gt=gt, gt...
python
def get_items(self, sequence_id, gt=None, gte=None, lt=None, lte=None, limit=None, query_ascending=True, results_ascending=True): """ Returns sequenced item generator. """ records = self.get_records( sequence_id=sequence_id, gt=gt, gt...
[ "def", "get_items", "(", "self", ",", "sequence_id", ",", "gt", "=", "None", ",", "gte", "=", "None", ",", "lt", "=", "None", ",", "lte", "=", "None", ",", "limit", "=", "None", ",", "query_ascending", "=", "True", ",", "results_ascending", "=", "Tru...
Returns sequenced item generator.
[ "Returns", "sequenced", "item", "generator", "." ]
de2c22c653fdccf2f5ee96faea74453ff1847e42
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/infrastructure/base.py#L67-L84
train
johnbywater/eventsourcing
eventsourcing/infrastructure/base.py
AbstractSequencedItemRecordManager.to_record
def to_record(self, sequenced_item): """ Constructs a record object from given sequenced item object. """ kwargs = self.get_field_kwargs(sequenced_item) # Supply application_name, if needed. if hasattr(self.record_class, 'application_name'): kwargs['applicatio...
python
def to_record(self, sequenced_item): """ Constructs a record object from given sequenced item object. """ kwargs = self.get_field_kwargs(sequenced_item) # Supply application_name, if needed. if hasattr(self.record_class, 'application_name'): kwargs['applicatio...
[ "def", "to_record", "(", "self", ",", "sequenced_item", ")", ":", "kwargs", "=", "self", ".", "get_field_kwargs", "(", "sequenced_item", ")", "if", "hasattr", "(", "self", ".", "record_class", ",", "'application_name'", ")", ":", "kwargs", "[", "'application_n...
Constructs a record object from given sequenced item object.
[ "Constructs", "a", "record", "object", "from", "given", "sequenced", "item", "object", "." ]
de2c22c653fdccf2f5ee96faea74453ff1847e42
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/infrastructure/base.py#L99-L110
train
johnbywater/eventsourcing
eventsourcing/infrastructure/base.py
AbstractSequencedItemRecordManager.from_record
def from_record(self, record): """ Constructs and returns a sequenced item object, from given ORM object. """ kwargs = self.get_field_kwargs(record) return self.sequenced_item_class(**kwargs)
python
def from_record(self, record): """ Constructs and returns a sequenced item object, from given ORM object. """ kwargs = self.get_field_kwargs(record) return self.sequenced_item_class(**kwargs)
[ "def", "from_record", "(", "self", ",", "record", ")", ":", "kwargs", "=", "self", ".", "get_field_kwargs", "(", "record", ")", "return", "self", ".", "sequenced_item_class", "(", "**", "kwargs", ")" ]
Constructs and returns a sequenced item object, from given ORM object.
[ "Constructs", "and", "returns", "a", "sequenced", "item", "object", "from", "given", "ORM", "object", "." ]
de2c22c653fdccf2f5ee96faea74453ff1847e42
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/infrastructure/base.py#L112-L117
train
johnbywater/eventsourcing
eventsourcing/infrastructure/base.py
ACIDRecordManager.get_pipeline_and_notification_id
def get_pipeline_and_notification_id(self, sequence_id, position): """ Returns pipeline ID and notification ID for event at given position in given sequence. """ # Todo: Optimise query by selecting only two columns, pipeline_id and id (notification ID)? record = self.get_...
python
def get_pipeline_and_notification_id(self, sequence_id, position): """ Returns pipeline ID and notification ID for event at given position in given sequence. """ # Todo: Optimise query by selecting only two columns, pipeline_id and id (notification ID)? record = self.get_...
[ "def", "get_pipeline_and_notification_id", "(", "self", ",", "sequence_id", ",", "position", ")", ":", "record", "=", "self", ".", "get_record", "(", "sequence_id", ",", "position", ")", "notification_id", "=", "getattr", "(", "record", ",", "self", ".", "noti...
Returns pipeline ID and notification ID for event at given position in given sequence.
[ "Returns", "pipeline", "ID", "and", "notification", "ID", "for", "event", "at", "given", "position", "in", "given", "sequence", "." ]
de2c22c653fdccf2f5ee96faea74453ff1847e42
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/infrastructure/base.py#L194-L202
train
johnbywater/eventsourcing
eventsourcing/infrastructure/base.py
SQLRecordManager.insert_select_max
def insert_select_max(self): """ SQL statement that inserts records with contiguous IDs, by selecting max ID from indexed table records. """ if self._insert_select_max is None: if hasattr(self.record_class, 'application_name'): # Todo: Maybe make it su...
python
def insert_select_max(self): """ SQL statement that inserts records with contiguous IDs, by selecting max ID from indexed table records. """ if self._insert_select_max is None: if hasattr(self.record_class, 'application_name'): # Todo: Maybe make it su...
[ "def", "insert_select_max", "(", "self", ")", ":", "if", "self", ".", "_insert_select_max", "is", "None", ":", "if", "hasattr", "(", "self", ".", "record_class", ",", "'application_name'", ")", ":", "assert", "hasattr", "(", "self", ".", "record_class", ",",...
SQL statement that inserts records with contiguous IDs, by selecting max ID from indexed table records.
[ "SQL", "statement", "that", "inserts", "records", "with", "contiguous", "IDs", "by", "selecting", "max", "ID", "from", "indexed", "table", "records", "." ]
de2c22c653fdccf2f5ee96faea74453ff1847e42
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/infrastructure/base.py#L236-L253
train
johnbywater/eventsourcing
eventsourcing/infrastructure/base.py
SQLRecordManager.insert_values
def insert_values(self): """ SQL statement that inserts records without ID. """ if self._insert_values is None: self._insert_values = self._prepare_insert( tmpl=self._insert_values_tmpl, placeholder_for_id=True, record_class=sel...
python
def insert_values(self): """ SQL statement that inserts records without ID. """ if self._insert_values is None: self._insert_values = self._prepare_insert( tmpl=self._insert_values_tmpl, placeholder_for_id=True, record_class=sel...
[ "def", "insert_values", "(", "self", ")", ":", "if", "self", ".", "_insert_values", "is", "None", ":", "self", ".", "_insert_values", "=", "self", ".", "_prepare_insert", "(", "tmpl", "=", "self", ".", "_insert_values_tmpl", ",", "placeholder_for_id", "=", "...
SQL statement that inserts records without ID.
[ "SQL", "statement", "that", "inserts", "records", "without", "ID", "." ]
de2c22c653fdccf2f5ee96faea74453ff1847e42
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/infrastructure/base.py#L270-L281
train
johnbywater/eventsourcing
eventsourcing/infrastructure/base.py
SQLRecordManager.insert_tracking_record
def insert_tracking_record(self): """ SQL statement that inserts tracking records. """ if self._insert_tracking_record is None: self._insert_tracking_record = self._prepare_insert( tmpl=self._insert_values_tmpl, placeholder_for_id=True, ...
python
def insert_tracking_record(self): """ SQL statement that inserts tracking records. """ if self._insert_tracking_record is None: self._insert_tracking_record = self._prepare_insert( tmpl=self._insert_values_tmpl, placeholder_for_id=True, ...
[ "def", "insert_tracking_record", "(", "self", ")", ":", "if", "self", ".", "_insert_tracking_record", "is", "None", ":", "self", ".", "_insert_tracking_record", "=", "self", ".", "_prepare_insert", "(", "tmpl", "=", "self", ".", "_insert_values_tmpl", ",", "plac...
SQL statement that inserts tracking records.
[ "SQL", "statement", "that", "inserts", "tracking", "records", "." ]
de2c22c653fdccf2f5ee96faea74453ff1847e42
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/infrastructure/base.py#L284-L295
train
johnbywater/eventsourcing
eventsourcing/contrib/paxos/application.py
PaxosAggregate.start
def start(cls, originator_id, quorum_size, network_uid): """ Factory method that returns a new Paxos aggregate. """ assert isinstance(quorum_size, int), "Not an integer: {}".format(quorum_size) return cls.__create__( event_class=cls.Started, originator_id=...
python
def start(cls, originator_id, quorum_size, network_uid): """ Factory method that returns a new Paxos aggregate. """ assert isinstance(quorum_size, int), "Not an integer: {}".format(quorum_size) return cls.__create__( event_class=cls.Started, originator_id=...
[ "def", "start", "(", "cls", ",", "originator_id", ",", "quorum_size", ",", "network_uid", ")", ":", "assert", "isinstance", "(", "quorum_size", ",", "int", ")", ",", "\"Not an integer: {}\"", ".", "format", "(", "quorum_size", ")", "return", "cls", ".", "__c...
Factory method that returns a new Paxos aggregate.
[ "Factory", "method", "that", "returns", "a", "new", "Paxos", "aggregate", "." ]
de2c22c653fdccf2f5ee96faea74453ff1847e42
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/contrib/paxos/application.py#L105-L115
train
johnbywater/eventsourcing
eventsourcing/contrib/paxos/application.py
PaxosAggregate.propose_value
def propose_value(self, value, assume_leader=False): """ Proposes a value to the network. """ if value is None: raise ValueError("Not allowed to propose value None") paxos = self.paxos_instance paxos.leader = assume_leader msg = paxos.propose_value(val...
python
def propose_value(self, value, assume_leader=False): """ Proposes a value to the network. """ if value is None: raise ValueError("Not allowed to propose value None") paxos = self.paxos_instance paxos.leader = assume_leader msg = paxos.propose_value(val...
[ "def", "propose_value", "(", "self", ",", "value", ",", "assume_leader", "=", "False", ")", ":", "if", "value", "is", "None", ":", "raise", "ValueError", "(", "\"Not allowed to propose value None\"", ")", "paxos", "=", "self", ".", "paxos_instance", "paxos", "...
Proposes a value to the network.
[ "Proposes", "a", "value", "to", "the", "network", "." ]
de2c22c653fdccf2f5ee96faea74453ff1847e42
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/contrib/paxos/application.py#L117-L130
train
johnbywater/eventsourcing
eventsourcing/contrib/paxos/application.py
PaxosAggregate.receive_message
def receive_message(self, msg): """ Responds to messages from other participants. """ if isinstance(msg, Resolution): return paxos = self.paxos_instance while msg: if isinstance(msg, Resolution): self.print_if_verbose("{} resolved v...
python
def receive_message(self, msg): """ Responds to messages from other participants. """ if isinstance(msg, Resolution): return paxos = self.paxos_instance while msg: if isinstance(msg, Resolution): self.print_if_verbose("{} resolved v...
[ "def", "receive_message", "(", "self", ",", "msg", ")", ":", "if", "isinstance", "(", "msg", ",", "Resolution", ")", ":", "return", "paxos", "=", "self", ".", "paxos_instance", "while", "msg", ":", "if", "isinstance", "(", "msg", ",", "Resolution", ")", ...
Responds to messages from other participants.
[ "Responds", "to", "messages", "from", "other", "participants", "." ]
de2c22c653fdccf2f5ee96faea74453ff1847e42
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/contrib/paxos/application.py#L132-L151
train
johnbywater/eventsourcing
eventsourcing/contrib/paxos/application.py
PaxosAggregate.announce
def announce(self, msg): """ Announces a Paxos message. """ self.print_if_verbose("{} -> {}".format(self.network_uid, msg.__class__.__name__)) self.__trigger_event__( event_class=self.MessageAnnounced, msg=msg, )
python
def announce(self, msg): """ Announces a Paxos message. """ self.print_if_verbose("{} -> {}".format(self.network_uid, msg.__class__.__name__)) self.__trigger_event__( event_class=self.MessageAnnounced, msg=msg, )
[ "def", "announce", "(", "self", ",", "msg", ")", ":", "self", ".", "print_if_verbose", "(", "\"{} -> {}\"", ".", "format", "(", "self", ".", "network_uid", ",", "msg", ".", "__class__", ".", "__name__", ")", ")", "self", ".", "__trigger_event__", "(", "e...
Announces a Paxos message.
[ "Announces", "a", "Paxos", "message", "." ]
de2c22c653fdccf2f5ee96faea74453ff1847e42
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/contrib/paxos/application.py#L153-L161
train
johnbywater/eventsourcing
eventsourcing/contrib/paxos/application.py
PaxosAggregate.setattrs_from_paxos
def setattrs_from_paxos(self, paxos): """ Registers changes of attribute value on Paxos instance. """ changes = {} for name in self.paxos_variables: paxos_value = getattr(paxos, name) if paxos_value != getattr(self, name, None): self.print_...
python
def setattrs_from_paxos(self, paxos): """ Registers changes of attribute value on Paxos instance. """ changes = {} for name in self.paxos_variables: paxos_value = getattr(paxos, name) if paxos_value != getattr(self, name, None): self.print_...
[ "def", "setattrs_from_paxos", "(", "self", ",", "paxos", ")", ":", "changes", "=", "{", "}", "for", "name", "in", "self", ".", "paxos_variables", ":", "paxos_value", "=", "getattr", "(", "paxos", ",", "name", ")", "if", "paxos_value", "!=", "getattr", "(...
Registers changes of attribute value on Paxos instance.
[ "Registers", "changes", "of", "attribute", "value", "on", "Paxos", "instance", "." ]
de2c22c653fdccf2f5ee96faea74453ff1847e42
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/contrib/paxos/application.py#L163-L178
train
johnbywater/eventsourcing
eventsourcing/contrib/paxos/application.py
PaxosProcess.propose_value
def propose_value(self, key, value, assume_leader=False): """ Starts new Paxos aggregate and proposes a value for a key. Decorated with retry in case of notification log conflict or operational error. """ assert isinstance(key, UUID) paxos_aggregate = PaxosAggreg...
python
def propose_value(self, key, value, assume_leader=False): """ Starts new Paxos aggregate and proposes a value for a key. Decorated with retry in case of notification log conflict or operational error. """ assert isinstance(key, UUID) paxos_aggregate = PaxosAggreg...
[ "def", "propose_value", "(", "self", ",", "key", ",", "value", ",", "assume_leader", "=", "False", ")", ":", "assert", "isinstance", "(", "key", ",", "UUID", ")", "paxos_aggregate", "=", "PaxosAggregate", ".", "start", "(", "originator_id", "=", "key", ","...
Starts new Paxos aggregate and proposes a value for a key. Decorated with retry in case of notification log conflict or operational error.
[ "Starts", "new", "Paxos", "aggregate", "and", "proposes", "a", "value", "for", "a", "key", "." ]
de2c22c653fdccf2f5ee96faea74453ff1847e42
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/contrib/paxos/application.py#L203-L223
train
johnbywater/eventsourcing
eventsourcing/contrib/paxos/composable.py
MessageHandler.receive
def receive(self, msg): ''' Message dispatching function. This function accepts any PaxosMessage subclass and calls the appropriate handler function ''' handler = getattr(self, 'receive_' + msg.__class__.__name__.lower(), None) if handler is None: raise Invali...
python
def receive(self, msg): ''' Message dispatching function. This function accepts any PaxosMessage subclass and calls the appropriate handler function ''' handler = getattr(self, 'receive_' + msg.__class__.__name__.lower(), None) if handler is None: raise Invali...
[ "def", "receive", "(", "self", ",", "msg", ")", ":", "handler", "=", "getattr", "(", "self", ",", "'receive_'", "+", "msg", ".", "__class__", ".", "__name__", ".", "lower", "(", ")", ",", "None", ")", "if", "handler", "is", "None", ":", "raise", "I...
Message dispatching function. This function accepts any PaxosMessage subclass and calls the appropriate handler function
[ "Message", "dispatching", "function", ".", "This", "function", "accepts", "any", "PaxosMessage", "subclass", "and", "calls", "the", "appropriate", "handler", "function" ]
de2c22c653fdccf2f5ee96faea74453ff1847e42
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/contrib/paxos/composable.py#L176-L184
train
johnbywater/eventsourcing
eventsourcing/contrib/paxos/composable.py
Proposer.propose_value
def propose_value(self, value): ''' Sets the proposal value for this node iff this node is not already aware of a previous proposal value. If the node additionally believes itself to be the current leader, an Accept message will be returned ''' if self.proposed_value is N...
python
def propose_value(self, value): ''' Sets the proposal value for this node iff this node is not already aware of a previous proposal value. If the node additionally believes itself to be the current leader, an Accept message will be returned ''' if self.proposed_value is N...
[ "def", "propose_value", "(", "self", ",", "value", ")", ":", "if", "self", ".", "proposed_value", "is", "None", ":", "self", ".", "proposed_value", "=", "value", "if", "self", ".", "leader", ":", "self", ".", "current_accept_msg", "=", "Accept", "(", "se...
Sets the proposal value for this node iff this node is not already aware of a previous proposal value. If the node additionally believes itself to be the current leader, an Accept message will be returned
[ "Sets", "the", "proposal", "value", "for", "this", "node", "iff", "this", "node", "is", "not", "already", "aware", "of", "a", "previous", "proposal", "value", ".", "If", "the", "node", "additionally", "believes", "itself", "to", "be", "the", "current", "le...
de2c22c653fdccf2f5ee96faea74453ff1847e42
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/contrib/paxos/composable.py#L210-L221
train
johnbywater/eventsourcing
eventsourcing/contrib/paxos/composable.py
Proposer.prepare
def prepare(self): ''' Returns a new Prepare message with a proposal id higher than that of any observed proposals. A side effect of this method is to clear the leader flag if it is currently set. ''' self.leader = False self.promises_received = set() sel...
python
def prepare(self): ''' Returns a new Prepare message with a proposal id higher than that of any observed proposals. A side effect of this method is to clear the leader flag if it is currently set. ''' self.leader = False self.promises_received = set() sel...
[ "def", "prepare", "(", "self", ")", ":", "self", ".", "leader", "=", "False", "self", ".", "promises_received", "=", "set", "(", ")", "self", ".", "nacks_received", "=", "set", "(", ")", "self", ".", "proposal_id", "=", "ProposalID", "(", "self", ".", ...
Returns a new Prepare message with a proposal id higher than that of any observed proposals. A side effect of this method is to clear the leader flag if it is currently set.
[ "Returns", "a", "new", "Prepare", "message", "with", "a", "proposal", "id", "higher", "than", "that", "of", "any", "observed", "proposals", ".", "A", "side", "effect", "of", "this", "method", "is", "to", "clear", "the", "leader", "flag", "if", "it", "is"...
de2c22c653fdccf2f5ee96faea74453ff1847e42
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/contrib/paxos/composable.py#L223-L237
train
johnbywater/eventsourcing
eventsourcing/contrib/paxos/composable.py
Proposer.receive_nack
def receive_nack(self, msg): ''' Returns a new Prepare message if the number of Nacks received reaches a quorum. ''' self.observe_proposal(msg.promised_proposal_id) if msg.proposal_id == self.proposal_id and self.nacks_received is not None: self.nacks_receive...
python
def receive_nack(self, msg): ''' Returns a new Prepare message if the number of Nacks received reaches a quorum. ''' self.observe_proposal(msg.promised_proposal_id) if msg.proposal_id == self.proposal_id and self.nacks_received is not None: self.nacks_receive...
[ "def", "receive_nack", "(", "self", ",", "msg", ")", ":", "self", ".", "observe_proposal", "(", "msg", ".", "promised_proposal_id", ")", "if", "msg", ".", "proposal_id", "==", "self", ".", "proposal_id", "and", "self", ".", "nacks_received", "is", "not", "...
Returns a new Prepare message if the number of Nacks received reaches a quorum.
[ "Returns", "a", "new", "Prepare", "message", "if", "the", "number", "of", "Nacks", "received", "reaches", "a", "quorum", "." ]
de2c22c653fdccf2f5ee96faea74453ff1847e42
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/contrib/paxos/composable.py#L251-L262
train
johnbywater/eventsourcing
eventsourcing/contrib/paxos/composable.py
Proposer.receive_promise
def receive_promise(self, msg): ''' Returns an Accept messages if a quorum of Promise messages is achieved ''' self.observe_proposal(msg.proposal_id) if not self.leader and msg.proposal_id == self.proposal_id and msg.from_uid not in self.promises_received: self.prom...
python
def receive_promise(self, msg): ''' Returns an Accept messages if a quorum of Promise messages is achieved ''' self.observe_proposal(msg.proposal_id) if not self.leader and msg.proposal_id == self.proposal_id and msg.from_uid not in self.promises_received: self.prom...
[ "def", "receive_promise", "(", "self", ",", "msg", ")", ":", "self", ".", "observe_proposal", "(", "msg", ".", "proposal_id", ")", "if", "not", "self", ".", "leader", "and", "msg", ".", "proposal_id", "==", "self", ".", "proposal_id", "and", "msg", ".", ...
Returns an Accept messages if a quorum of Promise messages is achieved
[ "Returns", "an", "Accept", "messages", "if", "a", "quorum", "of", "Promise", "messages", "is", "achieved" ]
de2c22c653fdccf2f5ee96faea74453ff1847e42
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/contrib/paxos/composable.py#L264-L284
train
johnbywater/eventsourcing
eventsourcing/contrib/paxos/composable.py
Acceptor.receive_prepare
def receive_prepare(self, msg): ''' Returns either a Promise or a Nack in response. The Acceptor's state must be persisted to disk prior to transmitting the Promise message. ''' if self.promised_id is None or msg.proposal_id >= self.promised_id: self.promised_id = msg...
python
def receive_prepare(self, msg): ''' Returns either a Promise or a Nack in response. The Acceptor's state must be persisted to disk prior to transmitting the Promise message. ''' if self.promised_id is None or msg.proposal_id >= self.promised_id: self.promised_id = msg...
[ "def", "receive_prepare", "(", "self", ",", "msg", ")", ":", "if", "self", ".", "promised_id", "is", "None", "or", "msg", ".", "proposal_id", ">=", "self", ".", "promised_id", ":", "self", ".", "promised_id", "=", "msg", ".", "proposal_id", "return", "Pr...
Returns either a Promise or a Nack in response. The Acceptor's state must be persisted to disk prior to transmitting the Promise message.
[ "Returns", "either", "a", "Promise", "or", "a", "Nack", "in", "response", ".", "The", "Acceptor", "s", "state", "must", "be", "persisted", "to", "disk", "prior", "to", "transmitting", "the", "Promise", "message", "." ]
de2c22c653fdccf2f5ee96faea74453ff1847e42
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/contrib/paxos/composable.py#L310-L319
train
johnbywater/eventsourcing
eventsourcing/contrib/paxos/composable.py
Acceptor.receive_accept
def receive_accept(self, msg): ''' Returns either an Accepted or Nack message in response. The Acceptor's state must be persisted to disk prior to transmitting the Accepted message. ''' if self.promised_id is None or msg.proposal_id >= self.promised_id: self.promised_...
python
def receive_accept(self, msg): ''' Returns either an Accepted or Nack message in response. The Acceptor's state must be persisted to disk prior to transmitting the Accepted message. ''' if self.promised_id is None or msg.proposal_id >= self.promised_id: self.promised_...
[ "def", "receive_accept", "(", "self", ",", "msg", ")", ":", "if", "self", ".", "promised_id", "is", "None", "or", "msg", ".", "proposal_id", ">=", "self", ".", "promised_id", ":", "self", ".", "promised_id", "=", "msg", ".", "proposal_id", "self", ".", ...
Returns either an Accepted or Nack message in response. The Acceptor's state must be persisted to disk prior to transmitting the Accepted message.
[ "Returns", "either", "an", "Accepted", "or", "Nack", "message", "in", "response", ".", "The", "Acceptor", "s", "state", "must", "be", "persisted", "to", "disk", "prior", "to", "transmitting", "the", "Accepted", "message", "." ]
de2c22c653fdccf2f5ee96faea74453ff1847e42
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/contrib/paxos/composable.py#L321-L332
train
johnbywater/eventsourcing
eventsourcing/contrib/paxos/composable.py
Learner.receive_accepted
def receive_accepted(self, msg): ''' Called when an Accepted message is received from an acceptor. Once the final value is determined, the return value of this method will be a Resolution message containing the consentual value. Subsequent calls after the resolution is chosen will contin...
python
def receive_accepted(self, msg): ''' Called when an Accepted message is received from an acceptor. Once the final value is determined, the return value of this method will be a Resolution message containing the consentual value. Subsequent calls after the resolution is chosen will contin...
[ "def", "receive_accepted", "(", "self", ",", "msg", ")", ":", "if", "self", ".", "final_value", "is", "not", "None", ":", "if", "msg", ".", "proposal_id", ">=", "self", ".", "final_proposal_id", "and", "msg", ".", "proposal_value", "==", "self", ".", "fi...
Called when an Accepted message is received from an acceptor. Once the final value is determined, the return value of this method will be a Resolution message containing the consentual value. Subsequent calls after the resolution is chosen will continue to add new Acceptors to the final_acceptor...
[ "Called", "when", "an", "Accepted", "message", "is", "received", "from", "an", "acceptor", ".", "Once", "the", "final", "value", "is", "determined", "the", "return", "value", "of", "this", "method", "will", "be", "a", "Resolution", "message", "containing", "...
de2c22c653fdccf2f5ee96faea74453ff1847e42
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/contrib/paxos/composable.py#L360-L408
train
johnbywater/eventsourcing
eventsourcing/utils/topic.py
resolve_topic
def resolve_topic(topic): """Return class described by given topic. Args: topic: A string describing a class. Returns: A class. Raises: TopicResolutionError: If there is no such class. """ try: module_name, _, class_name = topic.partition('#') module = ...
python
def resolve_topic(topic): """Return class described by given topic. Args: topic: A string describing a class. Returns: A class. Raises: TopicResolutionError: If there is no such class. """ try: module_name, _, class_name = topic.partition('#') module = ...
[ "def", "resolve_topic", "(", "topic", ")", ":", "try", ":", "module_name", ",", "_", ",", "class_name", "=", "topic", ".", "partition", "(", "'#'", ")", "module", "=", "importlib", ".", "import_module", "(", "module_name", ")", "except", "ImportError", "as...
Return class described by given topic. Args: topic: A string describing a class. Returns: A class. Raises: TopicResolutionError: If there is no such class.
[ "Return", "class", "described", "by", "given", "topic", "." ]
de2c22c653fdccf2f5ee96faea74453ff1847e42
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/utils/topic.py#L18-L39
train
johnbywater/eventsourcing
eventsourcing/utils/topic.py
resolve_attr
def resolve_attr(obj, path): """A recursive version of getattr for navigating dotted paths. Args: obj: An object for which we want to retrieve a nested attribute. path: A dot separated string containing zero or more attribute names. Returns: The attribute referred to by obj.a1.a2.a...
python
def resolve_attr(obj, path): """A recursive version of getattr for navigating dotted paths. Args: obj: An object for which we want to retrieve a nested attribute. path: A dot separated string containing zero or more attribute names. Returns: The attribute referred to by obj.a1.a2.a...
[ "def", "resolve_attr", "(", "obj", ",", "path", ")", ":", "if", "not", "path", ":", "return", "obj", "head", ",", "_", ",", "tail", "=", "path", ".", "partition", "(", "'.'", ")", "head_obj", "=", "getattr", "(", "obj", ",", "head", ")", "return", ...
A recursive version of getattr for navigating dotted paths. Args: obj: An object for which we want to retrieve a nested attribute. path: A dot separated string containing zero or more attribute names. Returns: The attribute referred to by obj.a1.a2.a3... Raises: AttributeE...
[ "A", "recursive", "version", "of", "getattr", "for", "navigating", "dotted", "paths", "." ]
de2c22c653fdccf2f5ee96faea74453ff1847e42
https://github.com/johnbywater/eventsourcing/blob/de2c22c653fdccf2f5ee96faea74453ff1847e42/eventsourcing/utils/topic.py#L42-L59
train
openeventdata/mordecai
mordecai/utilities.py
make_skip_list
def make_skip_list(cts): """ Return hand-defined list of place names to skip and not attempt to geolocate. If users would like to exclude country names, this would be the function to do it with. """ # maybe make these non-country searches but don't discard, at least for # some (esp. bodies of wa...
python
def make_skip_list(cts): """ Return hand-defined list of place names to skip and not attempt to geolocate. If users would like to exclude country names, this would be the function to do it with. """ # maybe make these non-country searches but don't discard, at least for # some (esp. bodies of wa...
[ "def", "make_skip_list", "(", "cts", ")", ":", "special_terms", "=", "[", "\"Europe\"", ",", "\"West\"", ",", "\"the West\"", ",", "\"South Pacific\"", ",", "\"Gulf of Mexico\"", ",", "\"Atlantic\"", ",", "\"the Black Sea\"", ",", "\"Black Sea\"", ",", "\"North Amer...
Return hand-defined list of place names to skip and not attempt to geolocate. If users would like to exclude country names, this would be the function to do it with.
[ "Return", "hand", "-", "defined", "list", "of", "place", "names", "to", "skip", "and", "not", "attempt", "to", "geolocate", ".", "If", "users", "would", "like", "to", "exclude", "country", "names", "this", "would", "be", "the", "function", "to", "do", "i...
bd82b8bcc27621345c57cbe9ec7f8c8552620ffc
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/utilities.py#L138-L164
train
openeventdata/mordecai
mordecai/utilities.py
country_list_nlp
def country_list_nlp(cts): """NLP countries so we can use for vector comparisons""" ct_nlp = [] for i in cts.keys(): nlped = nlp(i) ct_nlp.append(nlped) return ct_nlp
python
def country_list_nlp(cts): """NLP countries so we can use for vector comparisons""" ct_nlp = [] for i in cts.keys(): nlped = nlp(i) ct_nlp.append(nlped) return ct_nlp
[ "def", "country_list_nlp", "(", "cts", ")", ":", "ct_nlp", "=", "[", "]", "for", "i", "in", "cts", ".", "keys", "(", ")", ":", "nlped", "=", "nlp", "(", "i", ")", "ct_nlp", ".", "append", "(", "nlped", ")", "return", "ct_nlp" ]
NLP countries so we can use for vector comparisons
[ "NLP", "countries", "so", "we", "can", "use", "for", "vector", "comparisons" ]
bd82b8bcc27621345c57cbe9ec7f8c8552620ffc
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/utilities.py#L167-L173
train
openeventdata/mordecai
mordecai/utilities.py
make_country_nationality_list
def make_country_nationality_list(cts, ct_file): """Combine list of countries and list of nationalities""" countries = pd.read_csv(ct_file) nationality = dict(zip(countries.nationality,countries.alpha_3_code)) both_codes = {**nationality, **cts} return both_codes
python
def make_country_nationality_list(cts, ct_file): """Combine list of countries and list of nationalities""" countries = pd.read_csv(ct_file) nationality = dict(zip(countries.nationality,countries.alpha_3_code)) both_codes = {**nationality, **cts} return both_codes
[ "def", "make_country_nationality_list", "(", "cts", ",", "ct_file", ")", ":", "countries", "=", "pd", ".", "read_csv", "(", "ct_file", ")", "nationality", "=", "dict", "(", "zip", "(", "countries", ".", "nationality", ",", "countries", ".", "alpha_3_code", "...
Combine list of countries and list of nationalities
[ "Combine", "list", "of", "countries", "and", "list", "of", "nationalities" ]
bd82b8bcc27621345c57cbe9ec7f8c8552620ffc
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/utilities.py#L176-L181
train
openeventdata/mordecai
mordecai/utilities.py
structure_results
def structure_results(res): """Format Elasticsearch result as Python dictionary""" out = {'hits': {'hits': []}} keys = [u'admin1_code', u'admin2_code', u'admin3_code', u'admin4_code', u'alternativenames', u'asciiname', u'cc2', u'coordinates', u'country_code2', u'country_code3', u'dem...
python
def structure_results(res): """Format Elasticsearch result as Python dictionary""" out = {'hits': {'hits': []}} keys = [u'admin1_code', u'admin2_code', u'admin3_code', u'admin4_code', u'alternativenames', u'asciiname', u'cc2', u'coordinates', u'country_code2', u'country_code3', u'dem...
[ "def", "structure_results", "(", "res", ")", ":", "out", "=", "{", "'hits'", ":", "{", "'hits'", ":", "[", "]", "}", "}", "keys", "=", "[", "u'admin1_code'", ",", "u'admin2_code'", ",", "u'admin3_code'", ",", "u'admin4_code'", ",", "u'alternativenames'", "...
Format Elasticsearch result as Python dictionary
[ "Format", "Elasticsearch", "result", "as", "Python", "dictionary" ]
bd82b8bcc27621345c57cbe9ec7f8c8552620ffc
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/utilities.py#L218-L231
train
openeventdata/mordecai
mordecai/utilities.py
setup_es
def setup_es(hosts, port, use_ssl=False, auth=None): """ Setup an Elasticsearch connection Parameters ---------- hosts: list Hostnames / IP addresses for elasticsearch cluster port: string Port for elasticsearch cluster use_ssl: boolean Whether to use SSL...
python
def setup_es(hosts, port, use_ssl=False, auth=None): """ Setup an Elasticsearch connection Parameters ---------- hosts: list Hostnames / IP addresses for elasticsearch cluster port: string Port for elasticsearch cluster use_ssl: boolean Whether to use SSL...
[ "def", "setup_es", "(", "hosts", ",", "port", ",", "use_ssl", "=", "False", ",", "auth", "=", "None", ")", ":", "kwargs", "=", "dict", "(", "hosts", "=", "hosts", "or", "[", "'localhost'", "]", ",", "port", "=", "port", "or", "9200", ",", "use_ssl"...
Setup an Elasticsearch connection Parameters ---------- hosts: list Hostnames / IP addresses for elasticsearch cluster port: string Port for elasticsearch cluster use_ssl: boolean Whether to use SSL for the elasticsearch connection auth: tuple (us...
[ "Setup", "an", "Elasticsearch", "connection" ]
bd82b8bcc27621345c57cbe9ec7f8c8552620ffc
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/utilities.py#L233-L261
train
openeventdata/mordecai
mordecai/geoparse.py
Geoparser._feature_country_mentions
def _feature_country_mentions(self, doc): """ Given a document, count how many times different country names and adjectives are mentioned. These are features used in the country picking phase. Parameters --------- doc: a spaCy nlp'ed piece of text Returns ...
python
def _feature_country_mentions(self, doc): """ Given a document, count how many times different country names and adjectives are mentioned. These are features used in the country picking phase. Parameters --------- doc: a spaCy nlp'ed piece of text Returns ...
[ "def", "_feature_country_mentions", "(", "self", ",", "doc", ")", ":", "c_list", "=", "[", "]", "for", "i", "in", "doc", ".", "ents", ":", "try", ":", "country", "=", "self", ".", "_both_codes", "[", "i", ".", "text", "]", "c_list", ".", "append", ...
Given a document, count how many times different country names and adjectives are mentioned. These are features used in the country picking phase. Parameters --------- doc: a spaCy nlp'ed piece of text Returns ------- countries: dict the top two coun...
[ "Given", "a", "document", "count", "how", "many", "times", "different", "country", "names", "and", "adjectives", "are", "mentioned", ".", "These", "are", "features", "used", "in", "the", "country", "picking", "phase", "." ]
bd82b8bcc27621345c57cbe9ec7f8c8552620ffc
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/geoparse.py#L78-L112
train
openeventdata/mordecai
mordecai/geoparse.py
Geoparser.clean_entity
def clean_entity(self, ent): """ Strip out extra words that often get picked up by spaCy's NER. To do: preserve info about what got stripped out to help with ES/Geonames resolution later. Parameters --------- ent: a spaCy named entity Span Returns ...
python
def clean_entity(self, ent): """ Strip out extra words that often get picked up by spaCy's NER. To do: preserve info about what got stripped out to help with ES/Geonames resolution later. Parameters --------- ent: a spaCy named entity Span Returns ...
[ "def", "clean_entity", "(", "self", ",", "ent", ")", ":", "dump_list", "=", "[", "'province'", ",", "'the'", ",", "'area'", ",", "'airport'", ",", "'district'", ",", "'square'", ",", "'town'", ",", "'village'", ",", "'prison'", ",", "\"river\"", ",", "\"...
Strip out extra words that often get picked up by spaCy's NER. To do: preserve info about what got stripped out to help with ES/Geonames resolution later. Parameters --------- ent: a spaCy named entity Span Returns ------- new_ent: a spaCy Span, wit...
[ "Strip", "out", "extra", "words", "that", "often", "get", "picked", "up", "by", "spaCy", "s", "NER", "." ]
bd82b8bcc27621345c57cbe9ec7f8c8552620ffc
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/geoparse.py#L115-L149
train
openeventdata/mordecai
mordecai/geoparse.py
Geoparser._feature_most_alternative
def _feature_most_alternative(self, results, full_results=False): """ Find the placename with the most alternative names and return its country. More alternative names are a rough measure of importance. Paramaters ---------- results: dict output of `query_geo...
python
def _feature_most_alternative(self, results, full_results=False): """ Find the placename with the most alternative names and return its country. More alternative names are a rough measure of importance. Paramaters ---------- results: dict output of `query_geo...
[ "def", "_feature_most_alternative", "(", "self", ",", "results", ",", "full_results", "=", "False", ")", ":", "try", ":", "alt_names", "=", "[", "len", "(", "i", "[", "'alternativenames'", "]", ")", "for", "i", "in", "results", "[", "'hits'", "]", "[", ...
Find the placename with the most alternative names and return its country. More alternative names are a rough measure of importance. Paramaters ---------- results: dict output of `query_geonames` Returns ------- most_alt: str ISO code of ...
[ "Find", "the", "placename", "with", "the", "most", "alternative", "names", "and", "return", "its", "country", ".", "More", "alternative", "names", "are", "a", "rough", "measure", "of", "importance", "." ]
bd82b8bcc27621345c57cbe9ec7f8c8552620ffc
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/geoparse.py#L176-L200
train
openeventdata/mordecai
mordecai/geoparse.py
Geoparser._feature_most_population
def _feature_most_population(self, results): """ Find the placename with the largest population and return its country. More population is a rough measure of importance. Paramaters ---------- results: dict output of `query_geonames` Returns -...
python
def _feature_most_population(self, results): """ Find the placename with the largest population and return its country. More population is a rough measure of importance. Paramaters ---------- results: dict output of `query_geonames` Returns -...
[ "def", "_feature_most_population", "(", "self", ",", "results", ")", ":", "try", ":", "populations", "=", "[", "i", "[", "'population'", "]", "for", "i", "in", "results", "[", "'hits'", "]", "[", "'hits'", "]", "]", "most_pop", "=", "results", "[", "'h...
Find the placename with the largest population and return its country. More population is a rough measure of importance. Paramaters ---------- results: dict output of `query_geonames` Returns ------- most_pop: str ISO code of country of p...
[ "Find", "the", "placename", "with", "the", "largest", "population", "and", "return", "its", "country", ".", "More", "population", "is", "a", "rough", "measure", "of", "importance", "." ]
bd82b8bcc27621345c57cbe9ec7f8c8552620ffc
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/geoparse.py#L203-L225
train
openeventdata/mordecai
mordecai/geoparse.py
Geoparser._feature_word_embedding
def _feature_word_embedding(self, text): """ Given a word, guess the appropriate country by word vector. Parameters --------- text: str the text to extract locations from. Returns ------- country_picking: dict The top two countrie...
python
def _feature_word_embedding(self, text): """ Given a word, guess the appropriate country by word vector. Parameters --------- text: str the text to extract locations from. Returns ------- country_picking: dict The top two countrie...
[ "def", "_feature_word_embedding", "(", "self", ",", "text", ")", ":", "try", ":", "simils", "=", "np", ".", "dot", "(", "self", ".", "_prebuilt_vec", ",", "text", ".", "vector", ")", "except", "Exception", "as", "e", ":", "return", "{", "\"country_1\"", ...
Given a word, guess the appropriate country by word vector. Parameters --------- text: str the text to extract locations from. Returns ------- country_picking: dict The top two countries (ISO codes) and two measures confidence for the...
[ "Given", "a", "word", "guess", "the", "appropriate", "country", "by", "word", "vector", "." ]
bd82b8bcc27621345c57cbe9ec7f8c8552620ffc
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/geoparse.py#L228-L261
train
openeventdata/mordecai
mordecai/geoparse.py
Geoparser._feature_first_back
def _feature_first_back(self, results): """ Get the country of the first two results back from geonames. Parameters ----------- results: dict elasticsearch results Returns ------- top: tuple first and second results' country name ...
python
def _feature_first_back(self, results): """ Get the country of the first two results back from geonames. Parameters ----------- results: dict elasticsearch results Returns ------- top: tuple first and second results' country name ...
[ "def", "_feature_first_back", "(", "self", ",", "results", ")", ":", "try", ":", "first_back", "=", "results", "[", "'hits'", "]", "[", "'hits'", "]", "[", "0", "]", "[", "'country_code3'", "]", "except", "(", "TypeError", ",", "IndexError", ")", ":", ...
Get the country of the first two results back from geonames. Parameters ----------- results: dict elasticsearch results Returns ------- top: tuple first and second results' country name (ISO)
[ "Get", "the", "country", "of", "the", "first", "two", "results", "back", "from", "geonames", "." ]
bd82b8bcc27621345c57cbe9ec7f8c8552620ffc
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/geoparse.py#L264-L288
train
openeventdata/mordecai
mordecai/geoparse.py
Geoparser.is_country
def is_country(self, text): """Check if a piece of text is in the list of countries""" ct_list = self._just_cts.keys() if text in ct_list: return True else: return False
python
def is_country(self, text): """Check if a piece of text is in the list of countries""" ct_list = self._just_cts.keys() if text in ct_list: return True else: return False
[ "def", "is_country", "(", "self", ",", "text", ")", ":", "ct_list", "=", "self", ".", "_just_cts", ".", "keys", "(", ")", "if", "text", "in", "ct_list", ":", "return", "True", "else", ":", "return", "False" ]
Check if a piece of text is in the list of countries
[ "Check", "if", "a", "piece", "of", "text", "is", "in", "the", "list", "of", "countries" ]
bd82b8bcc27621345c57cbe9ec7f8c8552620ffc
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/geoparse.py#L291-L297
train
openeventdata/mordecai
mordecai/geoparse.py
Geoparser.query_geonames
def query_geonames(self, placename): """ Wrap search parameters into an elasticsearch query to the geonames index and return results. Parameters --------- conn: an elasticsearch Search conn, like the one returned by `setup_es()` placename: str the pl...
python
def query_geonames(self, placename): """ Wrap search parameters into an elasticsearch query to the geonames index and return results. Parameters --------- conn: an elasticsearch Search conn, like the one returned by `setup_es()` placename: str the pl...
[ "def", "query_geonames", "(", "self", ",", "placename", ")", ":", "if", "self", ".", "is_country", "(", "placename", ")", ":", "q", "=", "{", "\"multi_match\"", ":", "{", "\"query\"", ":", "placename", ",", "\"fields\"", ":", "[", "'name'", ",", "'asciin...
Wrap search parameters into an elasticsearch query to the geonames index and return results. Parameters --------- conn: an elasticsearch Search conn, like the one returned by `setup_es()` placename: str the placename text extracted by NER system Returns ...
[ "Wrap", "search", "parameters", "into", "an", "elasticsearch", "query", "to", "the", "geonames", "index", "and", "return", "results", "." ]
bd82b8bcc27621345c57cbe9ec7f8c8552620ffc
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/geoparse.py#L301-L341
train
openeventdata/mordecai
mordecai/geoparse.py
Geoparser.query_geonames_country
def query_geonames_country(self, placename, country): """ Like query_geonames, but this time limited to a specified country. """ # first, try for an exact phrase match q = {"multi_match": {"query": placename, "fields": ['name^5', 'asciiname^5', 'alter...
python
def query_geonames_country(self, placename, country): """ Like query_geonames, but this time limited to a specified country. """ # first, try for an exact phrase match q = {"multi_match": {"query": placename, "fields": ['name^5', 'asciiname^5', 'alter...
[ "def", "query_geonames_country", "(", "self", ",", "placename", ",", "country", ")", ":", "q", "=", "{", "\"multi_match\"", ":", "{", "\"query\"", ":", "placename", ",", "\"fields\"", ":", "[", "'name^5'", ",", "'asciiname^5'", ",", "'alternativenames'", "]", ...
Like query_geonames, but this time limited to a specified country.
[ "Like", "query_geonames", "but", "this", "time", "limited", "to", "a", "specified", "country", "." ]
bd82b8bcc27621345c57cbe9ec7f8c8552620ffc
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/geoparse.py#L345-L365
train
openeventdata/mordecai
mordecai/geoparse.py
Geoparser.make_country_matrix
def make_country_matrix(self, loc): """ Create features for all possible country labels, return as matrix for keras. Parameters ---------- loc: dict one entry from the list of locations and features that come out of make_country_features Returns ----...
python
def make_country_matrix(self, loc): """ Create features for all possible country labels, return as matrix for keras. Parameters ---------- loc: dict one entry from the list of locations and features that come out of make_country_features Returns ----...
[ "def", "make_country_matrix", "(", "self", ",", "loc", ")", ":", "top", "=", "loc", "[", "'features'", "]", "[", "'ct_mention'", "]", "top_count", "=", "loc", "[", "'features'", "]", "[", "'ctm_count1'", "]", "two", "=", "loc", "[", "'features'", "]", ...
Create features for all possible country labels, return as matrix for keras. Parameters ---------- loc: dict one entry from the list of locations and features that come out of make_country_features Returns -------- keras_inputs: dict with two keys, "label" a...
[ "Create", "features", "for", "all", "possible", "country", "labels", "return", "as", "matrix", "for", "keras", "." ]
bd82b8bcc27621345c57cbe9ec7f8c8552620ffc
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/geoparse.py#L595-L643
train
openeventdata/mordecai
mordecai/geoparse.py
Geoparser.infer_country
def infer_country(self, doc): """NLP a doc, find its entities, get their features, and return the model's country guess for each. Maybe use a better name. Parameters ----------- doc: str or spaCy the document to country-resolve the entities in Returns ...
python
def infer_country(self, doc): """NLP a doc, find its entities, get their features, and return the model's country guess for each. Maybe use a better name. Parameters ----------- doc: str or spaCy the document to country-resolve the entities in Returns ...
[ "def", "infer_country", "(", "self", ",", "doc", ")", ":", "if", "not", "hasattr", "(", "doc", ",", "\"ents\"", ")", ":", "doc", "=", "nlp", "(", "doc", ")", "proced", "=", "self", ".", "make_country_features", "(", "doc", ",", "require_maj", "=", "F...
NLP a doc, find its entities, get their features, and return the model's country guess for each. Maybe use a better name. Parameters ----------- doc: str or spaCy the document to country-resolve the entities in Returns ------- proced: list of dict ...
[ "NLP", "a", "doc", "find", "its", "entities", "get", "their", "features", "and", "return", "the", "model", "s", "country", "guess", "for", "each", ".", "Maybe", "use", "a", "better", "name", "." ]
bd82b8bcc27621345c57cbe9ec7f8c8552620ffc
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/geoparse.py#L647-L714
train
openeventdata/mordecai
mordecai/geoparse.py
Geoparser.get_admin1
def get_admin1(self, country_code2, admin1_code): """ Convert a geonames admin1 code to the associated place name. Parameters --------- country_code2: string The two character country code admin1_code: string The admin1 code to...
python
def get_admin1(self, country_code2, admin1_code): """ Convert a geonames admin1 code to the associated place name. Parameters --------- country_code2: string The two character country code admin1_code: string The admin1 code to...
[ "def", "get_admin1", "(", "self", ",", "country_code2", ",", "admin1_code", ")", ":", "lookup_key", "=", "\".\"", ".", "join", "(", "[", "country_code2", ",", "admin1_code", "]", ")", "try", ":", "admin1_name", "=", "self", ".", "_admin1_dict", "[", "looku...
Convert a geonames admin1 code to the associated place name. Parameters --------- country_code2: string The two character country code admin1_code: string The admin1 code to be converted. (Admin1 is the highest subnational...
[ "Convert", "a", "geonames", "admin1", "code", "to", "the", "associated", "place", "name", "." ]
bd82b8bcc27621345c57cbe9ec7f8c8552620ffc
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/geoparse.py#L716-L742
train
openeventdata/mordecai
mordecai/geoparse.py
Geoparser.ranker
def ranker(self, X, meta): """ Sort the place features list by the score of its relevance. """ # total score is just a sum of each row total_score = X.sum(axis=1).transpose() total_score = np.squeeze(np.asarray(total_score)) # matrix to array ranks = total_score....
python
def ranker(self, X, meta): """ Sort the place features list by the score of its relevance. """ # total score is just a sum of each row total_score = X.sum(axis=1).transpose() total_score = np.squeeze(np.asarray(total_score)) # matrix to array ranks = total_score....
[ "def", "ranker", "(", "self", ",", "X", ",", "meta", ")", ":", "total_score", "=", "X", ".", "sum", "(", "axis", "=", "1", ")", ".", "transpose", "(", ")", "total_score", "=", "np", ".", "squeeze", "(", "np", ".", "asarray", "(", "total_score", "...
Sort the place features list by the score of its relevance.
[ "Sort", "the", "place", "features", "list", "by", "the", "score", "of", "its", "relevance", "." ]
bd82b8bcc27621345c57cbe9ec7f8c8552620ffc
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/geoparse.py#L819-L831
train
openeventdata/mordecai
mordecai/geoparse.py
Geoparser.format_for_prodigy
def format_for_prodigy(self, X, meta, placename, return_feature_subset=False): """ Given a feature matrix, geonames data, and the original query, construct a prodigy task. Make meta nicely readable: "A town in Germany" Parameters ---------- X: matrix ...
python
def format_for_prodigy(self, X, meta, placename, return_feature_subset=False): """ Given a feature matrix, geonames data, and the original query, construct a prodigy task. Make meta nicely readable: "A town in Germany" Parameters ---------- X: matrix ...
[ "def", "format_for_prodigy", "(", "self", ",", "X", ",", "meta", ",", "placename", ",", "return_feature_subset", "=", "False", ")", ":", "all_tasks", "=", "[", "]", "sorted_X", ",", "sorted_meta", "=", "self", ".", "ranker", "(", "X", ",", "meta", ")", ...
Given a feature matrix, geonames data, and the original query, construct a prodigy task. Make meta nicely readable: "A town in Germany" Parameters ---------- X: matrix vector of features for ranking. Output of features_for_rank() meta: list of dictionaries ...
[ "Given", "a", "feature", "matrix", "geonames", "data", "and", "the", "original", "query", "construct", "a", "prodigy", "task", "." ]
bd82b8bcc27621345c57cbe9ec7f8c8552620ffc
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/geoparse.py#L833-L880
train
openeventdata/mordecai
mordecai/geoparse.py
Geoparser.format_geonames
def format_geonames(self, entry, searchterm=None): """ Pull out just the fields we want from a geonames entry To do: - switch to model picking Parameters ----------- res : dict ES/geonames result searchterm : str (not implemented...
python
def format_geonames(self, entry, searchterm=None): """ Pull out just the fields we want from a geonames entry To do: - switch to model picking Parameters ----------- res : dict ES/geonames result searchterm : str (not implemented...
[ "def", "format_geonames", "(", "self", ",", "entry", ",", "searchterm", "=", "None", ")", ":", "try", ":", "lat", ",", "lon", "=", "entry", "[", "'coordinates'", "]", ".", "split", "(", "\",\"", ")", "new_res", "=", "{", "\"admin1\"", ":", "self", "....
Pull out just the fields we want from a geonames entry To do: - switch to model picking Parameters ----------- res : dict ES/geonames result searchterm : str (not implemented). Needed for better results picking Returns -------- ...
[ "Pull", "out", "just", "the", "fields", "we", "want", "from", "a", "geonames", "entry" ]
bd82b8bcc27621345c57cbe9ec7f8c8552620ffc
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/geoparse.py#L883-L926
train
openeventdata/mordecai
mordecai/geoparse.py
Geoparser.clean_proced
def clean_proced(self, proced): """Small helper function to delete the features from the final dictionary. These features are mostly interesting for debugging but won't be relevant for most users. """ for loc in proced: try: del loc['all_countries'] ...
python
def clean_proced(self, proced): """Small helper function to delete the features from the final dictionary. These features are mostly interesting for debugging but won't be relevant for most users. """ for loc in proced: try: del loc['all_countries'] ...
[ "def", "clean_proced", "(", "self", ",", "proced", ")", ":", "for", "loc", "in", "proced", ":", "try", ":", "del", "loc", "[", "'all_countries'", "]", "except", "KeyError", ":", "pass", "try", ":", "del", "loc", "[", "'matrix'", "]", "except", "KeyErro...
Small helper function to delete the features from the final dictionary. These features are mostly interesting for debugging but won't be relevant for most users.
[ "Small", "helper", "function", "to", "delete", "the", "features", "from", "the", "final", "dictionary", ".", "These", "features", "are", "mostly", "interesting", "for", "debugging", "but", "won", "t", "be", "relevant", "for", "most", "users", "." ]
bd82b8bcc27621345c57cbe9ec7f8c8552620ffc
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/geoparse.py#L928-L961
train
openeventdata/mordecai
mordecai/geoparse.py
Geoparser.geoparse
def geoparse(self, doc, verbose=False): """Main geoparsing function. Text to extracted, resolved entities. Parameters ---------- doc : str or spaCy The document to be geoparsed. Can be either raw text or already spacy processed. In some cases, it makes sense to b...
python
def geoparse(self, doc, verbose=False): """Main geoparsing function. Text to extracted, resolved entities. Parameters ---------- doc : str or spaCy The document to be geoparsed. Can be either raw text or already spacy processed. In some cases, it makes sense to b...
[ "def", "geoparse", "(", "self", ",", "doc", ",", "verbose", "=", "False", ")", ":", "if", "not", "hasattr", "(", "doc", ",", "\"ents\"", ")", ":", "doc", "=", "nlp", "(", "doc", ")", "proced", "=", "self", ".", "infer_country", "(", "doc", ")", "...
Main geoparsing function. Text to extracted, resolved entities. Parameters ---------- doc : str or spaCy The document to be geoparsed. Can be either raw text or already spacy processed. In some cases, it makes sense to bulk parse using spacy's .pipe() before sending ...
[ "Main", "geoparsing", "function", ".", "Text", "to", "extracted", "resolved", "entities", "." ]
bd82b8bcc27621345c57cbe9ec7f8c8552620ffc
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/geoparse.py#L963-L1024
train
openeventdata/mordecai
mordecai/geoparse.py
Geoparser.batch_geoparse
def batch_geoparse(self, text_list): """ Batch geoparsing function. Take in a list of text documents and return a list of lists of the geoparsed documents. The speed improvements come exclusively from using spaCy's `nlp.pipe`. Parameters ---------- text_list : list of st...
python
def batch_geoparse(self, text_list): """ Batch geoparsing function. Take in a list of text documents and return a list of lists of the geoparsed documents. The speed improvements come exclusively from using spaCy's `nlp.pipe`. Parameters ---------- text_list : list of st...
[ "def", "batch_geoparse", "(", "self", ",", "text_list", ")", ":", "if", "not", "self", ".", "threads", ":", "print", "(", "\"batch_geoparsed should be used with threaded searches. Please set `threads=True` when initializing the geoparser.\"", ")", "nlped_docs", "=", "list", ...
Batch geoparsing function. Take in a list of text documents and return a list of lists of the geoparsed documents. The speed improvements come exclusively from using spaCy's `nlp.pipe`. Parameters ---------- text_list : list of strs List of documents. The documents should no...
[ "Batch", "geoparsing", "function", ".", "Take", "in", "a", "list", "of", "text", "documents", "and", "return", "a", "list", "of", "lists", "of", "the", "geoparsed", "documents", ".", "The", "speed", "improvements", "come", "exclusively", "from", "using", "sp...
bd82b8bcc27621345c57cbe9ec7f8c8552620ffc
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/geoparse.py#L1027-L1050
train
openeventdata/mordecai
train/train_country_model.py
entry_to_matrix
def entry_to_matrix(prodigy_entry): """ Take in a line from the labeled json and return a vector of labels and a matrix of features for training. Two ways to get 0s: - marked as false by user - generated automatically from other entries when guess is correct Rather than iterating t...
python
def entry_to_matrix(prodigy_entry): """ Take in a line from the labeled json and return a vector of labels and a matrix of features for training. Two ways to get 0s: - marked as false by user - generated automatically from other entries when guess is correct Rather than iterating t...
[ "def", "entry_to_matrix", "(", "prodigy_entry", ")", ":", "doc", "=", "prodigy_entry", "[", "'text'", "]", "doc", "=", "nlp", "(", "doc", ")", "geo_proced", "=", "geo", ".", "process_text", "(", "doc", ",", "require_maj", "=", "False", ")", "ent_text", "...
Take in a line from the labeled json and return a vector of labels and a matrix of features for training. Two ways to get 0s: - marked as false by user - generated automatically from other entries when guess is correct Rather than iterating through entities, just get the number of the corr...
[ "Take", "in", "a", "line", "from", "the", "labeled", "json", "and", "return", "a", "vector", "of", "labels", "and", "a", "matrix", "of", "features", "for", "training", "." ]
bd82b8bcc27621345c57cbe9ec7f8c8552620ffc
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/train/train_country_model.py#L22-L92
train
picklepete/pyicloud
pyicloud/services/findmyiphone.py
FindMyiPhoneServiceManager.refresh_client
def refresh_client(self): """ Refreshes the FindMyiPhoneService endpoint, This ensures that the location data is up-to-date. """ req = self.session.post( self._fmip_refresh_url, params=self.params, data=json.dumps( { ...
python
def refresh_client(self): """ Refreshes the FindMyiPhoneService endpoint, This ensures that the location data is up-to-date. """ req = self.session.post( self._fmip_refresh_url, params=self.params, data=json.dumps( { ...
[ "def", "refresh_client", "(", "self", ")", ":", "req", "=", "self", ".", "session", ".", "post", "(", "self", ".", "_fmip_refresh_url", ",", "params", "=", "self", ".", "params", ",", "data", "=", "json", ".", "dumps", "(", "{", "'clientContext'", ":",...
Refreshes the FindMyiPhoneService endpoint, This ensures that the location data is up-to-date.
[ "Refreshes", "the", "FindMyiPhoneService", "endpoint" ]
9bb6d750662ce24c8febc94807ddbdcdf3cadaa2
https://github.com/picklepete/pyicloud/blob/9bb6d750662ce24c8febc94807ddbdcdf3cadaa2/pyicloud/services/findmyiphone.py#L30-L67
train
picklepete/pyicloud
pyicloud/services/findmyiphone.py
AppleDevice.status
def status(self, additional=[]): """ Returns status information for device. This returns only a subset of possible properties. """ self.manager.refresh_client() fields = ['batteryLevel', 'deviceDisplayName', 'deviceStatus', 'name'] fields += additional properties...
python
def status(self, additional=[]): """ Returns status information for device. This returns only a subset of possible properties. """ self.manager.refresh_client() fields = ['batteryLevel', 'deviceDisplayName', 'deviceStatus', 'name'] fields += additional properties...
[ "def", "status", "(", "self", ",", "additional", "=", "[", "]", ")", ":", "self", ".", "manager", ".", "refresh_client", "(", ")", "fields", "=", "[", "'batteryLevel'", ",", "'deviceDisplayName'", ",", "'deviceStatus'", ",", "'name'", "]", "fields", "+=", ...
Returns status information for device. This returns only a subset of possible properties.
[ "Returns", "status", "information", "for", "device", "." ]
9bb6d750662ce24c8febc94807ddbdcdf3cadaa2
https://github.com/picklepete/pyicloud/blob/9bb6d750662ce24c8febc94807ddbdcdf3cadaa2/pyicloud/services/findmyiphone.py#L115-L126
train
picklepete/pyicloud
pyicloud/services/findmyiphone.py
AppleDevice.lost_device
def lost_device( self, number, text='This iPhone has been lost. Please call me.', newpasscode="" ): """ Send a request to the device to trigger 'lost mode'. The device will show the message in `text`, and if a number has been passed, then the person holding the devic...
python
def lost_device( self, number, text='This iPhone has been lost. Please call me.', newpasscode="" ): """ Send a request to the device to trigger 'lost mode'. The device will show the message in `text`, and if a number has been passed, then the person holding the devic...
[ "def", "lost_device", "(", "self", ",", "number", ",", "text", "=", "'This iPhone has been lost. Please call me.'", ",", "newpasscode", "=", "\"\"", ")", ":", "data", "=", "json", ".", "dumps", "(", "{", "'text'", ":", "text", ",", "'userText'", ":", "True",...
Send a request to the device to trigger 'lost mode'. The device will show the message in `text`, and if a number has been passed, then the person holding the device can call the number without entering the passcode.
[ "Send", "a", "request", "to", "the", "device", "to", "trigger", "lost", "mode", "." ]
9bb6d750662ce24c8febc94807ddbdcdf3cadaa2
https://github.com/picklepete/pyicloud/blob/9bb6d750662ce24c8febc94807ddbdcdf3cadaa2/pyicloud/services/findmyiphone.py#L169-L193
train
picklepete/pyicloud
pyicloud/services/calendar.py
CalendarService.events
def events(self, from_dt=None, to_dt=None): """ Retrieves events for a given date range, by default, this month. """ self.refresh_client(from_dt, to_dt) return self.response['Event']
python
def events(self, from_dt=None, to_dt=None): """ Retrieves events for a given date range, by default, this month. """ self.refresh_client(from_dt, to_dt) return self.response['Event']
[ "def", "events", "(", "self", ",", "from_dt", "=", "None", ",", "to_dt", "=", "None", ")", ":", "self", ".", "refresh_client", "(", "from_dt", ",", "to_dt", ")", "return", "self", ".", "response", "[", "'Event'", "]" ]
Retrieves events for a given date range, by default, this month.
[ "Retrieves", "events", "for", "a", "given", "date", "range", "by", "default", "this", "month", "." ]
9bb6d750662ce24c8febc94807ddbdcdf3cadaa2
https://github.com/picklepete/pyicloud/blob/9bb6d750662ce24c8febc94807ddbdcdf3cadaa2/pyicloud/services/calendar.py#L58-L63
train
picklepete/pyicloud
pyicloud/services/calendar.py
CalendarService.calendars
def calendars(self): """ Retrieves calendars for this month """ today = datetime.today() first_day, last_day = monthrange(today.year, today.month) from_dt = datetime(today.year, today.month, first_day) to_dt = datetime(today.year, today.month, last_day) pa...
python
def calendars(self): """ Retrieves calendars for this month """ today = datetime.today() first_day, last_day = monthrange(today.year, today.month) from_dt = datetime(today.year, today.month, first_day) to_dt = datetime(today.year, today.month, last_day) pa...
[ "def", "calendars", "(", "self", ")", ":", "today", "=", "datetime", ".", "today", "(", ")", "first_day", ",", "last_day", "=", "monthrange", "(", "today", ".", "year", ",", "today", ".", "month", ")", "from_dt", "=", "datetime", "(", "today", ".", "...
Retrieves calendars for this month
[ "Retrieves", "calendars", "for", "this", "month" ]
9bb6d750662ce24c8febc94807ddbdcdf3cadaa2
https://github.com/picklepete/pyicloud/blob/9bb6d750662ce24c8febc94807ddbdcdf3cadaa2/pyicloud/services/calendar.py#L65-L82
train
picklepete/pyicloud
pyicloud/cmdline.py
create_pickled_data
def create_pickled_data(idevice, filename): """This helper will output the idevice to a pickled file named after the passed filename. This allows the data to be used without resorting to screen / pipe scrapping. """ data = {} for x in idevice.content: data[x] = idevice.content[x] l...
python
def create_pickled_data(idevice, filename): """This helper will output the idevice to a pickled file named after the passed filename. This allows the data to be used without resorting to screen / pipe scrapping. """ data = {} for x in idevice.content: data[x] = idevice.content[x] l...
[ "def", "create_pickled_data", "(", "idevice", ",", "filename", ")", ":", "data", "=", "{", "}", "for", "x", "in", "idevice", ".", "content", ":", "data", "[", "x", "]", "=", "idevice", ".", "content", "[", "x", "]", "location", "=", "filename", "pick...
This helper will output the idevice to a pickled file named after the passed filename. This allows the data to be used without resorting to screen / pipe scrapping.
[ "This", "helper", "will", "output", "the", "idevice", "to", "a", "pickled", "file", "named", "after", "the", "passed", "filename", "." ]
9bb6d750662ce24c8febc94807ddbdcdf3cadaa2
https://github.com/picklepete/pyicloud/blob/9bb6d750662ce24c8febc94807ddbdcdf3cadaa2/pyicloud/cmdline.py#L23-L35
train
picklepete/pyicloud
pyicloud/services/contacts.py
ContactsService.refresh_client
def refresh_client(self, from_dt=None, to_dt=None): """ Refreshes the ContactsService endpoint, ensuring that the contacts data is up-to-date. """ params_contacts = dict(self.params) params_contacts.update({ 'clientVersion': '2.1', 'locale': 'en_US...
python
def refresh_client(self, from_dt=None, to_dt=None): """ Refreshes the ContactsService endpoint, ensuring that the contacts data is up-to-date. """ params_contacts = dict(self.params) params_contacts.update({ 'clientVersion': '2.1', 'locale': 'en_US...
[ "def", "refresh_client", "(", "self", ",", "from_dt", "=", "None", ",", "to_dt", "=", "None", ")", ":", "params_contacts", "=", "dict", "(", "self", ".", "params", ")", "params_contacts", ".", "update", "(", "{", "'clientVersion'", ":", "'2.1'", ",", "'l...
Refreshes the ContactsService endpoint, ensuring that the contacts data is up-to-date.
[ "Refreshes", "the", "ContactsService", "endpoint", "ensuring", "that", "the", "contacts", "data", "is", "up", "-", "to", "-", "date", "." ]
9bb6d750662ce24c8febc94807ddbdcdf3cadaa2
https://github.com/picklepete/pyicloud/blob/9bb6d750662ce24c8febc94807ddbdcdf3cadaa2/pyicloud/services/contacts.py#L20-L46
train
picklepete/pyicloud
pyicloud/base.py
PyiCloudService.authenticate
def authenticate(self): """ Handles authentication, and persists the X-APPLE-WEB-KB cookie so that subsequent logins will not cause additional e-mails from Apple. """ logger.info("Authenticating as %s", self.user['apple_id']) data = dict(self.user) # We authent...
python
def authenticate(self): """ Handles authentication, and persists the X-APPLE-WEB-KB cookie so that subsequent logins will not cause additional e-mails from Apple. """ logger.info("Authenticating as %s", self.user['apple_id']) data = dict(self.user) # We authent...
[ "def", "authenticate", "(", "self", ")", ":", "logger", ".", "info", "(", "\"Authenticating as %s\"", ",", "self", ".", "user", "[", "'apple_id'", "]", ")", "data", "=", "dict", "(", "self", ".", "user", ")", "data", ".", "update", "(", "{", "'extended...
Handles authentication, and persists the X-APPLE-WEB-KB cookie so that subsequent logins will not cause additional e-mails from Apple.
[ "Handles", "authentication", "and", "persists", "the", "X", "-", "APPLE", "-", "WEB", "-", "KB", "cookie", "so", "that", "subsequent", "logins", "will", "not", "cause", "additional", "e", "-", "mails", "from", "Apple", "." ]
9bb6d750662ce24c8febc94807ddbdcdf3cadaa2
https://github.com/picklepete/pyicloud/blob/9bb6d750662ce24c8febc94807ddbdcdf3cadaa2/pyicloud/base.py#L195-L230
train
picklepete/pyicloud
pyicloud/base.py
PyiCloudService.trusted_devices
def trusted_devices(self): """ Returns devices trusted for two-step authentication.""" request = self.session.get( '%s/listDevices' % self._setup_endpoint, params=self.params ) return request.json().get('devices')
python
def trusted_devices(self): """ Returns devices trusted for two-step authentication.""" request = self.session.get( '%s/listDevices' % self._setup_endpoint, params=self.params ) return request.json().get('devices')
[ "def", "trusted_devices", "(", "self", ")", ":", "request", "=", "self", ".", "session", ".", "get", "(", "'%s/listDevices'", "%", "self", ".", "_setup_endpoint", ",", "params", "=", "self", ".", "params", ")", "return", "request", ".", "json", "(", ")",...
Returns devices trusted for two-step authentication.
[ "Returns", "devices", "trusted", "for", "two", "-", "step", "authentication", "." ]
9bb6d750662ce24c8febc94807ddbdcdf3cadaa2
https://github.com/picklepete/pyicloud/blob/9bb6d750662ce24c8febc94807ddbdcdf3cadaa2/pyicloud/base.py#L247-L253
train
picklepete/pyicloud
pyicloud/base.py
PyiCloudService.send_verification_code
def send_verification_code(self, device): """ Requests that a verification code is sent to the given device""" data = json.dumps(device) request = self.session.post( '%s/sendVerificationCode' % self._setup_endpoint, params=self.params, data=data ) ...
python
def send_verification_code(self, device): """ Requests that a verification code is sent to the given device""" data = json.dumps(device) request = self.session.post( '%s/sendVerificationCode' % self._setup_endpoint, params=self.params, data=data ) ...
[ "def", "send_verification_code", "(", "self", ",", "device", ")", ":", "data", "=", "json", ".", "dumps", "(", "device", ")", "request", "=", "self", ".", "session", ".", "post", "(", "'%s/sendVerificationCode'", "%", "self", ".", "_setup_endpoint", ",", "...
Requests that a verification code is sent to the given device
[ "Requests", "that", "a", "verification", "code", "is", "sent", "to", "the", "given", "device" ]
9bb6d750662ce24c8febc94807ddbdcdf3cadaa2
https://github.com/picklepete/pyicloud/blob/9bb6d750662ce24c8febc94807ddbdcdf3cadaa2/pyicloud/base.py#L255-L263
train
picklepete/pyicloud
pyicloud/base.py
PyiCloudService.validate_verification_code
def validate_verification_code(self, device, code): """ Verifies a verification code received on a trusted device""" device.update({ 'verificationCode': code, 'trustBrowser': True }) data = json.dumps(device) try: request = self.session.post( ...
python
def validate_verification_code(self, device, code): """ Verifies a verification code received on a trusted device""" device.update({ 'verificationCode': code, 'trustBrowser': True }) data = json.dumps(device) try: request = self.session.post( ...
[ "def", "validate_verification_code", "(", "self", ",", "device", ",", "code", ")", ":", "device", ".", "update", "(", "{", "'verificationCode'", ":", "code", ",", "'trustBrowser'", ":", "True", "}", ")", "data", "=", "json", ".", "dumps", "(", "device", ...
Verifies a verification code received on a trusted device
[ "Verifies", "a", "verification", "code", "received", "on", "a", "trusted", "device" ]
9bb6d750662ce24c8febc94807ddbdcdf3cadaa2
https://github.com/picklepete/pyicloud/blob/9bb6d750662ce24c8febc94807ddbdcdf3cadaa2/pyicloud/base.py#L265-L289
train
picklepete/pyicloud
pyicloud/base.py
PyiCloudService.devices
def devices(self): """ Return all devices.""" service_root = self.webservices['findme']['url'] return FindMyiPhoneServiceManager( service_root, self.session, self.params )
python
def devices(self): """ Return all devices.""" service_root = self.webservices['findme']['url'] return FindMyiPhoneServiceManager( service_root, self.session, self.params )
[ "def", "devices", "(", "self", ")", ":", "service_root", "=", "self", ".", "webservices", "[", "'findme'", "]", "[", "'url'", "]", "return", "FindMyiPhoneServiceManager", "(", "service_root", ",", "self", ".", "session", ",", "self", ".", "params", ")" ]
Return all devices.
[ "Return", "all", "devices", "." ]
9bb6d750662ce24c8febc94807ddbdcdf3cadaa2
https://github.com/picklepete/pyicloud/blob/9bb6d750662ce24c8febc94807ddbdcdf3cadaa2/pyicloud/base.py#L292-L299
train
kennethreitz/grequests
grequests.py
send
def send(r, pool=None, stream=False): """Sends the request object using the specified pool. If a pool isn't specified this method blocks. Pools are useful because you can specify size and can hence limit concurrency.""" if pool is not None: return pool.spawn(r.send, stream=stream) return ge...
python
def send(r, pool=None, stream=False): """Sends the request object using the specified pool. If a pool isn't specified this method blocks. Pools are useful because you can specify size and can hence limit concurrency.""" if pool is not None: return pool.spawn(r.send, stream=stream) return ge...
[ "def", "send", "(", "r", ",", "pool", "=", "None", ",", "stream", "=", "False", ")", ":", "if", "pool", "is", "not", "None", ":", "return", "pool", ".", "spawn", "(", "r", ".", "send", ",", "stream", "=", "stream", ")", "return", "gevent", ".", ...
Sends the request object using the specified pool. If a pool isn't specified this method blocks. Pools are useful because you can specify size and can hence limit concurrency.
[ "Sends", "the", "request", "object", "using", "the", "specified", "pool", ".", "If", "a", "pool", "isn", "t", "specified", "this", "method", "blocks", ".", "Pools", "are", "useful", "because", "you", "can", "specify", "size", "and", "can", "hence", "limit"...
ba25872510e06af213b0c209d204cdc913e3a429
https://github.com/kennethreitz/grequests/blob/ba25872510e06af213b0c209d204cdc913e3a429/grequests.py#L79-L86
train
kennethreitz/grequests
grequests.py
imap
def imap(requests, stream=False, size=2, exception_handler=None): """Concurrently converts a generator object of Requests to a generator of Responses. :param requests: a generator of Request objects. :param stream: If True, the content will not be downloaded immediately. :param size: Specifies the ...
python
def imap(requests, stream=False, size=2, exception_handler=None): """Concurrently converts a generator object of Requests to a generator of Responses. :param requests: a generator of Request objects. :param stream: If True, the content will not be downloaded immediately. :param size: Specifies the ...
[ "def", "imap", "(", "requests", ",", "stream", "=", "False", ",", "size", "=", "2", ",", "exception_handler", "=", "None", ")", ":", "pool", "=", "Pool", "(", "size", ")", "def", "send", "(", "r", ")", ":", "return", "r", ".", "send", "(", "strea...
Concurrently converts a generator object of Requests to a generator of Responses. :param requests: a generator of Request objects. :param stream: If True, the content will not be downloaded immediately. :param size: Specifies the number of requests to make at a time. default is 2 :param exception_h...
[ "Concurrently", "converts", "a", "generator", "object", "of", "Requests", "to", "a", "generator", "of", "Responses", "." ]
ba25872510e06af213b0c209d204cdc913e3a429
https://github.com/kennethreitz/grequests/blob/ba25872510e06af213b0c209d204cdc913e3a429/grequests.py#L132-L155
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.set_user_profile
def set_user_profile(self, displayname=None, avatar_url=None, reason="Changing room profile information"): """Set user profile within a room. This sets displayname and avatar_url for the logged in user only in a specific...
python
def set_user_profile(self, displayname=None, avatar_url=None, reason="Changing room profile information"): """Set user profile within a room. This sets displayname and avatar_url for the logged in user only in a specific...
[ "def", "set_user_profile", "(", "self", ",", "displayname", "=", "None", ",", "avatar_url", "=", "None", ",", "reason", "=", "\"Changing room profile information\"", ")", ":", "member", "=", "self", ".", "client", ".", "api", ".", "get_membership", "(", "self"...
Set user profile within a room. This sets displayname and avatar_url for the logged in user only in a specific room. It does not change the user's global user profile.
[ "Set", "user", "profile", "within", "a", "room", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L57-L81
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.display_name
def display_name(self): """Calculates the display name for a room.""" if self.name: return self.name elif self.canonical_alias: return self.canonical_alias # Member display names without me members = [u.get_display_name(self) for u in self.get_joined_memb...
python
def display_name(self): """Calculates the display name for a room.""" if self.name: return self.name elif self.canonical_alias: return self.canonical_alias # Member display names without me members = [u.get_display_name(self) for u in self.get_joined_memb...
[ "def", "display_name", "(", "self", ")", ":", "if", "self", ".", "name", ":", "return", "self", ".", "name", "elif", "self", ".", "canonical_alias", ":", "return", "self", ".", "canonical_alias", "members", "=", "[", "u", ".", "get_display_name", "(", "s...
Calculates the display name for a room.
[ "Calculates", "the", "display", "name", "for", "a", "room", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L84-L104
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.send_text
def send_text(self, text): """Send a plain text message to the room.""" return self.client.api.send_message(self.room_id, text)
python
def send_text(self, text): """Send a plain text message to the room.""" return self.client.api.send_message(self.room_id, text)
[ "def", "send_text", "(", "self", ",", "text", ")", ":", "return", "self", ".", "client", ".", "api", ".", "send_message", "(", "self", ".", "room_id", ",", "text", ")" ]
Send a plain text message to the room.
[ "Send", "a", "plain", "text", "message", "to", "the", "room", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L106-L108
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.send_html
def send_html(self, html, body=None, msgtype="m.text"): """Send an html formatted message. Args: html (str): The html formatted message to be sent. body (str): The unformatted body of the message to be sent. """ return self.client.api.send_message_event( ...
python
def send_html(self, html, body=None, msgtype="m.text"): """Send an html formatted message. Args: html (str): The html formatted message to be sent. body (str): The unformatted body of the message to be sent. """ return self.client.api.send_message_event( ...
[ "def", "send_html", "(", "self", ",", "html", ",", "body", "=", "None", ",", "msgtype", "=", "\"m.text\"", ")", ":", "return", "self", ".", "client", ".", "api", ".", "send_message_event", "(", "self", ".", "room_id", ",", "\"m.room.message\"", ",", "sel...
Send an html formatted message. Args: html (str): The html formatted message to be sent. body (str): The unformatted body of the message to be sent.
[ "Send", "an", "html", "formatted", "message", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L118-L126
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.send_file
def send_file(self, url, name, **fileinfo): """Send a pre-uploaded file to the room. See http://matrix.org/docs/spec/r0.2.0/client_server.html#m-file for fileinfo. Args: url (str): The mxc url of the file. name (str): The filename of the image. filei...
python
def send_file(self, url, name, **fileinfo): """Send a pre-uploaded file to the room. See http://matrix.org/docs/spec/r0.2.0/client_server.html#m-file for fileinfo. Args: url (str): The mxc url of the file. name (str): The filename of the image. filei...
[ "def", "send_file", "(", "self", ",", "url", ",", "name", ",", "**", "fileinfo", ")", ":", "return", "self", ".", "client", ".", "api", ".", "send_content", "(", "self", ".", "room_id", ",", "url", ",", "name", ",", "\"m.file\"", ",", "extra_informatio...
Send a pre-uploaded file to the room. See http://matrix.org/docs/spec/r0.2.0/client_server.html#m-file for fileinfo. Args: url (str): The mxc url of the file. name (str): The filename of the image. fileinfo (): Extra information about the file
[ "Send", "a", "pre", "-", "uploaded", "file", "to", "the", "room", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L150-L165
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.send_image
def send_image(self, url, name, **imageinfo): """Send a pre-uploaded image to the room. See http://matrix.org/docs/spec/r0.0.1/client_server.html#m-image for imageinfo Args: url (str): The mxc url of the image. name (str): The filename of the image. ...
python
def send_image(self, url, name, **imageinfo): """Send a pre-uploaded image to the room. See http://matrix.org/docs/spec/r0.0.1/client_server.html#m-image for imageinfo Args: url (str): The mxc url of the image. name (str): The filename of the image. ...
[ "def", "send_image", "(", "self", ",", "url", ",", "name", ",", "**", "imageinfo", ")", ":", "return", "self", ".", "client", ".", "api", ".", "send_content", "(", "self", ".", "room_id", ",", "url", ",", "name", ",", "\"m.image\"", ",", "extra_informa...
Send a pre-uploaded image to the room. See http://matrix.org/docs/spec/r0.0.1/client_server.html#m-image for imageinfo Args: url (str): The mxc url of the image. name (str): The filename of the image. imageinfo (): Extra information about the image.
[ "Send", "a", "pre", "-", "uploaded", "image", "to", "the", "room", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L173-L187
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.send_location
def send_location(self, geo_uri, name, thumb_url=None, **thumb_info): """Send a location to the room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#m-location for thumb_info Args: geo_uri (str): The geo uri representing the location. name (str): Desc...
python
def send_location(self, geo_uri, name, thumb_url=None, **thumb_info): """Send a location to the room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#m-location for thumb_info Args: geo_uri (str): The geo uri representing the location. name (str): Desc...
[ "def", "send_location", "(", "self", ",", "geo_uri", ",", "name", ",", "thumb_url", "=", "None", ",", "**", "thumb_info", ")", ":", "return", "self", ".", "client", ".", "api", ".", "send_location", "(", "self", ".", "room_id", ",", "geo_uri", ",", "na...
Send a location to the room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#m-location for thumb_info Args: geo_uri (str): The geo uri representing the location. name (str): Description for the location. thumb_url (str): URL to the thumbnail of th...
[ "Send", "a", "location", "to", "the", "room", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L189-L202
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.send_video
def send_video(self, url, name, **videoinfo): """Send a pre-uploaded video to the room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#m-video for videoinfo Args: url (str): The mxc url of the video. name (str): The filename of the video. ...
python
def send_video(self, url, name, **videoinfo): """Send a pre-uploaded video to the room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#m-video for videoinfo Args: url (str): The mxc url of the video. name (str): The filename of the video. ...
[ "def", "send_video", "(", "self", ",", "url", ",", "name", ",", "**", "videoinfo", ")", ":", "return", "self", ".", "client", ".", "api", ".", "send_content", "(", "self", ".", "room_id", ",", "url", ",", "name", ",", "\"m.video\"", ",", "extra_informa...
Send a pre-uploaded video to the room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#m-video for videoinfo Args: url (str): The mxc url of the video. name (str): The filename of the video. videoinfo (): Extra information about the video.
[ "Send", "a", "pre", "-", "uploaded", "video", "to", "the", "room", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L204-L216
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.send_audio
def send_audio(self, url, name, **audioinfo): """Send a pre-uploaded audio to the room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#m-audio for audioinfo Args: url (str): The mxc url of the audio. name (str): The filename of the audio. ...
python
def send_audio(self, url, name, **audioinfo): """Send a pre-uploaded audio to the room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#m-audio for audioinfo Args: url (str): The mxc url of the audio. name (str): The filename of the audio. ...
[ "def", "send_audio", "(", "self", ",", "url", ",", "name", ",", "**", "audioinfo", ")", ":", "return", "self", ".", "client", ".", "api", ".", "send_content", "(", "self", ".", "room_id", ",", "url", ",", "name", ",", "\"m.audio\"", ",", "extra_informa...
Send a pre-uploaded audio to the room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#m-audio for audioinfo Args: url (str): The mxc url of the audio. name (str): The filename of the audio. audioinfo (): Extra information about the audio.
[ "Send", "a", "pre", "-", "uploaded", "audio", "to", "the", "room", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L218-L230
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.redact_message
def redact_message(self, event_id, reason=None): """Redacts the message with specified event_id for the given reason. See https://matrix.org/docs/spec/r0.0.1/client_server.html#id112 """ return self.client.api.redact_event(self.room_id, event_id, reason)
python
def redact_message(self, event_id, reason=None): """Redacts the message with specified event_id for the given reason. See https://matrix.org/docs/spec/r0.0.1/client_server.html#id112 """ return self.client.api.redact_event(self.room_id, event_id, reason)
[ "def", "redact_message", "(", "self", ",", "event_id", ",", "reason", "=", "None", ")", ":", "return", "self", ".", "client", ".", "api", ".", "redact_event", "(", "self", ".", "room_id", ",", "event_id", ",", "reason", ")" ]
Redacts the message with specified event_id for the given reason. See https://matrix.org/docs/spec/r0.0.1/client_server.html#id112
[ "Redacts", "the", "message", "with", "specified", "event_id", "for", "the", "given", "reason", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L232-L237
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.add_listener
def add_listener(self, callback, event_type=None): """Add a callback handler for events going to this room. Args: callback (func(room, event)): Callback called when an event arrives. event_type (str): The event_type to filter for. Returns: uuid.UUID: Unique i...
python
def add_listener(self, callback, event_type=None): """Add a callback handler for events going to this room. Args: callback (func(room, event)): Callback called when an event arrives. event_type (str): The event_type to filter for. Returns: uuid.UUID: Unique i...
[ "def", "add_listener", "(", "self", ",", "callback", ",", "event_type", "=", "None", ")", ":", "listener_id", "=", "uuid4", "(", ")", "self", ".", "listeners", ".", "append", "(", "{", "'uid'", ":", "listener_id", ",", "'callback'", ":", "callback", ",",...
Add a callback handler for events going to this room. Args: callback (func(room, event)): Callback called when an event arrives. event_type (str): The event_type to filter for. Returns: uuid.UUID: Unique id of the listener, can be used to identify the listener.
[ "Add", "a", "callback", "handler", "for", "events", "going", "to", "this", "room", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L239-L256
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.remove_listener
def remove_listener(self, uid): """Remove listener with given uid.""" self.listeners[:] = (listener for listener in self.listeners if listener['uid'] != uid)
python
def remove_listener(self, uid): """Remove listener with given uid.""" self.listeners[:] = (listener for listener in self.listeners if listener['uid'] != uid)
[ "def", "remove_listener", "(", "self", ",", "uid", ")", ":", "self", ".", "listeners", "[", ":", "]", "=", "(", "listener", "for", "listener", "in", "self", ".", "listeners", "if", "listener", "[", "'uid'", "]", "!=", "uid", ")" ]
Remove listener with given uid.
[ "Remove", "listener", "with", "given", "uid", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L258-L261
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.add_ephemeral_listener
def add_ephemeral_listener(self, callback, event_type=None): """Add a callback handler for ephemeral events going to this room. Args: callback (func(room, event)): Callback called when an ephemeral event arrives. event_type (str): The event_type to filter for. Returns: ...
python
def add_ephemeral_listener(self, callback, event_type=None): """Add a callback handler for ephemeral events going to this room. Args: callback (func(room, event)): Callback called when an ephemeral event arrives. event_type (str): The event_type to filter for. Returns: ...
[ "def", "add_ephemeral_listener", "(", "self", ",", "callback", ",", "event_type", "=", "None", ")", ":", "listener_id", "=", "uuid4", "(", ")", "self", ".", "ephemeral_listeners", ".", "append", "(", "{", "'uid'", ":", "listener_id", ",", "'callback'", ":", ...
Add a callback handler for ephemeral events going to this room. Args: callback (func(room, event)): Callback called when an ephemeral event arrives. event_type (str): The event_type to filter for. Returns: uuid.UUID: Unique id of the listener, can be used to identify...
[ "Add", "a", "callback", "handler", "for", "ephemeral", "events", "going", "to", "this", "room", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L263-L280
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.remove_ephemeral_listener
def remove_ephemeral_listener(self, uid): """Remove ephemeral listener with given uid.""" self.ephemeral_listeners[:] = (listener for listener in self.ephemeral_listeners if listener['uid'] != uid)
python
def remove_ephemeral_listener(self, uid): """Remove ephemeral listener with given uid.""" self.ephemeral_listeners[:] = (listener for listener in self.ephemeral_listeners if listener['uid'] != uid)
[ "def", "remove_ephemeral_listener", "(", "self", ",", "uid", ")", ":", "self", ".", "ephemeral_listeners", "[", ":", "]", "=", "(", "listener", "for", "listener", "in", "self", ".", "ephemeral_listeners", "if", "listener", "[", "'uid'", "]", "!=", "uid", "...
Remove ephemeral listener with given uid.
[ "Remove", "ephemeral", "listener", "with", "given", "uid", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L282-L285
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.invite_user
def invite_user(self, user_id): """Invite a user to this room. Returns: boolean: Whether invitation was sent. """ try: self.client.api.invite_user(self.room_id, user_id) return True except MatrixRequestError: return False
python
def invite_user(self, user_id): """Invite a user to this room. Returns: boolean: Whether invitation was sent. """ try: self.client.api.invite_user(self.room_id, user_id) return True except MatrixRequestError: return False
[ "def", "invite_user", "(", "self", ",", "user_id", ")", ":", "try", ":", "self", ".", "client", ".", "api", ".", "invite_user", "(", "self", ".", "room_id", ",", "user_id", ")", "return", "True", "except", "MatrixRequestError", ":", "return", "False" ]
Invite a user to this room. Returns: boolean: Whether invitation was sent.
[ "Invite", "a", "user", "to", "this", "room", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L323-L333
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.kick_user
def kick_user(self, user_id, reason=""): """Kick a user from this room. Args: user_id (str): The matrix user id of a user. reason (str): A reason for kicking the user. Returns: boolean: Whether user was kicked. """ try: self.cli...
python
def kick_user(self, user_id, reason=""): """Kick a user from this room. Args: user_id (str): The matrix user id of a user. reason (str): A reason for kicking the user. Returns: boolean: Whether user was kicked. """ try: self.cli...
[ "def", "kick_user", "(", "self", ",", "user_id", ",", "reason", "=", "\"\"", ")", ":", "try", ":", "self", ".", "client", ".", "api", ".", "kick_user", "(", "self", ".", "room_id", ",", "user_id", ")", "return", "True", "except", "MatrixRequestError", ...
Kick a user from this room. Args: user_id (str): The matrix user id of a user. reason (str): A reason for kicking the user. Returns: boolean: Whether user was kicked.
[ "Kick", "a", "user", "from", "this", "room", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L335-L350
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.leave
def leave(self): """Leave the room. Returns: boolean: Leaving the room was successful. """ try: self.client.api.leave_room(self.room_id) del self.client.rooms[self.room_id] return True except MatrixRequestError: return ...
python
def leave(self): """Leave the room. Returns: boolean: Leaving the room was successful. """ try: self.client.api.leave_room(self.room_id) del self.client.rooms[self.room_id] return True except MatrixRequestError: return ...
[ "def", "leave", "(", "self", ")", ":", "try", ":", "self", ".", "client", ".", "api", ".", "leave_room", "(", "self", ".", "room_id", ")", "del", "self", ".", "client", ".", "rooms", "[", "self", ".", "room_id", "]", "return", "True", "except", "Ma...
Leave the room. Returns: boolean: Leaving the room was successful.
[ "Leave", "the", "room", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L380-L391
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.update_room_name
def update_room_name(self): """Updates self.name and returns True if room name has changed.""" try: response = self.client.api.get_room_name(self.room_id) if "name" in response and response["name"] != self.name: self.name = response["name"] return ...
python
def update_room_name(self): """Updates self.name and returns True if room name has changed.""" try: response = self.client.api.get_room_name(self.room_id) if "name" in response and response["name"] != self.name: self.name = response["name"] return ...
[ "def", "update_room_name", "(", "self", ")", ":", "try", ":", "response", "=", "self", ".", "client", ".", "api", ".", "get_room_name", "(", "self", ".", "room_id", ")", "if", "\"name\"", "in", "response", "and", "response", "[", "\"name\"", "]", "!=", ...
Updates self.name and returns True if room name has changed.
[ "Updates", "self", ".", "name", "and", "returns", "True", "if", "room", "name", "has", "changed", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L393-L403
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.set_room_name
def set_room_name(self, name): """Return True if room name successfully changed.""" try: self.client.api.set_room_name(self.room_id, name) self.name = name return True except MatrixRequestError: return False
python
def set_room_name(self, name): """Return True if room name successfully changed.""" try: self.client.api.set_room_name(self.room_id, name) self.name = name return True except MatrixRequestError: return False
[ "def", "set_room_name", "(", "self", ",", "name", ")", ":", "try", ":", "self", ".", "client", ".", "api", ".", "set_room_name", "(", "self", ".", "room_id", ",", "name", ")", "self", ".", "name", "=", "name", "return", "True", "except", "MatrixRequest...
Return True if room name successfully changed.
[ "Return", "True", "if", "room", "name", "successfully", "changed", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L405-L412
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.send_state_event
def send_state_event(self, event_type, content, state_key=""): """Send a state event to the room. Args: event_type (str): The type of event that you are sending. content (): An object with the content of the message. state_key (str, optional): A unique key to identif...
python
def send_state_event(self, event_type, content, state_key=""): """Send a state event to the room. Args: event_type (str): The type of event that you are sending. content (): An object with the content of the message. state_key (str, optional): A unique key to identif...
[ "def", "send_state_event", "(", "self", ",", "event_type", ",", "content", ",", "state_key", "=", "\"\"", ")", ":", "return", "self", ".", "client", ".", "api", ".", "send_state_event", "(", "self", ".", "room_id", ",", "event_type", ",", "content", ",", ...
Send a state event to the room. Args: event_type (str): The type of event that you are sending. content (): An object with the content of the message. state_key (str, optional): A unique key to identify the state.
[ "Send", "a", "state", "event", "to", "the", "room", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L414-L427
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.update_room_topic
def update_room_topic(self): """Updates self.topic and returns True if room topic has changed.""" try: response = self.client.api.get_room_topic(self.room_id) if "topic" in response and response["topic"] != self.topic: self.topic = response["topic"] ...
python
def update_room_topic(self): """Updates self.topic and returns True if room topic has changed.""" try: response = self.client.api.get_room_topic(self.room_id) if "topic" in response and response["topic"] != self.topic: self.topic = response["topic"] ...
[ "def", "update_room_topic", "(", "self", ")", ":", "try", ":", "response", "=", "self", ".", "client", ".", "api", ".", "get_room_topic", "(", "self", ".", "room_id", ")", "if", "\"topic\"", "in", "response", "and", "response", "[", "\"topic\"", "]", "!=...
Updates self.topic and returns True if room topic has changed.
[ "Updates", "self", ".", "topic", "and", "returns", "True", "if", "room", "topic", "has", "changed", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L429-L439
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.set_room_topic
def set_room_topic(self, topic): """Set room topic. Returns: boolean: True if the topic changed, False if not """ try: self.client.api.set_room_topic(self.room_id, topic) self.topic = topic return True except MatrixRequestError: ...
python
def set_room_topic(self, topic): """Set room topic. Returns: boolean: True if the topic changed, False if not """ try: self.client.api.set_room_topic(self.room_id, topic) self.topic = topic return True except MatrixRequestError: ...
[ "def", "set_room_topic", "(", "self", ",", "topic", ")", ":", "try", ":", "self", ".", "client", ".", "api", ".", "set_room_topic", "(", "self", ".", "room_id", ",", "topic", ")", "self", ".", "topic", "=", "topic", "return", "True", "except", "MatrixR...
Set room topic. Returns: boolean: True if the topic changed, False if not
[ "Set", "room", "topic", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L441-L452
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.update_aliases
def update_aliases(self): """Get aliases information from room state. Returns: boolean: True if the aliases changed, False if not """ try: response = self.client.api.get_room_state(self.room_id) for chunk in response: if "content" in c...
python
def update_aliases(self): """Get aliases information from room state. Returns: boolean: True if the aliases changed, False if not """ try: response = self.client.api.get_room_state(self.room_id) for chunk in response: if "content" in c...
[ "def", "update_aliases", "(", "self", ")", ":", "try", ":", "response", "=", "self", ".", "client", ".", "api", ".", "get_room_state", "(", "self", ".", "room_id", ")", "for", "chunk", "in", "response", ":", "if", "\"content\"", "in", "chunk", "and", "...
Get aliases information from room state. Returns: boolean: True if the aliases changed, False if not
[ "Get", "aliases", "information", "from", "room", "state", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L454-L470
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.add_room_alias
def add_room_alias(self, room_alias): """Add an alias to the room and return True if successful.""" try: self.client.api.set_room_alias(self.room_id, room_alias) return True except MatrixRequestError: return False
python
def add_room_alias(self, room_alias): """Add an alias to the room and return True if successful.""" try: self.client.api.set_room_alias(self.room_id, room_alias) return True except MatrixRequestError: return False
[ "def", "add_room_alias", "(", "self", ",", "room_alias", ")", ":", "try", ":", "self", ".", "client", ".", "api", ".", "set_room_alias", "(", "self", ".", "room_id", ",", "room_alias", ")", "return", "True", "except", "MatrixRequestError", ":", "return", "...
Add an alias to the room and return True if successful.
[ "Add", "an", "alias", "to", "the", "room", "and", "return", "True", "if", "successful", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L472-L478
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.backfill_previous_messages
def backfill_previous_messages(self, reverse=False, limit=10): """Backfill handling of previous messages. Args: reverse (bool): When false messages will be backfilled in their original order (old to new), otherwise the order will be reversed (new to old). limit (...
python
def backfill_previous_messages(self, reverse=False, limit=10): """Backfill handling of previous messages. Args: reverse (bool): When false messages will be backfilled in their original order (old to new), otherwise the order will be reversed (new to old). limit (...
[ "def", "backfill_previous_messages", "(", "self", ",", "reverse", "=", "False", ",", "limit", "=", "10", ")", ":", "res", "=", "self", ".", "client", ".", "api", ".", "get_room_messages", "(", "self", ".", "room_id", ",", "self", ".", "prev_batch", ",", ...
Backfill handling of previous messages. Args: reverse (bool): When false messages will be backfilled in their original order (old to new), otherwise the order will be reversed (new to old). limit (int): Number of messages to go back.
[ "Backfill", "handling", "of", "previous", "messages", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L502-L516
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.modify_user_power_levels
def modify_user_power_levels(self, users=None, users_default=None): """Modify the power level for a subset of users Args: users(dict): Power levels to assign to specific users, in the form {"@name0:host0": 10, "@name1:host1": 100, "@name3:host3", None} A leve...
python
def modify_user_power_levels(self, users=None, users_default=None): """Modify the power level for a subset of users Args: users(dict): Power levels to assign to specific users, in the form {"@name0:host0": 10, "@name1:host1": 100, "@name3:host3", None} A leve...
[ "def", "modify_user_power_levels", "(", "self", ",", "users", "=", "None", ",", "users_default", "=", "None", ")", ":", "try", ":", "content", "=", "self", ".", "client", ".", "api", ".", "get_power_levels", "(", "self", ".", "room_id", ")", "if", "users...
Modify the power level for a subset of users Args: users(dict): Power levels to assign to specific users, in the form {"@name0:host0": 10, "@name1:host1": 100, "@name3:host3", None} A level of None causes the user to revert to the default level as spe...
[ "Modify", "the", "power", "level", "for", "a", "subset", "of", "users" ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L518-L549
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.modify_required_power_levels
def modify_required_power_levels(self, events=None, **kwargs): """Modifies room power level requirements. Args: events(dict): Power levels required for sending specific event types, in the form {"m.room.whatever0": 60, "m.room.whatever2": None}. Overrides eve...
python
def modify_required_power_levels(self, events=None, **kwargs): """Modifies room power level requirements. Args: events(dict): Power levels required for sending specific event types, in the form {"m.room.whatever0": 60, "m.room.whatever2": None}. Overrides eve...
[ "def", "modify_required_power_levels", "(", "self", ",", "events", "=", "None", ",", "**", "kwargs", ")", ":", "try", ":", "content", "=", "self", ".", "client", ".", "api", ".", "get_power_levels", "(", "self", ".", "room_id", ")", "content", ".", "upda...
Modifies room power level requirements. Args: events(dict): Power levels required for sending specific event types, in the form {"m.room.whatever0": 60, "m.room.whatever2": None}. Overrides events_default and state_default for the specified events. A ...
[ "Modifies", "room", "power", "level", "requirements", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L551-L594
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.set_invite_only
def set_invite_only(self, invite_only): """Set how the room can be joined. Args: invite_only(bool): If True, users will have to be invited to join the room. If False, anyone who knows the room link can join. Returns: True if successful, False if not ...
python
def set_invite_only(self, invite_only): """Set how the room can be joined. Args: invite_only(bool): If True, users will have to be invited to join the room. If False, anyone who knows the room link can join. Returns: True if successful, False if not ...
[ "def", "set_invite_only", "(", "self", ",", "invite_only", ")", ":", "join_rule", "=", "\"invite\"", "if", "invite_only", "else", "\"public\"", "try", ":", "self", ".", "client", ".", "api", ".", "set_join_rule", "(", "self", ".", "room_id", ",", "join_rule"...
Set how the room can be joined. Args: invite_only(bool): If True, users will have to be invited to join the room. If False, anyone who knows the room link can join. Returns: True if successful, False if not
[ "Set", "how", "the", "room", "can", "be", "joined", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L596-L612
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.set_guest_access
def set_guest_access(self, allow_guests): """Set whether guests can join the room and return True if successful.""" guest_access = "can_join" if allow_guests else "forbidden" try: self.client.api.set_guest_access(self.room_id, guest_access) self.guest_access = allow_guest...
python
def set_guest_access(self, allow_guests): """Set whether guests can join the room and return True if successful.""" guest_access = "can_join" if allow_guests else "forbidden" try: self.client.api.set_guest_access(self.room_id, guest_access) self.guest_access = allow_guest...
[ "def", "set_guest_access", "(", "self", ",", "allow_guests", ")", ":", "guest_access", "=", "\"can_join\"", "if", "allow_guests", "else", "\"forbidden\"", "try", ":", "self", ".", "client", ".", "api", ".", "set_guest_access", "(", "self", ".", "room_id", ",",...
Set whether guests can join the room and return True if successful.
[ "Set", "whether", "guests", "can", "join", "the", "room", "and", "return", "True", "if", "successful", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L614-L622
train
matrix-org/matrix-python-sdk
matrix_client/room.py
Room.enable_encryption
def enable_encryption(self): """Enables encryption in the room. NOTE: Once enabled, encryption cannot be disabled. Returns: True if successful, False if not """ try: self.send_state_event("m.room.encryption", {"algorithm": "...
python
def enable_encryption(self): """Enables encryption in the room. NOTE: Once enabled, encryption cannot be disabled. Returns: True if successful, False if not """ try: self.send_state_event("m.room.encryption", {"algorithm": "...
[ "def", "enable_encryption", "(", "self", ")", ":", "try", ":", "self", ".", "send_state_event", "(", "\"m.room.encryption\"", ",", "{", "\"algorithm\"", ":", "\"m.megolm.v1.aes-sha2\"", "}", ")", "self", ".", "encrypted", "=", "True", "return", "True", "except",...
Enables encryption in the room. NOTE: Once enabled, encryption cannot be disabled. Returns: True if successful, False if not
[ "Enables", "encryption", "in", "the", "room", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L624-L638
train
matrix-org/matrix-python-sdk
samples/UserPassOrTokenClient.py
example
def example(host, user, password, token): """run the example.""" client = None try: if token: print('token login') client = MatrixClient(host, token=token, user_id=user) else: print('password login') client = MatrixClient(host) toke...
python
def example(host, user, password, token): """run the example.""" client = None try: if token: print('token login') client = MatrixClient(host, token=token, user_id=user) else: print('password login') client = MatrixClient(host) toke...
[ "def", "example", "(", "host", ",", "user", ",", "password", ",", "token", ")", ":", "client", "=", "None", "try", ":", "if", "token", ":", "print", "(", "'token login'", ")", "client", "=", "MatrixClient", "(", "host", ",", "token", "=", "token", ",...
run the example.
[ "run", "the", "example", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/samples/UserPassOrTokenClient.py#L24-L57
train
matrix-org/matrix-python-sdk
samples/UserPassOrTokenClient.py
main
def main(): """Main entry.""" parser = argparse.ArgumentParser() parser.add_argument("--host", type=str, required=True) parser.add_argument("--user", type=str, required=True) parser.add_argument("--password", type=str) parser.add_argument("--token", type=str) args = parser.parse_args() i...
python
def main(): """Main entry.""" parser = argparse.ArgumentParser() parser.add_argument("--host", type=str, required=True) parser.add_argument("--user", type=str, required=True) parser.add_argument("--password", type=str) parser.add_argument("--token", type=str) args = parser.parse_args() i...
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "\"--host\"", ",", "type", "=", "str", ",", "required", "=", "True", ")", "parser", ".", "add_argument", "(", "\"--user\"", ",",...
Main entry.
[ "Main", "entry", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/samples/UserPassOrTokenClient.py#L60-L71
train
matrix-org/matrix-python-sdk
matrix_client/api.py
MatrixHttpApi.sync
def sync(self, since=None, timeout_ms=30000, filter=None, full_state=None, set_presence=None): """ Perform a sync request. Args: since (str): Optional. A token which specifies where to continue a sync from. timeout_ms (int): Optional. The time in milliseconds to wai...
python
def sync(self, since=None, timeout_ms=30000, filter=None, full_state=None, set_presence=None): """ Perform a sync request. Args: since (str): Optional. A token which specifies where to continue a sync from. timeout_ms (int): Optional. The time in milliseconds to wai...
[ "def", "sync", "(", "self", ",", "since", "=", "None", ",", "timeout_ms", "=", "30000", ",", "filter", "=", "None", ",", "full_state", "=", "None", ",", "set_presence", "=", "None", ")", ":", "request", "=", "{", "\"timeout\"", ":", "int", "(", "time...
Perform a sync request. Args: since (str): Optional. A token which specifies where to continue a sync from. timeout_ms (int): Optional. The time in milliseconds to wait. filter (int|str): Either a Filter ID or a JSON string. full_state (bool): Return the full sta...
[ "Perform", "a", "sync", "request", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/api.py#L92-L123
train
matrix-org/matrix-python-sdk
matrix_client/api.py
MatrixHttpApi.send_location
def send_location(self, room_id, geo_uri, name, thumb_url=None, thumb_info=None, timestamp=None): """Send m.location message event Args: room_id (str): The room ID to send the event in. geo_uri (str): The geo uri representing the location. name ...
python
def send_location(self, room_id, geo_uri, name, thumb_url=None, thumb_info=None, timestamp=None): """Send m.location message event Args: room_id (str): The room ID to send the event in. geo_uri (str): The geo uri representing the location. name ...
[ "def", "send_location", "(", "self", ",", "room_id", ",", "geo_uri", ",", "name", ",", "thumb_url", "=", "None", ",", "thumb_info", "=", "None", ",", "timestamp", "=", "None", ")", ":", "content_pack", "=", "{", "\"geo_uri\"", ":", "geo_uri", ",", "\"msg...
Send m.location message event Args: room_id (str): The room ID to send the event in. geo_uri (str): The geo uri representing the location. name (str): Description for the location. thumb_url (str): URL to the thumbnail of the location. thumb_info (dic...
[ "Send", "m", ".", "location", "message", "event" ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/api.py#L351-L374
train
matrix-org/matrix-python-sdk
matrix_client/api.py
MatrixHttpApi.kick_user
def kick_user(self, room_id, user_id, reason=""): """Calls set_membership with membership="leave" for the user_id provided """ self.set_membership(room_id, user_id, "leave", reason)
python
def kick_user(self, room_id, user_id, reason=""): """Calls set_membership with membership="leave" for the user_id provided """ self.set_membership(room_id, user_id, "leave", reason)
[ "def", "kick_user", "(", "self", ",", "room_id", ",", "user_id", ",", "reason", "=", "\"\"", ")", ":", "self", ".", "set_membership", "(", "room_id", ",", "user_id", ",", "\"leave\"", ",", "reason", ")" ]
Calls set_membership with membership="leave" for the user_id provided
[ "Calls", "set_membership", "with", "membership", "=", "leave", "for", "the", "user_id", "provided" ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/api.py#L555-L558
train
matrix-org/matrix-python-sdk
matrix_client/api.py
MatrixHttpApi.media_download
def media_download(self, mxcurl, allow_remote=True): """Download raw media from provided mxc URL. Args: mxcurl (str): mxc media URL. allow_remote (bool): indicates to the server that it should not attempt to fetch the media if it is deemed remote. Defaults ...
python
def media_download(self, mxcurl, allow_remote=True): """Download raw media from provided mxc URL. Args: mxcurl (str): mxc media URL. allow_remote (bool): indicates to the server that it should not attempt to fetch the media if it is deemed remote. Defaults ...
[ "def", "media_download", "(", "self", ",", "mxcurl", ",", "allow_remote", "=", "True", ")", ":", "query_params", "=", "{", "}", "if", "not", "allow_remote", ":", "query_params", "[", "\"allow_remote\"", "]", "=", "False", "if", "mxcurl", ".", "startswith", ...
Download raw media from provided mxc URL. Args: mxcurl (str): mxc media URL. allow_remote (bool): indicates to the server that it should not attempt to fetch the media if it is deemed remote. Defaults to true if not provided.
[ "Download", "raw", "media", "from", "provided", "mxc", "URL", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/api.py#L791-L813
train
matrix-org/matrix-python-sdk
matrix_client/api.py
MatrixHttpApi.get_thumbnail
def get_thumbnail(self, mxcurl, width, height, method='scale', allow_remote=True): """Download raw media thumbnail from provided mxc URL. Args: mxcurl (str): mxc media URL width (int): desired thumbnail width height (int): desired thumbnail height method ...
python
def get_thumbnail(self, mxcurl, width, height, method='scale', allow_remote=True): """Download raw media thumbnail from provided mxc URL. Args: mxcurl (str): mxc media URL width (int): desired thumbnail width height (int): desired thumbnail height method ...
[ "def", "get_thumbnail", "(", "self", ",", "mxcurl", ",", "width", ",", "height", ",", "method", "=", "'scale'", ",", "allow_remote", "=", "True", ")", ":", "if", "method", "not", "in", "[", "'scale'", ",", "'crop'", "]", ":", "raise", "ValueError", "("...
Download raw media thumbnail from provided mxc URL. Args: mxcurl (str): mxc media URL width (int): desired thumbnail width height (int): desired thumbnail height method (str): thumb creation method. Must be in ['scale', 'crop']. Default 'scale'. ...
[ "Download", "raw", "media", "thumbnail", "from", "provided", "mxc", "URL", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/api.py#L815-L849
train
matrix-org/matrix-python-sdk
matrix_client/api.py
MatrixHttpApi.get_url_preview
def get_url_preview(self, url, ts=None): """Get preview for URL. Args: url (str): URL to get a preview ts (double): The preferred point in time to return a preview for. The server may return a newer version if it does not have the requested ...
python
def get_url_preview(self, url, ts=None): """Get preview for URL. Args: url (str): URL to get a preview ts (double): The preferred point in time to return a preview for. The server may return a newer version if it does not have the requested ...
[ "def", "get_url_preview", "(", "self", ",", "url", ",", "ts", "=", "None", ")", ":", "params", "=", "{", "'url'", ":", "url", "}", "if", "ts", ":", "params", "[", "'ts'", "]", "=", "ts", "return", "self", ".", "_send", "(", "\"GET\"", ",", "\"\""...
Get preview for URL. Args: url (str): URL to get a preview ts (double): The preferred point in time to return a preview for. The server may return a newer version if it does not have the requested version available.
[ "Get", "preview", "for", "URL", "." ]
e734cce3ccd35f2d355c6a19a7a701033472498a
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/api.py#L851-L868
train