_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q229200 | MessageHandler.receive | train | 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 | {
"resource": ""
} |
q229201 | Proposer.propose_value | train | 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 | {
"resource": ""
} |
q229202 | Proposer.prepare | train | 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 | {
"resource": ""
} |
q229203 | Proposer.receive_nack | train | 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 | {
"resource": ""
} |
q229204 | Proposer.receive_promise | train | 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 | {
"resource": ""
} |
q229205 | Acceptor.receive_prepare | train | 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 | {
"resource": ""
} |
q229206 | Acceptor.receive_accept | train | 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 | {
"resource": ""
} |
q229207 | Learner.receive_accepted | train | 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 | {
"resource": ""
} |
q229208 | resolve_topic | train | 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 | {
"resource": ""
} |
q229209 | resolve_attr | train | 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 | {
"resource": ""
} |
q229210 | make_skip_list | train | 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 | {
"resource": ""
} |
q229211 | country_list_nlp | train | 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 | {
"resource": ""
} |
q229212 | make_country_nationality_list | train | 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 | {
"resource": ""
} |
q229213 | structure_results | train | 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 | {
"resource": ""
} |
q229214 | setup_es | train | 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 | {
"resource": ""
} |
q229215 | Geoparser._feature_country_mentions | train | 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 | {
"resource": ""
} |
q229216 | Geoparser.clean_entity | train | 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 | {
"resource": ""
} |
q229217 | Geoparser._feature_most_alternative | train | 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 | {
"resource": ""
} |
q229218 | Geoparser._feature_most_population | train | 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 | {
"resource": ""
} |
q229219 | Geoparser._feature_word_embedding | train | 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 | {
"resource": ""
} |
q229220 | Geoparser._feature_first_back | train | 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 | {
"resource": ""
} |
q229221 | Geoparser.is_country | train | 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 | {
"resource": ""
} |
q229222 | Geoparser.query_geonames | train | 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 | {
"resource": ""
} |
q229223 | Geoparser.query_geonames_country | train | 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 | {
"resource": ""
} |
q229224 | Geoparser.make_country_matrix | train | 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 | {
"resource": ""
} |
q229225 | Geoparser.infer_country | train | 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 | {
"resource": ""
} |
q229226 | Geoparser.get_admin1 | train | 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 | {
"resource": ""
} |
q229227 | Geoparser.ranker | train | 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 | {
"resource": ""
} |
q229228 | Geoparser.format_for_prodigy | train | 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 | {
"resource": ""
} |
q229229 | Geoparser.format_geonames | train | 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 | {
"resource": ""
} |
q229230 | Geoparser.clean_proced | train | 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 | {
"resource": ""
} |
q229231 | Geoparser.geoparse | train | 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 | {
"resource": ""
} |
q229232 | Geoparser.batch_geoparse | train | 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 | {
"resource": ""
} |
q229233 | entry_to_matrix | train | 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 | {
"resource": ""
} |
q229234 | FindMyiPhoneServiceManager.refresh_client | train | 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 | {
"resource": ""
} |
q229235 | AppleDevice.status | train | 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 | {
"resource": ""
} |
q229236 | AppleDevice.lost_device | train | 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 | {
"resource": ""
} |
q229237 | CalendarService.events | train | 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 | {
"resource": ""
} |
q229238 | CalendarService.calendars | train | 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 | {
"resource": ""
} |
q229239 | create_pickled_data | train | 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 | {
"resource": ""
} |
q229240 | ContactsService.refresh_client | train | 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 | {
"resource": ""
} |
q229241 | PyiCloudService.authenticate | train | 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 | {
"resource": ""
} |
q229242 | PyiCloudService.trusted_devices | train | 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 | {
"resource": ""
} |
q229243 | PyiCloudService.send_verification_code | train | 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 | {
"resource": ""
} |
q229244 | PyiCloudService.validate_verification_code | train | 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 | {
"resource": ""
} |
q229245 | PyiCloudService.devices | train | def devices(self):
""" Return all devices."""
service_root = self.webservices['findme']['url']
return FindMyiPhoneServiceManager(
service_root,
self.session,
self.params
) | python | {
"resource": ""
} |
q229246 | send | train | 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 | {
"resource": ""
} |
q229247 | imap | train | 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 | {
"resource": ""
} |
q229248 | Room.set_user_profile | train | 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 | {
"resource": ""
} |
q229249 | Room.display_name | train | 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 | {
"resource": ""
} |
q229250 | Room.send_text | train | def send_text(self, text):
"""Send a plain text message to the room."""
return self.client.api.send_message(self.room_id, text) | python | {
"resource": ""
} |
q229251 | Room.send_html | train | 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 | {
"resource": ""
} |
q229252 | Room.send_file | train | 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 | {
"resource": ""
} |
q229253 | Room.send_image | train | 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 | {
"resource": ""
} |
q229254 | Room.send_location | train | 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 | {
"resource": ""
} |
q229255 | Room.send_video | train | 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 | {
"resource": ""
} |
q229256 | Room.send_audio | train | 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 | {
"resource": ""
} |
q229257 | Room.redact_message | train | 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 | {
"resource": ""
} |
q229258 | Room.add_listener | train | 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 | {
"resource": ""
} |
q229259 | Room.remove_listener | train | def remove_listener(self, uid):
"""Remove listener with given uid."""
self.listeners[:] = (listener for listener in self.listeners
if listener['uid'] != uid) | python | {
"resource": ""
} |
q229260 | Room.add_ephemeral_listener | train | 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 | {
"resource": ""
} |
q229261 | Room.remove_ephemeral_listener | train | 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 | {
"resource": ""
} |
q229262 | Room.invite_user | train | 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 | {
"resource": ""
} |
q229263 | Room.kick_user | train | 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 | {
"resource": ""
} |
q229264 | Room.leave | train | 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 | {
"resource": ""
} |
q229265 | Room.update_room_name | train | 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 | {
"resource": ""
} |
q229266 | Room.set_room_name | train | 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 | {
"resource": ""
} |
q229267 | Room.send_state_event | train | 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 | {
"resource": ""
} |
q229268 | Room.update_room_topic | train | 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 | {
"resource": ""
} |
q229269 | Room.set_room_topic | train | 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 | {
"resource": ""
} |
q229270 | Room.update_aliases | train | 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 | {
"resource": ""
} |
q229271 | Room.add_room_alias | train | 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 | {
"resource": ""
} |
q229272 | Room.backfill_previous_messages | train | 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 | {
"resource": ""
} |
q229273 | Room.modify_user_power_levels | train | 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 | {
"resource": ""
} |
q229274 | Room.modify_required_power_levels | train | 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 | {
"resource": ""
} |
q229275 | Room.set_invite_only | train | 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 | {
"resource": ""
} |
q229276 | Room.set_guest_access | train | 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 | {
"resource": ""
} |
q229277 | Room.enable_encryption | train | 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 | {
"resource": ""
} |
q229278 | example | train | 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 | {
"resource": ""
} |
q229279 | main | train | 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 | {
"resource": ""
} |
q229280 | MatrixHttpApi.sync | train | 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 | {
"resource": ""
} |
q229281 | MatrixHttpApi.send_location | train | 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 | {
"resource": ""
} |
q229282 | MatrixHttpApi.kick_user | train | 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 | {
"resource": ""
} |
q229283 | MatrixHttpApi.media_download | train | 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 | {
"resource": ""
} |
q229284 | MatrixHttpApi.get_thumbnail | train | 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 | {
"resource": ""
} |
q229285 | MatrixHttpApi.get_url_preview | train | 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 | {
"resource": ""
} |
q229286 | MatrixHttpApi.get_room_id | train | def get_room_id(self, room_alias):
"""Get room id from its alias.
Args:
room_alias (str): The room alias name.
Returns:
Wanted room's id.
"""
content = self._send("GET", "/directory/room/{}".format(quote(room_alias)))
return content.get("room_id"... | python | {
"resource": ""
} |
q229287 | MatrixHttpApi.set_room_alias | train | def set_room_alias(self, room_id, room_alias):
"""Set alias to room id
Args:
room_id (str): The room id.
room_alias (str): The room wanted alias name.
"""
data = {
"room_id": room_id
}
return self._send("PUT", "/directory/room/{}".for... | python | {
"resource": ""
} |
q229288 | MatrixHttpApi.set_join_rule | train | def set_join_rule(self, room_id, join_rule):
"""Set the rule for users wishing to join the room.
Args:
room_id(str): The room to set the rules for.
join_rule(str): The chosen rule. One of: ["public", "knock",
"invite", "private"]
"""
content = {
... | python | {
"resource": ""
} |
q229289 | MatrixHttpApi.set_guest_access | train | def set_guest_access(self, room_id, guest_access):
"""Set the guest access policy of the room.
Args:
room_id(str): The room to set the rules for.
guest_access(str): Wether guests can join. One of: ["can_join",
"forbidden"]
"""
content = {
... | python | {
"resource": ""
} |
q229290 | MatrixHttpApi.update_device_info | train | def update_device_info(self, device_id, display_name):
"""Update the display name of a device.
Args:
device_id (str): The device ID of the device to update.
display_name (str): New display name for the device.
"""
content = {
"display_name": display_n... | python | {
"resource": ""
} |
q229291 | MatrixHttpApi.delete_device | train | def delete_device(self, auth_body, device_id):
"""Deletes the given device, and invalidates any access token associated with it.
NOTE: This endpoint uses the User-Interactive Authentication API.
Args:
auth_body (dict): Authentication params.
device_id (str): The device ... | python | {
"resource": ""
} |
q229292 | MatrixHttpApi.delete_devices | train | def delete_devices(self, auth_body, devices):
"""Bulk deletion of devices.
NOTE: This endpoint uses the User-Interactive Authentication API.
Args:
auth_body (dict): Authentication params.
devices (list): List of device ID"s to delete.
"""
content = {
... | python | {
"resource": ""
} |
q229293 | MatrixHttpApi.upload_keys | train | def upload_keys(self, device_keys=None, one_time_keys=None):
"""Publishes end-to-end encryption keys for the device.
Said device must be the one used when logging in.
Args:
device_keys (dict): Optional. Identity keys for the device. The required
keys are:
... | python | {
"resource": ""
} |
q229294 | MatrixHttpApi.query_keys | train | def query_keys(self, user_devices, timeout=None, token=None):
"""Query HS for public keys by user and optionally device.
Args:
user_devices (dict): The devices whose keys to download. Should be
formatted as <user_id>: [<device_ids>]. No device_ids indicates
a... | python | {
"resource": ""
} |
q229295 | MatrixHttpApi.claim_keys | train | def claim_keys(self, key_request, timeout=None):
"""Claims one-time keys for use in pre-key messages.
Args:
key_request (dict): The keys to be claimed. Format should be
<user_id>: { <device_id>: <algorithm> }.
timeout (int): Optional. The time (in milliseconds) t... | python | {
"resource": ""
} |
q229296 | MatrixHttpApi.key_changes | train | def key_changes(self, from_token, to_token):
"""Gets a list of users who have updated their device identity keys.
Args:
from_token (str): The desired start point of the list. Should be the
next_batch field from a response to an earlier call to /sync.
to_token (st... | python | {
"resource": ""
} |
q229297 | MatrixHttpApi.send_to_device | train | def send_to_device(self, event_type, messages, txn_id=None):
"""Sends send-to-device events to a set of client devices.
Args:
event_type (str): The type of event to send.
messages (dict): The messages to send. Format should be
<user_id>: {<device_id>: <event_cont... | python | {
"resource": ""
} |
q229298 | MatrixClient.register_with_password | train | def register_with_password(self, username, password):
""" Register for a new account on this HS.
Args:
username (str): Account username
password (str): Account password
Returns:
str: Access Token
Raises:
MatrixRequestError
"""
... | python | {
"resource": ""
} |
q229299 | MatrixClient.login_with_password_no_sync | train | def login_with_password_no_sync(self, username, password):
"""Deprecated. Use ``login`` with ``sync=False``.
Login to the homeserver.
Args:
username (str): Account username
password (str): Account password
Returns:
str: Access token
Raises:... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.