_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q41200
Component.get_state_string
train
def get_state_string(self, add_colour=True): '''Get the state of this component as an optionally-coloured string. @param add_colour If True, ANSI colour codes will be added to the string. @return A string describing the state of this component. ''' wit...
python
{ "resource": "" }
q41201
Component.get_state_in_ec_string
train
def get_state_in_ec_string(self, ec_index, add_colour=True): '''Get the state of the component in an execution context as a string. @param ec_index The index of the execution context to check the state in. This index is into the total array of contexts, t...
python
{ "resource": "" }
q41202
Component.reset_in_ec
train
def reset_in_ec(self, ec_index): '''Reset this component in an execution context. @param ec_index The index of the execution context to reset in. This index is into the total array of contexts, that is both owned and participating contexts. If the value o...
python
{ "resource": "" }
q41203
Component.state_in_ec
train
def state_in_ec(self, ec_index): '''Get the state of the component in an execution context. @param ec_index The index of the execution context to check the state in. This index is into the total array of contexts, that is both owned and participating cont...
python
{ "resource": "" }
q41204
Component.refresh_state_in_ec
train
def refresh_state_in_ec(self, ec_index): '''Get the up-to-date state of the component in an execution context. This function will update the state, rather than using the cached value. This may take time, if the component is executing on a remote node. @param ec_index The index ...
python
{ "resource": "" }
q41205
Component.alive
train
def alive(self): '''Is this component alive?''' with self._mutex: if self.exec_contexts: for ec in self.exec_contexts: if self._obj.is_alive(ec): return True return False
python
{ "resource": "" }
q41206
Component.owned_ec_states
train
def owned_ec_states(self): '''The state of each execution context this component owns.''' with self._mutex: if not self._owned_ec_states: if self.owned_ecs: states = [] for ec in self.owned_ecs: states.append(sel...
python
{ "resource": "" }
q41207
Component.owned_ecs
train
def owned_ecs(self): '''A list of the execution contexts owned by this component.''' with self._mutex: if not self._owned_ecs: self._owned_ecs = [ExecutionContext(ec, self._obj.get_context_handle(ec)) \ for ec in self._obj.get_owned_con...
python
{ "resource": "" }
q41208
Component.participating_ec_states
train
def participating_ec_states(self): '''The state of each execution context this component is participating in. ''' with self._mutex: if not self._participating_ec_states: if self.participating_ecs: states = [] for ec in ...
python
{ "resource": "" }
q41209
Component.participating_ecs
train
def participating_ecs(self): '''A list of the execution contexts this component is participating in. ''' with self._mutex: if not self._participating_ecs: self._participating_ecs = [ExecutionContext(ec, self._obj.get_context_handle...
python
{ "resource": "" }
q41210
Component.state
train
def state(self): '''The merged state of all the execution context states, which can be used as the overall state of this component. The order of precedence is: Error > Active > Inactive > Created > Unknown ''' def merge_state(current, new): if new == sel...
python
{ "resource": "" }
q41211
Component.get_extended_fsm_service
train
def get_extended_fsm_service(self): '''Get a reference to the ExtendedFsmService. @return A reference to the ExtendedFsmService object @raises InvalidSdoServiceError ''' with self._mutex: try: return self._obj.get_sdo_service(RTC.ExtendedFsmService._...
python
{ "resource": "" }
q41212
Component.get_port_by_name
train
def get_port_by_name(self, port_name): '''Get a port of this component by name.''' with self._mutex: for p in self.ports: if p.name == port_name: return p return None
python
{ "resource": "" }
q41213
Component.get_port_by_ref
train
def get_port_by_ref(self, port_ref): '''Get a port of this component by reference to a CORBA PortService object. ''' with self._mutex: for p in self.ports: if p.object._is_equivalent(port_ref): return p return None
python
{ "resource": "" }
q41214
Component.has_port_by_name
train
def has_port_by_name(self, port_name): '''Check if this component has a port by the given name.''' with self._mutex: if self.get_port_by_name(port_name): return True return False
python
{ "resource": "" }
q41215
Component.has_port_by_ref
train
def has_port_by_ref(self, port_ref): '''Check if this component has a port by the given reference to a CORBA PortService object. ''' with self._mutex: if self.get_port_by_ref(self, port_ref): return True return False
python
{ "resource": "" }
q41216
Component.connected_inports
train
def connected_inports(self): '''The list of all input ports belonging to this component that are connected to one or more other ports. ''' return [p for p in self.ports \ if p.__class__.__name__ == 'DataInPort' and p.is_connected]
python
{ "resource": "" }
q41217
Component.connected_outports
train
def connected_outports(self): '''The list of all output ports belonging to this component that are connected to one or more other ports. ''' return [p for p in self.ports \ if p.__class__.__name__ == 'DataOutPort' \ and p.is_connected]
python
{ "resource": "" }
q41218
Component.connected_svcports
train
def connected_svcports(self): '''The list of all service ports belonging to this component that are connected to one or more other ports. ''' return [p for p in self.ports \ if p.__class__.__name__ == 'CorbaPort' and p.is_connected]
python
{ "resource": "" }
q41219
Component.ports
train
def ports(self): '''The list of all ports belonging to this component.''' with self._mutex: if not self._ports: self._ports = [ports.parse_port(port, self) \ for port in self._obj.get_ports()] return self._ports
python
{ "resource": "" }
q41220
Component.add_logger
train
def add_logger(self, cb, level='NORMAL', filters='ALL'): '''Add a callback to receive log events from this component. @param cb The callback function to receive log events. It must have the signature cb(name, time, source, level, message), where name is the name of the component...
python
{ "resource": "" }
q41221
Component.remove_logger
train
def remove_logger(self, cb_id): '''Remove a logger. @param cb_id The ID of the logger to remove. @raises NoLoggerError ''' if cb_id not in self._loggers: raise exceptions.NoLoggerError(cb_id, self.name) conf = self.object.get_configuration() res = co...
python
{ "resource": "" }
q41222
Component.activate_conf_set
train
def activate_conf_set(self, set_name): '''Activate a configuration set by name. @raises NoSuchConfSetError ''' with self._mutex: if not set_name in self.conf_sets: raise exceptions.NoSuchConfSetError(set_name) self._conf.activate_configuration_se...
python
{ "resource": "" }
q41223
Component.set_conf_set_value
train
def set_conf_set_value(self, set_name, param, value): '''Set a configuration set parameter value. @param set_name The name of the configuration set the destination parameter is in. @param param The name of the parameter to set. @param value The new value for the ...
python
{ "resource": "" }
q41224
Component.active_conf_set
train
def active_conf_set(self): '''The currently-active configuration set.''' with self._mutex: if not self.conf_sets: return None if not self._active_conf_set: return None return self.conf_sets[self._active_conf_set]
python
{ "resource": "" }
q41225
Component.active_conf_set_name
train
def active_conf_set_name(self): '''The name of the currently-active configuration set.''' with self._mutex: if not self.conf_sets: return '' if not self._active_conf_set: return '' return self._active_conf_set
python
{ "resource": "" }
q41226
Component.conf_sets
train
def conf_sets(self): '''The dictionary of configuration sets in this component, if any.''' with self._mutex: if not self._conf_sets: self._parse_configuration() return self._conf_sets
python
{ "resource": "" }
q41227
CacheTableManager.setup
train
def setup(self): """Setup cache tables.""" for table_spec in self._table_specs: with self._conn: table_spec.setup(self._conn)
python
{ "resource": "" }
q41228
CacheTableManager.teardown
train
def teardown(self): """Cleanup cache tables.""" for table_spec in reversed(self._table_specs): with self._conn: table_spec.teardown(self._conn)
python
{ "resource": "" }
q41229
ElasticsearchClient.from_normal
train
def from_normal(self, hosts=default.ELASTICSEARCH_HOSTS, **kwargs): """ Initialize a Elasticsearch client by specified hosts list. :param hosts: list of nodes we should connect to. Node should be a dictionary ({"host": "localhost", "port": 9200}), the entire dictionary w...
python
{ "resource": "" }
q41230
ElasticsearchClient.from_ssl
train
def from_ssl(self, ca_certs, client_cert, client_key, hosts=default.ELASTICSEARCH_HOSTS, use_ssl=True, verify_certs=True, **kwargs): """ Initialize a Elasticsearch client by SSL. :param ca_cert...
python
{ "resource": "" }
q41231
ElasticsearchClient.transfer_data_from_mongo
train
def transfer_data_from_mongo(self, index, doc_type, use_mongo_id=False, indexed_flag_field_name='', mongo_query_params={}, ...
python
{ "resource": "" }
q41232
ElasticsearchClient.bulk
train
def bulk(self, actions, stats_only=False, **kwargs): """ Executes bulk api by elasticsearch.helpers.bulk. :param actions: iterator containing the actions :param stats_only:if `True` only report number of successful/failed operations instead of just number of successful and a lis...
python
{ "resource": "" }
q41233
ElasticsearchClient.automatic_syn_data_from_mongo
train
def automatic_syn_data_from_mongo(self, index, doc_type, indexed_flag_field_name, thread_name='automatic_syn_data_thread', interva...
python
{ "resource": "" }
q41234
__run_blast
train
def __run_blast(blast_command, input_file, *args, **kwargs): ''' Run a blast variant on the given input file. ''' # XXX: Eventually, translate results on the fly as requested? Or # just always use our parsed object? if 'outfmt' in kwargs: raise Exception('Use of the -outfmt option ...
python
{ "resource": "" }
q41235
Segment.get_frames
train
def get_frames(self, channels=2): """Get numpy array of frames corresponding to the segment. :param integer channels: Number of channels in output array :returns: Array of frames in the segment :rtype: numpy array """ tmp_frame = self.track.current_frame self.tr...
python
{ "resource": "" }
q41236
Composition.duration
train
def duration(self): """Get duration of composition """ return max([x.comp_location + x.duration for x in self.segments])
python
{ "resource": "" }
q41237
Composition.add_segment
train
def add_segment(self, segment): """Add a segment to the composition :param segment: Segment to add to composition :type segment: :py:class:`radiotool.composer.Segment` """ self.tracks.add(segment.track) self.segments.append(segment)
python
{ "resource": "" }
q41238
Composition.add_segments
train
def add_segments(self, segments): """Add a list of segments to the composition :param segments: Segments to add to composition :type segments: list of :py:class:`radiotool.composer.Segment` """ self.tracks.update([seg.track for seg in segments]) self.segments.extend(segm...
python
{ "resource": "" }
q41239
Composition.fade_in
train
def fade_in(self, segment, duration, fade_type="linear"): """Adds a fade in to a segment in the composition :param segment: Segment to fade in to :type segment: :py:class:`radiotool.composer.Segment` :param duration: Duration of fade-in (in seconds) :type duration: float ...
python
{ "resource": "" }
q41240
Composition.fade_out
train
def fade_out(self, segment, duration, fade_type="linear"): """Adds a fade out to a segment in the composition :param segment: Segment to fade out :type segment: :py:class:`radiotool.composer.Segment` :param duration: Duration of fade-out (in seconds) :type duration: float ...
python
{ "resource": "" }
q41241
Composition.extended_fade_in
train
def extended_fade_in(self, segment, duration): """Add a fade-in to a segment that extends the beginning of the segment. :param segment: Segment to fade in :type segment: :py:class:`radiotool.composer.Segment` :param duration: Duration of fade-in (in seconds) :returns: Th...
python
{ "resource": "" }
q41242
Composition.extended_fade_out
train
def extended_fade_out(self, segment, duration): """Add a fade-out to a segment that extends the beginning of the segment. :param segment: Segment to fade out :type segment: :py:class:`radiotool.composer.Segment` :param duration: Duration of fade-out (in seconds) :returns...
python
{ "resource": "" }
q41243
Composition.cross_fade
train
def cross_fade(self, seg1, seg2, duration): """Add a linear crossfade to the composition between two segments. :param seg1: First segment (fading out) :type seg1: :py:class:`radiotool.composer.Segment` :param seg2: Second segment (fading in) :type seg2: :py:class:`radiot...
python
{ "resource": "" }
q41244
Composition.empty_over_span
train
def empty_over_span(self, time, duration): """Helper method that tests whether composition contains any segments at a given time for a given duration. :param time: Time (in seconds) to start span :param duration: Duration (in seconds) of span :returns: `True` if there are no se...
python
{ "resource": "" }
q41245
Composition.contract
train
def contract(self, time, duration, min_contraction=0.0): """Remove empty gaps from the composition starting at a given time for a given duration. """ # remove audio from the composition starting at time # for duration contract_dur = 0.0 contract_start...
python
{ "resource": "" }
q41246
Composition.export
train
def export(self, **kwargs): """ Generate audio file from composition. :param str. filename: Output filename (no extension) :param str. filetype: Output file type (only .wav supported for now) :param integer samplerate: Sample rate of output audio :param integer channels:...
python
{ "resource": "" }
q41247
get_episode_types
train
def get_episode_types(db) -> Iterator[EpisodeType]: """Get all episode types.""" cur = db.cursor() cur.execute('SELECT id, name, prefix FROM episode_type') for type_id, name, prefix in cur: yield EpisodeType(type_id, name, prefix)
python
{ "resource": "" }
q41248
EpisodeTypes.get_epno
train
def get_epno(self, episode: Episode): """Return epno for an Episode instance. epno is a string formatted with the episode number and type, e.g., S1, T2. >>> x = EpisodeTypes([EpisodeType(1, 'foo', 'F')]) >>> ep = Episode(type=1, number=2) >>> x.get_epno(ep) 'F2'...
python
{ "resource": "" }
q41249
Reporter.on_service_add
train
def on_service_add(self, service): """ When a new service is added, a worker thread is launched to periodically run the checks for that service. """ self.launch_thread(service.name, self.check_loop, service)
python
{ "resource": "" }
q41250
Reporter.check_loop
train
def check_loop(self, service): """ While the reporter is not shutting down and the service being checked is present in the reporter's configuration, this method will launch a job to run all of the service's checks and then pause for the configured interval. """ lo...
python
{ "resource": "" }
q41251
Reporter.run_checks
train
def run_checks(self, service): """ Runs each check for the service and reports to the service's discovery method based on the results. If all checks pass and the service's present node was previously reported as down, the present node is reported as up. Conversely, if a...
python
{ "resource": "" }
q41252
PetFinderClient._do_api_call
train
def _do_api_call(self, method, data): """ Convenience method to carry out a standard API call against the Petfinder API. :param basestring method: The API method name to call. :param dict data: Key/value parameters to send to the API method. This varies based on the ...
python
{ "resource": "" }
q41253
PetFinderClient._do_autopaginating_api_call
train
def _do_autopaginating_api_call(self, method, kwargs, parser_func): """ Given an API method, the arguments passed to it, and a function to hand parsing off to, loop through the record sets in the API call until all records have been yielded. This is mostly done this way to reduc...
python
{ "resource": "" }
q41254
PetFinderClient.breed_list
train
def breed_list(self, **kwargs): """ breed.list wrapper. Returns a list of breed name strings. :rtype: list :returns: A list of breed names. """ root = self._do_api_call("breed.list", kwargs) breeds = [] for breed in root.find("breeds"): bree...
python
{ "resource": "" }
q41255
PetFinderClient.pet_get
train
def pet_get(self, **kwargs): """ pet.get wrapper. Returns a record dict for the requested pet. :rtype: dict :returns: The pet's record dict. """ root = self._do_api_call("pet.get", kwargs) return self._parse_pet_record(root.find("pet"))
python
{ "resource": "" }
q41256
PetFinderClient.pet_getrandom
train
def pet_getrandom(self, **kwargs): """ pet.getRandom wrapper. Returns a record dict or Petfinder ID for a random pet. :rtype: dict or str :returns: A dict of pet data if ``output`` is ``'basic'`` or ``'full'``, and a string if ``output`` is ``'id'``. """ ...
python
{ "resource": "" }
q41257
PetFinderClient.pet_find
train
def pet_find(self, **kwargs): """ pet.find wrapper. Returns a generator of pet record dicts matching your search criteria. :rtype: generator :returns: A generator of pet record dicts. :raises: :py:exc:`petfinder.exceptions.LimitExceeded` once you have reached...
python
{ "resource": "" }
q41258
PetFinderClient.shelter_find
train
def shelter_find(self, **kwargs): """ shelter.find wrapper. Returns a generator of shelter record dicts matching your search criteria. :rtype: generator :returns: A generator of shelter record dicts. :raises: :py:exc:`petfinder.exceptions.LimitExceeded` once you have ...
python
{ "resource": "" }
q41259
PetFinderClient.shelter_get
train
def shelter_get(self, **kwargs): """ shelter.get wrapper. Given a shelter ID, retrieve its details in dict form. :rtype: dict :returns: The shelter's details. """ root = self._do_api_call("shelter.get", kwargs) shelter = root.find("shelter") for...
python
{ "resource": "" }
q41260
PetFinderClient.shelter_listbybreed
train
def shelter_listbybreed(self, **kwargs): """ shelter.listByBreed wrapper. Given a breed and an animal type, list the shelter IDs with pets of said breed. :rtype: generator :returns: A generator of shelter IDs that have breed matches. """ root = self._do_api_call...
python
{ "resource": "" }
q41261
TreeNode.add_callback
train
def add_callback(self, event, cb, args=None): '''Add a callback to this node. Callbacks are called when the specified event occurs. The available events depends on the specific node type. Args should be a value to pass to the callback when it is called. The callback should be of the ...
python
{ "resource": "" }
q41262
TreeNode.get_node
train
def get_node(self, path): '''Get a child node of this node, or this node, based on a path. @param path A list of path elements pointing to a node in the tree. For example, ['/', 'localhost', 'dir.host']. The first element in this path should be this node's name. ...
python
{ "resource": "" }
q41263
TreeNode.has_path
train
def has_path(self, path): '''Check if a path exists below this node. @param path A list of path elements pointing to a node in the tree. For example, ['/', 'localhost', 'dir.host']. The first element in this path should be this node's name. @return True i...
python
{ "resource": "" }
q41264
TreeNode.iterate
train
def iterate(self, func, args=None, filter=[]): '''Call a function on this node, and recursively all its children. This is a depth-first iteration. @param func The function to call. Its declaration must be 'def blag(node, args)', where 'node' is the current node ...
python
{ "resource": "" }
q41265
TreeNode.rem_callback
train
def rem_callback(self, event, cb): '''Remove a callback from this node. The callback is removed from the specified event. @param cb The callback function to remove. ''' if event not in self._cbs: raise exceptions.NoSuchEventError(self.name, event) c = [(x[0...
python
{ "resource": "" }
q41266
TreeNode.full_path
train
def full_path(self): '''The full path of this node.''' with self._mutex: if self._parent: return self._parent.full_path + [self._name] else: return [self._name]
python
{ "resource": "" }
q41267
TreeNode.full_path_str
train
def full_path_str(self): '''The full path of this node as a string.''' with self._mutex: if self._parent: if self._parent._name == '/': return self._parent.full_path_str + self._name else: return self._parent.full_path_s...
python
{ "resource": "" }
q41268
TreeNode.orb
train
def orb(self): '''The ORB used to access this object. This property's value will be None if no object above this object is a name server. ''' with self._mutex: if self._parent.name == '/': return None return self._parent.orb
python
{ "resource": "" }
q41269
TreeNode.root
train
def root(self): '''The root node of the tree this node is in.''' with self._mutex: if self._parent: return self._parent.root else: return self
python
{ "resource": "" }
q41270
command
train
def command(state, args): """Delete priority rule.""" args = parser.parse_args(args[1:]) query.files.delete_priority_rule(state.db, args.id) del state.file_picker
python
{ "resource": "" }
q41271
upsert
train
def upsert(db, table, key_cols, update_dict): """Fabled upsert for SQLiteDB. Perform an upsert based on primary key. :param SQLiteDB db: database :param str table: table to upsert into :param str key_cols: name of key columns :param dict update_dict: key-value pairs to upsert """ with...
python
{ "resource": "" }
q41272
Node.current
train
def current(cls, service, port): """ Returns a Node instance representing the current service node. Collects the host and IP information for the current machine and the port information from the given service. """ host = socket.getfqdn() return cls( h...
python
{ "resource": "" }
q41273
Node.serialize
train
def serialize(self): """ Serializes the node data as a JSON map string. """ return json.dumps({ "port": self.port, "ip": self.ip, "host": self.host, "peer": self.peer.serialize() if self.peer else None, "metadata": json.dumps(se...
python
{ "resource": "" }
q41274
Node.deserialize
train
def deserialize(cls, value): """ Creates a new Node instance via a JSON map string. Note that `port` and `ip` and are required keys for the JSON map, `peer` and `host` are optional. If `peer` is not present, the new Node instance will use the current peer. If `host` is not pre...
python
{ "resource": "" }
q41275
ConfigWatcher.start
train
def start(self): """ Iterates over the `watched_configurabes` attribute and starts a config file monitor for each. The resulting observer threads are kept in an `observers` list attribute. """ for config_class in self.watched_configurables: monitor = ConfigFi...
python
{ "resource": "" }
q41276
ConfigWatcher.launch_thread
train
def launch_thread(self, name, fn, *args, **kwargs): """ Adds a named thread to the "thread pool" dictionary of Thread objects. A daemon thread that executes the passed-in function `fn` with the given args and keyword args is started and tracked in the `thread_pool` attribute wit...
python
{ "resource": "" }
q41277
ConfigWatcher.kill_thread
train
def kill_thread(self, name): """ Joins the thread in the `thread_pool` dict with the given `name` key. """ if name not in self.thread_pool: return self.thread_pool[name].join() del self.thread_pool[name]
python
{ "resource": "" }
q41278
ConfigWatcher.update_configurable
train
def update_configurable(self, configurable_class, name, config): """ Callback fired when a configurable instance is updated. Looks up the existing configurable in the proper "registry" and `apply_config()` is called on it. If a method named "on_<configurable classname>_update" ...
python
{ "resource": "" }
q41279
ConfigWatcher.remove_configurable
train
def remove_configurable(self, configurable_class, name): """ Callback fired when a configurable instance is removed. Looks up the existing configurable in the proper "registry" and removes it. If a method named "on_<configurable classname>_remove" is defined it is calle...
python
{ "resource": "" }
q41280
ConfigWatcher.stop
train
def stop(self): """ Method for shutting down the watcher. All config file observers are stopped and their threads joined, along with the worker thread pool. """ self.shutdown.set() for monitor in self.observers: monitor.stop() self.wind_down...
python
{ "resource": "" }
q41281
BaseResource.get_resource_url
train
def get_resource_url(cls, resource, base_url): """ Construct the URL for talking to this resource. i.e.: http://myapi.com/api/resource Note that this is NOT the method for calling individual instances i.e. http://myapi.com/api/resource/1 Args: res...
python
{ "resource": "" }
q41282
BaseResource.get_url
train
def get_url(cls, url, uid, **kwargs): """ Construct the URL for talking to an individual resource. http://myapi.com/api/resource/1 Args: url: The url for this resource uid: The unique identifier for an individual resource kwargs: Additional keyword a...
python
{ "resource": "" }
q41283
BaseResource.get_method_name
train
def get_method_name(resource, method_type): """ Generate a method name for this resource based on the method type. """ return '{}_{}'.format(method_type.lower(), resource.Meta.name.lower())
python
{ "resource": "" }
q41284
BaseResource._parse_url_and_validate
train
def _parse_url_and_validate(cls, url): """ Recieves a URL string and validates it using urlparse. Args: url: A URL string Returns: parsed_url: A validated URL Raises: BadURLException """ parsed_url = urlparse(url) if pa...
python
{ "resource": "" }
q41285
HypermediaResource.set_related_method
train
def set_related_method(self, resource, full_resource_url): """ Using reflection, generate the related method and return it. """ method_name = self.get_method_name(resource, 'get') def get(self, **kwargs): return self._call_api_single_related_resource( ...
python
{ "resource": "" }
q41286
HypermediaResource.match_urls_to_resources
train
def match_urls_to_resources(self, url_values): """ For the list of valid URLs, try and match them up to resources in the related_resources attribute. Args: url_values: A dictionary of keys and URL strings that could be related resources. Retur...
python
{ "resource": "" }
q41287
add_episode
train
def add_episode(db, aid, episode): """Add an episode.""" values = { 'aid': aid, 'type': episode.type, 'number': episode.number, 'title': episode.title, 'length': episode.length, } upsert(db, 'episode', ['aid', 'type', 'number'], values)
python
{ "resource": "" }
q41288
delete_episode
train
def delete_episode(db, aid, episode): """Delete an episode.""" db.cursor().execute( 'DELETE FROM episode WHERE aid=:aid AND type=:type AND number=:number', { 'aid': aid, 'type': episode.type, 'number': episode.number, })
python
{ "resource": "" }
q41289
bump
train
def bump(db, aid): """Bump anime regular episode count.""" anime = lookup(db, aid) if anime.complete: return episode = anime.watched_episodes + 1 with db: set_watched(db, aid, get_eptype(db, 'regular').id, episode) set_status( db, aid, anime.enddate an...
python
{ "resource": "" }
q41290
MistClient.__authenticate
train
def __authenticate(self): """ Sends a json payload with the email and password in order to get the authentication api_token to be used with the rest of the requests """ if self.api_token: # verify current API token check_auth_uri = self.uri.split('/api/v1'...
python
{ "resource": "" }
q41291
MistClient.supported_providers
train
def supported_providers(self): """ Request a list of all available providers :returns: A list of all available providers (e.g. {'provider': 'ec2_ap_northeast', 'title': 'EC2 AP NORTHEAST'}) """ req = self.request(self.uri + '/providers', api_version=2) providers ...
python
{ "resource": "" }
q41292
MistClient._list_clouds
train
def _list_clouds(self): """ Request a list of all added clouds. Populates self._clouds dict with mist.client.model.Cloud instances """ req = self.request(self.uri + '/clouds') clouds = req.get().json() if clouds: for cloud in clouds: s...
python
{ "resource": "" }
q41293
MistClient.clouds
train
def clouds(self, id=None, name=None, provider=None, search=None): """ Property-like function to call the _list_clouds function in order to populate self._clouds dict :returns: A list of Cloud instances. """ if self._clouds is None: self._clouds = {} ...
python
{ "resource": "" }
q41294
MistClient._list_keys
train
def _list_keys(self): """ Retrieves a list of all added Keys and populates the self._keys dict with Key instances :returns: A list of Keys instances """ req = self.request(self.uri + '/keys') keys = req.get().json() if keys: self._keys = {} ...
python
{ "resource": "" }
q41295
MistClient.keys
train
def keys(self, id=None, search=None): """ Property-like function to call the _list_keys function in order to populate self._keys dict :returns: A list of Key instances """ if self._keys is None: self._keys = {} self._list_keys() if id: ...
python
{ "resource": "" }
q41296
MistClient.generate_key
train
def generate_key(self): """ Ask mist.io to randomly generate a private ssh-key to be used with the creation of a new Key :returns: A string of a randomly generated ssh private key """ req = self.request(self.uri + "/keys") private_key = req.post().json() ...
python
{ "resource": "" }
q41297
MistClient.add_key
train
def add_key(self, key_name, private): """ Add a new key to mist.io :param key_name: Name of the new key (it will be used as the key's id as well). :param private: Private ssh-key in string format (see also generate_key() ). :returns: An updated list of added keys. """ ...
python
{ "resource": "" }
q41298
command
train
def command(state, args): """Add a priority rule for files.""" args = parser.parse_args(args[1:]) row_id = query.files.add_priority_rule(state.db, args.regexp, args.priority) del state.file_picker print('Added rule {}'.format(row_id))
python
{ "resource": "" }
q41299
Episode.number
train
def number(self) -> int: """Episode number. Unique for an anime and episode type, but not unique across episode types for the same anime. """ match = self._NUMBER_SUFFIX.search(self.epno) return int(match.group(1))
python
{ "resource": "" }