_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q16400
DeviceServer.request_restart
train
def request_restart(self, req, msg): """Restart the device server. Returns ------- success : {'ok', 'fail'} Whether scheduling the restart succeeded. Examples -------- :: ?restart !restart ok """ if self._res...
python
{ "resource": "" }
q16401
DeviceServer.request_client_list
train
def request_client_list(self, req, msg): """Request the list of connected clients. The list of clients is sent as a sequence of #client-list informs. Informs ------- addr : str The address of the client as host:port with host in dotted quad notation. If ...
python
{ "resource": "" }
q16402
DeviceServer.request_version_list
train
def request_version_list(self, req, msg): """Request the list of versions of roles and subcomponents. Informs ------- name : str Name of the role or component. version : str A string identifying the version of the component. Individual compone...
python
{ "resource": "" }
q16403
DeviceServer.request_sensor_list
train
def request_sensor_list(self, req, msg): """Request the list of sensors. The list of sensors is sent as a sequence of #sensor-list informs. Parameters ---------- name : str, optional Name of the sensor to list (the default is to list all sensors). If nam...
python
{ "resource": "" }
q16404
DeviceServer.request_sensor_value
train
def request_sensor_value(self, req, msg): """Request the value of a sensor or sensors. A list of sensor values as a sequence of #sensor-value informs. Parameters ---------- name : str, optional Name of the sensor to poll (the default is to send values for all ...
python
{ "resource": "" }
q16405
DeviceServer.request_sensor_sampling
train
def request_sensor_sampling(self, req, msg): """Configure or query the way a sensor is sampled. Sampled values are reported asynchronously using the #sensor-status message. Parameters ---------- name : str Name of the sensor whose sampling strategy to query ...
python
{ "resource": "" }
q16406
DeviceServer.request_sensor_sampling_clear
train
def request_sensor_sampling_clear(self, req): """Set all sampling strategies for this client to none. Returns ------- success : {'ok', 'fail'} Whether sending the list of devices succeeded. Examples -------- ?sensor-sampling-clear !sensor-sam...
python
{ "resource": "" }
q16407
DeviceLogger.level_name
train
def level_name(self, level=None): """Return the name of the given level value. If level is None, return the name of the current level. Parameters ---------- level : logging level constant The logging level constant whose name to retrieve. Returns --...
python
{ "resource": "" }
q16408
DeviceLogger.level_from_name
train
def level_from_name(self, level_name): """Return the level constant for a given name. If the *level_name* is not known, raise a ValueError. Parameters ---------- level_name : str The logging level name whose logging level constant to retrieve. R...
python
{ "resource": "" }
q16409
DeviceLogger.set_log_level
train
def set_log_level(self, level): """Set the logging level. Parameters ---------- level : logging level constant The value to set the logging level to. """ self._log_level = level if self._python_logger: try: level = self.PY...
python
{ "resource": "" }
q16410
DeviceLogger.log
train
def log(self, level, msg, *args, **kwargs): """Log a message and inform all clients. Parameters ---------- level : logging level constant The level to log the message at. msg : str The text format for the log message. args : list of objects ...
python
{ "resource": "" }
q16411
DeviceLogger.warn
train
def warn(self, msg, *args, **kwargs): """Log an warning message.""" self.log(self.WARN, msg, *args, **kwargs)
python
{ "resource": "" }
q16412
DeviceLogger.log_to_python
train
def log_to_python(cls, logger, msg): """Log a KATCP logging message to a Python logger. Parameters ---------- logger : logging.Logger object The Python logger to log the given message to. msg : Message object The #log message to create a log entry from. ...
python
{ "resource": "" }
q16413
DeviceExampleServer.request_echo
train
def request_echo(self, sock, msg): """Echo the arguments of the message sent.""" return katcp.Message.reply(msg.name, "ok", *msg.arguments)
python
{ "resource": "" }
q16414
log_future_exceptions
train
def log_future_exceptions(logger, f, ignore=()): """Log any exceptions set to a future Parameters ---------- logger : logging.Logger instance logger.exception(...) is called if the future resolves with an exception f : Future object Future to be monitored for exceptions ignore :...
python
{ "resource": "" }
q16415
steal_docstring_from
train
def steal_docstring_from(obj): """Decorator that lets you steal a docstring from another object Example ------- :: @steal_docstring_from(superclass.meth) def meth(self, arg): "Extra subclass documentation" pass In this case the docstring of the new 'meth' will be copied f...
python
{ "resource": "" }
q16416
hashable_identity
train
def hashable_identity(obj): """Generate a hashable ID that is stable for methods etc Approach borrowed from blinker. Why it matters: see e.g. http://stackoverflow.com/questions/13348031/python-bound-and-unbound-method-object """ if hasattr(obj, '__func__'): return (id(obj.__func__), id(obj...
python
{ "resource": "" }
q16417
until_any
train
def until_any(*futures, **kwargs): """Return a future that resolves when any of the passed futures resolves. Resolves with the value yielded by the first future to resolve. Note, this will only work with tornado futures. """ timeout = kwargs.get('timeout', None) ioloop = kwargs.get('ioloop', ...
python
{ "resource": "" }
q16418
future_timeout_manager
train
def future_timeout_manager(timeout=None, ioloop=None): """Create Helper function for yielding with a cumulative timeout if required Keeps track of time over multiple timeout calls so that a single timeout can be placed over multiple operations. Parameters ---------- timeout : int or None ...
python
{ "resource": "" }
q16419
until_some
train
def until_some(*args, **kwargs): """Return a future that resolves when some of the passed futures resolve. The futures can be passed as either a sequence of *args* or a dict of *kwargs* (but not both). Some additional keyword arguments are supported, as described below. Once a specified number of under...
python
{ "resource": "" }
q16420
Message.format_argument
train
def format_argument(self, arg): """Format a Message argument to a string""" if isinstance(arg, float): return repr(arg) elif isinstance(arg, bool): return str(int(arg)) else: try: return str(arg) except UnicodeEncodeError: ...
python
{ "resource": "" }
q16421
Message.reply_ok
train
def reply_ok(self): """Return True if this is a reply and its first argument is 'ok'.""" return (self.mtype == self.REPLY and self.arguments and self.arguments[0] == self.OK)
python
{ "resource": "" }
q16422
Message.request
train
def request(cls, name, *args, **kwargs): """Helper method for creating request messages. Parameters ---------- name : str The name of the message. args : list of strings The message arguments. Keyword arguments ----------------- m...
python
{ "resource": "" }
q16423
Message.reply
train
def reply(cls, name, *args, **kwargs): """Helper method for creating reply messages. Parameters ---------- name : str The name of the message. args : list of strings The message arguments. Keyword Arguments ----------------- mid :...
python
{ "resource": "" }
q16424
Message.reply_to_request
train
def reply_to_request(cls, req_msg, *args): """Helper method for creating reply messages to a specific request. Copies the message name and message identifier from request message. Parameters ---------- req_msg : katcp.core.Message instance The request message that t...
python
{ "resource": "" }
q16425
Message.inform
train
def inform(cls, name, *args, **kwargs): """Helper method for creating inform messages. Parameters ---------- name : str The name of the message. args : list of strings The message arguments. """ mid = kwargs.pop('mid', None) if le...
python
{ "resource": "" }
q16426
Message.reply_inform
train
def reply_inform(cls, req_msg, *args): """Helper method for creating inform messages in reply to a request. Copies the message name and message identifier from request message. Parameters ---------- req_msg : katcp.core.Message instance The request message that this...
python
{ "resource": "" }
q16427
MessageParser._unescape_match
train
def _unescape_match(self, match): """Given an re.Match, unescape the escape code it represents.""" char = match.group(1) if char in self.ESCAPE_LOOKUP: return self.ESCAPE_LOOKUP[char] elif not char: raise KatcpSyntaxError("Escape slash at end of argument.") ...
python
{ "resource": "" }
q16428
MessageParser._parse_arg
train
def _parse_arg(self, arg): """Parse an argument.""" match = self.SPECIAL_RE.search(arg) if match: raise KatcpSyntaxError("Unescaped special %r." % (match.group(),)) return self.UNESCAPE_RE.sub(self._unescape_match, arg)
python
{ "resource": "" }
q16429
MessageParser.parse
train
def parse(self, line): """Parse a line, return a Message. Parameters ---------- line : str The line to parse (should not contain the terminating newline or carriage return). Returns ------- msg : Message object The resulting M...
python
{ "resource": "" }
q16430
DeviceServerMetaclass.check_protocol
train
def check_protocol(mcs, handler): """ True if the current server's protocol flags satisfy handler requirements """ protocol_info = mcs.PROTOCOL_INFO protocol_version = (protocol_info.major, protocol_info.minor) protocol_flags = protocol_info.flags # Check if min...
python
{ "resource": "" }
q16431
Sensor.integer
train
def integer(cls, name, description=None, unit='', params=None, default=None, initial_status=None): """Instantiate a new integer sensor object. Parameters ---------- name : str The name of the sensor. description : str A short description o...
python
{ "resource": "" }
q16432
Sensor.float
train
def float(cls, name, description=None, unit='', params=None, default=None, initial_status=None): """Instantiate a new float sensor object. Parameters ---------- name : str The name of the sensor. description : str A short description of the ...
python
{ "resource": "" }
q16433
Sensor.boolean
train
def boolean(cls, name, description=None, unit='', default=None, initial_status=None): """Instantiate a new boolean sensor object. Parameters ---------- name : str The name of the sensor. description : str A short description of the sensor....
python
{ "resource": "" }
q16434
Sensor.lru
train
def lru(cls, name, description=None, unit='', default=None, initial_status=None): """Instantiate a new lru sensor object. Parameters ---------- name : str The name of the sensor. description : str A short description of the sensor. uni...
python
{ "resource": "" }
q16435
Sensor.string
train
def string(cls, name, description=None, unit='', default=None, initial_status=None): """Instantiate a new string sensor object. Parameters ---------- name : str The name of the sensor. description : str A short description of the sensor. ...
python
{ "resource": "" }
q16436
Sensor.discrete
train
def discrete(cls, name, description=None, unit='', params=None, default=None, initial_status=None): """Instantiate a new discrete sensor object. Parameters ---------- name : str The name of the sensor. description : str A short descriptio...
python
{ "resource": "" }
q16437
Sensor.timestamp
train
def timestamp(cls, name, description=None, unit='', default=None, initial_status=None): """Instantiate a new timestamp sensor object. Parameters ---------- name : str The name of the sensor. description : str A short description of the s...
python
{ "resource": "" }
q16438
Sensor.address
train
def address(cls, name, description=None, unit='', default=None, initial_status=None): """Instantiate a new IP address sensor object. Parameters ---------- name : str The name of the sensor. description : str A short description of the sens...
python
{ "resource": "" }
q16439
Sensor.notify
train
def notify(self, reading): """Notify all observers of changes to this sensor.""" # copy list before iterating in case new observers arrive for o in list(self._observers): o.update(self, reading)
python
{ "resource": "" }
q16440
Sensor.set_value
train
def set_value(self, value, status=NOMINAL, timestamp=None, major=DEFAULT_KATCP_MAJOR): """Check and then set the value of the sensor. Parameters ---------- value : object Value of the appropriate type for the sensor. status : Sensor status constant ...
python
{ "resource": "" }
q16441
Sensor.parse_type
train
def parse_type(cls, type_string): """Parse KATCP formatted type code into Sensor type constant. Parameters ---------- type_string : str KATCP formatted type code. Returns ------- sensor_type : Sensor type constant The corresponding Sensor...
python
{ "resource": "" }
q16442
Sensor.parse_params
train
def parse_params(cls, sensor_type, formatted_params, major=DEFAULT_KATCP_MAJOR): """Parse KATCP formatted parameters into Python values. Parameters ---------- sensor_type : Sensor type constant The type of sensor the parameters are for. formatted...
python
{ "resource": "" }
q16443
AsyncEvent.wait_with_ioloop
train
def wait_with_ioloop(self, ioloop, timeout=None): """Do blocking wait until condition is event is set. Parameters ---------- ioloop : tornadio.ioloop.IOLoop instance MUST be the same ioloop that set() / clear() is called from timeout : float, int or None ...
python
{ "resource": "" }
q16444
AsyncState.until_state
train
def until_state(self, state, timeout=None): """Return a tornado Future that will resolve when the requested state is set""" if state not in self._valid_states: raise ValueError('State must be one of {0}, not {1}' .format(self._valid_states, state)) if sta...
python
{ "resource": "" }
q16445
AsyncState.until_state_in
train
def until_state_in(self, *states, **kwargs): """Return a tornado Future, resolves when any of the requested states is set""" timeout = kwargs.get('timeout', None) state_futures = (self.until_state(s, timeout=timeout) for s in states) return until_any(*state_futures)
python
{ "resource": "" }
q16446
LatencyTimer.check_future
train
def check_future(self, fut): """Call with each future that is to be yielded on""" done = self.done = fut.done() if done and not self.prev_done: self.done_since = self.ioloop.time() self.prev_done = done
python
{ "resource": "" }
q16447
request_check
train
def request_check(client, exception, *msg_parms, **kwargs): """Make blocking request to client and raise exception if reply is not ok. Parameters ---------- client : DeviceClient instance exception: Exception class to raise *msg_parms : Message parameters sent to the Message.request() call ...
python
{ "resource": "" }
q16448
DeviceClient.convert_seconds
train
def convert_seconds(self, time_seconds): """Convert a time in seconds to the device timestamp units. KATCP v4 and earlier, specified all timestamps in milliseconds. Since KATCP v5, all timestamps are in seconds. If the device KATCP version has been detected, this method converts a value...
python
{ "resource": "" }
q16449
DeviceClient._next_id
train
def _next_id(self): """Return the next available message id.""" assert get_thread_ident() == self.ioloop_thread_id self._last_msg_id += 1 return str(self._last_msg_id)
python
{ "resource": "" }
q16450
DeviceClient._get_mid_and_update_msg
train
def _get_mid_and_update_msg(self, msg, use_mid): """Get message ID for current request and assign to msg.mid if needed. Parameters ---------- msg : katcp.Message ?request message use_mid : bool or None If msg.mid is None, a new message ID will be created. msg.mid will b...
python
{ "resource": "" }
q16451
DeviceClient.request
train
def request(self, msg, use_mid=None): """Send a request message, with automatic message ID assignment. Parameters ---------- msg : katcp.Message request message use_mid : bool or None, default=None Returns ------- mid : string or None The mes...
python
{ "resource": "" }
q16452
DeviceClient.send_message
train
def send_message(self, msg): """Send any kind of message. Parameters ---------- msg : Message object The message to send. """ assert get_thread_ident() == self.ioloop_thread_id data = str(msg) + "\n" # Log all sent messages here so no one els...
python
{ "resource": "" }
q16453
DeviceClient._disconnect
train
def _disconnect(self, exc_info=False): """Disconnect and cleanup.""" if self._stream: self._stream.close(exc_info=exc_info)
python
{ "resource": "" }
q16454
DeviceClient.handle_message
train
def handle_message(self, msg): """Handle a message from the server. Parameters ---------- msg : Message object The Message to dispatch to the handler methods. """ # log messages received so that no one else has to if self._logger.isEnabledFor(logging...
python
{ "resource": "" }
q16455
DeviceClient.handle_reply
train
def handle_reply(self, msg): """Dispatch a reply message to the appropriate method. Parameters ---------- msg : Message object The reply message to dispatch. """ method = self.__class__.unhandled_reply if msg.name in self._reply_handlers: ...
python
{ "resource": "" }
q16456
DeviceClient.set_ioloop
train
def set_ioloop(self, ioloop=None): """Set the tornado.ioloop.IOLoop instance to use. This defaults to IOLoop.current(). If set_ioloop() is never called the IOLoop is managed: started in a new thread, and will be stopped if self.stop() is called. Notes ----- Must...
python
{ "resource": "" }
q16457
DeviceClient.enable_thread_safety
train
def enable_thread_safety(self): """Enable thread-safety features. Must be called before start(). """ if self.threadsafe: return # Already done! if self._running.isSet(): raise RuntimeError('Cannot enable thread safety after start')...
python
{ "resource": "" }
q16458
DeviceClient.start
train
def start(self, timeout=None): """Start the client in a new thread. Parameters ---------- timeout : float in seconds Seconds to wait for client thread to start. Do not specify a timeout if start() is being called from the same ioloop that this client ...
python
{ "resource": "" }
q16459
DeviceClient.wait_running
train
def wait_running(self, timeout=None): """Wait until the client is running. Parameters ---------- timeout : float in seconds Seconds to wait for the client to start running. Returns ------- running : bool Whether the client is running ...
python
{ "resource": "" }
q16460
DeviceClient.until_connected
train
def until_connected(self, timeout=None): """Return future that resolves when the client is connected.""" t0 = self.ioloop.time() yield self.until_running(timeout=timeout) t1 = self.ioloop.time() if timeout: timedelta = timeout - (t1 - t0) else: tim...
python
{ "resource": "" }
q16461
DeviceClient.until_protocol
train
def until_protocol(self, timeout=None): """Return future that resolves after receipt of katcp protocol info. If the returned future resolves, the server's protocol information is available in the ProtocolFlags instance self.protocol_flags. """ t0 = self.ioloop.time() yi...
python
{ "resource": "" }
q16462
AsyncClient._pop_async_request
train
def _pop_async_request(self, msg_id, msg_name): """Pop the set of callbacks for a request. Return tuple of Nones if callbacks already popped (or don't exist). """ assert get_thread_ident() == self.ioloop_thread_id if msg_id is None: msg_id = self._msg_id_for_name(ms...
python
{ "resource": "" }
q16463
AsyncClient._peek_async_request
train
def _peek_async_request(self, msg_id, msg_name): """Peek at the set of callbacks for a request. Return tuple of Nones if callbacks don't exist. """ assert get_thread_ident() == self.ioloop_thread_id if msg_id is None: msg_id = self._msg_id_for_name(msg_name) ...
python
{ "resource": "" }
q16464
AsyncClient._msg_id_for_name
train
def _msg_id_for_name(self, msg_name): """Find the msg_id for a given request name. Return None if no message id exists. """ if msg_name in self._async_id_stack and self._async_id_stack[msg_name]: return self._async_id_stack[msg_name][0]
python
{ "resource": "" }
q16465
AsyncClient.blocking_request
train
def blocking_request(self, msg, timeout=None, use_mid=None): """Send a request messsage and wait for its reply. Parameters ---------- msg : Message object The request Message to send. timeout : float in seconds How long to wait for a reply. The default is...
python
{ "resource": "" }
q16466
AsyncClient.handle_inform
train
def handle_inform(self, msg): """Handle inform messages related to any current requests. Inform messages not related to the current request go up to the base class method. Parameters ---------- msg : Message object The inform message to dispatch. ""...
python
{ "resource": "" }
q16467
AsyncClient._do_fail_callback
train
def _do_fail_callback( self, reason, msg, reply_cb, inform_cb, user_data, timeout_handle): """Do callback for a failed request.""" # this may also result in reply_cb being None if no # reply_cb was passed to the request method if reply_cb is None: # this happens ...
python
{ "resource": "" }
q16468
AsyncClient._handle_timeout
train
def _handle_timeout(self, msg_id, start_time): """Handle a timed-out callback request. Parameters ---------- msg_id : uuid.UUID for message The name of the reply which was expected. """ msg, reply_cb, inform_cb, user_data, timeout_handle = \ self...
python
{ "resource": "" }
q16469
AsyncClient.handle_reply
train
def handle_reply(self, msg): """Handle a reply message related to the current request. Reply messages not related to the current request go up to the base class method. Parameters ---------- msg : Message object The reply message to dispatch. """ ...
python
{ "resource": "" }
q16470
SubmissionSerializer.validate_answer
train
def validate_answer(self, value): """ Check that the answer is JSON-serializable and not too long. """ # Check that the answer is JSON-serializable try: serialized = json.dumps(value) except (ValueError, TypeError): raise serializers.ValidationErro...
python
{ "resource": "" }
q16471
ScoreSerializer.get_annotations
train
def get_annotations(self, obj): """ Inspect ScoreAnnotations to attach all relevant annotations. """ annotations = ScoreAnnotation.objects.filter(score_id=obj.id) return [ ScoreAnnotationSerializer(instance=annotation).data for annotation in annotations ...
python
{ "resource": "" }
q16472
ScoreSummary.update_score_summary
train
def update_score_summary(sender, **kwargs): """ Listen for new Scores and update the relevant ScoreSummary. Args: sender: not used Kwargs: instance (Score): The score model whose save triggered this receiver. """ score = kwargs['instance'] ...
python
{ "resource": "" }
q16473
Command.handle
train
def handle(self, *args, **options): """ By default, we're going to do this in chunks. This way, if there ends up being an error, we can check log messages and continue from that point after fixing the issue. """ # Note that by taking last_id here, we're going to miss any submissi...
python
{ "resource": "" }
q16474
get_submissions_for_student_item
train
def get_submissions_for_student_item(request, course_id, student_id, item_id): """Retrieve all submissions associated with the given student item. Developer utility for accessing all the submissions associated with a student item. The student item is specified by the unique combination of course, stude...
python
{ "resource": "" }
q16475
create_submission
train
def create_submission(student_item_dict, answer, submitted_at=None, attempt_number=None): """Creates a submission for assessment. Generic means by which to submit an answer for assessment. Args: student_item_dict (dict): The student_item this submission is associated with. This is used...
python
{ "resource": "" }
q16476
_get_submission_model
train
def _get_submission_model(uuid, read_replica=False): """ Helper to retrieve a given Submission object from the database. Helper is needed to centralize logic that fixes EDUCATOR-1090, because uuids are stored both with and without hyphens. """ submission_qs = Submission.objects if read_replica: ...
python
{ "resource": "" }
q16477
get_submission
train
def get_submission(submission_uuid, read_replica=False): """Retrieves a single submission by uuid. Args: submission_uuid (str): Identifier for the submission. Kwargs: read_replica (bool): If true, attempt to use the read replica database. If no read replica is available, use th...
python
{ "resource": "" }
q16478
get_submission_and_student
train
def get_submission_and_student(uuid, read_replica=False): """ Retrieve a submission by its unique identifier, including the associated student item. Args: uuid (str): the unique identifier of the submission. Kwargs: read_replica (bool): If true, attempt to use the read replica database...
python
{ "resource": "" }
q16479
get_submissions
train
def get_submissions(student_item_dict, limit=None): """Retrieves the submissions for the specified student item, ordered by most recent submitted date. Returns the submissions relative to the specified student item. Exception thrown if no submission is found relative to this location. Args: ...
python
{ "resource": "" }
q16480
get_all_submissions
train
def get_all_submissions(course_id, item_id, item_type, read_replica=True): """For the given item, get the most recent submission for every student who has submitted. This may return a very large result set! It is implemented as a generator for efficiency. Args: course_id, item_id, item_type (strin...
python
{ "resource": "" }
q16481
get_all_course_submission_information
train
def get_all_course_submission_information(course_id, item_type, read_replica=True): """ For the given course, get all student items of the given item type, all the submissions for those itemes, and the latest scores for each item. If a submission was given a score that is not the latest score for the releva...
python
{ "resource": "" }
q16482
get_top_submissions
train
def get_top_submissions(course_id, item_id, item_type, number_of_top_scores, use_cache=True, read_replica=True): """Get a number of top scores for an assessment based on a particular student item This function will return top scores for the piece of assessment. It will consider only the latest and greater ...
python
{ "resource": "" }
q16483
get_score
train
def get_score(student_item): """Get the score for a particular student item Each student item should have a unique score. This function will return the score if it is available. A score is only calculated for a student item if it has completed the workflow for a particular assessment module. Args:...
python
{ "resource": "" }
q16484
get_scores
train
def get_scores(course_id, student_id): """Return a dict mapping item_ids to scores. Scores are represented by serialized Score objects in JSON-like dict format. This method would be used by an LMS to find all the scores for a given student in a given course. Scores that are "hidden" (because ...
python
{ "resource": "" }
q16485
reset_score
train
def reset_score(student_id, course_id, item_id, clear_state=False, emit_signal=True): """ Reset scores for a specific student on a specific problem. Note: this does *not* delete `Score` models from the database, since these are immutable. It simply creates a new score with the "reset" flag set to ...
python
{ "resource": "" }
q16486
set_score
train
def set_score(submission_uuid, points_earned, points_possible, annotation_creator=None, annotation_type=None, annotation_reason=None): """Set a score for a particular submission. Sets the score for a particular submission. This score is calculated externally to the API. Args: sub...
python
{ "resource": "" }
q16487
_log_submission
train
def _log_submission(submission, student_item): """ Log the creation of a submission. Args: submission (dict): The serialized submission model. student_item (dict): The serialized student item model. Returns: None """ logger.info( u"Created submission uuid={submi...
python
{ "resource": "" }
q16488
_log_score
train
def _log_score(score): """ Log the creation of a score. Args: score (Score): The score model. Returns: None """ logger.info( "Score of ({}/{}) set for submission {}" .format(score.points_earned, score.points_possible, score.submission.uuid) )
python
{ "resource": "" }
q16489
_get_or_create_student_item
train
def _get_or_create_student_item(student_item_dict): """Gets or creates a Student Item that matches the values specified. Attempts to get the specified Student Item. If it does not exist, the specified parameters are validated, and a new Student Item is created. Args: student_item_dict (dict): ...
python
{ "resource": "" }
q16490
RawMantaClient._request
train
def _request(self, path, method="GET", query=None, body=None, headers=None): """Make a Manta request ... @returns (res, content) """ assert path.startswith('/'), "bogus path: %r" % path ...
python
{ "resource": "" }
q16491
MantaClient.ls
train
def ls(self, mdir, limit=None, marker=None): """List a directory. Dev Notes: - If `limit` and `marker` are *not* specified. This handles paging through a directory with more entries than Manta will return in one request (1000). - This returns a dict mapping name to d...
python
{ "resource": "" }
q16492
MantaClient.stat
train
def stat(self, mpath): """Return available dirent info for the given Manta path.""" parts = mpath.split('/') if len(parts) == 0: raise errors.MantaError("cannot stat empty manta path: %r" % mpath) elif len(parts) <= 3: raise errors.MantaError("cannot stat special ...
python
{ "resource": "" }
q16493
MantaClient.type
train
def type(self, mpath): """Return the manta type for the given manta path. @param mpath {str} The manta path for which to get the type. @returns {str|None} The manta type, e.g. "object" or "directory", or None if the path doesn't exist. """ try: return sel...
python
{ "resource": "" }
q16494
option
train
def option(*args, **kwargs): """Decorator to add an option to the optparser argument of a Cmdln subcommand. Example: class MyShell(cmdln.Cmdln): @cmdln.option("-f", "--force", help="force removal") def do_remove(self, subcmd, opts, *args): #... """ #...
python
{ "resource": "" }
q16495
man_sections_from_cmdln
train
def man_sections_from_cmdln(inst, summary=None, description=None, author=None): """Return man page sections appropriate for the given Cmdln instance. Join these sections for man page content. The man page sections generated are: NAME SYNOPSIS DESCRIPTION (if `description` is given)...
python
{ "resource": "" }
q16496
_format_linedata
train
def _format_linedata(linedata, indent, indent_width): """Format specific linedata into a pleasant layout. "linedata" is a list of 2-tuples of the form: (<item-display-string>, <item-docstring>) "indent" is a string to use for one level of indentation "indent_width" is a number o...
python
{ "resource": "" }
q16497
_summarize_doc
train
def _summarize_doc(doc, length=60): r"""Parse out a short one line summary from the given doclines. "doc" is the doc string to summarize. "length" is the max length for the summary >>> _summarize_doc("this function does this") 'this function does this' >>> _summarize_doc("this function...
python
{ "resource": "" }
q16498
line2argv
train
def line2argv(line): r"""Parse the given line into an argument vector. "line" is the line of input to parse. This may get niggly when dealing with quoting and escaping. The current state of this parsing may not be completely thorough/correct in this respect. >>> from cmdln import line2arg...
python
{ "resource": "" }
q16499
argv2line
train
def argv2line(argv): r"""Put together the given argument vector into a command line. "argv" is the argument vector to process. >>> from cmdln import argv2line >>> argv2line(['foo']) 'foo' >>> argv2line(['foo', 'bar']) 'foo bar' >>> argv2line(['foo', 'bar baz']) 'foo "bar baz"' ...
python
{ "resource": "" }