_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q46300
PriceHandler.put
train
async def put(self, cid): """Update price of current content Accepts: Query string args: - "cid" - int Request body params: - "access_type" - str - "price" - int - "coinid" - str Returns: dict with following fields: - "confirmed": None - "txid" - str - "description" - str ...
python
{ "resource": "" }
q46301
ReviewsHandler.get
train
async def get(self, cid, coinid): """Receives all contents reviews """ if settings.SIGNATURE_VERIFICATION: super().verify() if coinid in settings.bridges.keys(): self.account.blockchain.setendpoint(settings.bridges[coinid]) reviews = await self.account.blockchain.getreviews(cid=cid) if isinstance(r...
python
{ "resource": "" }
q46302
ReviewHandler.post
train
async def post(self, public_key): """Writes contents review """ if settings.SIGNATURE_VERIFICATION: super().verify() try: body = json.loads(self.request.body) except: self.set_status(400) self.write({"error":400, "reason":"Unexpected data format. JSON required"}) raise tornado.web.Finish ...
python
{ "resource": "" }
q46303
AMSHandler.post
train
async def post(self): """Creates new account Accepts: - message (signed dict): - "device_id" - str - "email" - str - "phone" - str - "public_key" - str - "signature" - str Returns: dictionary with following fields: - "device_id" - str - "phone" - str - "public_key" - str ...
python
{ "resource": "" }
q46304
AccountHandler.get
train
async def get(self, public_key): """ Receive account data Accepts: Query string: - "public_key" - str Query string params: - message ( signed dictionary ): - "timestamp" - str Returns: - "device_id" - str - "phone" - str - "public_key" - str - "count" - int ( wallets amount ...
python
{ "resource": "" }
q46305
NewsHandler.get
train
async def get(self, public_key): """Receives public key, looking up document at storage, sends document id to the balance server """ if settings.SIGNATURE_VERIFICATION: super().verify() response = await self.account.getnews(public_key=public_key) # If we`ve got a empty or list with news if isinstan...
python
{ "resource": "" }
q46306
upload_content_fee
train
async def upload_content_fee(*args, **kwargs): """Estimating uploading content """ cus = kwargs.get("cus") owneraddr = kwargs.get("owneraddr") description = kwargs.get("description") coinid = kwargs.get("coinid", "PUT") #Check if required fields exists if not all([cus, owneraddr, description]): return {"erro...
python
{ "resource": "" }
q46307
SupervisorProcessManager.__get_supervisor
train
def __get_supervisor(self): """ Return the supervisor proxy object Should probably use this more rather than supervisorctl directly """ options = supervisorctl.ClientOptions() options.realize(args=['-c', self.supervisord_conf_path]) return supervisorctl.Controller(option...
python
{ "resource": "" }
q46308
SupervisorProcessManager.update
train
def update(self): """ Add newly defined servers, remove any that are no longer present """ configs, meta_changes = self.config_manager.determine_config_changes() self._process_config_changes(configs, meta_changes) self.supervisorctl('update')
python
{ "resource": "" }
q46309
NormalJSONDecoder.parse_object
train
def parse_object(self, data): """ Look for datetime looking strings. """ for key, value in data.items(): if isinstance(value, (str, type(u''))) and \ self.strict_iso_match.match(value): data[key] = dateutil.parser.parse(value) return data
python
{ "resource": "" }
q46310
AsarArchive.extract
train
def extract(self, destination): """Extracts the contents of the archive to the specifed directory. Args: destination (str): Path to an empty directory to extract the files to. """ if os.path.exists(destination): raise OSError(20, 'Destination exi...
python
{ "resource": "" }
q46311
AsarArchive.__extract_directory
train
def __extract_directory(self, path, files, destination): """Extracts a single directory to the specified directory on disk. Args: path (str): Relative (to the root of the archive) path of the directory to extract. files (dict): A ...
python
{ "resource": "" }
q46312
AsarArchive.__extract_file
train
def __extract_file(self, path, fileinfo, destination): """Extracts the specified file to the specified destination. Args: path (str): Relative (to the root of the archive) path of the file to extract. fileinfo (dict): Dictionary c...
python
{ "resource": "" }
q46313
AsarArchive.__copy_extracted
train
def __copy_extracted(self, path, destination): """Copies a file that was already extracted to the destination directory. Args: path (str): Relative (to the root of the archive) of the file to copy. destination (str): Directory to extract the arch...
python
{ "resource": "" }
q46314
FormFieldWidget.value_from_datadict
train
def value_from_datadict(self, data, files, name): """Ensure the payload is a list of values. In the case of a sub form, we need to ensure the data is returned as a list and not a dictionary. When a dict is found in the given data, we need to ensure the data is converted to a lis...
python
{ "resource": "" }
q46315
FormFieldWidget.decompress
train
def decompress(self, value): """ Retreieve each field value or provide the initial values """ if value: return [value.get(field.name, None) for field in self.fields] return [field.field.initial for field in self.fields]
python
{ "resource": "" }
q46316
FormFieldWidget.format_label
train
def format_label(self, field, counter): """ Format the label for each field """ return '<label for="id_formfield_%s" %s>%s</label>' % ( counter, field.field.required and 'class="required"', field.label)
python
{ "resource": "" }
q46317
FormFieldWidget.format_output
train
def format_output(self, rendered_widgets): """ This output will yeild all widgets grouped in a un-ordered list """ ret = [u'<ul class="formfield">'] for i, field in enumerate(self.fields): label = self.format_label(field, i) help_text = self.format_help_te...
python
{ "resource": "" }
q46318
Document.sentiment
train
def sentiment(self): """ Returns average sentiment of document. Must have sentiment enabled in XML output. :getter: returns average sentiment of the document :type: float """ if self._sentiment is None: results = self._xml.xpath('/root/document/sentences') ...
python
{ "resource": "" }
q46319
Document._get_sentences_dict
train
def _get_sentences_dict(self): """ Returns sentence objects :return: order dict of sentences :rtype: collections.OrderedDict """ if self._sentences_dict is None: sentences = [Sentence(element) for element in self._xml.xpath('/root/document/sentences/sentence...
python
{ "resource": "" }
q46320
Document.coreferences
train
def coreferences(self): """ Returns a list of Coreference classes :getter: Returns a list of coreferences :type: list of corenlp_xml.coreference.Coreference """ if self._coreferences is None: coreferences = self._xml.xpath('/root/document/coreference/corefer...
python
{ "resource": "" }
q46321
Sentence.sentiment
train
def sentiment(self): """ The sentiment of this sentence :getter: Returns the sentiment value of this sentence :type: int """ if self._sentiment is None: self._sentiment = int(self._element.get('sentiment')) return self._sentiment
python
{ "resource": "" }
q46322
Sentence._get_tokens_dict
train
def _get_tokens_dict(self): """ Accesses tokens dict :return: The ordered dict of the tokens :rtype: collections.OrderedDict """ if self._tokens_dict is None: tokens = [Token(element) for element in self._element.xpath('tokens/token')] self._toke...
python
{ "resource": "" }
q46323
Sentence.subtrees_for_phrase
train
def subtrees_for_phrase(self, phrase_type): """ Returns subtrees corresponding all phrases matching a given phrase type :param phrase_type: POS such as "NP", "VP", "det", etc. :type phrase_type: str :return: a list of NLTK.Tree.Subtree instances :rtype: list of NLTK.Tre...
python
{ "resource": "" }
q46324
Sentence.phrase_strings
train
def phrase_strings(self, phrase_type): """ Returns strings corresponding all phrases matching a given phrase type :param phrase_type: POS such as "NP", "VP", "det", etc. :type phrase_type: str :return: a list of strings representing those phrases """ return [u"...
python
{ "resource": "" }
q46325
Sentence.parse_string
train
def parse_string(self): """ Accesses the S-Expression parse string stored on the XML document :getter: Returns the parse string :type: str """ if self._parse_string is None: parse_text = self._element.xpath('parse/text()') if len(parse_text) > 0:...
python
{ "resource": "" }
q46326
Sentence.parse
train
def parse(self): """ Accesses the parse tree based on the S-expression parse string in the XML :getter: Returns the NLTK parse tree :type: nltk.Tree """ if self.parse_string is not None and self._parse is None: self._parse = Tree.parse(self._parse_string) ...
python
{ "resource": "" }
q46327
Sentence.basic_dependencies
train
def basic_dependencies(self): """ Accesses basic dependencies from the XML output :getter: Returns the dependency graph for basic dependencies :type: corenlp_xml.dependencies.DependencyGraph """ if self._basic_dependencies is None: deps = self._element.xpath...
python
{ "resource": "" }
q46328
Sentence.collapsed_dependencies
train
def collapsed_dependencies(self): """ Accessess collapsed dependencies for this sentence :getter: Returns the dependency graph for collapsed dependencies :type: corenlp_xml.dependencies.DependencyGraph """ if self._basic_dependencies is None: deps = self._el...
python
{ "resource": "" }
q46329
Sentence.collapsed_ccprocessed_dependencies
train
def collapsed_ccprocessed_dependencies(self): """ Accesses collapsed, CC-processed dependencies :getter: Returns the dependency graph for collapsed and cc processed dependencies :type: corenlp_xml.dependencies.DependencyGraph """ if self._basic_dependencies is None: ...
python
{ "resource": "" }
q46330
Token.word
train
def word(self): """ Lazy-loads word value :getter: Returns the plain string value of the word :type: str """ if self._word is None: words = self._element.xpath('word/text()') if len(words) > 0: self._word = words[0] return...
python
{ "resource": "" }
q46331
Token.lemma
train
def lemma(self): """ Lazy-loads the lemma for this word :getter: Returns the plain string value of the word lemma :type: str """ if self._lemma is None: lemmata = self._element.xpath('lemma/text()') if len(lemmata) > 0: self._lemm...
python
{ "resource": "" }
q46332
Token.character_offset_begin
train
def character_offset_begin(self): """ Lazy-loads character offset begin node :getter: Returns the integer value of the beginning offset :type: int """ if self._character_offset_begin is None: offsets = self._element.xpath('CharacterOffsetBegin/text()') ...
python
{ "resource": "" }
q46333
Token.character_offset_end
train
def character_offset_end(self): """ Lazy-loads character offset end node :getter: Returns the integer value of the ending offset :type: int """ if self._character_offset_end is None: offsets = self._element.xpath('CharacterOffsetEnd/text()') if l...
python
{ "resource": "" }
q46334
Token.pos
train
def pos(self): """ Lazy-loads the part of speech tag for this word :getter: Returns the plain string value of the POS tag for the word :type: str """ if self._pos is None: poses = self._element.xpath('POS/text()') if len(poses) > 0: ...
python
{ "resource": "" }
q46335
Token.ner
train
def ner(self): """ Lazy-loads the NER for this word :getter: Returns the plain string value of the NER tag for the word :type: str """ if self._ner is None: ners = self._element.xpath('NER/text()') if len(ners) > 0: self._ner = ne...
python
{ "resource": "" }
q46336
Token.speaker
train
def speaker(self): """ Lazy-loads the speaker for this word :getter: Returns the plain string value of the speaker tag for the word :type: str """ if self._speaker is None: speakers = self._element.xpath('Speaker/text()') if len(speakers) > 0: ...
python
{ "resource": "" }
q46337
TerraformGenerator._generate_iam_role_policy
train
def _generate_iam_role_policy(self): """ Generate the policy for the IAM Role. Terraform name: aws_iam_role.lambda_role """ endpoints = self.config.get('endpoints') queue_arns = [] for ep in endpoints: for qname in endpoints[ep]['queues']: ...
python
{ "resource": "" }
q46338
TerraformGenerator._generate_iam_invoke_role_policy
train
def _generate_iam_invoke_role_policy(self): """ Generate the policy for the IAM role used by API Gateway to invoke the lambda function. Terraform name: aws_iam_role.invoke_role """ invoke_pol = { "Version": "2012-10-17", "Statement": [ ...
python
{ "resource": "" }
q46339
TerraformGenerator._generate_iam_role
train
def _generate_iam_role(self): """ Generate the IAM Role needed by the Lambda function. Terraform name: aws_iam_role.lambda_role """ pol = { "Version": "2012-10-17", "Statement": [ { "Action": "sts:AssumeRole", ...
python
{ "resource": "" }
q46340
TerraformGenerator._generate_iam_invoke_role
train
def _generate_iam_invoke_role(self): """ Generate the IAM Role for API Gateway to use to invoke the function. Terraform name: aws_iam_role.invoke_role :return: """ invoke_assume = { "Version": "2012-10-17", "Statement": [ { ...
python
{ "resource": "" }
q46341
TerraformGenerator._generate_lambda
train
def _generate_lambda(self): """ Generate the lambda function and its IAM role, and add to self.tf_conf """ self.tf_conf['resource']['aws_lambda_function']['lambda_func'] = { 'filename': 'webhook2lambda2sqs_func.zip', 'function_name': self.resource_name, ...
python
{ "resource": "" }
q46342
TerraformGenerator._set_account_info
train
def _set_account_info(self): """ Connect to the AWS IAM API via boto3 and run the GetUser operation on the current user. Use this to set ``self.aws_account_id`` and ``self.aws_region``. """ if 'AWS_DEFAULT_REGION' in os.environ: logger.debug('Connecting to IAM...
python
{ "resource": "" }
q46343
TerraformGenerator._generate_api_gateway
train
def _generate_api_gateway(self): """ Generate the full configuration for the API Gateway, and add to self.tf_conf """ self.tf_conf['resource']['aws_api_gateway_rest_api']['rest_api'] = { 'name': self.resource_name, 'description': self.description }...
python
{ "resource": "" }
q46344
TerraformGenerator._get_config
train
def _get_config(self, func_src): """ Return the full terraform configuration as a JSON string :param func_src: lambda function source :type func_src: str :return: terraform configuration :rtype: str """ self._set_account_info() self._generate_iam_...
python
{ "resource": "" }
q46345
TerraformGenerator._write_zip
train
def _write_zip(self, func_src, fpath): """ Write the function source to a zip file, suitable for upload to Lambda. Note there's a bit of undocumented magic going on here; Lambda needs the execute bit set on the module with the handler in it (i.e. 0755 or 0555 permissions...
python
{ "resource": "" }
q46346
Zmanim.zmanim
train
def zmanim(self): """Return a dictionary of the zmanim the object represents.""" return {key: self.utc_minute_timezone(value) for key, value in self.get_utc_sun_time_full().items()}
python
{ "resource": "" }
q46347
Zmanim.candle_lighting
train
def candle_lighting(self): """Return the time for candle lighting, or None if not applicable.""" today = HDate(gdate=self.date, diaspora=self.location.diaspora) tomorrow = HDate(gdate=self.date + dt.timedelta(days=1), diaspora=self.location.diaspora) # If today...
python
{ "resource": "" }
q46348
Zmanim._havdalah_datetime
train
def _havdalah_datetime(self): """Compute the havdalah time based on settings.""" if self.havdalah_offset == 0: return self.zmanim["three_stars"] # Otherwise, use the offset. return (self.zmanim["sunset"] + dt.timedelta(minutes=self.havdalah_offset))
python
{ "resource": "" }
q46349
Zmanim.havdalah
train
def havdalah(self): """Return the time for havdalah, or None if not applicable. If havdalah_offset is 0, uses the time for three_stars. Otherwise, adds the offset to the time of sunset and uses that. If it's currently a multi-day YomTov, and the end of the stretch is after today...
python
{ "resource": "" }
q46350
Zmanim.issur_melacha_in_effect
train
def issur_melacha_in_effect(self): """At the given time, return whether issur melacha is in effect.""" # TODO: Rewrite this in terms of candle_lighting/havdalah properties. weekday = self.date.weekday() tomorrow = self.date + dt.timedelta(days=1) tomorrow_holiday_type = HDate( ...
python
{ "resource": "" }
q46351
Zmanim.gday_of_year
train
def gday_of_year(self): """Return the number of days since January 1 of the given year.""" return (self.date - dt.date(self.date.year, 1, 1)).days
python
{ "resource": "" }
q46352
Zmanim.utc_minute_timezone
train
def utc_minute_timezone(self, minutes_from_utc): """Return the local time for a given time UTC.""" from_zone = tz.gettz('UTC') to_zone = self.location.timezone utc = dt.datetime.combine(self.date, dt.time()) + \ dt.timedelta(minutes=minutes_from_utc) utc = utc.replace...
python
{ "resource": "" }
q46353
Zmanim.get_utc_sun_time_full
train
def get_utc_sun_time_full(self): """Return a list of Jewish times for the given location.""" # sunset and rise time sunrise, sunset = self._get_utc_sun_time_deg(90.833) # shaa zmanit by gara, 1/12 of light time sun_hour = (sunset - sunrise) // 12 midday = (sunset + sunri...
python
{ "resource": "" }
q46354
cutoff
train
def cutoff(s, length=120): """Cuts a given string if it is longer than a given length.""" if length < 5: raise ValueError('length must be >= 5') if len(s) <= length: return s else: i = (length - 2) / 2 j = (length - 3) / 2 return s[:i] + '...' + s[-j:]
python
{ "resource": "" }
q46355
MediaFile.save
train
def save(self, reload=False): """Save changes to the file.""" self.wrapper.raw.save() if reload: self.reload()
python
{ "resource": "" }
q46356
StopWord.rebase
train
def rebase(self, text, char='X'): """ Rebases text with stop words removed. """ regexp = re.compile(r'\b(%s)\b' % '|'.join(self.collection), re.IGNORECASE | re.UNICODE) def replace(m): word = m.group(1) return char * len(word) ...
python
{ "resource": "" }
q46357
show_stat_base
train
def show_stat_base(count_value, max_count_value, prepend, speed, tet, ttg, width, **kwargs): """A function that formats the progress information This function will be called periodically for each progress that is monitored. Overwrite this function in a subclass to implement a specific formating of the prog...
python
{ "resource": "" }
q46358
_show_stat_wrapper_multi_Progress
train
def _show_stat_wrapper_multi_Progress(count, last_count, start_time, max_count, speed_calc_cycles, width, q, last_speed, prepend, show_stat_function, len_, add_args, lock, info_line, no_move_up=False): """ call the static method s...
python
{ "resource": "" }
q46359
Loop.__cleanup
train
def __cleanup(self): """ Wait at most twice as long as the given repetition interval for the _wrapper_function to terminate. If after that time the _wrapper_function has not terminated, send SIGTERM to and the process. Wait at most five times as long as ...
python
{ "resource": "" }
q46360
Loop.start
train
def start(self, timeout=None): """ uses multiprocess Process to call _wrapper_func in subprocess """ if self.is_alive(): log.warning("a process with pid %s is already running", self._proc.pid) return self._run.value = True self._func...
python
{ "resource": "" }
q46361
Progress._reset_i
train
def _reset_i(self, i): """ reset i-th progress information """ self.count[i].value=0 log.debug("reset counter %s", i) self.lock[i].acquire() for x in range(self.q[i].qsize()): self.q[i].get() self.lock[i].release() self.sta...
python
{ "resource": "" }
q46362
Progress._show_stat
train
def _show_stat(self): """ convenient functions to call the static show_stat_wrapper_multi with the given class members """ _show_stat_wrapper_multi_Progress(self.count, self.last_count, s...
python
{ "resource": "" }
q46363
Progress.stop
train
def stop(self): """ trigger clean up by hand, needs to be done when not using context management via 'with' statement - will terminate loop process - show a last progress -> see the full 100% on exit - releases terminal reservation """...
python
{ "resource": "" }
q46364
ImportPathsResolver.candidate_paths
train
def candidate_paths(self, filepath): """ Return candidates path for given path * If Filename does not starts with ``_``, will build a candidate for both with and without ``_`` prefix; * Will build For each available extensions if filename does not have an explicit ex...
python
{ "resource": "" }
q46365
ImportPathsResolver.check_candidate_exists
train
def check_candidate_exists(self, basepath, candidates): """ Check that at least one candidate exist into a directory. Args: basepath (str): Directory path where to search for candidate. candidates (list): List of candidate file paths. Returns: list: ...
python
{ "resource": "" }
q46366
ImportPathsResolver.resolve
train
def resolve(self, sourcepath, paths, library_paths=None): """ Resolve given paths from given base paths Return resolved path list. Note: Resolving strategy is made like libsass do, meaning paths in import rules are resolved from the source file where the import ...
python
{ "resource": "" }
q46367
SettingsBackendYaml.parse
train
def parse(self, filepath, content): """ Parse opened settings content using YAML parser. Args: filepath (str): Settings object, depends from backend content (str): Settings content from opened file, depends from backend. Raises: bouss...
python
{ "resource": "" }
q46368
DisconnectingSentinel.filter_slaves
train
def filter_slaves(selfie, slaves): """ Remove slaves that are in an ODOWN or SDOWN state also remove slaves that do not have 'ok' master-link-status """ return [(s['ip'], s['port']) for s in slaves if not s['is_odown'] and not s['is_sdown'] and ...
python
{ "resource": "" }
q46369
Listener.listen
train
def listen(zelf): """ listen indefinitely, handling messages as they come all redis specific exceptions are handled, anything your handler raises will not be handled. setting active to False on the Listener object will gracefully stop the listen() function """ wh...
python
{ "resource": "" }
q46370
setup_config
train
def setup_config(command, filename, section, vars): """Place any commands to setup cogenircapp here""" conf = appconfig('config:' + filename) load_environment(conf.global_conf, conf.local_conf)
python
{ "resource": "" }
q46371
SimpleConditionFactory._split_scheme
train
def _split_scheme(expression): """ Splits the scheme and actual expression :param str expression: The expression. :rtype: str """ match = re.search(r'^([a-z]+):(.*)$', expression) if not match: scheme = 'plain' actual = expression ...
python
{ "resource": "" }
q46372
SimpleConditionFactory.register_scheme
train
def register_scheme(scheme, constructor): """ Registers a scheme. :param str scheme: The scheme. :param callable constructor: The SimpleCondition constructor. """ if not re.search(r'^[a-z]+$', scheme): raise ValueError('{0!s} is not a valid scheme'.format(sch...
python
{ "resource": "" }
q46373
as_df
train
def as_df(): """Return a dataframe of isotopes.""" records = [] for sym, ele in vars(_this).items(): if sym not in ["Element", "Isotope"] and not sym.startswith("_"): for k, v in vars(ele).items(): if k.startswith("_") and k[1].isdigit(): records.appen...
python
{ "resource": "" }
q46374
Simulation._compute_one_step
train
def _compute_one_step(self, t, fields, pars): """ Compute one step of the simulation, then update the timers. """ fields, pars = self._hook(t, fields, pars) self.dt = (self.tmax - t if self.tmax and (t + self.dt >= self.tmax) else self.dt) ...
python
{ "resource": "" }
q46375
Simulation.compute
train
def compute(self): """Generator which yield the actual state of the system every dt. Yields ------ tuple : t, fields Actual time and updated fields container. """ fields = self.fields t = self.t pars = self.parameters self._started_tim...
python
{ "resource": "" }
q46376
Simulation.attach_container
train
def attach_container(self, path=None, save="all", mode="w", nbuffer=50, force=False): """add a Container to the simulation which allows some persistance to the simulation. Parameters ---------- path : str or None (default: None) path for the ...
python
{ "resource": "" }
q46377
Simulation.add_post_process
train
def add_post_process(self, name, post_process, description=""): """add a post-process Parameters ---------- name : str name of the post-traitment post_process : callback (function of a class with a __call__ method or a streamz.Stream)...
python
{ "resource": "" }
q46378
Simulation.remove_post_process
train
def remove_post_process(self, name): """remove a post-process Parameters ---------- name : str name of the post-process to remove. """ self._pprocesses = [post_process for post_process in self._pprocesses ...
python
{ "resource": "" }
q46379
cache_file
train
def cache_file(package, mode): """ Yields a file-like object for the purpose of writing to or reading from the cache. The code: with cache_file(...) as f: # do stuff with f is guaranteed to convert any exceptions to warnings (*), both in the cache_file(...) call and the 'd...
python
{ "resource": "" }
q46380
exception_to_warning
train
def exception_to_warning(description, category, always_raise=False): """ Catches any exceptions that happen in the corresponding with block and instead emits a warning of the given category, unless always_raise is True or the environment variable OUTDATED_RAISE_EXCEPTION is set to 1, in which caise ...
python
{ "resource": "" }
q46381
PdControl.transmit_length
train
def transmit_length(self, val=3): """Sets transmit length.""" if self.instrument == "Vectrino" and type(val) is float: if val == 0.3: self.pdx.TransmitLength = 0 elif val == 0.6: self.pdx.TransmitLength = 1 elif val == 1.2: ...
python
{ "resource": "" }
q46382
PdControl.sampling_volume
train
def sampling_volume(self, val): """Sets sampling volume.""" if self.instrument == "Vectrino" and type(val) is float: if val == 2.5: self.pdx.SamplingVolume = 0 elif val == 4.0: self.pdx.SamplingVolume = 1 elif val == 5.5: ...
python
{ "resource": "" }
q46383
PdControl.sound_speed_mode
train
def sound_speed_mode(self, mode): """Sets sound speed mode; 0 or "measured" for measured; 1 or "fixed" for fixed.""" if mode == "measured": mode = 0 if mode == "fixed": mode = 1 self.pdx.SoundSpeedMode = mode
python
{ "resource": "" }
q46384
PdControl.power_level
train
def power_level(self, val): """Sets the power level according to the index or string. 0 = High 1 = HighLow 2 = LowHigh 3 = Low""" if val in [0, 1, 2, 3]: self.pdx.PowerLevel = val elif type(val) is str: if val.lower() == "high": ...
python
{ "resource": "" }
q46385
PdControl.coordinate_system
train
def coordinate_system(self, coordsys): """Sets instrument coordinate system. Accepts an int or string.""" if coordsys.upper() == "ENU": ncs = 0 elif coordsys.upper() == "XYZ": ncs = 1 elif coordsys.upper() == "BEAM": ncs = 2 elif coordsys in [0...
python
{ "resource": "" }
q46386
PdControl.start_disk_recording
train
def start_disk_recording(self, filename, autoname=False): """Starts data recording to disk. Specify the filename without extension. If autoname = True a new file will be opened for data recording each time the specified time interval has elapsed. The current date and time is then auto...
python
{ "resource": "" }
q46387
PdControl.sampling_volume_value
train
def sampling_volume_value(self): """Returns the device samping volume value in m.""" svi = self.pdx.SamplingVolume tli = self.pdx.TransmitLength return self._sampling_volume_value(svi, tli)
python
{ "resource": "" }
q46388
autoasync
train
def autoasync(coro=None, *, loop=None, forever=False, pass_loop=False): ''' Convert an asyncio coroutine into a function which, when called, is evaluted in an event loop, and the return value returned. This is intented to make it easy to write entry points into asyncio coroutines, which otherwise ne...
python
{ "resource": "" }
q46389
Match.report_winner
train
async def report_winner(self, winner: Participant, scores_csv: str): """ report scores and give a winner |methcoro| Args: winner: :class:Participant instance scores_csv: Comma separated set/game scores with player 1 score first (e.g. "1-3,3-0,3-2") Raises: ...
python
{ "resource": "" }
q46390
Match.reopen
train
async def reopen(self): """ Reopens a match that was marked completed, automatically resetting matches that follow it |methcoro| Raises: APIException """ res = await self.connection('POST', 'tournaments/{}/matches/{}/reopen'.format(self._tournament_id, self._id)) ...
python
{ "resource": "" }
q46391
Match.change_votes
train
async def change_votes(self, player1_votes: int = None, player2_votes: int = None, add: bool = False): """ change the votes for either player |methcoro| The votes will be overriden by default, If `add` is set to True, another API request call will be made to ensure the local is up to da...
python
{ "resource": "" }
q46392
Match.attach_file
train
async def attach_file(self, file_path: str, description: str = None) -> Attachment: """ add a file as an attachment |methcoro| Warning: |unstable| Args: file_path: path to the file you want to add description: *optional* description for your attachm...
python
{ "resource": "" }
q46393
Match.attach_url
train
async def attach_url(self, url: str, description: str = None) -> Attachment: """ add an url as an attachment |methcoro| Args: url: url you want to add description: *optional* description for your attachment Returns: Attachment: Raises: ...
python
{ "resource": "" }
q46394
Match.destroy_attachment
train
async def destroy_attachment(self, a: Attachment): """ destroy a match attachment |methcoro| Args: a: the attachment you want to destroy Raises: APIException """ await self.connection('DELETE', 'tournaments/{}/matches/{}/attachments/{}'.format(...
python
{ "resource": "" }
q46395
class_subobjects
train
def class_subobjects( class_: Type) -> Generator[Tuple[str, Type, bool], None, None]: """Find the aggregated subobjects of an object. These are the public attributes. Args: class_: The class whose subobjects to return. Yields: Tuples (name, type, required) describing subobject...
python
{ "resource": "" }
q46396
get_frame_list
train
def get_frame_list(): """ Create the list of frames """ # TODO: use this function in IPS below (less code duplication) frame_info_list = [] frame_list = [] frame = inspect.currentframe() while frame is not None: frame_list.append(frame) info = inspect.getframeinfo(frame...
python
{ "resource": "" }
q46397
ip_shell_after_exception
train
def ip_shell_after_exception(frame): """ Launches an IPython embedded shell in the namespace where an exception occurred. :param frame: :return: """ # let the user know, where this shell is 'waking up' # construct frame list # this will be printed in the header frame_info_list = []...
python
{ "resource": "" }
q46398
ip_extra_syshook
train
def ip_extra_syshook(fnc, pdb=0, filename=None): """ Extended system hook for exceptions. supports logging of tracebacks to a file lets fnc() be executed imediately before the IPython Verbose Traceback is started this can be used to pop up a QTMessageBox: "An exception occured" """ a...
python
{ "resource": "" }
q46399
save_current_nb_as_html
train
def save_current_nb_as_html(info=False): """ Save the current notebook as html file in the same directory """ assert in_ipynb() full_path = get_notebook_name() path, filename = os.path.split(full_path) wd_save = os.getcwd() os.chdir(path) cmd = 'jupyter nbconvert --to html "{}"'.fo...
python
{ "resource": "" }