_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q48800
LearningProxyManager.get_my_learning_path_session_for_objective_bank
train
def get_my_learning_path_session_for_objective_bank(self, objective_bank_id, proxy): """Gets the ``OsidSession`` associated with the my learning path service for the given objective bank. :param objective_bank_id: the ``Id`` of the ``ObjectiveBank`` :type objective_bank_id: ``osid.id.Id`` ...
python
{ "resource": "" }
q48801
LearningProxyManager.get_objective_bank_query_session
train
def get_objective_bank_query_session(self, proxy): """Gets the OsidSession associated with the objective bank query service. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: an ``ObjectiveBankQuerySession`` :rtype: ``osid.learning.ObjectiveBankQuerySession`` ...
python
{ "resource": "" }
q48802
LearningProxyManager.get_objective_bank_search_session
train
def get_objective_bank_search_session(self, proxy): """Gets the OsidSession associated with the objective bank search service. :param proxy: a proxy :type proxy: ``osid.proxy.Proxy`` :return: an ``ObjectiveBankSearchSession`` :rtype: ``osid.learning.ObjectiveBankSearchSession`` ...
python
{ "resource": "" }
q48803
Spool.register_piece
train
def register_piece(self, from_address, to_address, hash, password, min_confirmations=6, sync=False, ownership=True): """ Register a piece Args: from_address (Tuple[str]): Federation address. All register transactions originate from the the Federation wallet ...
python
{ "resource": "" }
q48804
Spool.refill_main_wallet
train
def refill_main_wallet(self, from_address, to_address, nfees, ntokens, password, min_confirmations=6, sync=False): """ Refill the Federation wallet with tokens and fees. This keeps the federation wallet clean. Dealing with exact values simplifies the transactions. No need to calculate change. Ea...
python
{ "resource": "" }
q48805
Spool.refill
train
def refill(self, from_address, to_address, nfees, ntokens, password, min_confirmations=6, sync=False): """ Refill wallets with the necessary fuel to perform spool transactions Args: from_address (Tuple[str]): Federation wallet address. Fuels the wallets with tokens and fees. All tra...
python
{ "resource": "" }
q48806
Spool.simple_spool_transaction
train
def simple_spool_transaction(self, from_address, to, op_return, min_confirmations=6): """ Utililty function to create the spool transactions. Selects the inputs, encodes the op_return and constructs the transaction. Args: from_address (str): Address originating the transacti...
python
{ "resource": "" }
q48807
Spool.select_inputs
train
def select_inputs(self, address, nfees, ntokens, min_confirmations=6): """ Selects the inputs for the spool transaction. Args: address (str): bitcoin address to select inputs for nfees (int): number of fees ntokens (int): number of tokens min_conf...
python
{ "resource": "" }
q48808
is_admin
train
def is_admin(controller, client, actor): """Used to determine whether someone issuing a command is an admin. By default, checks to see if there's a line of the type nick=host that matches the command's actor in the [admins] section of the config file, or a key that matches the entire mask (e.g. "foo@ba...
python
{ "resource": "" }
q48809
ItemSearchResults.get_items
train
def get_items(self): """Gets the item list resulting from the search. return: (osid.assessment.ItemList) - the item list raise: IllegalState - the item list has already been retrieved *compliance: mandatory -- This method must be implemented.* """ if self.retrieved: ...
python
{ "resource": "" }
q48810
AssessmentSearchResults.get_assessments
train
def get_assessments(self): """Gets the assessment list resulting from the search. return: (osid.assessment.AssessmentList) - the assessment list raise: IllegalState - the assessment list has already been retrieved *compliance: mandatory -- This method must be implemente...
python
{ "resource": "" }
q48811
AssessmentOfferedSearchResults.get_assessments_offered
train
def get_assessments_offered(self): """Gets the assessment offered list resulting from the search. return: (osid.assessment.AssessmentOfferedList) - the assessment offered list raise: IllegalState - the assessment offered list has already been retrieved *...
python
{ "resource": "" }
q48812
AssessmentTakenSearchResults.get_assessments_taken
train
def get_assessments_taken(self): """Gets the assessment taken list resulting from the search. return: (osid.assessment.AssessmentTakenList) - the assessment taken list raise: IllegalState - the assessment taken list has already been retrieved *compliance...
python
{ "resource": "" }
q48813
BankSearchResults.get_banks
train
def get_banks(self): """Gets the bank list resulting from a search. return: (osid.assessment.BankList) - the bank list raise: IllegalState - the bank list has already been retrieved *compliance: mandatory -- This method must be implemented.* """ if self.retrieved: ...
python
{ "resource": "" }
q48814
Graph.roots
train
def roots(self): """get the nodes with no children""" return [x for x in self._nodes.values() if x.id not in self._c2p]
python
{ "resource": "" }
q48815
Graph.get_root_graph
train
def get_root_graph(self,root): """Return back a graph containing just the root and children""" children = self.get_children(root) g = Graph() nodes = [root]+children for node in nodes: g.add_node(node) node_ids = [x.id for x in nodes] edges = [x for x in self._edges.values() if...
python
{ "resource": "" }
q48816
Graph.merge_cycles
train
def merge_cycles(self): """Work on this graph and remove cycles, with nodes containing concatonated lists of payloads""" while True: ### remove any self edges own_edges = self.get_self_edges() if len(own_edges) > 0: for e in own_edges: self.remove_edge(e) c = ...
python
{ "resource": "" }
q48817
Graph.remove_node
train
def remove_node(self,node): """remove the node""" if node.id not in self._nodes: return """find edges to remove""" edges = set() for e in self._edges.values(): if e.node1.id == node.id: edges.add(e.id) if e.node2.id == node.id: edges.add(e.id) edges = [self._e...
python
{ "resource": "" }
q48818
Graph.remove_edge
train
def remove_edge(self,edge): """Remove the edge""" if edge.id not in self._edges: return # its not in the graph del self._p2c[edge.node1.id][edge.node2.id][edge.id] if len(self._p2c[edge.node1.id][edge.node2.id].keys()) == 0: del self._p2c[edge.node1.id][edge.node2.id] if len(self....
python
{ "resource": "" }
q48819
Graph.move_edges
train
def move_edges(self,n1,n2): """Move edges from node 1 to node 2 Not self edges though Overwrites edges """ #Traverse edges to find incoming with n1 incoming = [] for e in self._edges.values(): if e.node2.id == n1.id: incoming.append(e) #Traverse edges to...
python
{ "resource": "" }
q48820
Graph.find_cycle
train
def find_cycle(self): """greedy search for a cycle""" for node in self.nodes: cyc = self._follow_children(node) if len(cyc) > 0: return [self._nodes[x] for x in cyc] return None
python
{ "resource": "" }
q48821
AuthorizationSearchSession.get_authorizations_by_search
train
def get_authorizations_by_search(self, authorization_query, authorization_search): """Pass through to provider AuthorizationSearchSession.get_authorizations_by_search""" # Implemented from azosid template for - # osid.resource.ResourceSearchSession.get_resources_by_search_template if not...
python
{ "resource": "" }
q48822
FunctionSearchSession.get_functions_by_search
train
def get_functions_by_search(self, function_query, function_search): """Pass through to provider FunctionSearchSession.get_functions_by_search""" # Implemented from azosid template for - # osid.resource.ResourceSearchSession.get_resources_by_search_template if not self._can('search'): ...
python
{ "resource": "" }
q48823
QualifierSearchSession.get_qualifiers_by_search
train
def get_qualifiers_by_search(self, qualifier_query, qualifier_search): """Pass through to provider QualifierSearchSession.get_qualifiers_by_search""" # Implemented from azosid template for - # osid.resource.ResourceSearchSession.get_resources_by_search_template if not self._can('search')...
python
{ "resource": "" }
q48824
ZimbraClientException.print_trace
train
def print_trace(self): """ Prints stack trace for current exceptions chain. """ traceback.print_exc() for tb in self.tracebacks: print tb, print ''
python
{ "resource": "" }
q48825
TypeManager.get_type_lookup_session
train
def get_type_lookup_session(self): """Gets the OsidSession associated with the type lookup service. return: (osid.type.TypeLookupSession) - a TypeLookupSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_type_lookup() is false compliance...
python
{ "resource": "" }
q48826
TypeManager.get_type_admin_session
train
def get_type_admin_session(self): """Gets the OsidSession associated with the type admin service. return: (osid.type.TypeAdminSession) - a TypeAdminSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_type_admin() is false compliance: opt...
python
{ "resource": "" }
q48827
Bed12._line_to_entry
train
def _line_to_entry(self,line): """parse the line into entries and keys""" f = line.rstrip().split("\t") """ 'chrom' 'chromStart' 'chromEnd' 'name' 'score' 'strand' 'thickStart' 'thickEnd' 'itemRgb' 'blockCount' 'blockSizes' 'blockStarts' """ return Bed...
python
{ "resource": "" }
q48828
_to_swagger
train
def _to_swagger(base=None, description=None, resource=None, options=None): # type: (Dict[str, str], str, Resource, Dict[str, str]) -> Dict[str, str] """ Common to swagger definition. :param base: The base dict. :param description: An optional description. :param resource: An optional resource. ...
python
{ "resource": "" }
q48829
UrlPath.from_object
train
def from_object(cls, obj): # type: (Any) -> UrlPath """ Attempt to convert any object into a UrlPath. Raise a value error if this is not possible. """ if isinstance(obj, UrlPath): return obj if isinstance(obj, _compat.string_types): return...
python
{ "resource": "" }
q48830
UrlPath.startswith
train
def startswith(self, other): # type: (UrlPath) -> bool """ Return True if this path starts with the other path. """ try: other = UrlPath.from_object(other) except ValueError: raise TypeError('startswith first arg must be UrlPath, str, PathParam, no...
python
{ "resource": "" }
q48831
UrlPath.apply_args
train
def apply_args(self, **kwargs): # type: (**str) -> UrlPath """ Apply formatting to each path node. This is used to apply a name to nodes (used to apply key names) eg: >>> a = UrlPath("foo", PathParam('{key_field}'), "bar") >>> b = a.apply_args(id="item_id") >>> ...
python
{ "resource": "" }
q48832
UrlPath.odinweb_node_formatter
train
def odinweb_node_formatter(path_node): # type: (PathParam) -> str """ Format a node to be consumable by the `UrlPath.parse`. """ args = [path_node.name] if path_node.type: args.append(path_node.type.name) if path_node.type_args: args.append...
python
{ "resource": "" }
q48833
Param.path
train
def path(cls, name, type_=Type.String, description=None, default=None, minimum=None, maximum=None, enum=None, **options): """ Define a path parameter """ if minimum is not None and maximum is not None and minimum > maximum: raise ValueError("Minimum must be less ...
python
{ "resource": "" }
q48834
Param.query
train
def query(cls, name, type_=Type.String, description=None, required=None, default=None, minimum=None, maximum=None, enum=None, **options): """ Define a query parameter """ if minimum is not None and maximum is not None and minimum > maximum: raise ValueError("Min...
python
{ "resource": "" }
q48835
Param.header
train
def header(cls, name, type_=Type.String, description=None, default=None, required=None, **options): """ Define a header parameter. """ return cls(name, In.Header, type_, None, description, required=required, default=default, **options)
python
{ "resource": "" }
q48836
Param.body
train
def body(cls, description=None, default=None, resource=DefaultResource, **options): """ Define body parameter. """ return cls('body', In.Body, None, resource, description, required=True, default=default, **options)
python
{ "resource": "" }
q48837
Param.form
train
def form(cls, name, type_=Type.String, description=None, required=None, default=None, minimum=None, maximum=None, enum=None, **options): """ Define form parameter. """ if minimum is not None and maximum is not None and minimum > maximum: raise ValueError("Minimum...
python
{ "resource": "" }
q48838
MiddlewareList.pre_request
train
def pre_request(self): """ List of pre-request methods from registered middleware. """ middleware = sort_by_priority(self) return tuple(m.pre_request for m in middleware if hasattr(m, 'pre_request'))
python
{ "resource": "" }
q48839
MiddlewareList.pre_dispatch
train
def pre_dispatch(self): """ List of pre-dispatch methods from registered middleware. """ middleware = sort_by_priority(self) return tuple(m.pre_dispatch for m in middleware if hasattr(m, 'pre_dispatch'))
python
{ "resource": "" }
q48840
MiddlewareList.post_dispatch
train
def post_dispatch(self): """ List of post-dispatch methods from registered middleware. """ middleware = sort_by_priority(self, reverse=True) return tuple(m.post_dispatch for m in middleware if hasattr(m, 'post_dispatch'))
python
{ "resource": "" }
q48841
MiddlewareList.post_swagger
train
def post_swagger(self): """ List of post-swagger methods from registered middleware. This is used to modify documentation (eg add/remove any extra information, provided by the middleware) """ middleware = sort_by_priority(self) return tuple(m.post_swagger for m in middl...
python
{ "resource": "" }
q48842
MultiValueDict.add
train
def add(self, key, value): # type: (Hashable, Any) -> None """ Adds a new value for the key. :param key: the key for the value. :param value: the value to add. """ dict.setdefault(self, key, []).append(value)
python
{ "resource": "" }
q48843
MultiValueDict.get
train
def get(self, key, default=None, type_=None): """ Return the last data value for the passed key. If key doesn't exist or value is an empty list, return `default`. """ try: rv = self[key] except KeyError: return default if type_ is not None:...
python
{ "resource": "" }
q48844
MultiValueDict.getlist
train
def getlist(self, key, type_=None): # type: (Hashable, Callable) -> List[Any] """ Return the list of items for a given key. If that key is not in the `MultiDict`, the return value will be an empty list. Just as `get` `getlist` accepts a `type` parameter. All items will be conve...
python
{ "resource": "" }
q48845
MultiValueDict.values
train
def values(self, multi=False): # type: (bool) -> Iterator[Any] """ Yield the last value on every key list. :param multi: If set to `True` the iterator returned will have a pair for each value of each key. Otherwise it will only contain pairs ...
python
{ "resource": "" }
q48846
to_plain_text
train
def to_plain_text(str): ''' Return a plain-text version of a given string This is a dumb approach that tags and then removing entity markers but this is fine for the content from biocyc where entities are β etc. Stripping in this way turns these into plaintext 'beta' which is preferable ...
python
{ "resource": "" }
q48847
BioCyc.cache
train
def cache(self, obj): ''' Store an object in the cache (this allows temporarily assigning a new cache for exploring the DB without affecting the stored version ''' # Check cache path exists for current obj write_path = os.path.join( self.cache_path, obj.org_id ) i...
python
{ "resource": "" }
q48848
BioCyc.get_for_org
train
def get_for_org(self, org_id, ids, skip_cache=False): ''' Returns objects for the given identifiers If called with a list returns a list, else returns a single entity ''' t = type(ids) if t != list: ids = [ids] objs = [] ...
python
{ "resource": "" }
q48849
BioCycEntityBase.import_from_xml
train
def import_from_xml(self, xml): ''' Standard imports for all types of object These must fail gracefully, skip if not found ''' self._import_orgid(xml) self._import_parents_from_xml(xml) self._import_instances_from_xml(xml) self._import_common_name(xml) ...
python
{ "resource": "" }
q48850
BioCycEntityBase._set_var_from_xml_text
train
def _set_var_from_xml_text(self, xml, xmlpath, var): ''' Sets a object variable from the xml if it is there and passing it through a data conversion based on the variable datatype ''' xmle = xml.find(xmlpath) if xmle is not None: setattr(self, var, type_conver...
python
{ "resource": "" }
q48851
BioCycEntityBase._set_list_ids_from_xml_iter
train
def _set_list_ids_from_xml_iter(self, xml, xmlpath, var): ''' Set a list variable from the frameids of matching xml entities ''' es = xml.iterfind(xmlpath) if es is not None: l = [] for e in es: l.append( e.attrib['frameid'] ) ...
python
{ "resource": "" }
q48852
BioCycEntityBase._set_id_from_xml_frameid
train
def _set_id_from_xml_frameid(self, xml, xmlpath, var): ''' Set a single variable with the frameids of matching entity ''' e = xml.find(xmlpath) if e is not None: setattr(self, var, e.attrib['frameid'])
python
{ "resource": "" }
q48853
Resource.get_avatar_id
train
def get_avatar_id(self): """Gets the asset ``Id``. return: (osid.id.Id) - the asset ``Id`` raise: IllegalState - ``has_avatar()`` is ``false`` *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.resource.Resource.get_ava...
python
{ "resource": "" }
q48854
Resource.get_avatar
train
def get_avatar(self): """Gets the asset. return: (osid.repository.Asset) - the asset raise: IllegalState - ``has_avatar()`` is ``false`` raise: OperationFailed - unable to complete request *compliance: mandatory -- This method must be implemented.* """ # Imple...
python
{ "resource": "" }
q48855
ResourceForm.get_group_metadata
train
def get_group_metadata(self): """Gets the metadata for a group. return: (osid.Metadata) - metadata for the group *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.resource.ResourceForm.get_group_metadata_template metada...
python
{ "resource": "" }
q48856
ResourceForm.set_group
train
def set_group(self, group): """Sets the resource as a group. arg: group (boolean): ``true`` if this resource is a group, ``false`` otherwise raise: InvalidArgument - ``group`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` *compliance: ma...
python
{ "resource": "" }
q48857
ResourceForm.clear_group
train
def clear_group(self): """Clears the group designation. raise: NoAccess - ``Metadata.isRequired()`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.resource.ResourceFo...
python
{ "resource": "" }
q48858
ResourceForm.get_avatar_metadata
train
def get_avatar_metadata(self): """Gets the metadata for an asset. return: (osid.Metadata) - metadata for the asset *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.resource.ResourceForm.get_group_metadata_template meta...
python
{ "resource": "" }
q48859
ResourceForm.set_avatar
train
def set_avatar(self, asset_id): """Sets the avatar asset. arg: asset_id (osid.id.Id): an asset ``Id`` raise: InvalidArgument - ``asset_id`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* ...
python
{ "resource": "" }
q48860
ResourceForm.clear_avatar
train
def clear_avatar(self): """Clears the asset. raise: NoAccess - ``Metadata.isRequired()`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.resource.ResourceForm.clear_av...
python
{ "resource": "" }
q48861
BinNode.get_bin
train
def get_bin(self): """Gets the ``Bin`` at this node. return: (osid.resource.Bin) - the bin represented by this node *compliance: mandatory -- This method must be implemented.* """ if self._lookup_session is None: mgr = get_provider_manager('RESOURCE', runtime=self._...
python
{ "resource": "" }
q48862
BinNode.get_parent_bin_nodes
train
def get_parent_bin_nodes(self): """Gets the parents of this bin. return: (osid.resource.BinNodeList) - the parents of the ``id`` *compliance: mandatory -- This method must be implemented.* """ parent_bin_nodes = [] for node in self._my_map['parentNodes']: pa...
python
{ "resource": "" }
q48863
move_id_ahead
train
def move_id_ahead(element_id, reference_id, idstr_list): """Moves element_id ahead of reference_id in the list""" if element_id == reference_id: return idstr_list idstr_list.remove(str(element_id)) reference_index = idstr_list.index(str(reference_id)) idstr_list.insert(reference_index, str(e...
python
{ "resource": "" }
q48864
initialize_logging
train
def initialize_logging(args): """Configure the root logger with some sensible defaults.""" log_handler = logging.StreamHandler() log_formatter = logging.Formatter( "%(levelname)s %(asctime)s %(name)s:%(lineno)04d - %(message)s") log_handler.setFormatter(log_formatter) root_logger = logging....
python
{ "resource": "" }
q48865
main
train
def main(): """Run the bot.""" args = parser.parse_args() initialize_logging(args) # Allow expansion of paths even if the shell doesn't do it config_path = os.path.abspath(os.path.expanduser(args.config)) client = kitnirc.client.Client() controller = kitnirc.modular.Controller(client, conf...
python
{ "resource": "" }
q48866
LogEntry.get_agent_id
train
def get_agent_id(self): """Gets the agent ``Id`` who created this entry. return: (osid.id.Id) - the agent ``Id`` *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.resource.Resource.get_avatar_id_template if not bool(sel...
python
{ "resource": "" }
q48867
LogEntry.get_agent
train
def get_agent(self): """Gets the ``Agent`` who created this entry. return: (osid.authentication.Agent) - the ``Agent`` raise: OperationFailed - unable to complete request *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for os...
python
{ "resource": "" }
q48868
LogEntryForm.get_priority_metadata
train
def get_priority_metadata(self): """Gets the metadata for a priority type. return: (osid.Metadata) - metadata for the priority *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.logging.LogEntryForm.get_priority_metadata ...
python
{ "resource": "" }
q48869
LogEntryForm.set_priority
train
def set_priority(self, priority): """Sets the priority. arg: priority (osid.type.Type): the new priority raise: InvalidArgument - ``priority`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` raise: NullArgument - ``priority`` is ``null`` *complia...
python
{ "resource": "" }
q48870
LogEntryForm.clear_priority
train
def clear_priority(self): """Removes the priority. raise: NoAccess - ``Metadata.isRequired()`` is ``true`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.logging.LogE...
python
{ "resource": "" }
q48871
LogEntryForm.get_timestamp_metadata
train
def get_timestamp_metadata(self): """Gets the metadata for a timestamp. return: (osid.Metadata) - metadata for the timestamp *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.resource.ResourceForm.get_group_metadata_template ...
python
{ "resource": "" }
q48872
LogEntryForm.set_timestamp
train
def set_timestamp(self, timestamp): """Sets the timestamp. arg: timestamp (osid.calendaring.DateTime): the new timestamp raise: InvalidArgument - ``timestamp`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` raise: NullArgument - ``timestamp`` is ``null`...
python
{ "resource": "" }
q48873
LogEntryForm.get_agent_metadata
train
def get_agent_metadata(self): """Gets the metadata for the agent. return: (osid.Metadata) - metadata for the agent *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.resource.ResourceForm.get_group_metadata_template meta...
python
{ "resource": "" }
q48874
LogEntryForm.set_agent
train
def set_agent(self, agent_id): """Sets the agent. arg: agent_id (osid.id.Id): the new agent raise: InvalidArgument - ``agent_id`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` raise: NullArgument - ``agent_id`` is ``null`` *compliance: mandator...
python
{ "resource": "" }
q48875
LogNode.get_log
train
def get_log(self): """Gets the ``Log`` at this node. return: (osid.logging.Log) - the log represented by this node *compliance: mandatory -- This method must be implemented.* """ if self._lookup_session is None: mgr = get_provider_manager('LOGGING', runtime=self._ru...
python
{ "resource": "" }
q48876
LogNode.get_parent_log_nodes
train
def get_parent_log_nodes(self): """Gets the parents of this log. return: (osid.logging.LogNodeList) - the parents of this log *compliance: mandatory -- This method must be implemented.* """ parent_log_nodes = [] for node in self._my_map['parentNodes']: paren...
python
{ "resource": "" }
q48877
Index.POST
train
def POST(self): """ Add new entry """ form = self.form() if not form.validates(): todos = model.get_todos() return render.index(todos, form) model.new_todo(form.d.title) raise web.seeother('/')
python
{ "resource": "" }
q48878
Delete.POST
train
def POST(self, id): """ Delete based on ID """ id = int(id) model.del_todo(id) raise web.seeother('/')
python
{ "resource": "" }
q48879
OsidSession._can
train
def _can(self, func_name, qualifier_id=None): """Tests if the named function is authorized with agent and qualifier. Also, caches authz's in a dict. It is expected that this will not grow to big, as there are typically only a small number of qualifier + function combinations to store f...
python
{ "resource": "" }
q48880
OsidSession._can_for_object
train
def _can_for_object(self, func_name, object_id, method_name): """Checks if agent can perform function for object""" can_for_session = self._can(func_name) if (can_for_session or self._object_catalog_session is None or self._override_lookup_session is None): ...
python
{ "resource": "" }
q48881
AssetContentMultiLanguageAltTextFormRecord.get_alt_texts_metadata
train
def get_alt_texts_metadata(self): """Gets the metadata for all alt_texts. return: (osid.Metadata) - metadata for the alt_texts *compliance: mandatory -- This method must be implemented.* """ metadata = dict(self._alt_texts_metadata) metadata.update({'existing_string_val...
python
{ "resource": "" }
q48882
AssetContentMultiLanguageAltTextFormRecord.add_alt_text
train
def add_alt_text(self, alt_text): """Adds an alt_text. arg: alt_text (displayText): the new alt_text raise: InvalidArgument - ``alt_text`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` raise: NullArgument - ``alt_text`` is ``null`` *compliance:...
python
{ "resource": "" }
q48883
AssetContentMultiLanguageAltTextFormRecord.remove_alt_text_language
train
def remove_alt_text_language(self, language_type): """Removes the specified alt_text. raise: NoAccess - ``Metadata.isRequired()`` is ``true`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ if self.get_al...
python
{ "resource": "" }
q48884
AssetContentMultiLanguageMediaDescriptionFormRecord.get_media_descriptions_metadata
train
def get_media_descriptions_metadata(self): """Gets the metadata for all media descriptions. return: (osid.Metadata) - metadata for the media descriptions *compliance: mandatory -- This method must be implemented.* """ metadata = dict(self._media_descriptions_metadata) m...
python
{ "resource": "" }
q48885
AssetContentMultiLanguageMediaDescriptionFormRecord.add_media_description
train
def add_media_description(self, media_description): """Adds a media_description. arg: media_description (displayText): the new media_description raise: InvalidArgument - ``media_description`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` raise: NullArg...
python
{ "resource": "" }
q48886
AssetContentMultiLanguageMediaDescriptionFormRecord.remove_media_description_language
train
def remove_media_description_language(self, language_type): """Removes the specified media_description. raise: NoAccess - ``Metadata.isRequired()`` is ``true`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ ...
python
{ "resource": "" }
q48887
AssetContentMultiLanguageVTTFormRecord.add_vtt_file
train
def add_vtt_file(self, vtt_file, language_type=None): """Adds a vtt file tagged as the given language. arg: vtt_file (displayText): the new vtt_file raise: InvalidArgument - ``vtt_file`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` raise: NullArgument...
python
{ "resource": "" }
q48888
AssetContentMultiLanguageTranscriptFormRecord.add_transcript_file
train
def add_transcript_file(self, transcript_file, language_type=None): """Adds a transcript file tagged as the given language. arg: transcript_file (displayText): the new transcript_file raise: InvalidArgument - ``transcript_file`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`...
python
{ "resource": "" }
q48889
load_settings_sizes
train
def load_settings_sizes(): """ Load sizes from settings or fallback to the module constants """ page_size = AGNOCOMPLETE_DEFAULT_PAGESIZE settings_page_size = getattr( settings, 'AGNOCOMPLETE_DEFAULT_PAGESIZE', None) page_size = settings_page_size or page_size page_size_min = AGNOCO...
python
{ "resource": "" }
q48890
AgnocompleteBase.is_valid_query
train
def is_valid_query(self, query): """ Return True if the search query is valid. e.g.: * not empty, * not too short, """ # No query, no item if not query: return False # Query is too short, no item if len(query) < self.get_query_...
python
{ "resource": "" }
q48891
AgnocompleteModelBase.get_model
train
def get_model(self): """ Return the class Model used by this Agnocomplete """ if hasattr(self, 'model') and self.model: return self.model # Give me a "none" queryset try: none = self.get_queryset().none() return none.model excep...
python
{ "resource": "" }
q48892
AgnocompleteModelBase.get_field_name
train
def get_field_name(self): """ Return the model field name to be used as a value, or 'pk' if unset """ if hasattr(self, 'agnocomplete_field') and \ hasattr(self.agnocomplete_field, 'to_field_name'): return self.agnocomplete_field.to_field_name or 'pk' return...
python
{ "resource": "" }
q48893
AgnocompleteModel._construct_qs_filter
train
def _construct_qs_filter(self, field_name): """ Using a field name optionnaly prefixed by `^`, `=`, `@`, return a case-insensitive filter condition name usable as a queryset `filter()` keyword argument. """ if field_name.startswith('^'): return "%s__istartswit...
python
{ "resource": "" }
q48894
AgnocompleteModel.get_queryset_filters
train
def get_queryset_filters(self, query): """ Return the filtered queryset """ conditions = Q() for field_name in self.fields: conditions |= Q(**{ self._construct_qs_filter(field_name): query }) return conditions
python
{ "resource": "" }
q48895
AgnocompleteModel.item
train
def item(self, current_item): """ Return the current item. @param current_item: Current item @type param: django.models @return: Value and label of the current item @rtype : dict """ return { 'value': text(getattr(current_item, self.get_fiel...
python
{ "resource": "" }
q48896
AgnocompleteModel.build_filtered_queryset
train
def build_filtered_queryset(self, query, **kwargs): """ Build and return the fully-filtered queryset """ # Take the basic queryset qs = self.get_queryset() # filter it via the query conditions qs = qs.filter(self.get_queryset_filters(query)) return self.bu...
python
{ "resource": "" }
q48897
AgnocompleteModel.items
train
def items(self, query=None, **kwargs): """ Return the items to be sent to the client """ # Cut this, we don't need no empty query if not query: self.__final_queryset = self.get_model().objects.none() return self.serialize(self.__final_queryset) # Q...
python
{ "resource": "" }
q48898
AgnocompleteUrlProxy.http_call
train
def http_call(self, url=None, **kwargs): """ Call the target URL via HTTP and return the JSON result """ if not url: url = self.search_url http_func, arg_name = self.get_http_method_arg_name() # Build the argument dictionary to pass in the http function ...
python
{ "resource": "" }
q48899
TranscriptomeEmitter.emit
train
def emit(self): """Get a mapping from a transcript :return: One random Transcript sequence :rtype: sequence """ i = self.options.rand.get_weighted_random_index(self._weights) return self._transcriptome.transcripts[i]
python
{ "resource": "" }