_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q240300
RestController._handle_get
train
def _handle_get(self, method, remainder, request=None): ''' Routes ``GET`` actions to the appropriate controller. ''' if request is None: self._raise_method_deprecation_warning(self._handle_get) # route to a get_all or get if no additional parts are available ...
python
{ "resource": "" }
q240301
RestController._handle_delete
train
def _handle_delete(self, method, remainder, request=None): ''' Routes ``DELETE`` actions to the appropriate controller. ''' if request is None: self._raise_method_deprecation_warning(self._handle_delete) if remainder: match = self._handle_custom_action(me...
python
{ "resource": "" }
q240302
RestController._handle_post
train
def _handle_post(self, method, remainder, request=None): ''' Routes ``POST`` requests. ''' if request is None: self._raise_method_deprecation_warning(self._handle_post) # check for custom POST/PUT requests if remainder: match = self._handle_custom...
python
{ "resource": "" }
q240303
format_line_context
train
def format_line_context(filename, lineno, context=10): ''' Formats the the line context for error rendering. :param filename: the location of the file, within which the error occurred :param lineno: the offending line number :param context: number of lines of code to display before and after the ...
python
{ "resource": "" }
q240304
ExtraNamespace.make_ns
train
def make_ns(self, ns): ''' Returns the `lazily` created template namespace. ''' if self.namespace: val = {} val.update(self.namespace) val.update(ns) return val else: return ns
python
{ "resource": "" }
q240305
RendererFactory.get
train
def get(self, name, template_path): ''' Returns the renderer object. :param name: name of the requested renderer :param template_path: path to the template ''' if name not in self._renderers: cls = self._renderer_classes.get(name) if cls is None: ...
python
{ "resource": "" }
q240306
GenericJSON.default
train
def default(self, obj): ''' Converts an object and returns a ``JSON``-friendly structure. :param obj: object or structure to be converted into a ``JSON``-ifiable structure Considers the following special cases in order: * object has a callable __json__() at...
python
{ "resource": "" }
q240307
getargspec
train
def getargspec(method): """ Drill through layers of decorators attempting to locate the actual argspec for a method. """ argspec = _getargspec(method) args = argspec[0] if args and args[0] == 'self': return argspec if hasattr(method, '__func__'): method = method.__func__...
python
{ "resource": "" }
q240308
gunicorn_run
train
def gunicorn_run(): """ The ``gunicorn_pecan`` command for launching ``pecan`` applications """ try: from gunicorn.app.wsgiapp import WSGIApplication except ImportError as exc: args = exc.args arg0 = args[0] if args else '' arg0 += ' (are you sure `gunicorn` is instal...
python
{ "resource": "" }
q240309
ServeCommand.serve
train
def serve(self, app, conf): """ A very simple approach for a WSGI server. """ if self.args.reload: try: self.watch_and_spawn(conf) except ImportError: print('The `--reload` option requires `watchdog` to be ' '...
python
{ "resource": "" }
q240310
PecanWSGIRequestHandler.log_message
train
def log_message(self, format, *args): """ overrides the ``log_message`` method from the wsgiref server so that normal logging works with whatever configuration the application has been set to. Levels are inferred from the HTTP status code, 4XX codes are treated as warnin...
python
{ "resource": "" }
q240311
expose
train
def expose(template=None, generic=False, route=None, **kw): ''' Decorator used to flag controller methods as being "exposed" for access via HTTP, and to configure that access. :param template: The path to a template, relative to the base template d...
python
{ "resource": "" }
q240312
Time.to_dict
train
def to_dict(self): """Returns the Time instance as a usable dictionary for craftai""" return { "timestamp": int(self.timestamp), "timezone": self.timezone, "time_of_day": self.time_of_day, "day_of_week": self.day_of_week, "day_of_month": self.day_of_month, "month_of_year": se...
python
{ "resource": "" }
q240313
Time.timestamp_from_datetime
train
def timestamp_from_datetime(date_time): """Returns POSIX timestamp as float""" if date_time.tzinfo is None: return time.mktime((date_time.year, date_time.month, date_time.day, date_time.hour, date_time.minute, date_time.second, -1, -1, -1)) + date_time.m...
python
{ "resource": "" }
q240314
CraftAIClient.create_agent
train
def create_agent(self, configuration, agent_id=""): """Create an agent. :param dict configuration: Form given by the craftai documentation. :param str agent_id: Optional. The id of the agent to create. It must be an str containing only characters in "a-zA-Z0-9_-" and must be between 1 and 36 charac...
python
{ "resource": "" }
q240315
CraftAIClient.delete_agent
train
def delete_agent(self, agent_id): """Delete an agent. :param str agent_id: The id of the agent to delete. It must be an str containing only characters in "a-zA-Z0-9_-" and must be between 1 and 36 characters. :return: agent deleted. :rtype: dict. """ # Raises an error when agent_id is ...
python
{ "resource": "" }
q240316
CraftAIClient.delete_agents_bulk
train
def delete_agents_bulk(self, payload): """Delete a group of agents :param list payload: Contains the informations to delete the agents. It's in the form [{"id": agent_id}]. With id an str containing only characters in "a-zA-Z0-9_-" and must be between 1 and 36 characters. :return: the list of ...
python
{ "resource": "" }
q240317
CraftAIClient.add_operations
train
def add_operations(self, agent_id, operations): """Add operations to an agent. :param str agent_id: The id of the agent to delete. It must be an str containing only characters in "a-zA-Z0-9_-" and must be between 1 and 36 characters. It must referenced an existing agent. :param list operations: Con...
python
{ "resource": "" }
q240318
CraftAIClient._add_operations_bulk
train
def _add_operations_bulk(self, chunked_data): """Tool for the function add_operations_bulk. It send the requests to add the operations to the agents. :param list chunked_data: list of list of the agents and their operations to add. Each chunk can be requested at the same time. :return: list of age...
python
{ "resource": "" }
q240319
CraftAIClient.add_operations_bulk
train
def add_operations_bulk(self, payload): """Add operations to a group of agents. :param list payload: contains the informations necessary for the action. It's in the form [{"id": agent_id, "operations": operations}] With id that is an str containing only characters in "a-zA-Z0-9_-" and must be betwe...
python
{ "resource": "" }
q240320
CraftAIClient._get_decision_tree
train
def _get_decision_tree(self, agent_id, timestamp, version): """Tool for the function get_decision_tree. :param str agent_id: the id of the agent to get the tree. It must be an str containing only characters in "a-zA-Z0-9_-" and must be between 1 and 36 characters. :param int timestamp: Optional. Th...
python
{ "resource": "" }
q240321
CraftAIClient.get_decision_tree
train
def get_decision_tree(self, agent_id, timestamp=None, version=DEFAULT_DECISION_TREE_VERSION): """Get decision tree. :param str agent_id: the id of the agent to get the tree. It must be an str containing only characters in "a-zA-Z0-9_-" and must be between 1 and 36 characters. :param int timestamp: ...
python
{ "resource": "" }
q240322
CraftAIClient._get_decision_trees_bulk
train
def _get_decision_trees_bulk(self, payload, valid_indices, invalid_indices, invalid_dts): """Tool for the function get_decision_trees_bulk. :param list payload: contains the informations necessary for getting the trees. Its form is the same than for the function. get_decision_trees_bulk. :param lis...
python
{ "resource": "" }
q240323
CraftAIClient.get_decision_trees_bulk
train
def get_decision_trees_bulk(self, payload, version=DEFAULT_DECISION_TREE_VERSION): """Get a group of decision trees. :param list payload: contains the informations necessary for getting the trees. It's in the form [{"id": agent_id, "timestamp": timestamp}] With id a str containing only characters in "a...
python
{ "resource": "" }
q240324
CraftAIClient._decode_response
train
def _decode_response(response): """Decode the response of a request. :param response: response of a request. :return: decoded response. :raise Error: Raise the error given by the request. """ status_code = response.status_code message = "Status code " + str(status_code) try: me...
python
{ "resource": "" }
q240325
CraftAIClient._decode_response_bulk
train
def _decode_response_bulk(response_bulk): """Decode the response of each agent given by a bulk function. :param list response_bulk: list of dictionnary which represents the response for an agent. :return: decoded response. :rtype: list of dict. """ resp = [] for response in response_bu...
python
{ "resource": "" }
q240326
CraftAIClient._get_error_from_status
train
def _get_error_from_status(status_code, message): """Give the error corresponding to the status code. :param int status_code: status code of the response to a request. :param str message: error message given by the response. :return: error corresponding to the status code. :rtype: Error. "...
python
{ "resource": "" }
q240327
CraftAIClient._check_agent_id
train
def _check_agent_id(agent_id): """Checks that the given agent_id is a valid non-empty string. :param str agent_id: agent id to check. :raise CraftAiBadRequestError: If the given agent_id is not of type string or if it is an empty string. """ if (not isinstance(agent_id, six.string_types) or ...
python
{ "resource": "" }
q240328
CraftAIClient._check_agent_id_bulk
train
def _check_agent_id_bulk(self, payload): """Checks that all the given agent ids are valid non-empty strings and if the agents are serializable. :param list payload: list of dictionnary which represents an agent. :return: list of the agents with valid ids, list of the agents with invalid ids, list ...
python
{ "resource": "" }
q240329
CraftAIClient._recreate_list_with_indices
train
def _recreate_list_with_indices(indices1, values1, indices2, values2): """Create a list in the right order. :param list indices1: contains the list of indices corresponding to the values in values1. :param list values1: contains the first list of values. :param list indices2: contains the list of i...
python
{ "resource": "" }
q240330
CraftAIClient._create_and_send_json_bulk
train
def _create_and_send_json_bulk(self, payload, req_url, request_type="POST"): """Create a json, do a request to the URL and process the response. :param list payload: contains the informations necessary for the action. It's a list of dictionnary. :param str req_url: URL to request with the payload. ...
python
{ "resource": "" }
q240331
construct_ctcp
train
def construct_ctcp(*parts): """ Construct CTCP message. """ message = ' '.join(parts) message = message.replace('\0', CTCP_ESCAPE_CHAR + '0') message = message.replace('\n', CTCP_ESCAPE_CHAR + 'n') message = message.replace('\r', CTCP_ESCAPE_CHAR + 'r') message = message.replace(CTCP_ESCAPE_CHAR...
python
{ "resource": "" }
q240332
parse_ctcp
train
def parse_ctcp(query): """ Strip and de-quote CTCP messages. """ query = query.strip(CTCP_DELIMITER) query = query.replace(CTCP_ESCAPE_CHAR + '0', '\0') query = query.replace(CTCP_ESCAPE_CHAR + 'n', '\n') query = query.replace(CTCP_ESCAPE_CHAR + 'r', '\r') query = query.replace(CTCP_ESCAPE_CHAR ...
python
{ "resource": "" }
q240333
CTCPSupport.on_ctcp_version
train
async def on_ctcp_version(self, by, target, contents): """ Built-in CTCP version as some networks seem to require it. """ import pydle version = '{name} v{ver}'.format(name=pydle.__name__, ver=pydle.__version__) self.ctcp_reply(by, 'VERSION', version)
python
{ "resource": "" }
q240334
CTCPSupport.ctcp
train
async def ctcp(self, target, query, contents=None): """ Send a CTCP request to a target. """ if self.is_channel(target) and not self.in_channel(target): raise client.NotInChannel(target) await self.message(target, construct_ctcp(query, contents))
python
{ "resource": "" }
q240335
CTCPSupport.ctcp_reply
train
async def ctcp_reply(self, target, query, response): """ Send a CTCP reply to a target. """ if self.is_channel(target) and not self.in_channel(target): raise client.NotInChannel(target) await self.notice(target, construct_ctcp(query, response))
python
{ "resource": "" }
q240336
CTCPSupport.on_raw_privmsg
train
async def on_raw_privmsg(self, message): """ Modify PRIVMSG to redirect CTCP messages. """ nick, metadata = self._parse_user(message.source) target, msg = message.params if is_ctcp(msg): self._sync_user(nick, metadata) type, contents = parse_ctcp(msg) ...
python
{ "resource": "" }
q240337
CTCPSupport.on_raw_notice
train
async def on_raw_notice(self, message): """ Modify NOTICE to redirect CTCP messages. """ nick, metadata = self._parse_user(message.source) target, msg = message.params if is_ctcp(msg): self._sync_user(nick, metadata) type, response = parse_ctcp(msg) ...
python
{ "resource": "" }
q240338
CapabilityNegotiationSupport._register
train
async def _register(self): """ Hijack registration to send a CAP LS first. """ if self.registered: self.logger.debug("skipping cap registration, already registered!") return # Ask server to list capabilities. await self.rawmsg('CAP', 'LS', '302') # Regis...
python
{ "resource": "" }
q240339
CapabilityNegotiationSupport._capability_negotiated
train
async def _capability_negotiated(self, capab): """ Mark capability as negotiated, and end negotiation if we're done. """ self._capabilities_negotiating.discard(capab) if not self._capabilities_requested and not self._capabilities_negotiating: await self.rawmsg('CAP', 'END')
python
{ "resource": "" }
q240340
CapabilityNegotiationSupport.on_raw_cap
train
async def on_raw_cap(self, message): """ Handle CAP message. """ target, subcommand = message.params[:2] params = message.params[2:] # Call handler. attr = 'on_raw_cap_' + pydle.protocol.identifierify(subcommand) if hasattr(self, attr): await getattr(self, at...
python
{ "resource": "" }
q240341
CapabilityNegotiationSupport.on_raw_cap_ls
train
async def on_raw_cap_ls(self, params): """ Update capability mapping. Request capabilities. """ to_request = set() for capab in params[0].split(): capab, value = self._capability_normalize(capab) # Only process new capabilities. if capab in self._capabilitie...
python
{ "resource": "" }
q240342
CapabilityNegotiationSupport.on_raw_cap_list
train
async def on_raw_cap_list(self, params): """ Update active capabilities. """ self._capabilities = { capab: False for capab in self._capabilities } for capab in params[0].split(): capab, value = self._capability_normalize(capab) self._capabilities[capab] = value if value ...
python
{ "resource": "" }
q240343
CapabilityNegotiationSupport.on_raw_410
train
async def on_raw_410(self, message): """ Unknown CAP subcommand or CAP error. Force-end negotiations. """ self.logger.error('Server sent "Unknown CAP subcommand: %s". Aborting capability negotiation.', message.params[0]) self._capabilities_requested = set() self._capabilities_negotiatin...
python
{ "resource": "" }
q240344
SASLSupport._sasl_start
train
async def _sasl_start(self, mechanism): """ Initiate SASL authentication. """ # The rest will be handled in on_raw_authenticate()/_sasl_respond(). await self.rawmsg('AUTHENTICATE', mechanism) # create a partial, required for our callback to get the kwarg _sasl_partial = partial(s...
python
{ "resource": "" }
q240345
SASLSupport._sasl_abort
train
async def _sasl_abort(self, timeout=False): """ Abort SASL authentication. """ if timeout: self.logger.error('SASL authentication timed out: aborting.') else: self.logger.error('SASL authentication aborted.') if self._sasl_timer: self._sasl_timer.canc...
python
{ "resource": "" }
q240346
SASLSupport._sasl_end
train
async def _sasl_end(self): """ Finalize SASL authentication. """ if self._sasl_timer: self._sasl_timer.cancel() self._sasl_timer = None await self._capability_negotiated('sasl')
python
{ "resource": "" }
q240347
SASLSupport._sasl_respond
train
async def _sasl_respond(self): """ Respond to SASL challenge with response. """ # Formulate a response. if self._sasl_client: try: response = self._sasl_client.process(self._sasl_challenge) except puresasl.SASLError: response = None ...
python
{ "resource": "" }
q240348
SASLSupport.on_capability_sasl_available
train
async def on_capability_sasl_available(self, value): """ Check whether or not SASL is available. """ if value: self._sasl_mechanisms = value.upper().split(',') else: self._sasl_mechanisms = None if self.sasl_mechanism == 'EXTERNAL' or (self.sasl_username and self...
python
{ "resource": "" }
q240349
SASLSupport.on_capability_sasl_enabled
train
async def on_capability_sasl_enabled(self): """ Start SASL authentication. """ if self.sasl_mechanism: if self._sasl_mechanisms and self.sasl_mechanism not in self._sasl_mechanisms: self.logger.warning('Requested SASL mechanism is not in server mechanism list: aborting SASL a...
python
{ "resource": "" }
q240350
SASLSupport.on_raw_authenticate
train
async def on_raw_authenticate(self, message): """ Received part of the authentication challenge. """ # Cancel timeout timer. if self._sasl_timer: self._sasl_timer.cancel() self._sasl_timer = None # Add response data. response = ' '.join(message.params) ...
python
{ "resource": "" }
q240351
MonitoringSupport.monitor
train
def monitor(self, target): """ Start monitoring the online status of a user. Returns whether or not the server supports monitoring. """ if 'monitor-notify' in self._capabilities and not self.is_monitoring(target): yield from self.rawmsg('MONITOR', '+', target) self._monitoring.ad...
python
{ "resource": "" }
q240352
MonitoringSupport.unmonitor
train
def unmonitor(self, target): """ Stop monitoring the online status of a user. Returns whether or not the server supports monitoring. """ if 'monitor-notify' in self._capabilities and self.is_monitoring(target): yield from self.rawmsg('MONITOR', '-', target) self._monitoring.remov...
python
{ "resource": "" }
q240353
MonitoringSupport.on_raw_730
train
async def on_raw_730(self, message): """ Someone we are monitoring just came online. """ for nick in message.params[1].split(','): self._create_user(nick) await self.on_user_online(nickname)
python
{ "resource": "" }
q240354
MonitoringSupport.on_raw_731
train
async def on_raw_731(self, message): """ Someone we are monitoring got offline. """ for nick in message.params[1].split(','): self._destroy_user(nick, monitor_override=True) await self.on_user_offline(nickname)
python
{ "resource": "" }
q240355
IRCv3_1Support.on_raw_account
train
async def on_raw_account(self, message): """ Changes in the associated account for a nickname. """ if not self._capabilities.get('account-notify', False): return nick, metadata = self._parse_user(message.source) account = message.params[0] if nick not in self.users:...
python
{ "resource": "" }
q240356
IRCv3_1Support.on_raw_away
train
async def on_raw_away(self, message): """ Process AWAY messages. """ if 'away-notify' not in self._capabilities or not self._capabilities['away-notify']: return nick, metadata = self._parse_user(message.source) if nick not in self.users: return self._syn...
python
{ "resource": "" }
q240357
IRCv3_1Support.on_raw_join
train
async def on_raw_join(self, message): """ Process extended JOIN messages. """ if 'extended-join' in self._capabilities and self._capabilities['extended-join']: nick, metadata = self._parse_user(message.source) channels, account, realname = message.params self._sync_u...
python
{ "resource": "" }
q240358
MetadataSupport.on_raw_metadata
train
async def on_raw_metadata(self, message): """ Metadata event. """ target, targetmeta = self._parse_user(message.params[0]) key, visibility, value = message.params[1:4] if visibility == VISIBLITY_ALL: visibility = None if target in self.users: self._sync_u...
python
{ "resource": "" }
q240359
MetadataSupport.on_raw_762
train
async def on_raw_762(self, message): """ End of metadata. """ # No way to figure out whose query this belongs to, so make a best guess # it was the first one. if not self._metadata_queue: return nickname = self._metadata_queue.pop() future = self._pending['me...
python
{ "resource": "" }
q240360
MetadataSupport.on_raw_765
train
async def on_raw_765(self, message): """ Invalid metadata target. """ target, targetmeta = self._parse_user(message.params[0]) if target not in self._pending['metadata']: return if target in self.users: self._sync_user(target, targetmeta) self._metadata_...
python
{ "resource": "" }
q240361
Connection.connect
train
async def connect(self): """ Connect to target. """ self.tls_context = None if self.tls: self.tls_context = self.create_tls_context() (self.reader, self.writer) = await asyncio.open_connection( host=self.hostname, port=self.port, local_ad...
python
{ "resource": "" }
q240362
Connection.create_tls_context
train
def create_tls_context(self): """ Transform our regular socket into a TLS socket. """ # Create context manually, as we're going to set our own options. tls_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) # Load client/server certificate. if self.tls_certificate_file: t...
python
{ "resource": "" }
q240363
Connection.disconnect
train
async def disconnect(self): """ Disconnect from target. """ if not self.connected: return self.writer.close() self.reader = None self.writer = None
python
{ "resource": "" }
q240364
Connection.send
train
async def send(self, data): """ Add data to send queue. """ self.writer.write(data) await self.writer.drain()
python
{ "resource": "" }
q240365
identifierify
train
def identifierify(name): """ Clean up name so it works for a Python identifier. """ name = name.lower() name = re.sub('[^a-z0-9]', '_', name) return name
python
{ "resource": "" }
q240366
RFC1459Support._register
train
async def _register(self): """ Perform IRC connection registration. """ if self.registered: return self._registration_attempts += 1 # Don't throttle during registration, most ircds don't care for flooding during registration, # and it might speed it up significantly....
python
{ "resource": "" }
q240367
RFC1459Support._registration_completed
train
async def _registration_completed(self, message): """ We're connected and registered. Receive proper nickname and emit fake NICK message. """ if not self.registered: # Re-enable throttling. self.registered = True self.connection.throttle = True target = m...
python
{ "resource": "" }
q240368
RFC1459Support._has_message
train
def _has_message(self): """ Whether or not we have messages available for processing. """ sep = protocol.MINIMAL_LINE_SEPARATOR.encode(self.encoding) return sep in self._receive_buffer
python
{ "resource": "" }
q240369
RFC1459Support.join
train
async def join(self, channel, password=None): """ Join channel, optionally with password. """ if self.in_channel(channel): raise AlreadyInChannel(channel) if password: await self.rawmsg('JOIN', channel, password) else: await self.rawmsg('JOIN', channe...
python
{ "resource": "" }
q240370
RFC1459Support.part
train
async def part(self, channel, message=None): """ Leave channel, optionally with message. """ if not self.in_channel(channel): raise NotInChannel(channel) # Message seems to be an extension to the spec. if message: await self.rawmsg('PART', channel, message) ...
python
{ "resource": "" }
q240371
RFC1459Support.kick
train
async def kick(self, channel, target, reason=None): """ Kick user from channel. """ if not self.in_channel(channel): raise NotInChannel(channel) if reason: await self.rawmsg('KICK', channel, target, reason) else: await self.rawmsg('KICK', channel, tar...
python
{ "resource": "" }
q240372
RFC1459Support.unban
train
async def unban(self, channel, target, range=0): """ Unban user from channel. Target can be either a user or a host. See ban documentation for the range parameter. """ if target in self.users: host = self.users[target]['hostname'] else: host = targ...
python
{ "resource": "" }
q240373
RFC1459Support.kickban
train
async def kickban(self, channel, target, reason=None, range=0): """ Kick and ban user from channel. """ await self.ban(channel, target, range) await self.kick(channel, target, reason)
python
{ "resource": "" }
q240374
RFC1459Support.quit
train
async def quit(self, message=None): """ Quit network. """ if message is None: message = self.DEFAULT_QUIT_MESSAGE await self.rawmsg('QUIT', message) await self.disconnect(expected=True)
python
{ "resource": "" }
q240375
RFC1459Support.cycle
train
async def cycle(self, channel): """ Rejoin channel. """ if not self.in_channel(channel): raise NotInChannel(channel) password = self.channels[channel]['password'] await self.part(channel) await self.join(channel, password)
python
{ "resource": "" }
q240376
RFC1459Support.message
train
async def message(self, target, message): """ Message channel or user. """ hostmask = self._format_user_mask(self.nickname) # Leeway. chunklen = protocol.MESSAGE_LENGTH_LIMIT - len( '{hostmask} PRIVMSG {target} :'.format(hostmask=hostmask, target=target)) - 25 for li...
python
{ "resource": "" }
q240377
RFC1459Support.set_topic
train
async def set_topic(self, channel, topic): """ Set topic on channel. Users should only rely on the topic actually being changed when receiving an on_topic_change callback. """ if not self.is_channel(channel): raise ValueError('Not a channel: {}'.format(channel)) ...
python
{ "resource": "" }
q240378
RFC1459Support.on_raw_error
train
async def on_raw_error(self, message): """ Server encountered an error and will now close the connection. """ error = protocol.ServerError(' '.join(message.params)) await self.on_data_error(error)
python
{ "resource": "" }
q240379
RFC1459Support.on_raw_invite
train
async def on_raw_invite(self, message): """ INVITE command. """ nick, metadata = self._parse_user(message.source) self._sync_user(nick, metadata) target, channel = message.params target, metadata = self._parse_user(target) if self.is_same_nick(self.nickname, target): ...
python
{ "resource": "" }
q240380
RFC1459Support.on_raw_join
train
async def on_raw_join(self, message): """ JOIN command. """ nick, metadata = self._parse_user(message.source) self._sync_user(nick, metadata) channels = message.params[0].split(',') if self.is_same_nick(self.nickname, nick): # Add to our channel list, we joined here....
python
{ "resource": "" }
q240381
RFC1459Support.on_raw_kick
train
async def on_raw_kick(self, message): """ KICK command. """ kicker, kickermeta = self._parse_user(message.source) self._sync_user(kicker, kickermeta) if len(message.params) > 2: channels, targets, reason = message.params else: channels, targets = message....
python
{ "resource": "" }
q240382
RFC1459Support.on_raw_kill
train
async def on_raw_kill(self, message): """ KILL command. """ by, bymeta = self._parse_user(message.source) target, targetmeta = self._parse_user(message.params[0]) reason = message.params[1] self._sync_user(target, targetmeta) if by in self.users: self._sync_u...
python
{ "resource": "" }
q240383
RFC1459Support.on_raw_mode
train
async def on_raw_mode(self, message): """ MODE command. """ nick, metadata = self._parse_user(message.source) target, modes = message.params[0], message.params[1:] self._sync_user(nick, metadata) if self.is_channel(target): if self.in_channel(target): ...
python
{ "resource": "" }
q240384
RFC1459Support.on_raw_nick
train
async def on_raw_nick(self, message): """ NICK command. """ nick, metadata = self._parse_user(message.source) new = message.params[0] self._sync_user(nick, metadata) # Acknowledgement of nickname change: set it internally, too. # Alternatively, we were force nick-changed...
python
{ "resource": "" }
q240385
RFC1459Support.on_raw_notice
train
async def on_raw_notice(self, message): """ NOTICE command. """ nick, metadata = self._parse_user(message.source) target, message = message.params self._sync_user(nick, metadata) await self.on_notice(target, nick, message) if self.is_channel(target): await s...
python
{ "resource": "" }
q240386
RFC1459Support.on_raw_part
train
async def on_raw_part(self, message): """ PART command. """ nick, metadata = self._parse_user(message.source) channels = message.params[0].split(',') if len(message.params) > 1: reason = message.params[1] else: reason = None self._sync_user(nick, ...
python
{ "resource": "" }
q240387
RFC1459Support.on_raw_privmsg
train
async def on_raw_privmsg(self, message): """ PRIVMSG command. """ nick, metadata = self._parse_user(message.source) target, message = message.params self._sync_user(nick, metadata) await self.on_message(target, nick, message) if self.is_channel(target): awai...
python
{ "resource": "" }
q240388
RFC1459Support.on_raw_quit
train
async def on_raw_quit(self, message): """ QUIT command. """ nick, metadata = self._parse_user(message.source) self._sync_user(nick, metadata) if message.params: reason = message.params[0] else: reason = None await self.on_quit(nick, reason) ...
python
{ "resource": "" }
q240389
RFC1459Support.on_raw_topic
train
async def on_raw_topic(self, message): """ TOPIC command. """ setter, settermeta = self._parse_user(message.source) target, topic = message.params self._sync_user(setter, settermeta) # Update topic in our own channel list. if self.in_channel(target): self.ch...
python
{ "resource": "" }
q240390
RFC1459Support.on_raw_004
train
async def on_raw_004(self, message): """ Basic server information. """ target, hostname, ircd, user_modes, channel_modes = message.params[:5] # Set valid channel and user modes. self._channel_modes = set(channel_modes) self._user_modes = set(user_modes)
python
{ "resource": "" }
q240391
RFC1459Support.on_raw_301
train
async def on_raw_301(self, message): """ User is away. """ target, nickname, message = message.params info = { 'away': True, 'away_message': message } if nickname in self.users: self._sync_user(nickname, info) if nickname in self._pend...
python
{ "resource": "" }
q240392
RFC1459Support.on_raw_311
train
async def on_raw_311(self, message): """ WHOIS user info. """ target, nickname, username, hostname, _, realname = message.params info = { 'username': username, 'hostname': hostname, 'realname': realname } self._sync_user(nickname, info) ...
python
{ "resource": "" }
q240393
RFC1459Support.on_raw_312
train
async def on_raw_312(self, message): """ WHOIS server info. """ target, nickname, server, serverinfo = message.params info = { 'server': server, 'server_info': serverinfo } if nickname in self._pending['whois']: self._whois_info[nickname].upda...
python
{ "resource": "" }
q240394
RFC1459Support.on_raw_313
train
async def on_raw_313(self, message): """ WHOIS operator info. """ target, nickname = message.params[:2] info = { 'oper': True } if nickname in self._pending['whois']: self._whois_info[nickname].update(info)
python
{ "resource": "" }
q240395
RFC1459Support.on_raw_314
train
async def on_raw_314(self, message): """ WHOWAS user info. """ target, nickname, username, hostname, _, realname = message.params info = { 'username': username, 'hostname': hostname, 'realname': realname } if nickname in self._pending['whowas'...
python
{ "resource": "" }
q240396
RFC1459Support.on_raw_317
train
async def on_raw_317(self, message): """ WHOIS idle time. """ target, nickname, idle_time = message.params[:3] info = { 'idle': int(idle_time), } if nickname in self._pending['whois']: self._whois_info[nickname].update(info)
python
{ "resource": "" }
q240397
RFC1459Support.on_raw_319
train
async def on_raw_319(self, message): """ WHOIS active channels. """ target, nickname, channels = message.params[:3] channels = {channel.lstrip() for channel in channels.strip().split(' ')} info = { 'channels': channels } if nickname in self._pending['whois']:...
python
{ "resource": "" }
q240398
RFC1459Support.on_raw_324
train
async def on_raw_324(self, message): """ Channel mode. """ target, channel = message.params[:2] modes = message.params[2:] if not self.in_channel(channel): return self.channels[channel]['modes'] = self._parse_channel_modes(channel, modes)
python
{ "resource": "" }
q240399
RFC1459Support.on_raw_329
train
async def on_raw_329(self, message): """ Channel creation time. """ target, channel, timestamp = message.params if not self.in_channel(channel): return self.channels[channel]['created'] = datetime.datetime.fromtimestamp(int(timestamp))
python
{ "resource": "" }