_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q47200
topological_sort
train
def topological_sort(dependencies, start_nodes): """ Perform a topological sort on the dependency graph `dependencies`, starting from list `start_nodes`. """ retval = [] def edges(node): return dependencies[node][1] def in_degree(node): return dependencies[node][0] def remove_incoming(no...
python
{ "resource": "" }
q47201
run_and_exit_if
train
def run_and_exit_if(opts, action, *names): """ Run the no-arg function `action` if any of `names` appears in the option dict `opts`. """ for name in names: if name in opts: action() sys.exit(0)
python
{ "resource": "" }
q47202
main
train
def main(args=sys.argv): """ Main command-line invocation. """ try: opts, args = getopt.gnu_getopt(args[1:], 'p:o:jdt', [ 'jspath=', 'output=', 'private', 'json', 'dependencies', 'test', 'help']) opts = dict(opts) except getopt.GetoptError: usage() ...
python
{ "resource": "" }
q47203
FileDoc.functions
train
def functions(self): """ Returns a generator of all standalone functions in the file, in textual order. >>> file = FileDoc('module.js', read_file('examples/module.js')) >>> list(file.functions)[0].name 'the_first_function' >>> list(file.functions)[3].name ...
python
{ "resource": "" }
q47204
FileDoc.methods
train
def methods(self): """ Returns a generator of all member functions in the file, in textual order. >>> file = FileDoc('class.js', read_file('examples/class.js')) >>> file.methods.next().name 'first_method' """ def is_method(comment): return ...
python
{ "resource": "" }
q47205
CommentDoc.get_as_list
train
def get_as_list(self, tag_name): """ Return the value of a tag, making sure that it's a list. Absent tags are returned as an empty-list; single tags are returned as a one-element list. The returned list is a copy, and modifications do not affect the original object. ...
python
{ "resource": "" }
q47206
ModuleDoc.to_html
train
def to_html(self, codebase): """ Convert this to HTML. """ html = '' def build_line(key, include_pred, format_fn): val = getattr(self, key) if include_pred(val): return '<dt>%s</dt><dd>%s</dd>\n' % (printable(key), format_fn(val)) ...
python
{ "resource": "" }
q47207
FunctionDoc.params
train
def params(self): """ Returns a ParamDoc for each parameter of the function, picking up the order from the actual parameter list. >>> comments = parse_comments_for_file('examples/module_closure.js') >>> fn2 = FunctionDoc(comments[2]) >>> fn2.params[0].name 'elem'...
python
{ "resource": "" }
q47208
FunctionDoc.to_html
train
def to_html(self, codebase): """ Convert this `FunctionDoc` to HTML. """ body = '' for section in ('params', 'options', 'exceptions'): val = getattr(self, section) if val: body += '<h5>%s</h5>\n<dl class = "%s">%s</dl>' % ( ...
python
{ "resource": "" }
q47209
ClassDoc.get_method
train
def get_method(self, method_name, default=None): """ Returns the contained method of the specified name, or `default` if not found. """ for method in self.methods: if method.name == method_name: return method return default
python
{ "resource": "" }
q47210
ClassDoc.to_html
train
def to_html(self, codebase): """ Convert this ClassDoc to HTML. This returns the default long-form HTML description that's used when the full docs are built. """ return ('<a name = "%s" />\n<div class = "jsclass">\n' + '<h3>%s</h3>\n%s\n<h4>Methods</h4>\n%s</div...
python
{ "resource": "" }
q47211
mangle_scope_tree
train
def mangle_scope_tree(root, toplevel): """Walk over a scope tree and mangle symbol names. Args: toplevel: Defines if global scope should be mangled or not. """ def mangle(scope): # don't mangle global scope if not specified otherwise if scope.get_enclosing_scope() is None and no...
python
{ "resource": "" }
q47212
RefVisitor._fill_scope_refs
train
def _fill_scope_refs(name, scope): """Put referenced name in 'ref' dictionary of a scope. Walks up the scope tree and adds the name to 'ref' of every scope up in the tree until a scope that defines referenced name is reached. """ symbol = scope.resolve(name) if symbol is...
python
{ "resource": "" }
q47213
SwaggerSpec.base_path
train
def base_path(self): """ Calculate the APIs base path """ path = UrlPath() # Walk up the API to find the base object parent = self.parent while parent: path_prefix = getattr(parent, 'path_prefix', NoPath) path = path_prefix + path ...
python
{ "resource": "" }
q47214
SwaggerSpec.parse_operations
train
def parse_operations(self): """ Flatten routes into a path -> method -> route structure """ resource_defs = { getmeta(resources.Error).resource_name: resource_definition(resources.Error), getmeta(resources.Listing).resource_name: resource_definition(resources.List...
python
{ "resource": "" }
q47215
SwaggerSpec.get_swagger
train
def get_swagger(self, request): """ Generate this document. """ api_base = self.parent paths, definitions = self.parse_operations() codecs = getattr(self.cenancestor, 'registered_codecs', CODECS) # type: dict return dict_filter({ 'swagger': '2.0', ...
python
{ "resource": "" }
q47216
SwaggerSpec.get_ui
train
def get_ui(self, _): """ Load the Swagger UI interface """ if not self._ui_cache: content = self.load_static('ui.html') if isinstance(content, binary_type): content = content.decode('UTF-8') self._ui_cache = content.replace(u"{{SWAGGER_...
python
{ "resource": "" }
q47217
SwaggerSpec.get_static
train
def get_static(self, _, file_name=None): """ Get static content for UI. """ content_type = { 'ss': 'text/css', 'js': 'application/javascript', }.get(file_name[-2:]) if not content_type: raise HttpError(HTTPStatus.NOT_FOUND, 42) ...
python
{ "resource": "" }
q47218
perturbed_trajectory
train
def perturbed_trajectory(trajectory, sensitivity_trajectory, delta=1e-4): """ Slightly perturb trajectory wrt the parameter specified in sensitivity_trajectory. :param trajectory: the actual trajectory for an ODE term :type trajectory: :class:`Trajectory` :param sensitivity_trajectory: sensitivity ...
python
{ "resource": "" }
q47219
Trajectory.to_csv
train
def to_csv(self, file): """ Write this trajectory to a csv file with the headers 'time' and 'value'. :param file: a file object to write to :type file: :class:`file` :return: """ file.write("time,value\n") for t,v in self: file.write("%f,%f\n...
python
{ "resource": "" }
q47220
Trajectory.resample
train
def resample(self, new_timepoints, extrapolate=False): """ Use linear interpolation to resample trajectory values. The new values are interpolated for the provided time points. This is generally before comparing or averaging trajectories. :param new_timepoints: the new time poi...
python
{ "resource": "" }
q47221
TrajectoryCollection.to_csv
train
def to_csv(self, file): """ Write all the trajectories of a collection to a csv file with the headers 'description', 'time' and 'value'. :param file: a file object to write to :type file: :class:`file` :return: """ file.write("description,time,value\n") f...
python
{ "resource": "" }
q47222
Digits.xform
train
def xform(self, number, base): """ Get a number as a string. :param number: a number :type number: list of int :param int base: the base in which this number is being represented :raises BasesValueError: if config is unsuitable for number """ if self.CONF...
python
{ "resource": "" }
q47223
Strip._strip_trailing_zeros
train
def _strip_trailing_zeros(value): """ Strip trailing zeros from a list of ints. :param value: the value to be stripped :type value: list of str :returns: list with trailing zeros stripped :rtype: list of int """ return list( reversed( ...
python
{ "resource": "" }
q47224
Strip.xform
train
def xform(self, number, relation): """ Strip trailing zeros from a number according to config and relation. :param number: a number :type number: list of int :param int relation: the relation of the display value to the actual """ # pylint: disable=too-many-bool...
python
{ "resource": "" }
q47225
String.xform
train
def xform(self, radix, relation): """ Transform a radix and some information to a str according to configurations. :param Radix radix: the radix :param int relation: relation of display value to actual value :param units: element of UNITS() :returns: a string rep...
python
{ "resource": "" }
q47226
Asset.get_provider_link_ids
train
def get_provider_link_ids(self): """Gets the resource Ids representing the source of this asset in order from the most recent provider to the originating source. return: (osid.id.IdList) - the provider Ids compliance: mandatory - This method must be implemented. """ id_...
python
{ "resource": "" }
q47227
AssetForm.set_copyright_registration
train
def set_copyright_registration(self, registration): """Sets the copyright registration. arg: registration (string): the new copyright registration raise: InvalidArgument - ``copyright`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` raise: NullArgument ...
python
{ "resource": "" }
q47228
AssetList.get_next_asset
train
def get_next_asset(self): """Gets the next Asset in this list. return: (osid.repository.Asset) - the next Asset in this list. The has_next() method should be used to test that a next Asset is available before calling this method. raise: IllegalState - no more el...
python
{ "resource": "" }
q47229
AssetContentForm.add_accessibility_type
train
def add_accessibility_type(self, accessibility_type=None): """Adds an accessibility type. Multiple types can be added. :param accessibility_type: a new accessibility type :type accessibility_type: ``osid.type.Type`` :raise: ``InvalidArgument`` -- ``accessibility_type`` is inval...
python
{ "resource": "" }
q47230
AssetContentForm.remove_accessibility_type
train
def remove_accessibility_type(self, accessibility_type=None): """Removes an accessibility type. :param accessibility_type: accessibility type to remove :type accessibility_type: ``osid.type.Type`` :raise: ``NoAccess`` -- ``Metadata.isReadOnly()`` is ``true`` :raise: ``NotFound``...
python
{ "resource": "" }
q47231
AssetContentList.get_next_asset_content
train
def get_next_asset_content(self): """Gets the next AssetContent in this list. return: (osid.repository.AssetContent) - the next AssetContent in this list. The has_next() method should be used to test that a next AssetContent is available before calling th...
python
{ "resource": "" }
q47232
RepositoryList.get_next_repository
train
def get_next_repository(self): """Gets the next ``Repository`` in this list. :return: the next ``Repository`` in this list. The ``has_next()`` method should be used to test that a next ``Repository`` is available before calling this method. :rtype: ``osid.repository.Repository`` :raise:...
python
{ "resource": "" }
q47233
profile
train
def profile(message=None, verbose=False): """Decorator for profiling a function. TODO: Support `@profile` syntax (without parens). This would involve inspecting the args. In this case `profile` would receive a single argument, which is the function to be decorated. """ import functools fro...
python
{ "resource": "" }
q47234
AssessmentManager.get_item_lookup_session
train
def get_item_lookup_session(self): """Gets the ``OsidSession`` associated with the item lookup service. return: (osid.assessment.ItemLookupSession) - an ``ItemLookupSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_item_loo...
python
{ "resource": "" }
q47235
AssessmentManager.get_item_lookup_session_for_bank
train
def get_item_lookup_session_for_bank(self, bank_id): """Gets the ``OsidSession`` associated with the item lookup service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank return: (osid.assessment.ItemLookupSession) - ``an _item_lookup_session`` rai...
python
{ "resource": "" }
q47236
AssessmentManager.get_item_query_session
train
def get_item_query_session(self): """Gets the ``OsidSession`` associated with the item query service. return: (osid.assessment.ItemQuerySession) - an ``ItemQuerySession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_item_query()...
python
{ "resource": "" }
q47237
AssessmentManager.get_item_query_session_for_bank
train
def get_item_query_session_for_bank(self, bank_id): """Gets the ``OsidSession`` associated with the item query service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank return: (osid.assessment.ItemQuerySession) - ``an _item_query_session`` raise: ...
python
{ "resource": "" }
q47238
AssessmentManager.get_item_notification_session
train
def get_item_notification_session(self, item_receiver): """Gets the notification session for notifications pertaining to item changes. arg: item_receiver (osid.assessment.ItemReceiver): the item receiver interface return: (osid.assessment.ItemNotificationSession) - an ...
python
{ "resource": "" }
q47239
AssessmentManager.get_item_notification_session_for_bank
train
def get_item_notification_session_for_bank(self, item_receiver, bank_id): """Gets the ``OsidSession`` associated with the item notification service for the given bank. arg: item_receiver (osid.assessment.ItemReceiver): the item receiver interface arg: bank_id (osid.id.Id):...
python
{ "resource": "" }
q47240
AssessmentManager.get_item_bank_session
train
def get_item_bank_session(self): """Gets the ``OsidSession`` associated with the item banking service. return: (osid.assessment.ItemBankSession) - an ``ItemBankSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_item_bank()``...
python
{ "resource": "" }
q47241
AssessmentManager.get_item_bank_assignment_session
train
def get_item_bank_assignment_session(self): """Gets the ``OsidSession`` associated with the item bank assignment service. return: (osid.assessment.ItemBankAssignmentSession) - an ``ItemBankAssignmentSession`` raise: OperationFailed - unable to complete request raise: U...
python
{ "resource": "" }
q47242
AssessmentManager.get_assessment_admin_session
train
def get_assessment_admin_session(self): """Gets the ``OsidSession`` associated with the assessment administration service. return: (osid.assessment.AssessmentAdminSession) - an ``AssessmentAdminSession`` raise: OperationFailed - unable to complete request raise: Unimpl...
python
{ "resource": "" }
q47243
AssessmentManager.get_assessment_admin_session_for_bank
train
def get_assessment_admin_session_for_bank(self, bank_id): """Gets the ``OsidSession`` associated with the assessment admin service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank return: (osid.assessment.AssessmentAdminSession) - ``an _assessment_admin_s...
python
{ "resource": "" }
q47244
AssessmentManager.get_assessment_notification_session
train
def get_assessment_notification_session(self, assessment_receiver): """Gets the notification session for notifications pertaining to assessment changes. arg: assessment_receiver (osid.assessment.AssessmentReceiver): the assessment receiver interface return: (o...
python
{ "resource": "" }
q47245
AssessmentManager.get_assessment_notification_session_for_bank
train
def get_assessment_notification_session_for_bank(self, assessment_receiver, bank_id): """Gets the ``OsidSession`` associated with the assessment notification service for the given bank. arg: assessment_receiver (osid.assessment.AssessmentReceiver): the assessment rece...
python
{ "resource": "" }
q47246
AssessmentManager.get_assessment_offered_lookup_session
train
def get_assessment_offered_lookup_session(self): """Gets the ``OsidSession`` associated with the assessment offered lookup service. return: (osid.assessment.AssessmentOfferedLookupSession) - an ``AssessmentOfferedLookupSession`` raise: OperationFailed - unable to complete reque...
python
{ "resource": "" }
q47247
AssessmentManager.get_assessment_offered_lookup_session_for_bank
train
def get_assessment_offered_lookup_session_for_bank(self, bank_id): """Gets the ``OsidSession`` associated with the assessment offered lookup service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank return: (osid.assessment.AssessmentOfferedLookupSession) - an ...
python
{ "resource": "" }
q47248
AssessmentManager.get_assessment_offered_query_session
train
def get_assessment_offered_query_session(self): """Gets the ``OsidSession`` associated with the assessment offered query service. return: (osid.assessment.AssessmentOfferedQuerySession) - an ``AssessmentOfferedQuerySession`` raise: OperationFailed - unable to complete request ...
python
{ "resource": "" }
q47249
AssessmentManager.get_assessment_offered_query_session_for_bank
train
def get_assessment_offered_query_session_for_bank(self, bank_id): """Gets the ``OsidSession`` associated with the assessment offered query service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank return: (osid.assessment.AssessmentOfferedQuerySession) - an ...
python
{ "resource": "" }
q47250
AssessmentManager.get_assessment_taken_lookup_session
train
def get_assessment_taken_lookup_session(self): """Gets the ``OsidSession`` associated with the assessment taken lookup service. return: (osid.assessment.AssessmentTakenLookupSession) - an ``AssessmentTakenLookupSession`` raise: OperationFailed - unable to complete request ...
python
{ "resource": "" }
q47251
AssessmentManager.get_assessment_taken_lookup_session_for_bank
train
def get_assessment_taken_lookup_session_for_bank(self, bank_id): """Gets the ``OsidSession`` associated with the assessment taken lookup service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank return: (osid.assessment.AssessmentTakenLookupSession) - an `...
python
{ "resource": "" }
q47252
AssessmentManager.get_assessment_taken_query_session
train
def get_assessment_taken_query_session(self): """Gets the ``OsidSession`` associated with the assessment taken query service. return: (osid.assessment.AssessmentTakenQuerySession) - an ``AssessmentTakenQuerySession`` raise: OperationFailed - unable to complete request r...
python
{ "resource": "" }
q47253
AssessmentManager.get_assessment_taken_query_session_for_bank
train
def get_assessment_taken_query_session_for_bank(self, bank_id): """Gets the ``OsidSession`` associated with the assessment taken query service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank return: (osid.assessment.AssessmentTakenQuerySession) - an ``As...
python
{ "resource": "" }
q47254
AssessmentManager.get_bank_lookup_session
train
def get_bank_lookup_session(self): """Gets the OsidSession associated with the bank lookup service. return: (osid.assessment.BankLookupSession) - a ``BankLookupSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_bank_lookup()...
python
{ "resource": "" }
q47255
AssessmentManager.get_bank_query_session
train
def get_bank_query_session(self): """Gets the OsidSession associated with the bank query service. return: (osid.assessment.BankQuerySession) - a ``BankQuerySession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_bank_query() is f...
python
{ "resource": "" }
q47256
AssessmentManager.get_bank_admin_session
train
def get_bank_admin_session(self): """Gets the OsidSession associated with the bank administration service. return: (osid.assessment.BankAdminSession) - a ``BankAdminSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_bank_adm...
python
{ "resource": "" }
q47257
AssessmentManager.get_bank_hierarchy_session
train
def get_bank_hierarchy_session(self): """Gets the session traversing bank hierarchies. return: (osid.assessment.BankHierarchySession) - a ``BankHierarchySession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_bank_hierarchy() is ...
python
{ "resource": "" }
q47258
AssessmentProxyManager.get_assessment_session
train
def get_assessment_session(self, proxy): """Gets an ``AssessmentSession`` which is responsible for taking assessments and examining responses from assessments taken. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentSession) - an assessment session for...
python
{ "resource": "" }
q47259
AssessmentProxyManager.get_assessment_session_for_bank
train
def get_assessment_session_for_bank(self, bank_id, proxy): """Gets an ``AssessmentSession`` which is responsible for performing assessments for the given bank ``Id``. arg: bank_id (osid.id.Id): the ``Id`` of a bank arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.As...
python
{ "resource": "" }
q47260
AssessmentProxyManager.get_assessment_results_session
train
def get_assessment_results_session(self, proxy): """Gets an ``AssessmentResultsSession`` to retrieve assessment results. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentResultsSession) - an assessment results session for this service raise: ...
python
{ "resource": "" }
q47261
AssessmentProxyManager.get_assessment_results_session_for_bank
train
def get_assessment_results_session_for_bank(self, bank_id, proxy): """Gets an ``AssessmentResultsSession`` to retrieve assessment results for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the assessment taken arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessme...
python
{ "resource": "" }
q47262
AssessmentProxyManager.get_item_search_session
train
def get_item_search_session(self, proxy): """Gets the ``OsidSession`` associated with the item search service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.ItemSearchSession) - an ``ItemSearchSession`` raise: NullArgument - ``proxy`` is ``null`` ...
python
{ "resource": "" }
q47263
AssessmentProxyManager.get_item_search_session_for_bank
train
def get_item_search_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the item search service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.ItemSearchSession) ...
python
{ "resource": "" }
q47264
AssessmentProxyManager.get_item_admin_session
train
def get_item_admin_session(self, proxy): """Gets the ``OsidSession`` associated with the item administration service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.ItemAdminSession) - an ``ItemAdminSession`` raise: NullArgument - ``proxy`` is ``null...
python
{ "resource": "" }
q47265
AssessmentProxyManager.get_item_admin_session_for_bank
train
def get_item_admin_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the item admin service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.ItemAdminSession) - `...
python
{ "resource": "" }
q47266
AssessmentProxyManager.get_assessment_lookup_session
train
def get_assessment_lookup_session(self, proxy): """Gets the ``OsidSession`` associated with the assessment lookup service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentLookupSession) - an ``AssessmentLookupSession`` raise: NullArgument - ...
python
{ "resource": "" }
q47267
AssessmentProxyManager.get_assessment_lookup_session_for_bank
train
def get_assessment_lookup_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the assessment lookup service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.Assessm...
python
{ "resource": "" }
q47268
AssessmentProxyManager.get_assessment_query_session
train
def get_assessment_query_session(self, proxy): """Gets the ``OsidSession`` associated with the assessment query service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentQuerySession) - an ``AssessmentQuerySession`` raise: NullArgument - ``pr...
python
{ "resource": "" }
q47269
AssessmentProxyManager.get_assessment_query_session_for_bank
train
def get_assessment_query_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the assessment query service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.Assessmen...
python
{ "resource": "" }
q47270
AssessmentProxyManager.get_assessment_bank_session
train
def get_assessment_bank_session(self, proxy): """Gets the ``OsidSession`` associated with the assessment banking service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentBankSession) - an ``AssessmentBankSession`` raise: NullArgument - ``pro...
python
{ "resource": "" }
q47271
AssessmentProxyManager.get_assessment_bank_assignment_session
train
def get_assessment_bank_assignment_session(self, proxy): """Gets the ``OsidSession`` associated with the assessment bank assignment service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentBankAssignmentSession) - an ``AssessmentBankAssignmentSession...
python
{ "resource": "" }
q47272
AssessmentProxyManager.get_assessment_basic_authoring_session
train
def get_assessment_basic_authoring_session(self, proxy): """Gets the ``OsidSession`` associated with the assessment authoring service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentBasicAuthoringSession) - an ``AssessmentBasicAuthoringSession`` ...
python
{ "resource": "" }
q47273
AssessmentProxyManager.get_assessment_basic_authoring_session_for_bank
train
def get_assessment_basic_authoring_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the assessment authoring service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of a bank arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessme...
python
{ "resource": "" }
q47274
AssessmentProxyManager.get_assessment_offered_admin_session
train
def get_assessment_offered_admin_session(self, proxy): """Gets the ``OsidSession`` associated with the assessment offered administration service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentOfferedAdminSession) - an ``AssessmentOfferedAdminSessio...
python
{ "resource": "" }
q47275
AssessmentProxyManager.get_assessment_offered_admin_session_for_bank
train
def get_assessment_offered_admin_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the assessment offered admin service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank arg: proxy (osid.proxy.Proxy): a proxy return: (osid.asse...
python
{ "resource": "" }
q47276
AssessmentProxyManager.get_assessment_offered_bank_session
train
def get_assessment_offered_bank_session(self, proxy): """Gets the session for retrieving offered assessments to bank mappings. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentOfferedBankSession) - an ``AssessmentOfferedBankSession`` raise: N...
python
{ "resource": "" }
q47277
AssessmentProxyManager.get_assessment_offered_bank_assignment_session
train
def get_assessment_offered_bank_assignment_session(self, proxy): """Gets the session for assigning offered assessments to bank mappings. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentOfferedBankAssignmentSession) - an ``AssessmentOfferedBankAssignm...
python
{ "resource": "" }
q47278
AssessmentProxyManager.get_assessment_taken_admin_session
train
def get_assessment_taken_admin_session(self, proxy): """Gets the ``OsidSession`` associated with the assessment taken administration service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentTakenAdminSession) - an ``AssessmentTakenAdminSession`` ...
python
{ "resource": "" }
q47279
AssessmentProxyManager.get_assessment_taken_admin_session_for_bank
train
def get_assessment_taken_admin_session_for_bank(self, bank_id, proxy): """Gets the ``OsidSession`` associated with the assessment taken admin service for the given bank. arg: bank_id (osid.id.Id): the ``Id`` of the bank arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessme...
python
{ "resource": "" }
q47280
AssessmentProxyManager.get_assessment_taken_bank_session
train
def get_assessment_taken_bank_session(self, proxy): """Gets the session for retrieving taken assessments to bank mappings. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentTakenBankSession) - an ``AssessmentTakenBankSession`` raise: NullArgum...
python
{ "resource": "" }
q47281
AssessmentProxyManager.get_assessment_taken_bank_assignment_session
train
def get_assessment_taken_bank_assignment_session(self, proxy): """Gets the session for assigning taken assessments to bank mappings. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.AssessmentTakenBankAssignmentSession) - an ``AssessmentTakenBankAssignmentSessi...
python
{ "resource": "" }
q47282
AssessmentProxyManager.get_bank_hierarchy_design_session
train
def get_bank_hierarchy_design_session(self, proxy): """Gets the session designing bank hierarchies. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.assessment.BankHierarchyDesignSession) - a ``BankHierarchySession`` raise: NullArgument - ``proxy`` is ``null`` ...
python
{ "resource": "" }
q47283
helper_import
train
def helper_import(module_name, class_name=None): """ Return class or module object. if the argument is only a module name and return a module object. if the argument is a module and class name, and return a class object. """ try: module = __import__(module_name, globals(), locals(), [cla...
python
{ "resource": "" }
q47284
gather_repositories
train
def gather_repositories(): """ Collects all of the repositories. The current implementation searches for them in the current working directory. """ for (root, dirs, files) in os.walk('.', topdown=True): if '.git' not in dirs: continue for dir in list(dirs): ...
python
{ "resource": "" }
q47285
run
train
def run(command, exit, silent, check): """ Runs given command on all repos and checks status $ maintain repo run -- git checkout master """ status = 0 for (repo, path) in gather_repositories(): if check and not check_repo(repo, path): status = 1 if exit: ...
python
{ "resource": "" }
q47286
parse
train
def parse(inp, format=None, encoding='utf-8', force_types=True): """Parse input from file-like object, unicode string or byte string. Args: inp: file-like object, unicode string or byte string with the markup format: explicitly override the guessed `inp` markup format encoding: `inp` en...
python
{ "resource": "" }
q47287
parse_file
train
def parse_file(path, format=None, encoding='utf-8', force_types=True): """A convenience wrapper of parse, which accepts path of file to parse. Args: path: path to file to parse format: explicitly override the guessed `inp` markup format encoding: file encoding, defaults to utf-8 ...
python
{ "resource": "" }
q47288
serialize
train
def serialize(struct, format, target=None, encoding='utf-8'): """Serialize given structure and return it as encoded string or write it to file-like object. Args: struct: structure (dict or list) with unicode members to serialize; note that list can only be serialized to json format:...
python
{ "resource": "" }
q47289
serialize_file
train
def serialize_file(struct, path, format=None, encoding='utf-8'): """A convenience wrapper of serialize, which accepts path of file to serialize to. Args: struct: structure (dict or list) with unicode members to serialize; note that list can only be serialized to json path: path of t...
python
{ "resource": "" }
q47290
_do_parse
train
def _do_parse(inp, fmt, encoding, force_types): """Actually parse input. Args: inp: bytes yielding file-like object fmt: format to use for parsing encoding: encoding of `inp` force_types: if `True`, integers, floats, booleans and none/null are recogni...
python
{ "resource": "" }
q47291
_do_serialize
train
def _do_serialize(struct, fmt, encoding): """Actually serialize input. Args: struct: structure to serialize to fmt: format to serialize to encoding: encoding to use while serializing Returns: encoded serialized structure Raises: various sorts of errors raised by ...
python
{ "resource": "" }
q47292
_ensure_proper_types
train
def _ensure_proper_types(struct, encoding, force_types): """A convenience function that recursively makes sure the given structure contains proper types according to value of `force_types`. Args: struct: a structure to check and fix encoding: encoding to use on found bytestrings for...
python
{ "resource": "" }
q47293
_get_format
train
def _get_format(format, fname, inp=None): """Try to guess markup format of given input. Args: format: explicit format override to use fname: name of file, if a file was used to read `inp` inp: optional bytestring to guess format of (can be None, if markup format is to be gue...
python
{ "resource": "" }
q47294
_guess_fmt_from_bytes
train
def _guess_fmt_from_bytes(inp): """Try to guess format of given bytestring. Args: inp: byte string to guess format of Returns: guessed format """ stripped = inp.strip() fmt = None ini_section_header_re = re.compile(b'^\[([\w-]+)\]') if len(stripped) == 0: # this...
python
{ "resource": "" }
q47295
create_farm
train
def create_farm(farm_name): """ Create a farm. Creates a farm named FARM_NAME on the currently selected cloud server. You can use the `openag cloud select_farm` command to start mirroring data into it. """ utils.check_for_cloud_server() utils.check_for_cloud_user() server = Server(config...
python
{ "resource": "" }
q47296
list_farms
train
def list_farms(): """ List all farms you can manage. If you have selected a farm already, the name of that farm will be prefixed with an asterisk in the returned list. """ utils.check_for_cloud_server() utils.check_for_cloud_user() server = Server(config["cloud_server"]["url"]) server.lo...
python
{ "resource": "" }
q47297
init_farm
train
def init_farm(farm_name): """ Select a farm to use. This command sets up the replication between your local database and the selected cloud server if you have already initialized your local database with the `openag db init` command. """ utils.check_for_cloud_server() utils.check_for_cloud_u...
python
{ "resource": "" }
q47298
deinit_farm
train
def deinit_farm(): """ Detach from the current farm. Cancels the replication between your local server and the cloud instance if it is set up. """ utils.check_for_cloud_server() utils.check_for_cloud_user() utils.check_for_cloud_farm() farm_name = config["cloud_server"]["farm_name"] ...
python
{ "resource": "" }
q47299
Question.get_learning_objective_ids
train
def get_learning_objective_ids(self): """ This method mirrors that in the Item. So that questions can also be inspected for learning objectives """ if 'learningObjectiveIds' not in self._my_map: # Will this ever be the case? collection = JSONClientValidated('assessment', ...
python
{ "resource": "" }